Linux: how to view log entries with Tail

Linux: how to view log entries with Tail

One of the most useful tools in your Linux administration arsenal are log files. And with the open source platform, there are several log files to view. But how do you get the most out of your vision?

One of the best ways to use log files to troubleshoot a system is to view the log in real time. Since the logging system writes entries to the log file, it makes it considerably easier to see what is going on in order to help discern what is causing the problem.

The other option is to open the log file and browse or search for specific strings. Personally, I much prefer the real-time option.

To view a log file in this way, there is a handy command, called tail. According to the tail man page, tail will print the last 10 lines of each file to standard output. In simpler terms, tail prints the most recent entries in a file as they are written.

Let me show you how to use this command.

Open a terminal window on your server (or protect the shell on a server). Let’s say you want to follow the input in the syslog file. If you give the command: tail / var / log / syslog, you will see the last 10 lines of input written in the file. It’s not exactly real-time, but at least it’s easier to go through than if you were to view the entire contents of the file.

To view syslog in real time, you would add the follow option to the command, as in tail -f / var / log / syslog . This would print the last 10 lines written to syslog, but keep updating them as the input is written.

By using tail in this way, you can see (in real time) how errors and information are written to the log file. To close the queue, use the key combination Ctrl + C.

And that’s all it takes to use the command tail to more easily view the contents of the log file or view it as it is written in real time. This tool will very soon become your go-to for troubleshooting Linux operating system.

Similar Posts

Leave a Reply

Your email address will not be published.