codingstuff.io
ExploreTutorialsProblemsCS Subjects
Get Started
ExploreTutorialsProblemsCS Subjects
Get Started
codingstuff.io

Master the art of building software through interactive tutorials, real-world problems, and guided projects.

Pune, Maharashtra, India

codingstuffmail@gmail.com

Product

  • Explore
  • Tutorials
  • Problems
  • CS Subjects

Company

  • About
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Sitemap

© 2026 codingstuff.io. All rights reserved.

Built with ❤️ for developers everywhere

/
/
All Tutorials
🐧

Linux & Bash

7 / 60 topics
5File System Navigation6Creating Files and Directories7Viewing Files Content8Editing Files9File Permissions10Symbolic Links
Tutorials/Linux & Bash/Viewing Files Content
🐧Linux & Bash

Viewing Files Content

Updated 2026-05-15
10 min read

Viewing Files Content

Introduction

In this tutorial, we will explore various Linux and BASH commands that allow you to view the contents of files. Understanding how to view file content is a fundamental skill for any developer working in a Unix-based environment. We'll cover basic commands as well as more advanced options to suit different viewing needs.

Concept

Linux provides several tools to display the contents of files, each with its own set of features and use cases:

  1. cat: Concatenates and prints file content.
  2. less: Displays file content in a paginated manner.
  3. head: Displays the first few lines of a file.
  4. tail: Displays the last few lines of a file.
  5. more: An older command that displays file content one screen at a time.

Examples

1. Using cat

The cat (concatenate) command is used to display the entire contents of a file in the terminal.

Terminal

2. Using less

The less command is particularly useful for viewing large files as it allows you to scroll through the content using the arrow keys or Page Up/Page Down.

Terminal
Output
This is the first line.
This is the second line.
This is the third line.

Tip: By default, head displays the first 10 lines. You can specify a different number of lines using the -n option:

Terminal
Output
This is the third line.
This is the fourth line.
This is the fifth line.

Tip: By default, tail displays the last 10 lines. You can specify a different number of lines using the -n option:

Terminal

Tip: To exit more, press q. You can also move to the next page by pressing Space.

What's Next?

Now that you know how to view file contents, the next step is learning how to edit files. We will cover various text editors and commands in the upcoming tutorial on "Editing Files".

Stay tuned for more tutorials and happy coding!


PreviousCreating Files and DirectoriesNext Editing Files

Recommended Gear

Creating Files and DirectoriesEditing Files