text

tail

Prints the last part of files. Essential for log inspection, especially with the follow flag to stream new lines.

tail [OPTION]... [FILE]...

Common flags

Flag Purpose
-n Print the last N lines (use -n +N to start at line N)
-c Print the last N bytes
-f Follow the file as it grows
-F Follow by name -- reopens after rotation/truncation
--pid With -f, exit when the given PID dies

Examples

tail -n 100 app.log

Last 100 lines

tail -f /var/log/syslog

Stream new lines as they arrive

tail -F app.log

Follow across log rotation

tail -n +2 data.csv

Skip the CSV header row

Gotcha

-f follows the file descriptor, so logrotate replacements are missed; use -F for rotated logs.

Related commands

← All Linux commands · Linux cheat sheet