arrow_back Back to Notebook
linux
linux
January 10, 2019

What is TAIL in Linux and how you should use it!

You might wonder 'how do I get the last lines of a log file' or 'how do I get new lines written to a file in linux'. Well tail is what you need!

What is tail?

Tail is a program which Outputs a number of lines from a file depending on what arguments you call it with. There are quite a few arguments you can add but the core what is useful is below.

Usage

You can invoke tail but where it really shines is in a pipe operation.

Last 5 lines

./someFile.txt | tail -n 5

To print any new lines

./someFile.txt | tail -f

Useful Arguments to Remember

ARG Name Action
-f follow output new lines on the end
-F follow and retry follow and retry if the file is inaccessible
-n # number number of lines to output when the command is run
+ # number of lines to output at the start of the file
- # number of lines to output at the end of the file

Thanks for reading!

John Wiseman

Full-Stack Software Engineer building scalable digital solutions. specializing in modern web technologies and mission-critical systems.

© 2026 Wiseman Systems Pty. Ltd.

Navigation

Start a Conversation

Ready to discuss your next project? Let's build something extraordinary together.

Get in Touch