Which command is used to display the first few lines of a text file?

Prepare for the LPI 101-500 Certification Exam. Utilize flashcards, navigate multiple choice questions, and benefit from hints and explanations. Begin your Linux certification journey today!

The command used to display the first few lines of a text file is "head." This command is specifically designed for that purpose and, by default, shows the first ten lines of a given file. It is particularly useful for quickly viewing the beginning part of larger files without having to open the entire file.

The other commands serve different purposes: "tail" is used to display the last few lines of a file, "cat" concatenates and displays the entire content of a file, and "less" allows for viewing the content of a file one screen at a time but does not default to just the first few lines. Thus, "head" is the correct choice for this specific task.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy