Why can't I cd into a directory?
I am running Ubuntu 10.04.2 LTS. Why I can't I cd
into the /var/www
directory?
david@ubuntu:/var$ pwd
/var
david@ubuntu:/var$ ls -l
drwxrwxr-- 13 root root 4096 2011-02-26 21:53 www
david@ubuntu:/var$ cd www
-bash: cd: www: Permission denied
david@ubuntu:/var$ sudo cd www
sudo: cd: command not found
You need execute permission to cd into a directory.
sudo chmod o+x /var/www
There is some reason for prohibiting the ''others'' from entering the directory, no? So I would suggest to get root access to enter that directory, do some stuff, and leave it, dropping the sudo shell.
sudo -i
cd /var/www
# do your thing
cd -
exit
Just a little further info, it would be wise to create a web user and group for your system and not have services running as root. Then you can also add users to that group if needed and not be giving root privileges out.