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.

How can I get a list of non-writable files within my current directory?

share|improve this question

4 Answers 4

up vote 13 down vote accepted

Interpreting that as: user/group/other cannot write

find . -maxdepth 1 -not -perm /ugo+w

share|improve this answer
2  
+1 for -maxdepth 1 –  Aaron Copley May 2 '11 at 19:42

This find will find files that aren't writable by anyone:

find . ! -perm /222

EDIT: From hmont's suggestion on the comment:

find . ! -perm /222 -exec ls -l {} +

And as Mikey puts on his answer, you can use -maxdepth 1 to limit the find to a single directory.

share|improve this answer
    
Har! You beat me by 2 seconds, but forgot the 'in the current directory' (along with everybody else). :p –  MikeyB May 2 '11 at 19:32
2  
+1 because it's the clearest one. I would add a -exec ls -l {} \; to provide full information about permissions and owner/group stuff. –  hmontoliu May 2 '11 at 19:34
    
@Mikey that can be interpreted in many ways :) But your syntax is more readable than mine on the overall. –  coredump May 2 '11 at 19:34
    
@hmontoliu just to further refine the cmd: instead of "-exec", and since this is linux (vs. solaris et al), you can simply use the faster "-ls" option to find (the format is different, the content is mostly the same): find . -maxdepth 1 ! -perm /222 -ls –  michael_n May 5 '11 at 1:03
    
@michael_n: good to know –  hmontoliu May 5 '11 at 6:03

find . ! -perm /a+w
find . ! -perm -ug+w

or some other permutation with symbolic notation to meet your requirements.

To clarify, the '/' will match any user, group, or other. To match all, precede the mode with '-'.

share|improve this answer
perl -le 'print for grep { ! -w } <*>'
share|improve this answer

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.