1

Is it possible for me to view all files on the server with a specific permission?

3 Answers 3

5

I believe:

find / -type f -perm 0777
3
  • 1
    This will probably not show files with more mode bits set (yes, there are three more: s-gid, s-uid and 'sticky'). I guess a better choice would be: find / -type -f -perm /0777 Mar 19, 2010 at 19:18
  • @Jacek: not quite, "-perm /xxx" means "Any of the permission bits mode are set for the file", and would also match the "normal-644" file from my example below.
    – janmoesen
    Mar 20, 2010 at 13:25
  • Yeah, you are right. I mixed the things up. Should be: find / -type f -perm -0777 Mar 20, 2010 at 19:15
2

I know the previous answer was accepted, but I wanted to post this "caveat administrator". -perm 0777 matches that exact combination. setuid/setgid files are special, so I use -perm -777 to also include those:


-----[ 19:19:33 ] (!4054) [ :-) ] janmoesen@purplepixelhost ~/bar
$ for x in *; do printf "%4d %s\n" "$(stat -c %a "$x")" "$(ls -dalF "$x")"; done
 777 -rwxrwxrwx 1 janmoesen janmoesen 0 2010-03-19 19:17 all-777*
 644 -rw-r--r-- 1 janmoesen janmoesen 0 2010-03-19 19:17 normal-644
2777 -rwxrwsrwx 1 janmoesen janmoesen 0 2010-03-19 19:17 sgid-777*
4777 -rwsrwxrwx 1 janmoesen janmoesen 0 2010-03-19 19:17 suid-777*

-----[ 19:21:34 ] (!4054) [ :-) ] janmoesen@purplepixelhost ~/bar
$ find . -type f -perm 0777
./all-777

-----[ 19:21:37 ] (!4054) [ :-) ] janmoesen@purplepixelhost ~/bar
$ find . -type f -perm -777
./all-777
./suid-777
./sgid-777
1

Your question is not clear. You say 'view', but I think you mean 'find'.

Do you want to FIND all files with a specific permission? That would be something like:

find . -type f -perm 777

This would find all files which were Readable, writable and executable by all users on the system.

See some examples at http://linux.about.com/od/commands/l/blcmdl1_find.htm#examples

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .