oreilly.comSafari Books Online.Conferences.


Linux in a Nutshell

This directory of Linux commands is from Linux in a Nutshell, 5th Edition.

Click on any of the 687 commands below to get a description and list of available options. All links in the command summaries point to the online version of the book on Safari Bookshelf.

Buy it now, or read it online on Safari Bookshelf.


tail [options] [files]

Print the last 10 lines of each named file (or standard input if - is specified) on standard output. If more than one file is specified, the output includes a header at the beginning of each file:

= =>filename<= =

For options that take the number of bytes or lines as an argument, you prepend a plus sign (+) to num to begin printing with the numth item. These options can also specify a block size:


512 bytes


1 kilobyte


1 megabyte


-c num, --bytes num

Print the last num bytes.

-f, --follow[=name|descriptor]

Don't quit at the end of file; "follow" file as it grows and end when the user presses Ctrl-C. Following by file descriptor is the default, so -f, --follow, and --follow=descriptor are equivalent. Use --follow=name to track the actual name of a file even if the file is renamed, as with a rotated logfile.


Identical to --follow=name --retry.


Print a help message and exit.

-n num, --lines=num

Print the last num lines.


Used with --follow=name to reopen a file whose size hasn't changed after num iterations (default 5), to see if it has been unlinked or renamed (as with rotated logfiles).


Used with -f to end when process ID pid dies.

-q, --quiet, --silent

Suppress filename headers.


With -f, keep trying to open a file even if it isn't accessible when tail starts or if it becomes inaccessible later.

-s sec, --sleep-interval=sec

With -f, sleep approximately sec seconds between iterations. Default is 1 second.

-v, --verbose

With multiple files, always output the filename headers.


Print version information and then exit.


Show the last 20 lines containing instances of .Ah:

grep '\.Ah' file | tail -20

Show the last 10 characters of variable name:

echo "$name" | tail -c

Print the last two blocks of bigfile:

tail -2b bigfile

Linux Resources
  • Linux Online
  • The Linux FAQ
  • Linux Kernel Archives
  • Kernel Traffic

  • Sponsored by: