• Contact
  • About Me
  • Privacy Policy
DefenceDev
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
No Result
View All Result
DefenceDev
No Result
View All Result
ADVERTISEMENT
Home Linux Tutorials Commands

Linux Files Operation: touch, cat, less – Read Content of Files

neo by neo
May 27, 2025
in Commands
0
Linux Files Operation: touch, cat, less - Read Content of Files

Linux Files Operation: touch, cat, less - Read Content of Files

0
SHARES
4
VIEWS
Share on FacebookShare on Twitter
ADVERTISEMENT

Files Operation: Read Content of Files

Linux Files Operation: touch, cat, less – Read Content of Files are a cornerstone of Linux system management. Whether you’re creating, viewing, or searching for files, the tools available are both powerful and versatile. This article provides an overview of essential Linux commands such as touch, cat, less, and find, with practical examples to help you master reading the files.

Introduction

Managing and reading files is one of the most fundamental tasks in Linux, whether you’re a beginner or an experienced administrator. The commands touch, cat, and less provide a simple yet powerful way to create files, view their contents, and navigate through them efficiently.

In this article, we’ll explore these essential commands:

  • How to create empty files or update timestamps using touch.
  • How to read and concatenate file contents using cat.
  • How to navigate file content interactively using less.

touch: Create Empty Files or Update Timestamp

The touch command is often used to create empty files or update the timestamps of existing files. It’s a straightforward way to prepare files for editing or scripting.

Create an Empty File

This creates an empty file named example.txt in the current directory.

touch example.txt

Update a File’s Timestamp

This updates the last modified timestamp of existing_file.txt.

touch existing_file.txt

Create Multiple Files at Once

touch file1.txt file2.txt file3.txt

This creates three empty files in the current directory.

cat: View File Contents

The cat command is used to display the contents of a file, concatenate files, or even create simple files.

ADVERTISEMENT

View a File’s Content

cat example.txt

Combine Multiple Files

cat file1.txt file2.txt > combined.txt

This merges file1.txt and file2.txt into a new file called combined.txt.

Create a File With Content

cat > newfile.txt

Type the content, press Ctrl+D to save.

ADVERTISEMENT

less: View Large Files

The less command allows you to view large files one page at a time, making it ideal for files that exceed the terminal’s scrollback buffer.

View a File Page by Page

less largefile.log

Use the arrow keys to navigate.

Search for a Term Within the File

Press / followed by the search term while inside less, e.g., /error.

ADVERTISEMENT

defencedev.com

About The Author

neo

See author's posts

ADVERTISEMENT
Previous Post

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Next Post

Linux Files Operation: mv, rm, cp (Rename, Remove and Copy Files and Directories)

neo

neo

Next Post
Linux Files Operation: mv, rm, cp (Rename, Remove and Copy Files and Directories)

Linux Files Operation: mv, rm, cp (Rename, Remove and Copy Files and Directories)

Follow Us

  • Trending
  • Comments
  • Latest
MikroTik: Export Configuration in Text File

MikroTik: Export Configuration in Text File

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Fortinet FortiGate: Static Route Configuration via GUI and CLI

Immich: Installation on Ubuntu 22.04

Immich: Installation on Ubuntu 22.04

Fortinet FortiGate Upgrade Path Tool

Fortinet FortiGate Upgrade Path Tool

NextCloud: Port Forwarding - Essential Ports for Smooth Functionality

NextCloud: Port Forwarding – Essential Ports for Smooth Functionality and Remote Access

Organizing and Managing Photos with Immich: Features I Use

Organizing and Managing Photos with Immich: Features I Use

Install Ubuntu 22.04 on Oracle VM Virtual Box

Install Ubuntu 22.04 on Oracle VM Virtual Box

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Linux Directories: cd (Change Directory), pwd (Print Working Directory), mkdir (Make Directory)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nginx Proxy Manager on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

MikroTik: Check Your Wireless Password

MikroTik: Check Your Wireless Password

ADVERTISEMENT

DefenceDev Tutorials

defencedev Logo

Whether you’re just starting or looking to expand your skills, I hope you find useful information and engaging discussions here. Let me take you through my journey and the goals behind this space!

Follow Us

Browse by Category

  • Blog
  • Cloud
    • Private
  • Linux Tutorials
    • Bash Scripting Tutorials
    • Commands
    • Networking
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Solutions
    • Docker
  • Video Tutorials
    • MikroTik Videos

Recent News

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install WordPress on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

Install Nextcloud on Raspberry Pi 4 with Docker (Ubuntu 22.04)

  • Site Map
  • Privacy Policy
  • Facebook Page
  • Disclaimer
  • Contact
  • About Me

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Blog
  • Linux Tutorials
    • Bash Scripting Lessons
    • Commands
    • Networking
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos

© 2025 defencedev.com - All rights reserved.