Can't cd into my own directory?

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.

2 Answers

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

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).

2

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like