Find files based on permission

How can I find a list of files that have some specific permissions?

I want to find files owned by root user that have rwx permission for the owner.

Is there any way to find a list of such files? I am using Ubuntu 16.04.


Yes, GNU find can do it:

-user uname

File is owned by user uname (numeric user ID allowed).

-perm -mode

All of the permission bits mode are set for the file. Symbolic modes are accepted in this form, and this is usually the way in which you would want to use them. You must specify 'u', 'g' or 'o' if you use a symbolic mode. See the EXAMPLES section for some illustrative examples.

So, you want:

find /path/to/directory -user root -perm -u+rwx

If you want to find all files a user has certain permission for (regardless if he is the owner (and even set via ACL)) you can use find with -readable, -writable and -executable.

To find all files for which user sam has read-permission

sudo -u sam find /path/to/directory -readable -ls
  • sudo -u sam is needed because the three mentioned switches work with the permissions of the user that invoked find - so you need sudo to run find as user sam.
  • -ls shows the complete entry for each file found

further examples
To find all files for which sam has execute or write permissions

sudo -u sam find /path/to/directory -writable -or -executable -ls

To find all files for which sam has execute and read permissions

sudo -u sam find /path/to/directory -readable -and -executable -ls

writable is not misspelled!