Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

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

You must log in to answer this question.

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