Press "Enter" to skip to content

Find unowned files on your system

From time to time software packages may leave files on your server/workstation with random User ID’s (UID) or Group ID (GID), especially if compiling from source, tarballs, extracting .rpm’s etc… Though not really an major issue but it should be cleaned up so that files that should not be accessible by others stay that way.

Easy way to locate them:

#!/bin/bash
#locate files on local filesystem with no valid UID
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nouser -ls
#!/bin/bash
#locate files on local filesystem with no valid GID
df --local -P | awk {'if (NR!=1) print $6'} | xargs -I '{}' find '{}' -xdev -nogroup -ls