Reading files

The tail command

Shows the last lines of a file. The log watcher's command.

Syntax

tail [-n N] <archivo>

Most useful options

-n NShows N lines
-fDoes not quit: keeps showing new lines

Copy-ready examples

$ tail Documentos/tareas.txtThe last 10
$ tail -n 1 Documentos/tareas.txtOnly the last one

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

Typical mistakes

  • With -f it keeps listening: on a real log you see lines arrive live.

Related commands

FAQ

What exactly does tail -f do?

It follows the file: it shows new lines as they are appended.

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