Skip to main content

Linux and Shell Mastery Guide

Command fluency, scripting patterns, and troubleshooting checklists for cloud and Kubernetes hosts.


Linux and Shell Mastery Guide

Every container eventually runs on a Linux kernel. Platform engineers debug nodes, sidecars, and CI runners comfort on the shell is non-negotiable.


Command tiers

Tier 1 daily

CommandUse
ls, cd, pwd, mkdir, rm, cp, mvNavigation and files
cat, less, head, tailRead logs
grep, awk, sedFilter and transform
findLocate files by name/time
chmod, chownPermissions
ps, top, htopProcesses
df, duDisk
systemctlServices on systemd hosts
journalctlService logs
curl, wgetHTTP checks
ssh, scpRemote access

Tier 2 weekly in production

CommandUse
strace, lsofWhy is this process stuck?
tcpdump, ss, netstatNetwork debugging
tar, gzipArchives
crontab -eScheduled jobs
useradd, usermod, groupsAccount hygiene
iptables / nft basicsFirewall rules on nodes
mount, lsblkVolumes

Tier 3 incident mode

CommandUse
dmesgKernel / OOM events
iostat, vmstatIO and memory pressure
nsenter, crictlContainer runtime on node
kill -USR1App-specific signals (know your stack)

Research Core: Linux


Bash patterns worth memorizing

# Fail fast in scripts set -euo pipefail # Loop over files safely while IFS= read -r -d '' file; do echo "$file" done < <(find . -name '*.yaml' -print0) # Retry with backoff for i in 1 2 3 4 5; do curl -sf https://api.example/health && break sleep $((i * 2)) done

Troubleshooting playbooks

Disk full

  1. df -h which mount?
  2. du -sh /* largest top-level dirs
  3. journalctl --disk-usage logs?
  4. Rotate or truncate with approval; fix log shipping

High CPU

  1. top which PID?
  2. ps -p PID -o args what process?
  3. Thread dump or profiler per application type
  4. Scale horizontally if load is legitimate

Cannot SSH

  1. Console access via cloud serial / rescue
  2. Check sshd status, disk full, AllowUsers
  3. Verify security group / NSG / firewall rules
  4. Key permissions: chmod 600 private key

Security habits on servers

  • No direct root SSH; use sudo with logging
  • Unattended upgrades for security patches (with reboot window)
  • CIS or vendor hardening baseline documented
  • Auditd or equivalent for sensitive paths

Practice project

Build a bootstrap script that:

  1. Creates a deploy user with sudo
  2. Installs Docker or containerd
  3. Configures fail2ban for SSH
  4. Ships logs to a central collector (even a filebeat sidecar counts)

Commit to git with README portfolio-grade proof.