Linux How To Watch A Log File
It is easy to watch a log file in Linux.
Just use the tail command with the “-f” parameter. By default tail will display the last 10 lines of a file. Adding the “-f” parameter will tell it to follow the file. This means that it will constantly watch the file and display any additional lines that are added to it. You can run the command like this.
tail -f /var/log/dmesg
If you want to start out by displaying the last 100 lines of a file while still following that file for additional updates you can specify the number of lines to start with using the “-n” parameter. This is what that command would look like.
tail -n 100 -f /var/log/dmesg
If you don’t have permission to read a given log file you can use sudo like this.
sudo tail -n 100 -f /var/log/dmesg