21

My Ubuntu vitual server wen't offline. I rebooted it and now want to debug what happened.

I can browse to /etc/log but if I try cd apache2 it says Permission denied. I'm sure my user account has priviliges. I also tried sudo cd apache2 which gives the the error sudo: cd: command not found

How can I access the apache logs? I also tried via sftp without success

PS I am new to linux and virtual servers, but I am keen to learn everything I can.

4
  • Try sudo -i then cd apache2.
    – Wilf
    Feb 16, 2014 at 15:45
  • @Wilf it then says -bash: cd: apache2: No such file or directory
    – S..
    Feb 16, 2014 at 16:12
  • sudo su them access
    – vidur punj
    Aug 13, 2017 at 12:22
  • The logs are located under var not etc. You need to go to /var/log/apache2. If you dont have the rights to enter the folder, open a root terminal. do sudo -i and the go to cd /var/log/apache2 and take a look at the files there. Good luck...
    – s1mmel
    Dec 9, 2019 at 9:43

3 Answers 3

36

You need to add your username to the group adm

sudo usermod -aG adm YourUserName

You can then access the logfiles as normal user without sudo.

3
  • Thanks, this worked and made me able to actually browse to directory.
    – S..
    Feb 16, 2014 at 18:07
  • 18
    I had to log in / out of my user session for this permission to take effect.
    – Horba
    Jan 29, 2015 at 0:15
  • it working but you Need log-out from ssh and log-in again. then you have access. Dec 20, 2018 at 6:51
6

Try:

sudo cat /var/log/apache2/error.log
1
  • Thanks wojox, but is there a more permanent solution? Like being able to navigate to the apache2 folder?
    – S..
    Feb 16, 2014 at 16:13
2

You can log in as root user:

sudo su

And then you are able to do:

cd apache2
3
  • That works, thanks, although is it permanent or will su only have elevated privileges for the current session?
    – S..
    Jan 29, 2020 at 9:56
  • I like the solution by @rechengehirn as it's permanent.
    – S..
    Jan 29, 2020 at 9:57
  • Unfortunately it's not permanent.
    – david
    Mar 2, 2020 at 13:30

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.