↑↓ move Enter open Esc close

How to View the Last Lines of a File in Linux

Use tail to inspect recent log entries and control how many lines you see.

Large log files are rarely useful from the beginning. `tail` starts at the end, where the newest entries normally are, making it one of the first commands to reach for during troubleshooting.

Step by step

1 Show the last 10 lines

$ tail app.log

Ten lines is the default.

2 Show a specific number

$ tail -n 50 app.log

Displays the last 50 lines.

3 Show the last bytes

$ tail -c 2000 app.log

Useful when you need a byte-sized slice rather than a line count.

4 Follow new entries

$ tail -f app.log

Keeps the command running and prints new data as it is appended.

Tips worth knowing

Frequently asked questions

How do I see the last 100 lines of a file?

Use `tail -n 100 file.txt`.

What is the difference between tail and head?

tail reads from the end; head reads from the beginning.

How do I watch a log file live?

Use `tail -f app.log` or `tail -F app.log` when the file may be rotated.

The commands behind it

More how-to guides