What command shows the first 10 lines of a file?

Disable ads (and more) with a premium pass for a one time $4.99 payment

Boost your Linux skills with the CompTIA Linux+ Certification Exam simulator. Engage with multiple choice questions and detailed feedback. Master Linux concepts and prepare for your exam with confidence!

The command that shows the first 10 lines of a file is "head." This command is commonly used in Unix-like operating systems, including Linux, to display the beginning portion of a file. By default, head retrieves the first 10 lines, although this behavior can be modified by using additional options to specify a different number of lines if needed.

For example, if you wanted to see the first 20 lines of a file instead of the default 10, you could use the command head -n 20 filename. This versatility makes head a valuable tool for quickly viewing the initial content of files, especially large text files where navigating to the beginning can save time.

The other options provided do not correspond to any standard command in Linux that retrieves the first 10 lines of a file. While "first," "showtop," and "preview" may seem intuitive, they are not recognized commands in Linux for this specific purpose. This is why head is the correct choice for this question.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy