The tail command in Linux prints the last part of a file—by default the last 10 lines. It is part of GNU coreutils on Ubuntu and is the everyday tool for checking recent log output and watching files as they grow (-f / -F).
man tail tail --version
Official reference: Ubuntu man page tail(1). With no file (or -), tail reads standard input. If you already know your goal, jump to: -n, -f/-F, multiple files, or grep pipelines. To print a whole short file, use cat instead.

Basic Syntax
tail [OPTION]... [FILE]...
tail /var/log/syslog # last 10 lines tail notes.txt
With more than one file, GNU tail prints a header (==> filename <==<>) before each file’s output.
Show a Specific Number of Lines (-n)
tail -n 20 /var/log/syslog # last 20 lines tail -20 /var/log/syslog # short form (GNU)
Start from a given line number with +:
# Skip the first 99 lines; print from line 100 onward tail -n +100 bigfile.txt
Follow a Growing File (-f and -F)
Watch new lines as they are appended (Ctrl+C to stop):
tail -f /var/log/syslog tail -f app.log
From the man page:
| Mode | Behavior |
|---|---|
-f / --follow | Follow by file descriptor (default). If the file is renamed, tail still follows the old inode. |
-F | Same as --follow=name --retry—follow by name, reopen after rotation/unlink. |
# Better for rotated logs (logrotate) tail -F /var/log/nginx/access.log
Other useful follow options:
tail -f -s 2 app.log # sleep ~2s between checks tail -f --pid=1234 app.log # stop when PID 1234 exits (GNU) tail -f --retry missing.log # keep trying if file is inaccessible
Multiple Files in One Terminal
Ask Ubuntu tip—pass several paths to one tail -f:
tail -f /var/log/syslog /var/log/auth.log
Headers label which file each block came from. Alternatives: multitail, tmux/screen splits, or terminal tabs.
tail -q -n 5 a.log b.log # -q: quiet (no headers) tail -v file.txt # -v: always show headers
Bytes Instead of Lines (-c)
tail -c 100 file.bin # last 100 bytes tail -c +200 file.txt # from byte 200 to end
NUM can use suffixes like K, M (see man tail).
Pipelines: Filter While Following
For grep flags and buffering details beyond this page, see the grep command in Linux guide.
Common Ask Ubuntu pattern—follow then filter:
tail -f my_file.log | grep "X"
Chaining two greps can look “stuck” because of buffering. Fixes:
tail -f /path/to/log | grep --line-buffered 'X' | grep -v 'Y' # or tail -f /path/to/log | stdbuf -oL grep 'X' | grep -v 'Y' # or one awk rule tail -f /path/to/log | awk '/X/ && !/Y/'
Also useful:
dmesg | tail -n 30 journalctl -u ssh -n 50 # systemd: often better than raw files journalctl -f -u nginx # follow a unit (alternative to tail -f)
Head vs Tail
| Command | Shows |
|---|---|
head | Beginning of a file |
tail | End of a file |
tail -f / -F | Live end of a growing/rotated file |
head -n 20 file.txt tail -n 20 file.txt
Need the full file contents or to join files? That is cat's job—not tail.
Common Pitfalls
| Problem | What to try |
|---|---|
Log rotates and -f “stops” | Use tail -F (follow by name + retry) |
tail -f | grep | grep silent | --line-buffered / stdbuf -oL / awk |
| Live USB / overlayfs oddities | Some filesystems break inotify; see Ask Ubuntu workarounds |
| Huge noisy logs | tail -n first, then -f with grep |
| Need service-centric logs | Prefer journalctl -f -u … on systemd |
Stop a follow session with Ctrl+C. In scripts, prefer tail --pid=$$ -f … so follow ends when the parent process exits.
Quick Cheat Sheet
tail file # last 10 lines tail -n 50 file # last 50 lines tail -n +100 file # from line 100 tail -f file # follow (descriptor) tail -F file # follow name (rotation-safe) tail -f a.log b.log # multiple files tail -c 1K file # last 1K bytes tail -f log | grep --line-buffered ERROR tail -f --pid=$PID app.log
From Terminal Logs to Shareable Documents
tail and tail -f belong in the terminal. After you isolate the failing lines, the next step is often a short incident note, a timestamp table, or a PDF for teammates still on Microsoft Office. For that handoff, use a desktop suite—not another pager.
WPS Office for Linux covers Writer, Spreadsheet, Presentation, and PDF tools on Ubuntu and other mainstream distributions, so the report you write on Linux opens cleanly for Windows colleagues.

What you need after tail | What WPS gives you |
|---|---|
| Keep charts, tables, and slides intact in Office files | Strong .docx / .xlsx / .pptx layout fidelity when exchanging with Windows or macOS |
| One app for notes, sheets, slides, and PDF | Free core suite: Writer, Spreadsheet, Presentation, plus PDF view/edit/convert |
| A familiar UI on a modest laptop | Ribbon-style desktop apps with a lighter footprint than many heavyweight suites |
| A trusted install path | Official DEB (Ubuntu/Debian/Mint) and RPM packages—no random mirrors |
Get the current 64-bit build from the official WPS Office for Linux download page (choose Deb on Ubuntu), then install the local file—replace VERSION with the name you downloaded:
cd ~/Downloads sudo apt install ./wps-office_VERSION_amd64.deb
Open Writer, paste the snippet you pulled with tail and grep, and save as DOCX or export PDF so formatting survives the handoff. Keep tail for watching services; use WPS when those lines need to become a real document your team can open anywhere.
FAQ
What does the tail command do in Linux?
It prints the last part of a file (default: 10 lines), and can follow new data as the file grows.
What is the difference between tail -f and tail -F?-f follows the open file descriptor; -F follows the filename and retries—better when logs are rotated.
How do I show the last 100 lines?tail -n 100 filename
How do I follow two logs at once?tail -f /var/log/syslog /var/log/auth.log
Why did my grep pipeline stop updating?
Output buffering—use grep --line-buffered or stdbuf -oL.
Where is the official documentation?
Run man tail or see the Ubuntu tail(1) man page.


