Linux – Giving an admin user access to log files (like root would have) on Linux

linuxSecurity

I've just got a new dedicated server and have gone around setting up basic security on it.

Relevant securities I have added:

  • Can only login via private key
  • Changed ssh port
  • root cannot login via ssh, created admin user "james" <– my main issue involves this

I login as "james", who is a member of the "admin" group. I can do anything on this account, but I can't do the following:

tail -f /var/log/apache2/access.log

I can't access the access.log file, even though I thought (because I'm an admin) I should be able to do this.

How can I give "james" direct access to these files, and others that require root access, without having to su to root all the time (I'd like to disable this) and without changing permissions to 777 (death)?

Best Answer

Assuming the log has permissions that look something like this:

-rw-r--r-- 1 root root 580700 Aug 1 10:53 access_log

You could change the group access to the admin group by issuing a command such as:

sudo chown root:admin /var/log/apache2/access.log

Resulting in

-rw-r--r-- 1 root admin 580700 Aug 1 10:55 access_log

This would allow someone belonging to the admin group read permissions on the log.