Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using `find -perm` to find when a permission is not set

Tags:

linux

find

bash

I want to find the non-readable files in my directory (eg the files with g-r). So I tried this:

find . -perm -g-r

It shows me all of the files?? So I tried this:

find . -perm -g+r

And it showed me only the readable files. It appears that -perm -g-r matches all files. I'm using CentOS 5.5. Am I doing something wrong? It doesn't look like -perm -g-r does anything useful.

like image 738
User1 Avatar asked Dec 07 '10 23:12

User1


People also ask

How do I check access permissions?

Step 2 – Right-click the folder or file and click “Properties” in the context menu. Step 3 – Switch to “Security” tab and click “Advanced”. Step 4 – In the “Permissions” tab, you can see the permissions held by users over a particular file or folder.

How do you find effective permissions?

View Effective Permissions for User or User Groups To view the Effective Permissions for any files or folders, right-click on it and select Properties and click on the Security tab. Next, click on the Advanced button and then on the Effective Permissions tab.

How do I check permissions on a directory?

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.

How do I check permissions on a command?

Check Permissions in Command-Line with Ls Command If you prefer using the command line, you can easily find a file's permission settings with the ls command, used to list information about files/directories. You can also add the –l option to the command to see the information in the long list format.


2 Answers

Try:

find . ! -perm -g+r

like image 84
jgr Avatar answered Oct 08 '22 00:10

jgr


If you want to find files that are non-readable by you, you could use

find . ! -readable
like image 35
Charley Avatar answered Oct 07 '22 23:10

Charley