Prepare for the Linux Professional Institute Level 2 Certification. Study with practice questions, comprehensive explanations, and quizzes to boost your confidence. Get exam ready with our resources!

Multiple Choice

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

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.

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.