Linux Tail Command

Apr 19, 2023

Related to:: Linux - SysAdmin

Command to see the last lines of a file directly in the terminal.

By default, it shows the last 10 lines of a file.

tail filename

To get a different number of lines you can use the -n number option

tail -n 2 filename # Shows 2 lines
tail -n 100 filename # Shows 100 lines 

Tip: to see all lines of a file is best to use the cat command.

Flag -f - Used to “follow the file”. This shows the last lines and keeps waiting for new lines, showing them when the file gets updated.

This flag is ideal to check real-time logs.

tail -f file

Use the manual for all the available flags.

man tail

Graph View