Multiple choice unix

Which command is used to display the top of the file?

  1. cat

  2. head

  3. more

  4. grep

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

The head command is specifically designed to output the beginning (top) part of a file. cat concatenates and outputs the entire file, more pages through text, and grep searches for patterns.

AI explanation

The Unix/Linux head command displays the first (top) lines of a file by default (10 lines unless -n specifies otherwise). cat prints the entire file, not just the top. more is a pager for viewing a whole file page-by-page, not specifically the top portion. grep searches for pattern matches, unrelated to file position. head is the tool purpose-built for this.