Skip to content

Portal | Level: L0: Entry | Topics: jq / JSON Processing, ripgrep (rg), fzf, fd | Domain: CLI Tools

Modern Linux CLI Toolkit - Primer

Why This Matters

The classic Unix tools (find, grep, cat, ls, du, cd) are universal and important to know. But modern replacements are faster, more ergonomic, and increasingly expected in DevOps workflows. Knowing both gives you speed without losing portability.

The Modern Toolkit

fd (replaces find)

Find files by name. Respects .gitignore, uses regex by default, colorized output.

# Classic find
find . -name "*.yaml" -type f

# Modern fd
fd -e yaml

# fd is simpler for common patterns
fd Dockerfile              # Find all files named *Dockerfile*
fd -e py -x wc -l          # Find .py files and count lines in each
fd -H .env                 # Include hidden files

ripgrep / rg (replaces grep -r)

Search file contents recursively. Multi-threaded, respects .gitignore, fastest grep alternative.

# Classic grep
grep -rn "apiVersion" --include="*.yaml" .

# Modern rg
rg "apiVersion" -t yaml

# rg is especially good for large repos
rg "TODO|FIXME|HACK"       # Search for tech debt markers
rg -l "error_handler"      # Files containing a string (names only)
rg "func.*Error" -t go     # Type-filtered search
rg -C 3 "panic"            # Show 3 lines of context

fzf (fuzzy finder)

Interactive filter for any list. Transforms every command into a searchable, selectable interface.

# Interactive file finder
vim $(fzf)

# Pipe anything into fzf
kubectl get pods | fzf           # Select a pod interactively
git branch | fzf                 # Select a branch
history | fzf                    # Search command history

# Shell integration (add to .bashrc/.zshrc)
# Ctrl-R: fuzzy history search
# Ctrl-T: fuzzy file finder
# Alt-C: fuzzy cd into subdirectory

# Combine with other tools
rg --files | fzf --preview 'bat --color=always {}'   # Browse files with preview

bat (replaces cat)

Cat with syntax highlighting, git integration, and line numbers.

# Classic cat
cat deployment.yaml

# Modern bat
bat deployment.yaml               # Syntax-highlighted
bat -l yaml deployment.yaml       # Force language detection
bat --diff deployment.yaml        # Show git diff markers
bat -A deployment.yaml            # Show whitespace characters

# Use as pager for other tools
export MANPAGER="bat -l man -p"   # Colorized man pages

jq (JSON processor)

Filter, transform, and extract JSON data. Essential for DevOps.

# Parse kubectl output
kubectl get pods -o json | jq '.items[].metadata.name'
kubectl get pod mypod -o json | jq '.status.conditions[] | select(.type=="Ready")'

# Parse AWS CLI output
aws ec2 describe-instances | jq '.Reservations[].Instances[] | {id: .InstanceId, state: .State.Name}'

# Parse Terraform state
terraform show -json | jq '.values.root_module.resources[] | {type, name: .name, id: .values.id}'

# Common patterns
jq '.'                   # Pretty print
jq '.key'                # Extract a key
jq '.[] | .name'         # Extract from array
jq 'select(.status == "running")'  # Filter
jq 'length'             # Count items
jq -r '.name'           # Raw output (no quotes)
jq -s '.'               # Slurp: read all inputs into array

eza (replaces ls)

Modern ls with tree view, git integration, and color-coded file types.

# Classic ls
ls -la

# Modern eza
eza -la                    # Long listing
eza --tree --level 2       # Directory tree
eza -la --git              # Show git status per file
eza -la --icons            # File type icons (if font supports it)
eza --sort modified        # Sort by modification time

zoxide (replaces cd)

Frecency-based directory jumping. Learns which directories you visit most.

# Classic cd
cd /home/user/projects/grokdevops/training/exercises

# Modern zoxide
z exercises                # Jump to most frecent match
z grok                     # Jump to grokdevops
zi                        # Interactive selection with fzf

# Setup (add to .bashrc/.zshrc)
eval "$(zoxide init bash)"     # or zsh/fish

dust (replaces du)

Visual disk usage with bar charts, sorted by size.

# Classic du
du -sh /* | sort -rh | head -20

# Modern dust
dust                       # Current directory
dust /var                  # Specific path
dust -n 20                 # Top 20 entries
dust -d 2                  # Max depth 2

Additional Tools Worth Knowing

Tool Replaces Key Feature
delta diff Syntax-highlighted diffs, git integration
btop top/htop GPU, disk, network graphs
tldr man (companion) Community examples ("tldr tar")
xh curl Human-friendly HTTP, JSON by default
yq (YAML processor) jq syntax for YAML/TOML
procs ps Colorized, searchable, tree view

Installation

Most tools install via cargo (Rust) or your package manager:

# Debian/Ubuntu
apt install fd-find ripgrep bat fzf jq

# Note: fd is called 'fdfind' on Debian, bat is 'batcat'
# Create aliases:
alias fd='fdfind'
alias bat='batcat'

# Cargo (Rust - gets latest versions)
cargo install eza zoxide du-dust

# Homebrew (macOS)
brew install fd ripgrep fzf bat jq eza zoxide dust

See Also


Wiki Navigation

Next Steps

  • Skillcheck: Modern CLI Tools (Assessment, L0) — fd, fzf, jq / JSON Processing
  • Modern CLI Drills (Drill, L0) — fzf, jq / JSON Processing, Modern CLI Tools
  • CLI Tools Flashcards (CLI) (flashcard_deck, L1) — Modern CLI Tools
  • Modern CLI Flashcards (CLI) (flashcard_deck, L1) — Modern CLI Tools
  • Ripgrep Flashcards (CLI) (flashcard_deck, L1) — ripgrep (rg)
  • YAML, JSON & Config Formats (Topic Pack, L1) — jq / JSON Processing
  • fd (Topic Pack, L1) — fd
  • fd Flashcards (CLI) (flashcard_deck, L1) — fd
  • fzf (Topic Pack, L1) — fzf
  • fzf Flashcards (CLI) (flashcard_deck, L1) — fzf