Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find files that only have certain permission for owner?

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.

like image 481
Alex Gao Avatar asked Mar 06 '13 12:03

Alex Gao


People also ask

How do I find a file with specific permissions?

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.

Which options of the find command can you use to locate files owned by a particular user?

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.

How do I check permissions to list files and directories?

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.


1 Answers

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

like image 140
jim mcnamara Avatar answered Sep 18 '22 13:09

jim mcnamara