Report this

What is the reason for this report?

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

Posted on July 27, 2015

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?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

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.

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.

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.