I have newly created non-root(normal) user and want to grant access only to /var/log directory so that the user can view and monitor the logs. The user should not be able to cd/ls or access the /etc directory and do anything else apart from viewing files in /var/log. Is this setup possible?
I have tried to use setfacl -m u:user:--- on the /etc directory, but getting the /etc/profile permission denied error when logging in with the user.
How can i achieve this?
Method 1 :
Permission to view log files is granted to users being in the group adm.
sudo usermod -aG adm <USER>
Method 2 :
Use
logrotate
logrotate manual
Usage :
/var/log/messages { .... create 444 user group .... }
Method 3 :
Just tail it man! Tail whatever log you need.
tail -f /var/log/messages.log
I'll use the 3rd method. Because, I'm lazy. (zzzzzz)
Read
man journalctl
, and add thenormal
user to thesystemd-journal
oradm
groups.Alternatively, you could do it the complicated way:
While restricting access to other directories is (IMHO) silly, here's how you can grant access to parts of
/var/log
, by adding thenormal
user to groups. Readman group;man adduser;man find;man xargs;man stat;man sort;man uniq
. Note adding a user to a group will give that usergroup
access everywhere on the system.