Linux – How are r– directory permissions supposed to work on Linux

file-permissionslinux

I have created directory a created has these permissions – the other user has

drwxr–r– 5 user user 4096 2012-09-15 19:30 sites

When do an ls -l on the directory as another user

ls -l /home/user/sites

this is the directory output. I thought without the x bit set on that directory the filenames wouldn't show at all.

d????????? ? ? ? ?                ? dev.user.com  
-????????? ? ? ? ?                ? user.20120914_082804.sql.gz   
d????????? ? ? ? ?                ? shared  
-????????? ? ? ? ?                ? shared.tar.gz  
-????????? ? ? ? ?                ? www.20120914_083256.tar.gz
d????????? ? ? ? ?                ? www.user.com

Is there some inconsistency here?

Best Answer

x gives you permission to actually be in the directory and access the files in the directory, r gives you permission to see the contents of the directory.

If you reversed the situation by giving the directory the x bit and removing the r bit, then the user could open shared.tar.gz (assuming proper permissions on the file itself) but only if he knew the filename in advance since ls would be unable to list the files in the directory.