How to Follow a Log File in Real Time in Linux (tail -f)

tail -f prints the last lines of a file and then keeps running, displaying new lines as they're written — commonly used to watch logs live.

Published October 3, 2026

tail -f prints the end of a file and keeps watching it, showing new lines as they are written. It is the standard way to follow live logs.

How it works

Use -n to choose how many lines to start with. -F follows by name and survives log rotation.

Pipe to grep to filter, or use multitail/lnav for several files.

Try it

tail -f /var/log/nginx/access.log
10.0.0.1 GET /index 200
10.0.0.2 POST /api 500

Practical examples

Follow with a filter

tail -f app.log | grep --line-buffered ERROR

Survive rotation

tail -F /var/log/syslog

Last 100 lines then follow

tail -n 100 -f app.log

Multiple files

tail -f a.log b.log

Common mistakes

  • Using -f when logs rotate (use -F).
  • grep buffering hiding output (use --line-buffered).
  • Forgetting Ctrl+C to stop.

Key takeaways

  • tail -f follows new lines.
  • -F handles rotation.
  • Filter with grep.

FAQ

tail vs less +F?

less +F also follows and lets you scroll back.

journalctl equivalent?

journalctl -f.

More Linux articles