Operations 6 min read

Essential Linux File Management Commands (Part 2)

This guide walks through essential Linux file‑management commands—cat, more, less, head, tail, du, wc, grep, cut, sort, uniq, which, find, md5sum and tr—showing their common options and practical examples for everyday operations.

Linux Cloud-Native Ops Stack
Linux Cloud-Native Ops Stack
Linux Cloud-Native Ops Stack
Essential Linux File Management Commands (Part 2)

cat: view file contents

Displays the entire file and supports several options:

cat -n aa.txt    // show line numbers
cat -b aa.txt    // show line numbers for non‑empty lines
cat -A aa.txt    // show all special characters
cat -E aa.txt    // show $ as end‑of‑line marker

more: paginate text output

Interactive navigation while viewing:

b / space: page up / down
Enter: line break
q: quit

less: advanced pagination

Provides more navigation keys:

Up/Down arrows: scroll line by line
b / space: page up / down
Enter: line break
q: quit

head: show file beginning

Shows the first N lines (default 10). Example shows first 15 lines:

head -n 15 /var/log/message

tail: show file end

Shows the last N lines (default 10) and can follow a file in real time:

tail -n 15 /var/log/message    // last 15 lines
tail -f /var/log/message       // follow updates

du: disk usage of directories/files

Summarizes size; -s for current directory, -h for human‑readable output:

du -sh /app    // total size of /app in readable format

wc: word, line, byte count

Counts lines, words, bytes. Example counts lines in a file:

wc -l /app/aa.txt    // line count
-c    // byte count
-W    // word count

grep: search text patterns

Filters lines matching a pattern, with common flags:

grep -i "physicAl iD" /proc/cpuinfo    // case‑insensitive search
grep -i "^$" /proc/cpuinfo            // match empty lines
-v    // invert match
-i    // ignore case
-r    // recursive search
-E    // extended regex, e.g., -E "a|b|c"

cut: extract columns or characters

Extracts fields using a delimiter:

cut -d: -f1 /etc/passwd | head -3    // first field of passwd, first 3 lines
-d    // delimiter
-f    // field numbers (e.g., -f1,3 or -f1-3)

sort: order text lines

Sorts numerically, reverse, by specific columns, with custom delimiters:

sort -nr -k2 sort_demo.txt    // numeric reverse sort by column 2
sort -t: -nk3 /etc/passwd    // numeric sort by column 3 using ':'
-n    // numeric sort
-r    // reverse order
-k    // key (column)
-t    // field delimiter

uniq: filter duplicate lines

Counts or removes repeated lines:

uniq -c uniq.txt    // prefix each line with occurrence count
-c    // count occurrences
-d    // show only duplicates
-u    // show only unique lines
-i    // ignore case

which: locate executable path

Shows where a command resides in the system:

which cat
which ls

find: locate files and directories

Powerful search with many predicates:

find /etc -name init                     // exact name match
find / -name "pass"                     // exact filename
find / -size +204800k                    // files larger than 200 MB
find / -user root                        // files owned by root
find /etc -size +102400k -a -size -204800k // size between 100 MB and 200 MB
find /etc -name inittab -exec ls -l {} \; // show details of matching file
find / -size +200M -a -size -300M        // size between 200 MB and 300 MB
find / -name "*pass*"                   // fuzzy match (slower)
find / -type b                           // block devices
find / -type c                           // character devices

md5sum: compute and verify MD5 checksums

Used to detect file changes:

md5sum 111.txt    // prints MD5 hash for verification

tr: translate or delete characters

Works with pipelines to transform text streams:

cat test | tr 'A-Z' 'a-z'    // convert uppercase to lowercase
cat test | tr -d 'A-Z'      // delete all uppercase letters
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.

OperationsLinuxCommand Linefile managementshell-commands
Linux Cloud-Native Ops Stack
Written by

Linux Cloud-Native Ops Stack

Focused on practical internet operations, sharing server monitoring, troubleshooting, automated deployment, and cloud-native tech insights. From Linux basics to advanced K8s, from ops tools to architecture optimization, helping engineers avoid pitfalls, grow quickly, and become your tech companion.

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.