This guide gives operators and developers a practical path to the most useful Linux commands. You will set up a safe lab in your home directory, practice file and process operations, verify outcomes with checksums and listings, and learn to recover from common mistakes. All examples favor non-destructive flags and reversible steps, so you can build muscle memory with confidence.

## Who This Helps

- Developers who need reliable day-to-day shell usage.

- DevOps consultants who teach or standardize team practices.

- Startup teams that want consistent, low-risk operations habits.

## What You Will Achieve

- A safe practice area under your home directory.

- Command patterns for navigation, inspection, file management, permissions, search, process monitoring, and archiving.

- Verification steps that prove your changes worked.

- Recovery techniques for common failure modes.

Constructed examples are clearly labeled. Do not run commands with elevated privileges unless required and understood.

## Version and Environment Inventory

Before running any command, confirm what you are working on. Small differences in shell, distribution, and permissions can change behavior. Record the following. The example outputs are constructed examples.

uname -r
grep '^PRETTY_NAME' /etc/os-release
echo $SHELL
bash --version | head -1
echo $PATH
echo $HOME; pwd
umask; id
df -h "$HOME" | awk 'NR==2 {print $4}' 
 Constructed example outputs (yours will differ):

<div class="my-stack-md overflow-x-auto">
<table class="w-full min-w-[42rem] border-collapse text-left">
<thead><tr><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">What</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Command</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Example output</th></tr></thead>
<tbody><tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Kernel</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">uname -r</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">5.15.0-123-generic</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Distribution</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">grep &#39;^PRETTY_NAME&#39; /etc/os-release</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">PRETTY_NAME=&quot;Ubuntu 22.04 LTS&quot;</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Shell</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">echo $SHELL</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">/bin/bash</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Bash version</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">bash --version</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">GNU bash, version 5.1.x</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">PATH</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">echo $PATH</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Disk free under $HOME</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">df -h &quot;$HOME&quot;</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">42G free</td></tr></tbody>
</table>
</div>

## Safe Configuration Path

The safest way to learn is to operate in a disposable lab within your home directory and use safeguards that require confirmation or allow rollback.

### 1) Create a Disposable Lab

LAB="$HOME/tmp/linux-basic-commands-lab"
mkdir -p "$LAB"
cd "$LAB"
pwd 
 Expected: pwd shows your lab path. If the directory already existed, mkdir -p is safe and does not overwrite.

Initialize sample content:

# Create files and directories for practice
mkdir -p docs src bin data
printf "alpha\nbeta\ngamma\n" > data/greek.txt
printf "one\ntwo\nthree\n" > data/numbers.txt
printf "user: x:1000:1000: User,,,:/home/user:/bin/bash\n" > data/passwd.sample
printf "#!/usr/bin/env bash\necho Hello" > bin/hello.sh
chmod +x bin/hello.sh 
 Verification:

ls -l
ls -l data bin 
 Expected: directories exist, files present, bin/hello.sh is executable (x flag set for your user).

### 2) Navigate and Inspect Safely

- Print working directory: pwd

- List with details and human sizes: ls -alh

- Show most recent files first: ls -lt

- Limit depth with find to avoid surprises: find . -maxdepth 2 -type f -printf '%p\n'

- View file content without flooding your terminal: head -n 5 file , tail -n 5 file , less file (quit with q )

Examples:

pwd
ls -alh
find . -maxdepth 2 -type f -print
head -n 2 data/greek.txt 
 Expected: clear listings and first lines from greek.txt.

### 3) Create, Copy, Move, and Remove with Safeguards

Safer flags and habits:

- Use -i (interactive) with cp , mv , rm to confirm overwrites or deletions.

- Use -- to end option parsing when filenames start with dashes.

- Quote paths with spaces: "My File.txt" .

- Make a quick backup before edits: cp -a file{,.bak} .

Examples:

# Copy without overwriting existing files
cp -ai data/greek.txt docs/
cp -ai data/numbers.txt docs/

# Move a file, prompting if destination exists
mv -i docs/greek.txt docs/greek.list

# Create a file safely, refuse to overwrite an existing one
touch -- greek.new

# Remove with prompt (y to delete, n to cancel)
rm -i docs/greek.list 
 Verification:

ls -l docs
test -f docs/numbers.txt && echo OK || echo MISSING 
 Expected: docs contains numbers.txt; greek.list removed if you confirmed deletion.

### 4) Permissions You Can Reverse

Operate only inside $LAB .

# Show permission bits
ls -l bin/hello.sh

# Remove your write bit and demonstrate failure
chmod u-w bin/hello.sh
ls -l bin/hello.sh
# Attempt to append should fail with Permission denied
echo '# more' >> bin/hello.sh || echo 'as expected: Permission denied'

# Restore write bit
chmod u+w bin/hello.sh
ls -l bin/hello.sh 
 Expected: chmod toggles the user write bit; append fails when u-w is set; succeeds again after restoring.

Check umask for default file perms:

umask 
 Typical values: 0022 or 002 . Keep note for later troubleshooting.

### 5) Search and Filter Text Safely

- Search text recursively: grep -R --line-number --color=auto PATTERN PATH

- Match whole words: grep -Rw "\<word\>" PATH

- Count lines or matches: wc -l file , grep -c PATTERN file

- Sort and count unique lines: sort file | uniq -c | sort -nr

Examples:

# Find occurrences of digits in data
grep -R --line-number '[0-9]' data

# Count lines in greek.txt
wc -l data/greek.txt

# Show unique lines across data files
cat data/*.txt | sort | uniq -c | sort -nr 
 Expected: numbers.txt lines matched; greek.txt has 3 lines; unique counts are shown.

### 6) Process and System Inspection

- List your processes: ps -u "$USER" -o pid,ppid,cmd --sort=pid

- System-wide full-format: ps -ef | head

- Find processes by name: pgrep -af pattern

- Show memory and CPU quick view: top (quit with q )

- Disk usage summary: df -h (filesystems) and du -sh "$LAB" (directory)

Examples:

ps -u "$USER" -o pid,ppid,cmd --sort=pid | head
pgrep -af bash
free -h || cat /proc/meminfo | head -5
df -h | head
du -sh "$LAB" 
 Expected: running shells and memory/disk summaries appear. If free is not available, /proc/meminfo provides details.

### 7) Archiving and Checksums

- Create a tar archive: tar -czf archive.tgz DIR

- List archive contents: tar -tzf archive.tgz | head

- Extract: tar -xzf archive.tgz -C DEST

- Generate checksums: sha256sum file

Examples:

# Snapshot the lab
cd "$LAB"
tar -czf lab-snapshot.tgz .
sha256sum lab-snapshot.tgz > lab-snapshot.tgz.sha256

# Verify checksum
sha256sum -c lab-snapshot.tgz.sha256

# Inspect archive contents without extracting
tar -tzf lab-snapshot.tgz | head 
 Expected: checksum verification reports OK; archive listing shows your files and directories.

### 8) Redirection and Pipelines Without Surprises

- Append instead of overwrite: >> (safer). If you must overwrite, consider a backup first.

- Protect from clobbering with: set -o noclobber (within your current shell session), then use >| to force overwrite only when intended.

Examples:

set -o noclobber
printf 'safety-first\n' > data/safety.txt
# The next overwrite should fail due to noclobber
printf 'oops\n' > data/safety.txt || echo 'as expected: cannot overwrite'
# Force overwrite intentionally
printf 'overwrite\n' >| data/safety.txt
set +o noclobber 
 Verification:

tail -n 1 data/safety.txt 
 Expected: final line is "overwrite" after the forced overwrite.

### 9) Safer Use of Find for Bulk Changes

Preview with print, then apply using -exec only after review.

# Preview candidate files first
find "$LAB/data" -type f -name '*.txt' -print

# After confirming the list, copy them to docs
find "$LAB/data" -type f -name '*.txt' -exec cp -ai '{}' "$LAB/docs/" ';' 
 Verification:

ls -l "$LAB/docs" | grep '\.txt' || true 
 Expected: docs contains the copied .txt files.

## Verification and Diagnostics

Verification patterns keep you honest and prevent drift.

- Directory exists and owned by you:

[ -d "$LAB" ] && [ -w "$LAB" ] && echo OK || echo NOT_OK 

- Copy integrity with size and checksum:

 cp -a data/greek.txt docs/greek.txt
stat --format '%s' data/greek.txt docs/greek.txt
sha256sum data/greek.txt docs/greek.txt 
 Expected: sizes equal; checksums identical.

- Permission change took effect:

before=$(stat -c '%A %a' bin/hello.sh)
chmod u-w bin/hello.sh
after=$(stat -c '%A %a' bin/hello.sh)
echo "before=$before after=$after"
chmod u+w bin/hello.sh 
 Expected: user write bit toggles between on/off.

- Confirm what command will run:

which ls || type -a ls
command -V grep 
 Expected: paths to binaries or shell builtins are displayed.

- Confirm environment assumptions:

echo "SHELL=$SHELL"
echo "UMASK=$(umask)" 
 Expected: values printed for auditing or runbook inclusion.

## Failure Modes and Recovery

This section lists common pitfalls, how to identify them, and how to recover fast. Examples and numbers are constructed.

<div class="my-stack-md overflow-x-auto">
<table class="w-full min-w-[42rem] border-collapse text-left">
<thead><tr><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Failure mode</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Symptom</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Quick recovery</th></tr></thead>
<tbody><tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Overwrite by redirect (<code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">&gt;</code>)</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">File content unexpectedly replaced</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Use backups: if you ran <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">cp -a file{,.bak}</code> first, <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">mv -i file.bak file</code> to restore. Consider <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">set -o noclobber</code> to prevent accidental overwrites.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Globbing expands more than intended</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">rm</code> or <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">cp</code> affects many files</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Dry-run with <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">printf &#39;%s\n&#39;</code> on the glob first; switch to <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">find ... -print</code> to preview; use <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">rm -i</code> or <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">cp -ai</code>.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Filenames starting with dash</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Commands treat filename as option</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Use <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">--</code> to end options: <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">rm -- -weird</code>; or prefix path <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">./-weird</code>.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Spaces or special chars in names</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Command splits words</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Quote paths: <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">&quot;My File.txt&quot;</code>; use <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">find ... -print0 | xargs -0</code> for bulk ops.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Permission denied</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Cannot write or execute</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Check <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">ls -l</code>, fix with <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">chmod u+w file</code> or <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">chmod +x script</code> if appropriate; confirm ownership with <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">id</code> and <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">ls -ln</code>.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Wrong directory</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Operated on the wrong path</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Print <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">pwd</code>; restrict scope with absolute paths and <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">-maxdepth</code>; add <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">set -o noclobber</code> and <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">-i</code> flags for safety.</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Disk full</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Writes fail with No space left on device</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Check <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">df -h</code>; free space or write to another filesystem; compress or delete safe-to-remove temp files.</td></tr></tbody>
</table>
</div>

## Rollback Patterns You Can Rely On

- Pre-change local backup for single files:

cp -a target{,.bak}
# Later, to restore
diff -u target.bak target || true
mv -i target.bak target 

- Snapshot a directory before bulk edits:

 cp -a dir dir.prechange.$(date +%Y%m%d%H%M%S)
# Restore if needed (moves old copy back)
rm -rf dir && mv dir.prechange.* dir 
 Note: Use these inside your lab. For production data, prefer tested backup/restore procedures.

- Reverse permission changes:

# Record before state
stat -c '%a' file > file.perms
# Change and test
chmod g-w file
# Roll back
chmod $(cat file.perms) file 

- Recover moved or misplaced files:

 # Search from a known root
find "$LAB" -type f -name 'greek*' -print 

## Operations Checklist

 Use this short checklist to run routine tasks safely and consistently.

### Preparation

- Confirm environment: uname -r; grep '^PRETTY_NAME' /etc/os-release; echo $SHELL; umask

- Ensure space in $HOME : df -h "$HOME"

- Set up lab: LAB="$HOME/tmp/linux-basic-commands-lab"; mkdir -p "$LAB"; cd "$LAB"

### Navigation and Inspection

- pwd; ls -alh; find . -maxdepth 2 -type f -print

- head/tail/less to view content

### File Operations (Use Safeguards)

- Copy: cp -ai SRC DST

- Move/rename: mv -i OLD NEW

- Remove: rm -i FILE

- Quick backup: cp -a file{,.bak}

### Permissions

- Inspect: ls -l FILE; stat -c '%A %a' FILE

- Change (reversible): chmod u-w FILE; chmod u+w FILE

### Search and Filter

- grep -R --line-number PATTERN PATH

- wc -l FILE; sort FILE | uniq -c | sort -nr

### Process and System Status

- ps -u "$USER" -o pid,ppid,cmd --sort=pid | head

- df -h; du -sh "$LAB"

### Archiving and Checksums

- tar -czf snapshot.tgz .; sha256sum snapshot.tgz > snapshot.tgz.sha256

- sha256sum -c snapshot.tgz.sha256

### Verification After Changes

- stat --format '%s' SRC DST; sha256sum SRC DST

- grep or wc -l to confirm content expectations

### Recovery

- Use backups: mv -i file.bak file

- Reverse perms: chmod $(cat file.perms) file

- Find misplaced files: find "$LAB" -type f -name 'pattern'

### Cleanup (When Done)

- cd "$HOME"; rm -rf "$LAB" (confirm with pwd first)

## Concise Cheat Sheet of Common Commands

The following constructed table summarizes categories, examples, and safety tips you can adapt to your own runbooks.

<div class="my-stack-md overflow-x-auto">
<table class="w-full min-w-[42rem] border-collapse text-left">
<thead><tr><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Category</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Command</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Purpose</th><th scope="col" class="border border-outline-variant bg-surface-container-low px-4 py-3 text-left font-label-md font-semibold text-on-surface">Safety tip</th></tr></thead>
<tbody><tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Navigation</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">pwd; ls -alh</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">See where you are and what is there</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Use absolute paths for critical ops</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Find files</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">find . -maxdepth 2 -type f -print</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Preview target files</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Preview first; apply actions second</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">View content</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">head -n 10 file; tail -n 10 file; less file</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Inspect files without flooding the terminal</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">less</code> shows one screen; quit with <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">q</code></td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Copy/move</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">cp -ai SRC DST; mv -i OLD NEW</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Preserve and rename</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">-i</code> prompts to prevent accidental overwrite</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Delete</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">rm -i FILE</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Remove files</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">-i</code> prompts; consider backups first</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Permissions</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">chmod u+w FILE; chmod u-w FILE</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Grant or remove write access</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Record previous mode to enable rollback</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Search text</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">grep -R --line-number PATTERN PATH</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Locate patterns fast</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Quote patterns with special chars</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Disk usage</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">df -h; du -sh DIR</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Filesystem and dir sizes</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Limit <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">du</code> scope to avoid long scans</td></tr>
<tr><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Archive</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant"><code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">tar -czf out.tgz DIR; tar -tzf out.tgz</code></td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Snapshot and list</td><td class="border border-outline-variant px-4 py-3 align-top text-body-md text-on-surface-variant">Verify with <code class="font-mono text-[0.9em] bg-surface-container px-1 py-0.5 rounded">sha256sum</code> before cleanup</td></tr></tbody>
</table>
</div>

## Conclusion

You now have a safe, verifiable approach to core Linux commands, including a disposable lab layout, non-destructive defaults, and repeatable verification patterns. Keep the following habits front and center:

- Preview with find or printf before acting.

- Favor -i prompts and backups with cp -a file{,.bak} .

- Prove results with stat , checksums, and line counts.

- Record permission states before changing them.

As a next step, adapt the checklist and tables to your team runbooks. Start with a narrow, measurable pilot scenario (such as standardizing copy, move, and archive routines in home directories) that is easy to inspect locally before adopting across shared environments. This keeps risk low and builds consistent operator confidence.