Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

In linux how can I list the ordinary files in current directory that are not user writable? I tried with the ls -l command.But it displayed both the owner and group files.Is there a command to display this?

share|improve this question

1 Answer 1

You can do this using find:

find -maxdepth 1 -type f ! -writable -ls

The parameters:

  • -maxdepth 1: find is recursive, this limits results to the current folder and its children
  • -type f: Only return files (not folders or links)
  • ! -writable: Only return those that aren't writable to the current user.
  • -ls Don't just return the file names, but mimic ls -l output.

Alternatively, if you don't care about owner and group and the current user, just about the permission bits:

find -maxdepth 1 -type f ! -perm -200 -ls
  • ! -perm -200 returns those that do not have all of the set permission bits in 200 set (i.e. user-writable).
share|improve this answer
    
thank you...... –  subhashini Aug 25 '13 at 13:28
    
@subhashini You're welcome. To accept this answer as correct and mark the question as solved, click the check mark next to this answer. –  Daniel Beck Aug 25 '13 at 13:35

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.