Skip to main content

tail: Bottom of File

tail shows the last N lines of a file — the mirror of head. For logs, where the newest entries are at the bottom, tail is often more useful than head.

Basic usage

tail access.log

Shows the last 10 lines.

Specifying a line count

tail -n 5 access.log

Shows the last 5 lines.

Typical use: checking recent log entries

When a process is running and you want to see the most recent activity:

tail -n 20 server.log

This gives you the 20 most recent lines — enough context to see what's happening without scrolling through thousands of lines.

Comparing head and tail

CommandShows
head -n 5 fileFirst 5 lines
tail -n 5 fileLast 5 lines
head -n -5 fileEverything except the last 5 lines
tail -n +5 fileFrom line 5 onwards

The + and - variants are less common but good to know.

Practice

Show the last 5 lines of access.log using tail -n 5.

Loading terminal…
Donate to this project