Linux Terminal Productivity

Updated 2026-03-04

The terminal is still the most powerful tool in a developer’s toolkit — not because of nostalgia, but because text-based interfaces compose in ways that GUIs fundamentally cannot. These are the commands and patterns that actually save time.

Jump Around the Filesystem

1
2
3
4
5
6
7
8
9
10
11
12
# Fuzzy-find and cd into any directory (requires fzf)
cd $(find ~ -type d | fzf)

# Push/pop directory stack
pushd /tmp/build # switch to /tmp/build, push current dir to stack
popd # return to previous directory

# Return to last directory
cd -

# Show the directory stack
dirs -v

Better ls

1
2
3
4
5
6
# If you have eza (modern ls replacement)
eza --long --git --icons --sort=modified

# Otherwise, useful aliases
alias ll='ls -lhA --color=auto'
alias lt='ls -lhAt --color=auto' # sort by modification time

File Operations

Find Files Efficiently

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Find by name (fast, uses a database)
locate config.yml

# Update locate's database
sudo updatedb

# Find with find — newer options
find . -name "*.md" -newer _config.yml -type f

# Find large files
find . -type f -size +10M | sort -k5 -rh

# Delete all .DS_Store files recursively
find . -name ".DS_Store" -delete

Quick File Inspection

1
2
3
4
5
6
7
8
9
10
11
12
# First N lines
head -n 20 file.txt

# Last N lines, follow in real-time
tail -f -n 50 /var/log/nginx/error.log

# Count lines/words/bytes
wc -l posts/*.md
wc -w source/_posts/git-internals.md

# Peek at a binary file
xxd file.bin | head

Text Processing

grep Patterns

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Case-insensitive, show line numbers, recursive
grep -inr "syntax_highlighter" .

# Show 3 lines of context around matches
grep -C 3 "theme:" _config.yml

# Invert match (lines NOT containing pattern)
grep -v "^#" _config.yml # strip comments

# Count matches per file
grep -rl "highlight" themes/ | xargs grep -c "highlight"

# Extended regex
grep -E "^(title|date|tags):" source/_posts/*.md

sed for In-Place Editing

1
2
3
4
5
6
7
8
9
10
11
# Replace all occurrences in a file
sed -i 's/landscape/vaultex/g' _config.yml

# Delete lines matching a pattern
sed -i '/^#/d' config.txt

# Print only matching lines (like grep)
sed -n '/theme:/p' _config.yml

# Extract between two markers
sed -n '/^---$/,/^---$/p' post.md

awk for Column Extraction

1
2
3
4
5
6
7
8
# Print the second column
df -h | awk '{print $2}'

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

# Filter and print
ps aux | awk '$3 > 5.0 {print $1, $2, $3}' # processes using >5% CPU

Process Management

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Find a process by name
pgrep -l hexo

# Kill by name
pkill -f "hexo server"

# Background a running process
# While it's running: Ctrl+Z (suspend), then:
bg # resume in background
jobs # list background jobs
fg %1 # bring job 1 to foreground

# Run a command immune to hangup (survives terminal close)
nohup hexo server > server.log 2>&1 &

# Show resource usage in real time
top # standard
htop # better, if installed

SSH & Remote Work

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# SSH with key, jump host, and port forwarding
ssh -i ~/.ssh/id_ed25519 \
-J user@bastion.example.com \
-L 4000:localhost:4000 \
user@internal-server.example.com

# Copy files securely
rsync -avz --progress ./public/ user@server:/var/www/html/

# Persistent sessions that survive disconnects
tmux new -s work
tmux attach -t work

# Basic tmux keybindings (prefix = Ctrl+B)
# Ctrl+B c — new window
# Ctrl+B " — split pane horizontally
# Ctrl+B % — split pane vertically
# Ctrl+B d — detach session

Shell Scripting Essentials

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env bash
set -euo pipefail # exit on error, undefined vars, pipe failures

# Strict mode explained:
# -e exit immediately on error
# -u treat unset variables as errors
# -o pipefail a pipe fails if any command in it fails

POSTS_DIR="${1:-source/_posts}"
OUTPUT="post-stats.txt"

if [[ ! -d "$POSTS_DIR" ]]; then
echo "Error: directory '$POSTS_DIR' does not exist" >&2
exit 1
fi

echo "Analyzing posts in $POSTS_DIR..."

# Process each file
while IFS= read -r -d '' file; do
word_count=$(wc -w < "$file")
title=$(grep -m1 "^title:" "$file" | cut -d' ' -f2-)
printf "%-50s %5d words\n" "$title" "$word_count"
done < <(find "$POSTS_DIR" -name "*.md" -print0 | sort -z) | tee "$OUTPUT"

echo "Written to $OUTPUT"

Useful One-Liners

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# Watch a command every 2 seconds
watch -n 2 'ls -lh public/'

# Monitor disk usage changes
watch -d 'df -h /'

# Decode a JWT (without verification)
echo "eyJhbGci..." | cut -d. -f2 | base64 -d 2>/dev/null | jq .

# Generate a random password
openssl rand -base64 32

# Find the largest directories
du -sh */ | sort -rh | head -10

# Extract a tar.gz
tar -xzf archive.tar.gz -C /target/dir

# Create a tar.gz of a directory
tar -czf backup-$(date +%Y%m%d).tar.gz ./source/

# Port listening check
ss -tlnp | grep :4000
# or
lsof -i :4000

Keybindings to Memorize

Shortcut Action
Ctrl+R Reverse search command history
Ctrl+A Move to beginning of line
Ctrl+E Move to end of line
Ctrl+W Delete word to the left
Alt+F Move forward one word
Alt+B Move backward one word
Ctrl+L Clear screen (preserves scroll buffer)
Ctrl+U Delete from cursor to beginning of line
Ctrl+K Delete from cursor to end of line
!! Repeat last command
!$ Last argument of previous command
!^ First argument of previous command

The terminal rewards investment. The more you know, the faster you move — and unlike GUI tools, the skills compound indefinitely.