Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

I believe:

find / -type f -perm 0777
share|improve this answer
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 –  Jacek Konieczny Mar 19 '10 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 '10 at 13:25
    
Yeah, you are right. I mixed the things up. Should be: find / -type f -perm -0777 –  Jacek Konieczny Mar 20 '10 at 19:15
add comment

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
share|improve this answer
add comment

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.