Question

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

Posted July 27, 2015 6.6k views
Linux BasicsUbuntuApache

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?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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

Submit an Answer