Linux live log files

Linux live log files

To watch Linux live log files can help you a lot while debugging or fault finding your system. I personally use this technique to watch the access log files. With public servers on the internet there will be attacks against your servers. Everything from random brute force attacks, to specific attacks against your user accounts and applications.

Anyway, to watch linux live log files we use a command called tail. Tail simply just output the last part of a file. If you try tail /var/log/apache2/access.log, your output will be something like this:
root@web:~# tail /var/log/apache2/access.log – – [04/Jun/2016:17:54:33 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:17:54:54 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:19:26:19 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:21:26:18 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:23:15:55 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:23:16:12 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:23:21:38 +0200] “-” 408 0 “-” “-“ – – [04/Jun/2016:23:21:39 +0200] “i!/\xb0t\xa7\b@\x1f\xddE\xa9” 501 298 “-” “-“ – – [04/Jun/2016:23:26:17 +0200] “-” 408 0 “-” “-“ – – [05/Jun/2016:00:13:52 +0200] “-” 408 0 “-” “-“

This will just print the last 10 entries to access.log and quit the tail command. If you only need the last line of the log file, you can use the -n option with the tail command. If you type tail -n 1 /var/log/apache2/access.log, the output will be something like this: – – [05/Jun/2016:00:13:52 +0200] “-” 408 0 “-” “-“

Like before the tail command will display the log information, and then quit.

The most useful option if we want to keep an eye of the log files live, is the option -f. -f means follow.

If you type in tail -f /var/log/apache2/access.log, it will display the last 10 lines of the log file. Then it will stay open, and not quit like before and display new log file entries as they are appended into the log file. In the above example that means every time a user is visiting your web server they tail command will output the log file entries live.

That is how you can watch Linux live log files.

You can read more about the tail command here

Happy logging!

About Author

Related Posts

php8 gd

PHP8 gd Activate after installation

PHP8 GD activate after installation. GD doesn’t get activated by default. Not even a reboot after installation will activate it. So how do we do it? In…

Debian 12: linux-image-6.1.0-10amd64

Troubleshooting dependency issues in Debian 12: Resolving linux-image-6.1.0-10amd64 package dependency problems. If you installed the Debian 12 from the live image the issue is the raspi-firmware. Even…

4 Best Free Nas Software That Is Open Source

Free NAS software or operating systems that are free to use and will turn a computer into a NAS more advanced than the dedicated boxes sold. What…

Raspbian default password

Raspbian default password

Looking for the Raspbian default password? It is the most essential username and password that you will need for your raspberry. At least if you are running…

OpenMediaVault default password

OpenMediaVault default password

OpenMediaVault default password is printed in the documentation. I did not see it the first time I installed it either. So I had to do some detective…

Debian change dns

Debian change DNS settings to a new DNS

Debian change DNS settings for speed improvement or privacy. It is really easy to do. So let us see how it’s done and get to it. The…

Leave a Reply