Bash Tutorial with Examples.
Bash scripting tutorial with runnable examples: Linux shell scripting for automation, CI/CD pipelines, DevOps workflows and server administration.
Beginner
Start here — no prior experience needed
Introduction to Bash
Understand what Bash is, how it differs from a terminal and a shell, and why it is the backbone of DevOps, CI and automation work.
Bash Setup and First Script
Install Bash on Linux, macOS and Windows WSL, write and run your first script, and fix chmod, /bin/sh vs bash, and CRLF line-ending errors.
Bash Variables
Master variable assignment, quoting rules, environment variables, export, and special variables like $0, $1, $#, $@, and $$.
Bash Data Types
Learn how Bash handles strings, integers, indexed and associative arrays, namerefs and case attributes, with real output for every example.
Bash Operators
Learn arithmetic operators with $(( )), floating-point math with bc, string comparison, and the difference between test, [ ], and [[ ]].
Bash Control Flow
Master Bash if/elif/else, case, for, while and until loops, break and continue, with real output and the pipe-subshell and unmatched-glob traps.
Bash Functions
Learn how to define functions, use local variables, handle return codes, pass arguments, and build reusable script libraries.
Bash File Operations
Bash file operations: file tests, reading files safely, cp, mv, safe rm, find, stat, symlinks and atomic writes, each shown with its real output.
Bash Input and Output
Learn read, echo vs printf, stdin/stdout/stderr, redirection operators, tee, and pipes for building robust Bash pipelines.
Intermediate
For developers with core concepts down
Bash String Manipulation
Master Bash parameter expansion: substrings, prefix and suffix stripping, find-and-replace, case conversion, trimming, splitting and heredocs.
Bash Arrays
Work with Bash indexed and associative arrays: slicing, quoting with [@] vs [*], mapfile, filtering, sorting, and passing arrays to functions.
Bash Text Processing
Process text in Bash pipelines with grep, sed, awk, cut, sort, uniq, tr, wc and column, using real log and CSV examples and their real output.
Bash Process Management
Run background jobs, manage processes with jobs/fg/bg, send signals with kill, use trap for cleanup, and understand subshells.
Bash Error Handling
Write robust scripts with set -euo pipefail, trap ERR, exit codes, meaningful error messages, and safe cleanup patterns.
Regex in Bash
Use the Bash =~ operator, BASH_REMATCH capture groups, grep -E and -P, and sed -E for validation and parsing, with the pitfalls that fail silently.
Bash Networking
Bash networking with curl, jq, nc, /dev/tcp and rsync: status and exit codes, safe JSON, port checks, wait-for-port, and SSH heredoc quoting.
Bash System Information
Inspect a Linux system from Bash with uname, df, du, free, ps, pgrep, ss, lsof and systemctl, and parse their output reliably in scripts.
Cron and Scheduling in Bash
Crontab syntax, cron expressions, at for one-time jobs, systemd timers and logging cron output, with real cron and systemd runs.
Bash Security Best Practices
Write secure Bash scripts — safe temp files with mktemp, avoiding command injection, handling secrets, and setting file permissions.
Bash Script Patterns
Learn production-ready patterns — argument parsing with getopts, usage functions, loading config files, and script locking.
Advanced
Production-grade patterns for experienced engineers
Bash DevOps Scripts
Production Bash scripts for deploys with rollback, backups, log rotation, health checks and CI helpers, plus the real bugs these scripts often hide.
Bash Interview Preparation
Top 25 Bash and Shell scripting interview questions with real examples, covering everything from basics to advanced DevOps scenarios.
Also part of Bash
Taught in other topics. Each link opens the lesson in its home topic.
Permission Bits, Ownership, and Why passwd Needs setuid
A real permission-denied error from a locked-down file, then stripping the setuid bit from /usr/bin/passwd to see exactly why an ordinary user can't change their own password without it.
A Zombie Process That Never Gets Reaped — and the PID 1 That Fixes It
A child exits, its parent never calls wait(), and the zombie sits forever under a naive PID 1 — orphaned to PID 1 doesn't help unless that PID 1 actually reaps. Docker's --init does; a bare sleep infinity doesn't.