I would like to find files only by a certain user's permission. For example, if I want to find a file that I have full permission.
I may do something like:
find . -user $(whoami) -perm
But what should I put after -perm
if I want to ignore the permission of root and other users.
The -perm parameter of the find command can be used to find the files with specific permissions. The 2 ways to specify the permissions with the -perm parameter are : -perm -mode --- All of the permission bits mode are set for the file. -perm /mode --- Any of the permission bits mode are set for the file.
If you only want to find the files owned by a particular user and not the directories then you need to use -type f option with find command as shown below.
To view the permissions for all files in a directory, use the ls command with the -la options. Add other options as desired; for help, see List the files in a directory in Unix. In the output example above, the first character in each line indicates whether the listed object is a file or a directory.
Start with:
find /path/to/file -user user1 -perm -u+rwx
This means: look for files starting in /path/to/files
, owned by user1
, where the permissions for group and other can be anything (-
in front of the permission string) and the users permissions are only: rwx
To search for files only (no directories) then add -type f
.
Also, try some reading. This has great examples: Find tutorial
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With