Viewing Content

head

Shows the first lines of a file or stream.

head is useful for quickly checking file structure, headers, or the beginning of logs.

Syntax
head [options] [file]

Arguments explained

  • file is optional; without it, head reads standard input.
  • -n chooses the number of lines.
  • -c chooses bytes instead of lines.

Common examples

Show first 20 lines
head -n 20 access.log

Prints the beginning of a log file.

Preview command output
ps aux | head

Shows the first few process rows.

head Command
FieldDetails
Commandhead
CategoryViewing Content
Primary useShows the first lines of a file or stream.
Syntaxhead [options] [file]