When to use tail
Use tail to inspect recent output or monitor a growing log. Choose name-following for rotated application logs and remember that a continuous follow command must be stopped interactively.
Syntax
tail [OPTIONS] [FILE...]Square brackets mark optional arguments; an ellipsis means repetition. Replace example file names, user names and server addresses with your own values.
Common options and arguments
Usage examples
Show latest errors
tail -n 50 ./app.logThe most recent fifty lines are displayed.
Follow a log across rotation
tail -F ./app.logThe filename is followed across common rotation and recreation events rather than only the original descriptor.
Show lines starting from second
tail -n +2 ./report.tsvOutput begins at the second line, which can omit a single header row.
Notes and limitations
- Press Ctrl+C to stop following the file.
- After log rotation, -f may still follow the old file descriptor; -F is usually more suitable for logs.
Common questions and troubleshooting
How do I stop following a log?
Press Ctrl+C to interrupt tail and return to the shell. This stops the viewer, not the application writing the log.
Why do lines stop appearing after rotation?
Descriptor-following can remain attached to the old file. Name-following with retry is useful when the log is renamed and recreated.
Further help
Options vary by version and distribution. Check the installed documentation with this command: man tail.