Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

The Execute permission makes sense for files (which include scripts etc), but when it comes to directories, write (w) permission works the same way as execute (x), right? Which means, if we are giving write permission to a directory we also normally check "x" (for execute) for that directory as well, right?

share|improve this question
2  
Your question is now incomprehensible. It's not clear where you're talking about the permissions on a file and where you're talking about the permissions on the directory that contains it. –  Gilles Aug 5 '11 at 7:27
1  
If you have a new question can you just post it separately? –  Michael Mrozek Aug 5 '11 at 19:27
1  
What do you mean by "read permission is all we need for a file?" All you need for what? To read a file? Yes. To modify a file... no, unless you are the owner of that file. –  gabe. Aug 5 '11 at 19:32
    
In addition to leaving out the operations "can read, can rename/delete files within the directory", your "000: can't delete it" is factually incorrect. If the directory happens to already be empty, you can delete it if you can write to its parent directory. If it's not empty, you can't delete it until it is empty (making it empty is a recursive operation that requires all three permissions on it and all nonempty subdirectories) –  Random832 Aug 5 '11 at 19:35
    
Your edit to this question made it really confusing to figure out what was being asked and did not seem to add any value for future visitors. I reverted to the original simple question form that @Gilles answered. If you have a new issue you can ask another question. Please try to keep each question focused on one issue. –  Caleb Aug 6 '11 at 14:44

1 Answer 1

up vote 16 down vote accepted

The execute permission on directories allows accessing files inside the directory. The read permission allows enumerating the directory entries. The write permission allows changing the directory attributes (e.g. its modification time) and creating and removing entries in it.

Having read or write permission on a directory without execute permission is not useful. Having execute but not read permission is occasionally useful: it allows accessing files only if you know their exact name, a sort of primitive password protection.

So in practice the useful permissions on a directory are:

  • nothing
  • occasionally x: can access files whose name is known
  • rx: normal read-only access
  • rwx: normal read and write access

See also Directory with +x permission, parents without it. When would this be useful? and Do the parent directory's permissions matter when accessing a subdirectory?

share|improve this answer
    
If you have read permission without execute permission, you can "source" the file. –  Luc M Aug 5 '11 at 0:26
1  
@Luc M what do you mean by "source the file"? –  its_me Aug 5 '11 at 1:13
3  
@Luc This is about directories, not shell scripts. –  Gilles Aug 5 '11 at 1:14
    
@Gilles please see my question once again now. I have tested some permissions and put out my findings. –  its_me Aug 5 '11 at 1:30
    
@Aahan If you have a bash, perl... file and you have not permission to execute the file, you can /bin/bash path/to/file/with/read/permission/only. /bin/bash will read the file and execute the content. –  Luc M Aug 5 '11 at 4:20

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.