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

Create and Read Files in Linux with touch, cat, and less

neo by neo
September 11, 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
15
VIEWS
Share on FacebookShare on LinkedIn
Table of Contents
  • Files Operation: Read Content of Files
  • Introduction
  • touch: Create Empty Files or Update Timestamp
    • Create an Empty File
    • Update a File's Timestamp
    • Create Multiple Files at Once
  • cat: View File Contents
    • View a File's Content
    • Combine Multiple Files
    • Create a File With Content
  • less: View Large Files
    • View a File Page by Page
    • Search for a Term Within the File

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.

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 Directory Navigation and Creation with cd, pwd, and mkdir

Next Post

How to Rename, Remove, and Copy Files in Linux Using mv, rm, and cp Commands

neo

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands

10+ Useful Linux find Command Examples You Should Know

Check Disk Usage on the Linux with du Command
Commands

Check Disk Usage on the Linux with du Command

Linux Process, List all Running Services with ps Command
Commands

Check Running Processes and Services in Linux via ps

Descripton for kill command on Ubuntu
Commands

Linux Process Management, kill Command

Linux Files Operation: chwon (Change Ownership of The Files)
Commands

Linux Files Operation: chown (Change Ownership of the Files)

Linux Files Operation: grep, Efficient Text Search
Commands

Linux Files Operation: grep, Efficient Text Search

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

How to Rename, Remove, and Copy Files in Linux Using mv, rm, and cp Commands

Recommended

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

Install Docker on Raspberry Pi 4 with Ubuntu 22.04

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

FortiGate Country Address Object Generator – Block or Allow Access by Country

FortiGate Country Address Object Generator – Block or Allow Access by Country

View & Copy Image Metadata Online – Camera & GPS Info

View & Copy Image Metadata Online – Camera & GPS Info

Categories

  • 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
  • Web Tools
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

Recent News

Install Portainer on Ubuntu 24.04 Using Docker Compose

Install Portainer on Ubuntu 24.04 Using Docker Compose

FortiGate Country Address Object Generator – Block or Allow Access by Country

FortiGate Country Address Object Generator – Block or Allow Access by Country

  • 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
    • Bash Scripts
  • Solutions
    • Docker
  • Network Tutorials
    • FortiGate
    • MikroTik
  • Projects
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Cloud
  • Video Tutorials
    • YouTube Channel
    • MikroTik Videos
  • Web Tools

© 2025 defencedev.com - All rights reserved.