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

On an EC2 instance I have changed Apache's log location to a different directory than the default. This is so that I can hold the logs on a (non-boot, only data) EBS.

However, I can't cd into the logs directory. It belongs to my user and has read permissions for everyone. I can't cat the logs either (although with sudo it works and I can see that Apache is logging just fine).

$ ls -lh
total 4.0K
drw-rw-rw- 2 ubuntu ubuntu 4.0K 2011-05-15 14:52 apache
$ ls -lh apache/
ls: cannot access apache/error.log: Permission denied
ls: cannot access apache/access.log: Permission denied
total 0
-????????? ? ? ? ?                ? access.log
-????????? ? ? ? ?                ? error.log
$ cd apache
-bash: cd: apache: Permission denied
$ sudo ls -lh apache/
total 2.4M
-rw-r--r-- 1 ubuntu ubuntu 2.4M 2011-05-15 15:04 access.log
-rw-r--r-- 1 ubuntu ubuntu  27K 2011-05-15 15:00 error.log

This does not make any sense to me. Help?

Edit: the filesystem is ext4.

share|improve this question
up vote 11 down vote accepted

You need the execute bit set on directories if you want to be able to switch to that. (The filesystem type doesn't really matter.)

chmod u+x ./apache
share|improve this answer

http://www.albany.edu/faculty/gms/homepage101/unix_permissions.html says

TABLE 1. UNIX DIRECTORY Permissions

WHO                     WHAT THE PERMISSIONS ALLOW
USER   Read (r)         The account owner can list the files in the directory.
       Write (w)        The account owner can create or delete files in the 
                        directory.
       Execute (x)      access files in that directory by name (such as Web 
                        page files).

GROUP  Read (r)         Everyone in the designated group can list the files in 
                        the directory.
       Write (w)        Everyone in the group can create or delete files in the 
                        directory.
       Execute (x)      Everyone in the group can change (cd) into the 
                        directory and access files in that directory by name 
                        (such as Web page files).

OTHER  Read (r)         Anyone can list the files in the directory.
       Write (w)        Anyone can create or delete files in the directory.
       Execute (x)      Anyone can change (cd) into the directory and access 
                        files in that directory by name 
                        (such as Web page files).

The Wikipedia article is worth reading and says

The effect of setting the permissions on a directory (rather than a file) is "one of the most frequently misunderstood file permission issues" (Hatch 2003).

share|improve this answer
    
So you have to have execute permissions to cd into a directory? @RedGrittyBrick – AJP Jul 6 '13 at 9:22
    
Yes, you need execute permission on a directory to “traverse” it—that is, to do anything with its contents. If you do not have execute permission, you can still see the directory, and you can stat it, but you can't ls it or access its contents at all. – Blacklight Shining Oct 21 '13 at 5:43

You must log in to answer this question.

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