How to find orphaned files

It is easy to overlook orphaned files without assigned existing owner or group after moving large amount of data. Fortunately, it is easy to spot these files using the find utility.

Use the following command to find orphaned files inside /path.

$ find /path -nouser -or -nogroup

You can quickly verify obtained results in the following way.

$ find /path -nouser -or -nogroup -exec ls -l {} \;
-rwxrwxrwx 1 1008 users 92061 cze 17  2009 /path/media/journal.log
-rwxrwxrwx 1 1044 1044  54667 sie 27  2009 /path/media/scripts_backup.tgz
Milosz Galazka's Picture

About Milosz Galazka

Milosz is a Linux Foundation Certified Engineer working for a successful Polish company as a system administrator and a long time supporter of Free Software Foundation and Debian operating system.