When I was trying to monitor the /var/log/secure or /var/log/message using watch command the output showed as /var/log/messages: Permission denied. Is it possible to monitor the /var/log/messages and /var/log/secure using watch command?
2 Answers
Yes it is, but note that regular users don't have permission to read /var/log/messages and /var/log/secure.
sudo watch tail /var/log/messages
worked fine here when I tried.
-
Hi Ulrich Schwarz, im using centos 6.7 , i used root account rather than normal user account, i got the error message when i was using root account only.vinothsaran– vinothsaran2016-04-26 13:19:18 +00:00Commented Apr 26, 2016 at 13:19
-
Note that most sensible distros will make log files owned
root admand mode0640so anyone in theadmgroup can read them. If so,adduser regularjoe admwill allowregularjoeto read them once he logs in again.Shadur-don't-feed-the-AI– Shadur-don't-feed-the-AI2016-07-23 18:01:58 +00:00Commented Jul 23, 2016 at 18:01
You only have to issue:
sudo tail -f /var/log/messages
This will continuously add the latest line to the screen or file.
watcha file, you have to give it a command to run, like Ulrich Schwarz's answer withtail. For a file, you can just usetail -finstead ofwatch./var/log/securemay rotate while tailing them, causingtail -fto stop printing logs. To continue following even if the file is rotated, usetail -F.