Reading files

The head command

Shows the first lines of a file (10 by default).

Syntax

head [-n N] <archivo>

Most useful options

-n NShows N lines
-c NShows N bytes

Copy-ready examples

$ head Documentos/tareas.txtThe first 10
$ head -n 2 Documentos/tareas.txtOnly two lines

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • It is tail's twin brother, which does the same at the end.

Related commands

FAQ

How do I see only the last lines?

With tail -n N.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course