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.

I used the following commands in linux environment

[junk is a directory]

chmod –x junk      
ls junk 
ls –l junk

I got the outputs as..

 ls: cannot access junk/5: Permission denied  
 ls: cannot access junk/1: Permission denied  
 ls: cannot access junk/2: Permission denied  
 ls: cannot access junk/4: Permission denied  
 ls: cannot access junk/3: Permission denied 
 1  2  3  4  5

and

  ls: cannot access junk/5: Permission denied 
  ls: cannot access junk/1: Permission denied 
  ls: cannot access junk/2: Permission denied 
  ls: cannot access junk/4: Permission denied 
  ls: cannot access junk/3: Permission denied 
  total 0
  -????????? ? ? ? ?            ? 1
  -????????? ? ? ? ?            ? 2
  -????????? ? ? ? ?            ? 3
  -????????? ? ? ? ?            ? 4
  -????????? ? ? ? ?            ? 5

I googled it found that if a directory does not have the execute permission then its inode can not be accessed. My question is here if the inode of the directory "junk" is not accessible then how the name of the files in the directory are being shown?

share|improve this question

migrated from stackoverflow.com Nov 6 '12 at 2:35

This question came from our site for professional and enthusiast programmers.

add comment

1 Answer

Because you have read permission to that directory. As long as you have read access, you can list out the contents of the directory but can't read or write to the files inside the directory.

For example, if you do vi junk/1 Or cat junk/1, it will fail.

share|improve this answer
add comment

Your Answer

 
discard

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