Categories
SysOps

How to find orphaned files

It is easy to overlook orphaned files without an assigned existing owner or group after moving large amounts 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
/path/media/journal.log
/path/media/scripts_backup.tgz

You can quickly verify the 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