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 adm
and mode0640
so anyone in theadm
group can read them. If so,adduser regularjoe adm
will allowregularjoe
to 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
watch
a file, you have to give it a command to run, like Ulrich Schwarz's answer withtail
. For a file, you can just usetail -f
instead ofwatch
. – meuh Apr 26 '16 at 13:38/var/log/secure
may rotate while tailing them, causingtail -f
to stop printing logs. To continue following even if the file is rotated, usetail -F
. – Mike Feb 08 '18 at 10:10