The head Command

In some instances you may need to see the top of a file just like you may have needed to see the bottom of a file. To use the head command, do the same as you would with the tail command.

>head hosts.allow

Or

>head –20 hosts.allow

The output of this command starts from the top down (not the bottom up) and displays (by default) 10 lines from the top down instead of the bottom up.

Heads or Tails? Let's Flip for It! A good tip to remember when using head and tail is that when you are changing the default number of lines shown from 10, specify the amount of lines you do want to see. This can be done with the -# option that we just ...

Get SAMS Teach Yourself Unix in 10 Minutes now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.