UnixDroid

Text · Linux command

tail command in Linux

What does tail do?

tail shows the last lines of a file (10 by default). tail -f keeps the file open and prints new lines live — perfect for watching logs.

tail [-n N] [-f] file

Most useful options

OptionWhat it does
-n Nlast N lines
-ffollow: print new lines as they are written
-n +Neverything from line N

tail examples

$ tail /var/log/auth.log Try it ›

last 10 login events

$ tail -f /var/log/nginx/access.log Try it ›

watch web traffic live

$ tail -n 50 app.log Try it ›

last 50 lines

In security work

tail -f on auth.log during an incident shows attacks as they happen.

Questions about tail

How do I stop tail -f?

Press Ctrl+C.