How to use tail command in Ubuntu Linux with examples

The tail command on Ubuntu Linux allows users to output the end or ‘tail end of files. By default, it shows the last 10 lines.

For students and new users learning to use Linux, the easiest place to start might be on Ubuntu Linux OS.

Ubuntu is an open-source Linux operating system that runs on desktops, laptops, servers, and other devices.

About tail command:

The tail command on Ubuntu allows users to output the end or ‘tail end of files. By default, it shows the last 10 lines, like using your mouse and keyboard to read the end of files. The tail is the way to do it on the command line.

 The tail command can also be used to monitor real-time content being added to a file, displaying the newest content as it is being added.


The syntax is the rule and format of how the tail command can be used. The syntax options can be reordered. But a straight format must be followed.,.

Below is an example syntax of how to use the tail command.

tail [OPTION]. FILE.


The command line options are switches or flags that determine how the commands are executed or controlled. They modify the behavior of the command. They are separated by spaces and followed after the command options.

Below are some options for the tail command:

FILE.Replace FILE.. with the name of the file you want to read at its end. If the specified file does not already exist, the command will error.
-c, –bytes=[+]NUMUse the -c option output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file
-f, –followUse the -f or –follow option to output appended data as the file grows. this will cause the command to loop forever reading the content as it being added to the file
-n, –lines=[+]NUMUse the -n option output the last NUM lines, instead of the last 10 which is the default
-s num,
When following with -f or –followsleep for approximately num seconds between file checks. With –pid=pid, check process pidat least once every num seconds.
Verbose output. Print a message for each created directory.
–helpUse the –help option with the command to display this help and exit
–version Use the –version option to output version information and exit


Below are some examples of how to run and use the tail on Ubuntu Linux.

Run the command below to output the last 10 lines of the Confidential file without tail command options. This will come just out of the last 10 lines of the Confidential file.

tail Confidential

When you use the tail command with the -n option,  it will display the -n number of file lines. For example, run the commands below to list the last 100 lines of a file.

tail -n 100 Confidential

When you run the tail command with the -f option, it will display the last 10 lines of the file and loop forever, displaying any new lines being added to the file.

tail -f Confidential

The command above will output the last 10 lines of the Confidential file and monitor it for updates; the tail then continues to output any new lines that are added.

The tail command is a great tool to monitor log files and other data you want to monitor in real time.

When you run tail with the –help option, you’ll see the help text below:

Usage: tail [OPTION]. [FILE].
Print the last 10 lines of each FILE to standard output.
With more than one FILE, precede each with a header giving the file name.

With no FILE, or when FILE is -, read standard input.

That’s it!

I hope you like it, and please come back soon for more Ubuntu Linux commands!