User Tools

Site Tools


tipsandtricks:howtoreadlogs

This is an old revision of the document!


<== Back to menu
<= Back

How to read logs in *nix cli

This is mostly based on the bash terminal but should be more application (less, tail and so on) than the specific terminal.
This is also how i use the application listed below to read logs and to troubleshoot.

The commands

Less

Less man pages, external link
Less is the main tool I am using when reading logs. I find the search function good and its quick to open and search in.

Searching in the file

Using the / sign to search forward in the file. (top down)
Using the ? sign to search backwards in the file. (bottom up)

Using g to go to the top of the file.
Can also be used to go to a specific row ( g 11 [enter] ) g followed by 11 goes to row 11.
Using G go to the end of the file.

Tail

Less man pages, external link
Tail is a usefull application for looking att appending logs. Or just the last 10 rows in the logfile.

I use it for:

  1. See the end of the log-file.
  2. Let tail print new rows added to the logfile.
tail {logfile}

This will print out the last 10 rows to standard out = the screen.
You can choose the number of files to be printed to screen. Use the -n flag.

tail -n 20 {logfile}

This will print out the last 20 rows of the logfile.

tail -f {logfile}

This will print out the last 10 rows and continue to print out rows when they are added to the logfile.

You can also combine the two if you want to see more rows from the logfile at the start.

tail -f -n 20 {logfile}
tipsandtricks/howtoreadlogs.1637054037.txt.gz · Last modified: 2023/09/29 07:01 (external edit)