Linux and Unix head command tutorial with examples

Command head displays the beginning/top of the file at the terminal.
When “head” command is used without any option it will display the beginning/top ten lines of the file.

Syntax:

Example:
Suppose we have a file Employee.txt as shown below and we want to see the beginning/top of this file by default it will display the beginning/top ten lines of the file.

File 1: Employee.txt


Options of head command
Line count option (-n): potion “–n” is used to specify the number of lines to be display. Suppose we want to display the top 4 lines of file Employee.txt then the command is as follows:

Or

Output