Day 19/ 30 Days of Linux Mastery: File Viewing Commands (cat, less, more, head, tail)
Amanda Igwe

Amanda Igwe @amandaigwe

About: Cloud Engineer | DevOps | Security | Linux | Automation

Joined:
Apr 7, 2025

Day 19/ 30 Days of Linux Mastery: File Viewing Commands (cat, less, more, head, tail)

Publish Date: May 13
6 0

Table of Contents


Introduction

Welcome back to day 19!.Today’s focus is on file-viewing commands:

cat, less, more, head, and tail.

When working with files in Linux, being able to view logs, outputs, and configuration files quickly is critical. You don’t always need to open a full editor like vim, sometimes a simple peek is all you need.

Let’s get into it!


What Are These Commands?

Command Purpose
cat Concatenate and display file contents
less View file one page at a time, scrollable
more Similar to less, but can only scroll forward
head Show the first few lines of a file
tail Show the last few lines of a file (often logs)

Real-World Scenario: Using File Viewing Commands

You work as a Junior Linux Admin. Your team gives you a log file and says:

  • Let's view the file using cat

 man man > manualpage.txt   - # we created a file called manual page by opening the man command and copying the contents into manualpage.txt


cat manualpage.txt  # this views the file showing what we created.
Enter fullscreen mode Exit fullscreen mode

m1 description

  • Let's check the man page, and use more to view the content page by page. Note, you can only scroll forward. ( The up and arrow keys works, but forward and backward here means using the right and left arrow keys.)
more manualpage.txt

Enter fullscreen mode Exit fullscreen mode

m2 description

  • Let's view a large file or logs using less. This helps you view large files page by page, and you can scroll forward and backward unlike the more command.
less manualpage.txt
Enter fullscreen mode Exit fullscreen mode

m3 description

  • We use head to view the top lines of the files. You can include the number of lines you also intend to view.
head manualpage.txt

or

head -n 5 manualpage.txt to view the first 5 lines.
Enter fullscreen mode Exit fullscreen mode

m4 description

  • You can also view the last lines using tail command.
tail manualpage.txt

or

tail -5 manualpage.txt to view the last 5 lines.
Enter fullscreen mode Exit fullscreen mode

m5 description

Conclusion

These file viewing commands are very essential, and by mastering these commands, even a beginner can:

  • Quickly read and understand system logs

  • Debug issues like failed logins or service restarts

  • Monitor live updates without extra tools

If this is helpful to you, feel free to bookmark, comment, like and follow me for Day 20!


Let's Connect!

If you want to connect or share your journey, feel free to reach out on LinkedIn.
I am always happy to learn and build with others in the tech space.

#30DaysLinuxChallenge #Redhat#RHCSA #RHCE #CloudWhistler #Linux #Rhel #Ansible #Vim #CloudComputing #DevOps #LinuxAutomation #IaC #SysAdmin#CloudEngineer

Comments 0 total

    Add comment