Skip to main content

Command referencetail

tail command (Linux / bash / sh / zsh)

Linuxbashshzshtextbeginner

What it does

Print the end of input and optionally follow appended data. When people search for the tail command linux log, they usually want tail's everyday flags, safe examples, and how it differs from related tools. Below you'll find syntax, options, and copyable examples for Bash/sh/zsh.

Print the end of input and optionally follow appended data.

Syntax

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

Common options

Flag / optionMeaning
-n NPrint the last N lines.
-fFollow a growing file.
-FFollow by name and retry after rotation.
-c NPrint the last N bytes.

Practical examples

Last lines

tail -n 50 app.log

Shows the latest fifty log lines.

Follow log

tail -f server.log

Prints new lines as they arrive.

Survive rotation

tail -F /var/log/app.log

Reopens the named log after replacement.

Common mistakes

  • Using `-f` for rotated logs when `-F` is needed.
  • Leaving background follow processes running after a script finishes.

FAQ

What does tail do in Linux?

Print the end of input and optionally follow appended data.

How do I use tail from the terminal?

Start with `tail [OPTION]... [FILE]...`, then choose only the options needed for the task.

What is a practical tail example?

Try `tail -n 50 app.log` — Shows the latest fifty log lines.

Can I use tail in a shell script?

Yes. tail works in Bash, sh, and Zsh, but scripts should handle quoting, errors, and command output explicitly.

Browse the full Linux and Windows command reference to search more bash, CMD, PowerShell, Conda, and GitHub CLI commands.