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.
Students and new users who are learning to use Linux, the easiest place to start might be on Ubuntu Linux OS.
Ubuntu is an open-source Linux operating systems that runs on desktops, laptops, server 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 in real-time content being added to a file, displaying the newest content as it is being added.
Syntax is the rule and format of how the tail command can be used. the syntax options can be reordered. but 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 determined how the commands are executed or controlled. they modify the behavior of the command. they are separated by spaces and followed after the commands options.
Below are some options of the tail command:
|FILE.||Replace FILE.. with the name of the file you want to read its end. If the specified file does not already exist, the command will error out..|
|-c, –bytes=[+]NUM||Use the -c option output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file|
|-f, –follow||Use 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=[+]NUM||Use the -n option output the last NUM lines, instead of the last 10 which is the default|
|When following with -f or –follow, sleep 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.|
|–help||Use 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 any tail command options. This will just out the last 10 lines of the file called Confidential..
When you use the tail command with the -n option, it will display the -n number of lines of the file.. For example, to list the last 100 lines of a file, run the commands below.
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 Confidential file, and monitors it for updates; tail then continues to output any new lines that are adding to it.
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. Mandatory arguments to long options are mandatory for short options too. NUM may have a multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024, GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.
Hope you like it and please come back soon for more Ubuntu Linux command!