The tail command in Linux is a utility used to display the last few lines of a text file. It is commonly used for monitoring log files and viewing the most recent entries. By default, tail shows the last 10 lines of a file, but you can customize the number of lines displayed using the -n option.
Basic Usage
tail filename.txt
Displaying a Specific Number of Lines
To display, for example, the last 20 lines:
tail -n 20 filename.txt
Monitoring a File in Real-Time
You can also use the -f option to follow a file in real-time, which is useful for monitoring log files as they are updated:
tail -f logfile.txt
This command will keep the terminal open and display new lines as they are added to the file. To stop following the file, you can use Ctrl+C.
