As a part of security audit you want to find the files which aren’t being owned by any user. In such case you can use the find command to look for such files.
The following command will list the files which aren’t being owned by any user:
[[email protected] ~]# find / -nouser
Similarly you can find the files which does not belong to any group:
[[email protected] ~]# find / -nogroup
So take for example, we have a user(s) leaving the organization and we delete the user with recursive option (userdel -r USERNAME), it will delete the home directory and it’s contents. However, it won’t delete the files being owned by that user in other folders.
In such case we can use the following command to identify such files:
[[email protected] ~]# find / -nouser -nogroup
So depending on the requirement, we can either delete those files or change the ownership (user & group) for such files.