tail prints just the end of a file. Learn the default of ten lines, how to set the count with -n, and how -f follows a log as it is written, by running the commands in a real terminal in your browser.
Updated: 2026-09-05
tail [options] file...
Prints the end of a file. Without a count, that means ten lines.
The terminal on this page has a log file with 30 lines in it.
$ tail logs/app.log
line 21
line 22
line 23
line 24
line 25
line 26
line 27
line 28
line 29
line 30
The last ten lines. This is the useful end of a log, because new lines are appended at the bottom.
-n takes the count.
$ tail -n 3 logs/app.log
line 28
line 29
line 30
Right after something breaks, this is the first thing to look at.
Put a + in front of the number and the meaning flips.
It is no longer a count from the end, it is from that line onwards.
$ tail -n +28 logs/app.log
line 28
line 29
line 30
-f keeps the file open and prints new lines as they arrive.
tail -f app.log
This is the standard way to watch a running server. Press Ctrl+C to stop.
tail is how you watch what is happening now.
| Situation | What you type |
|---|---|
| See the error that just happened | tail -n 50 app.log |
| Follow a running log | tail -f app.log |
| Follow only the errors | tail -f app.log | grep ERROR |
| Skip a header row | tail -n +2 users.csv |
-f waits for you to stop it.
It never returns to the prompt on its own.
Ctrl+C ends it.
Short files come out whole.
$ tail -n 2 notes.txt
buy milk
call the bank
If the file has fewer than ten lines, tail and cat show you the same thing.
A file being written can look cut off at the end. You are reading a line that is not finished yet; wait a moment and the rest appears.
webterm.appthis site
Advanced Terminal Commands
Learn commands for specific situations
learn.webterm.appa separate site

Commands stick when they show up in a real sequence of work, not one at a time. There is a course that builds them up in order.
See the course