tailf Command in Linux

This tutorial explains Linux “tailf” command, options and its usage with examples.

tailf – follow the growth of a log file


tailf will print out the last 10 lines of a file and then wait for the file to grow. It is similar to tail -f but does not access the file when it is not growing. This has the side effect of not updating the access time for the file, so a filesystem flush does not occur periodically when no log activity is happening. tailf is extremely useful for monitoring log files on a laptop when logging is infrequent and the user desires that the hard disk spin down to conserve battery life.


tailf [OPTION] file



-n, –lines=N, -N
output the last N lines, instead of the last 10.


Sanfoundry Certification Contest of the Month is Live. 100+ Subjects. Participate Now!

1. Display the last 5 lines and then update the file as new lines are being added

$ tailf -n 5 myfile.txt

This is a great command to use to watch log files or logs in real-time.


2. If you’re trying to view a file such as the Apache access log file that is updated frequently you can pipe its output through the grep command to filter out only the content you want.

$ tailf access.log | grep

In this above example, we’re watching the access.log for any IP address of


Sanfoundry Global Education & Learning Series – 1000 Linux Tutorials.

If you wish to look at all Linux commands and their usage examples, go to Linux Commands Tutorial.

If you find any mistake above, kindly email to [email protected]

Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.