Reading the Beginning and End of a File

Learn how to read the beginning and the end of a file, and learn how to create a file anywhere in the filesystem by specifying the path to the directory.

Sometimes, the most interesting information in a file is in the first few lines or the last few lines. That’s where the head and tail commands come in handy.

The head command

The head command reads the first ten lines from a file and displays them to the screen:

$ head /var/log/bootstrap.log

Use the terminal below to practice this command.

Get hands-on with 1400+ tech skills courses.