MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat

Mon, Apr 13, 2015 11:25 pm

Finding files and/or directories with no owners

On a Unix/Linux system, you can locate files or directories that don't belong to a valid user account or group on the system with the command find and the -nouser or -nogroup option.
              No group corresponds to file's numeric group ID.

              No user corresponds to file's numeric user ID.
E.g., to find any such files in the current directory and below it, I can use find . -nouser
# find . -nouser

The above example shows that the directory temp and three files within it don't have a valid owner. Checking them with the ls command, I see a long sequence of digits listed for the ower and group instead of an account listed in /etc/passwd or /etc/group.

# ls -ld temp
drwxr-xr-x. 2 723184451 1286109195 74 Feb 13 17:09 temp
# ls -al temp
total 60
drwxr-xr-x. 2 723184451 1286109195    74 Feb 13 17:09 .
drwx------. 8 jasmith1  jasmith1    4096 Apr 10 22:26 ..
-rw-r--r--. 1 723184451 1286109195 45333 Oct  6  2014 bounced.txt
-rw-r--r--. 1 723184451 1286109195   192 Oct  6  2014 ._Oct14(10-2).pdf
-rw-r--r--. 1 723184451 1286109195   192 Oct  6  2014 ._Oct14.doc

Files or directories with no group listed in /etc/group corresponding to the numeric group id for the file or directory can be found with find . -nogroup to search in and beneath the current directory or find / -nogroup to search starting at the root directory.

# find . -nogroup
# ls -ld mail
drwx------. 3 jasmith1 508 18 Sep 29  2014 mail
# ls -al mail/.imap/INBOX
total 20
drwx------. 2 jasmith1 508    76 Sep 29  2014 .
drwx------. 3 jasmith1 508    18 Sep 29  2014 ..
-rw-------. 1 jasmith1 508   144 Sep 29  2014 dovecot.index
-rw-------. 1 jasmith1 508 10272 Sep 29  2014 dovecot.index.cache
-rw-------. 1 jasmith1 508    96 Sep 29  2014 dovecot.index.log 

You can use the -o option for "or" to find files and directories that either don't have a user account associated with the numeric user id or don't have a group associated with the numeric group id. E.g., find . -nogroup -o -nouser.

If you delete an account or group from the system, files or directories that remain that had that owner or group will then be displayed with the user id and group id associated with the account or group that was deleted when you use the ls command.

[/os/unix/commands] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo