Operations 6 min read

10 Essential Linux Commands for Quickly Viewing Text Files

This guide introduces ten commonly used Linux command‑line tools—cat, less, head, tail, wc, grep, find, locate, sort, and uniq—explaining their purpose, basic syntax, and practical examples for efficiently inspecting and processing text files.

Liangxu Linux
Liangxu Linux
Liangxu Linux
10 Essential Linux Commands for Quickly Viewing Text Files

When you need to inspect text files on a Linux system without opening a full‑featured editor, command‑line utilities provide fast and precise ways to view content. Below are ten widely used commands, each with a brief description, usage syntax, and example output.

cat

The cat command reads a file and prints its contents to the terminal.

Usage: cat [filename] Example: cat rumenz.com.txt Output:

This is an rumenz.com file.
It contains some random text.

less

less

displays large files page‑by‑page, preserving formatting and allowing scrolling and searching.

Usage: less [filename] Example: less rumenz.com.txt Output (first screen):

This is an rumenz.com file.
It contains some random text.

--more--

head

head

shows the beginning of a file, defaulting to the first 10 lines; the number of lines can be changed with -n.

Usage: head [-n number] [filename] Example: head -n 2 rumenz.com.txt Output:

This is an rumenz.com file.
It contains some random text.

tail

tail

shows the end of a file, also defaulting to 10 lines and configurable with -n.

Usage: tail [-n number] [filename] Example: tail -n 1 rumenz.com.txt Output:

It contains some random text.

wc

wc

counts lines, words, and bytes in a file.

Usage: wc [filename] Example: wc rumenz.com.txt Output:

2 6 42 rumenz.com.txt

grep

grep

searches for patterns (including regular expressions) within files.

Usage: grep [pattern] [filename] Example: grep "random" rumenz.com.txt Output:

It contains some random text.

find

find

locates files in a directory hierarchy that match given criteria.

Usage: find [path] -name [pattern] Example: find /etc -name "hosts" Output:

/etc/hosts

locate

locate

quickly finds files by name using a prebuilt database, faster than find but not real‑time.

Usage: locate [keyword] Example: locate "hosts" Sample output includes multiple paths containing "hosts".

sort

sort

orders the lines of a file alphabetically, numerically, or by date.

Usage: sort [filename] Example: sort rumenz.com.txt Output:

It contains some random text.
This is an rumenz.com file.

uniq

uniq

filters out consecutive duplicate lines, outputting only unique entries.

Usage: uniq [filename] Example: uniq rumenz.com.txt Output:

This is an rumenz.com file.
It contains some random text.

These ten commands enable rapid viewing, searching, and basic processing of text files on Linux, and they can be combined for more powerful workflows.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

CATGrepcommand-linelessfindsorttext-viewing
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.