# Linux Power User Guide: From Casual to Wizard

**Author:** kelexine  
**Date:** 2025-12-12  
**Category:** Linux  
**Tags:** Linux, Terminal, System Admin, Bash, DevOps  
**URL:** https://kelexine.is-a.dev/blog/linux-power-user-guide

---

# The Path to Linux Enlightenment

There's a moment in every Linux user's journey when `ls -la` becomes muscle memory and you start pitying people who use graphical file managers. This guide is about accelerating that transformation.

I've been living in terminals for years, and these are the skills, tricks, and forbidden knowledge that separate power users from mere mortals.

## The Philosophy of the Command Line

Before we dive into commands, understand this: **the terminal is not a limitation—it's a superpower**. Every click in a GUI is a command you could have typed faster.

> The command line is poetry. Each pipe is a verse, each grep a rhyme.

## Essential Navigation - Beyond cd and ls

### The Basics, Perfected

```bash
# Jump to previous directory (most underused command)
cd -

# Jump to home from anywhere
cd ~
# Or even simpler
cd

# Create nested directories in one shot
mkdir -p projects/client/src/components

# List with human-readable sizes and sort by time
ls -lhtr

# Show hidden files but not . and ..
ls -A
```

### Navigation Superpowers with pushd/popd

```bash
# Push current directory to stack and change
pushd /var/log

# Check the stack
dirs -v

# Pop back to where you were
popd

# This is incredibly useful when jumping between project directories
```

### The Z Revolution

Install `zoxide` and never type full paths again:

```bash
# Install
curl -sSfL https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | sh

# Add to .bashrc/.zshrc
eval "$(zoxide init bash)"

# Now just type partial paths
z proj     # Jumps to ~/Development/projects
z kelexine # Jumps to ~/Development/github/kelexine-dev
```

## Text Processing - Your Swiss Army Knife

### grep - The Eternal Search

```bash
# Search recursively with line numbers and context
grep -rn "function" --include="*.js" -C 2

# Invert match - show lines NOT matching
grep -v "DEBUG" app.log

# Count occurrences
grep -c "error" /var/log/syslog

# Extended regex for complex patterns
grep -E "error|warning|critical" logs.txt

# Grep with color (add to bashrc as alias)
alias grep='grep --color=auto'
```

### sed - Stream Editing Mastery

```bash
# Replace first occurrence on each line
sed 's/foo/bar/' file.txt

# Replace ALL occurrences
sed 's/foo/bar/g' file.txt

# In-place editing (WARNING: modifies file!)
sed -i 's/old/new/g' config.txt

# Delete lines matching pattern
sed '/DEBUG/d' app.log

# Print only lines 10-20
sed -n '10,20p' hugefile.txt

# Multiple operations
sed -e 's/a/b/g' -e 's/c/d/g' file.txt
```

### awk - When grep Isn't Enough

```bash
# Print specific columns (space-delimited)
awk '{print $1, $3}' file.txt

# Custom delimiter
awk -F':' '{print $1}' /etc/passwd

# Sum a column
awk '{sum += $2} END {print sum}' numbers.txt

# Filter and print
awk '$3 > 100 {print $1, $3}' data.txt

# Built-in variables: NR (line number), NF (field count)
awk '{print NR": "$0}' file.txt

# One-liner to get average
awk '{sum+=$1; count++} END {print sum/count}' numbers.txt
```

## Process Management - Taming the Beast

### Understanding Processes

```bash
# The classic
ps aux | grep process_name

# Better: pgrep
pgrep -a nginx

# Process tree view
pstree -p

# Real-time monitoring (better than top)
htop
# Or if you're fancy
btop
```

### Job Control

```bash
# Run in background
long_command &

# Suspend current process
Ctrl+Z

# Resume in background
bg

# Resume in foreground
fg

# List all jobs
jobs -l

# Disown a job (keeps running after terminal closes)
disown %1

# Run command immune to hangups
nohup ./long_script.sh &
```

### Process Priority

```bash
# Run with lower priority
nice -n 10 heavy_process

# Change priority of running process
renice -n 5 -p 12345

# Real-time process (be careful!)
sudo chrt -f 99 ./critical_process
```

## Disk and Storage - Where Does All the Space Go?

```bash
# Disk usage summary
df -h

# Directory sizes, sorted
du -sh * | sort -hr

# Find largest files
find / -type f -size +100M -exec ls -lh {} \; 2>/dev/null

# Better tool: ncdu (interactive)
ncdu /home

# Disk I/O monitoring
iotop

# Check what's using a mount point
lsof +D /mnt/usb

# Force unmount
sudo umount -l /mnt/stuck
```

## Networking - The Connected Terminal

### Diagnosing Network Issues

```bash
# What's listening?
ss -tlnp

# Legacy but still useful
netstat -tulpn

# DNS lookup
dig google.com
nslookup google.com

# Trace route with better output
mtr google.com

# Download with progress
curl -# -O https://example.com/large-file.zip

# Test port connectivity
nc -zv host.com 443

# Capture packets (requires root)
sudo tcpdump -i eth0 port 80
```

### SSH Power Moves

```bash
# SSH with key forwarding
ssh -A user@jumphost

# Local port forwarding (access remote:8080 via localhost:9000)
ssh -L 9000:localhost:8080 user@remote

# Remote port forwarding (expose local:3000 on remote:8000)
ssh -R 8000:localhost:3000 user@remote

# SOCKS proxy
ssh -D 9050 user@remote

# Execute command and exit
ssh user@host 'df -h && free -m'

# Copy files with progress
rsync -avzP source/ user@remote:/destination/
```

## systemd - The System Shepherd

Love it or hate it, systemd runs everything now.

```bash
# Service management
sudo systemctl start nginx
sudo systemctl stop nginx
sudo systemctl restart nginx
sudo systemctl reload nginx
sudo systemctl status nginx

# Enable/disable at boot
sudo systemctl enable nginx
sudo systemctl disable nginx

# View logs
journalctl -u nginx
journalctl -u nginx --since "1 hour ago"
journalctl -f  # Follow (like tail -f)

# Analyze boot performance
systemd-analyze
systemd-analyze blame
systemd-analyze critical-chain

# List all services
systemctl list-units --type=service
systemctl list-units --state=failed
```

### Creating Custom Services

```ini
# /etc/systemd/system/myapp.service
[Unit]
Description=My Application
After=network.target

[Service]
Type=simple
User=appuser
WorkingDirectory=/opt/myapp
ExecStart=/opt/myapp/run.sh
Restart=on-failure
RestartSec=5

[Install]
WantedBy=multi-user.target
```

```bash
# After creating:
sudo systemctl daemon-reload
sudo systemctl start myapp
```

## Bash Scripting - Automation is King

### Script Template

```bash
#!/bin/bash
set -euo pipefail  # Exit on error, undefined vars, pipe failures

# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color

log_info() { echo -e "${GREEN}[INFO]${NC} $1"; }
log_error() { echo -e "${RED}[ERROR]${NC} $1" >&2; }

# Argument parsing
while getopts "hvf:" opt; do
  case $opt in
    h) echo "Usage: $0 [-v] [-f file]"; exit 0 ;;
    v) VERBOSE=1 ;;
    f) FILE="$OPTARG" ;;
    *) exit 1 ;;
  esac
done

# Main logic here
main() {
    log_info "Starting script..."
    # Your code
    log_info "Done!"
}

main "$@"
```

### Useful Patterns

```bash
# Check if command exists
command -v docker &> /dev/null || { echo "Docker not found"; exit 1; }

# Cleanup trap
cleanup() { rm -rf "$TMP_DIR"; }
trap cleanup EXIT
TMP_DIR=$(mktemp -d)

# Parallel execution
for file in *.txt; do
    process "$file" &
done
wait

# Read file line by line
while IFS= read -r line; do
    echo "Processing: $line"
done < input.txt
```

## Shell Configuration - Make It Yours

### Essential .bashrc/.zshrc Additions

```bash
# History improvements
HISTSIZE=50000
HISTFILESIZE=100000
HISTCONTROL=ignoreboth:erasedups
shopt -s histappend

# Better globbing
shopt -s globstar  # ** matches subdirectories

# Useful aliases
alias ll='ls -lah'
alias ..='cd ..'
alias ...='cd ../..'
alias grep='grep --color=auto'
alias df='df -h'
alias free='free -h'
alias ports='ss -tlnp'
alias update='sudo apt update && sudo apt upgrade -y'
alias please='sudo $(history -p !!)'  # Rerun last command with sudo

# Functions
mkcd() { mkdir -p "$1" && cd "$1"; }
extract() {
    case $1 in
        *.tar.bz2) tar xjf "$1" ;;
        *.tar.gz)  tar xzf "$1" ;;
        *.tar.xz)  tar xJf "$1" ;;
        *.zip)     unzip "$1" ;;
        *.rar)     unrar x "$1" ;;
        *) echo "Unknown format" ;;
    esac
}
```

## Conclusion

Linux mastery isn't about memorizing commands—it's about understanding patterns. Every tool connects to others through pipes. Every problem has a one-liner solution waiting to be discovered.

The terminal is an instrument. Practice daily, and soon you'll be composing symphonies of automation.

> Remember: With great power comes great responsibility. And also the ability to `rm -rf /` everything if you're not careful.

---

**Keep Learning**:
- [ExplainShell](https://explainshell.com/) - Explains command syntax
- [ShellCheck](https://www.shellcheck.net/) - Bash script linter
- [The Linux Command Line](https://linuxcommand.org/tlcl.php) - Free book

---

*This content is available at [kelexine.is-a.dev/blog/linux-power-user-guide](https://kelexine.is-a.dev/blog/linux-power-user-guide)*
