Which command would you use to display the last 10 lines of a file?

Prepare for the LPI Linux Essentials 010-160 Test. Study with flashcards and multiple choice questions, each question offers hints and explanations. Get ready to ace your exam!

The command used to display the last 10 lines of a file is the tail command. This command is specifically designed to read the end of a file, and by default, it outputs the last 10 lines. This is particularly useful for quickly checking the most recent entries in log files or any other file where the end content is of interest.

To illustrate, when you run the command tail filename, it will show the last 10 lines of that file. You can customize the number of lines displayed by using the -n option, such as tail -n 20 filename, which would display the last 20 lines instead.

In contrast, other options like head, cat, and last serve different purposes. The head command displays the first lines of a file, the cat command outputs the entire contents of a file, and the last command is used to show the last logged-in users, which is unrelated to file content. Thus, tail is the correct choice for the task of displaying the last 10 lines of a file.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy