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…
The same way one uses his / her mouse and keyboard to read the content of a file and perform others tasks on Microsoft Windows OS, Ubuntu also makes it that easy…
Ubuntu desktop is intuitive and great for Linux beginners… However, when you’re learning to use and understand Ubuntu Linux, you’ll also want to learn the commands behind the graphics and mouse-clicking… and how to use them… This tutorial is going to show you how…..
This post shows new users and students what the tail command is used for and how to use it…
When you’re ready to learn how to use the tail commands, follow the guide below:
About tail command:
The tail command on Ubuntu allow 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:
||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…..
||Use the -c option output the last NUM bytes; or use -c +NUM to output starting with byte NUM of each file
||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
||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.
||Use the –help option with the command to display this help and exit
|| 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.
-c, --bytes=[+]NUM output the last NUM bytes; or use -c +NUM to
output starting with byte NUM of each file
output appended data as the file grows;
an absent option argument means 'descriptor'
-F same as --follow=name --retry
-n, --lines=[+]NUM output the last NUM lines, instead of the last 10;
or use -n +NUM to output starting with line NUM
with --follow=name, reopen a FILE which has not
changed size after N (default 5) iterations
to see if it has been unlinked or renamed
(this is the usual case of rotated log files);
with inotify, this option is rarely useful
--pid=PID with -f, terminate after process ID, PID dies
-q, --quiet, --silent never output headers giving file names
--retry keep trying to open a file if it is inaccessible
-s, --sleep-interval=N with -f, sleep for approximately N seconds
(default 1.0) between iterations;
with inotify and --pid=P, check process P at
least once every N seconds
-v, --verbose always output headers giving file names
-z, --zero-terminated line delimiter is NUL, not newline
--help display this help and exit
--version output version information and exit
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!
You may also like the commands below:
WordPress 5.0 “Bebo” Released — Here’s How to Install / Upgrade on Ubuntu 16.04 / 18.04 / 18.10