• Contact
  • About Me
  • Privacy Policy
  • Disclaimer
DefenceDev
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools
No Result
View All Result
DefenceDev
No Result
View All Result
Home Linux Commands&Tips

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

by neo
September 3, 2026
in Commands&Tips
0
Linux Files Operation: touch, cat, less - Read Content of Files

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

0
SHARES
36
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.

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.

defencedev.com

Tags: linux
Previous Post

Linux Directory Navigation and Creation with cd, pwd, and mkdir

Next Post

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

neo

Related Posts

10+ Useful Linux find Command Examples You Should Know
Commands&Tips

10+ Useful Linux find Command Examples You Should Know

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)
Commands&Tips

My Ultimate Linux/Ubuntu Commands Cheat Sheet (2025)

Timeshift on Linux: How to Create and Restore System Snapshots
Commands&Tips

Timeshift on Linux: How to Create and Restore System Snapshots

Remote Desktop Access to Ubuntu 24.04 from Windows
Commands&Tips

Remote Desktop Access to Ubuntu 24.04 from Windows

Fix "blk_update_request: critical target error" on Ubuntu Server (dev sdb, DISCARD Operation)
Commands&Tips

Fix “blk_update_request: critical target error” on Ubuntu Server with SSD (dev sdb, DISCARD Operation)

Passwordless SSH Login on Ubuntu: Secure Server Access
Commands&Tips

Passwordless SSH Login on Ubuntu: Secure Server Access

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

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

Recommended

Solutions: Check Disk Usage on Ubuntu Terminal with ncdu Application

Check Disk Usage on Ubuntu Terminal Using ncdu – Easy & Fast Guide

Descripton for kill command on Ubuntu

How to Kill All Processes which are using wget on Linux

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

Fix Proxmox VM Snapshot “Out of Space” Errors

Fix Proxmox VM Snapshot “Out of Space” Errors

Categories

  • Linux
    • Bash Scripting
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Web Tools

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

Briefly unavailable for scheduled maintenance. Check back in a minute.

WordPress Stuck in Maintenance Mode After Plugin Update

Promox Telegram Alert Example

Configure Telegram Notifications in Proxmox VE Using Webhooks

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

© 2025 defencedev.com - All rights reserved.

No Result
View All Result
  • Home
  • Linux
    • Bash Scripting
      • Bash Scripting Lessons
    • Commands&Tips
    • Monitoring
  • Networking
    • FortiGate
    • MikroTik
  • Projects & Case Studies
  • Self-Hosted
    • AdGuard
    • Immich
    • Nextcloud
    • WordPress
  • Virtualization
    • Proxmox
    • VMware
  • Tools

© 2025 defencedev.com - All rights reserved.