Apache2 logs: What file permissions to set and how to read with sudo?

July 27, 2015 5k views
Ubuntu Linux Basics Apache

I have Ubuntu 14.04 on two droplets. One was the one click LAMP install the other I installed Apache2 manually.

With both droplets the directory for the log files are set as:

drwxr-x— 2 root adm

When I try:

‘sudo cd /var/log/apache2’

I get the error: 'sudo: cd: command not found’

The only way of moving into that directory is to log in as root. Sudo doesn’t work.

However, I can do: 'sudo less /var/log/apache2/access.log’ and read the output.

Why isn’t 'cd’ working with sudo in this instance?

1 Answer

The sudo command works only for executables and cd is a shell builtin.

You can use sudo -s to move to a root shell and execute cd or do sudo ls /var/log/apache2 and then view the file of your choice.

Have another answer? Share your knowledge.