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?
Asked
Active
Viewed 1.1k times
4
William
- 13
vinothsaran
- 339
2 Answers
5
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.
Ulrich Schwarz
- 15,989
-
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 Apr 26 '16 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 Jul 23 '16 at 18:01
1
You only have to issue:
sudo tail -f /var/log/messages
This will continuously add the latest line to the screen or file.
Stephen Kitt
- 434,908
user201952
- 11
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. – meuh Apr 26 '16 at 13:38/var/log/securemay rotate while tailing them, causingtail -fto stop printing logs. To continue following even if the file is rotated, usetail -F. – Mike Feb 08 '18 at 10:10