Which command can be used in place of 'tail' to show the first 10 lines of a file?

Prepare for the LPIC-2 Certification Test with our study tools, including flashcards and multiple choice questions with hints and explanations. Get ready to pass your exam!

The command that can be used to display the first 10 lines of a file is "head filename." This command is specifically designed for this purpose, and it outputs the first portion of the file specified. By default, it emits the first 10 lines, making it a very straightforward tool for quickly inspecting the beginning of a file's contents.

In contrast, the other options do not serve this purpose. "first filename" and "showhead filename" are not standard commands in Linux, which means they would result in an error if attempted. "cat -n filename" would display the entire file contents while numbering the lines, rather than limiting the output to just the first 10 lines. This highlights why "head" is the optimal choice when the requirement is to view the initial lines of a file.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy