Bash
Learn Bash scripting from variables to robust, production-ready scripts. Loops, arrays, traps, set -euo pipefail, and a server bootstrap capstone.
12 lessons, in order
- 120 min
What Is Bash
Welcome. If you have never opened a terminal in your life, you are in the right place. Before we type a single command, we are going to spend ten...
Shell vs terminalBash vs sh vs zshInteractive shell vs scriptWhere Bash fits in DevOps - 225 min
Shebang and Your First Script
If the word "script" still sounds like something only real programmers write, relax. A script is just a text file with a list of commands in it, and...
Shebang#!/usr/bin/env bashChmod +x./script.sh vs bash script.shExit codes - 325 min
Variables and Quoting
If you have never used a variable before, do not worry. It is one of the simplest ideas in this whole course, and Bash's version of it is about as...
Variable assignmentDouble quotes vs single quotes${var} bracesCommand substitution $(...) - 430 min
Conditionals and Tests
Every script you have written so far runs the same lines no matter what. Real scripts need to make decisions: "only do this if that file exists",...
If statement[[ ]] testsString testsFile tests -f -d -e&& and ||Case statement - 525 min
Loops
So far every script you have written runs each line exactly once, top to bottom. That is fine for short scripts, but real work is repetitive: rename...
For loopWhile loopUntil loopFor f in *.txt globbingC-style for loopBreak and continue - 625 min
Functions
By now your scripts are starting to repeat themselves. Maybe you log a timestamped message in three different places, or you check whether a file...
Function definitionPositional args $1 $@ $#Return for exit codesEcho for outputLocal variables - 725 min
Arrays
So far, one variable has held one value. name="Ada" holds one string. If you wanted to hold three names, you would either need three separate...
Indexed arrays${arr[@]}${#arr[@]} lengthAssociative arrays declare -AIterating arrays - 825 min
String and Arithmetic Expansion
You will constantly find yourself with a variable that holds almost, but not quite, what you need. A full file path when you only want the filename....
${var#prefix}${var%suffix}${var//old/new}$(( arith ))Printf formatting - 925 min
IO Redirection and Pipes
Every command you run in Bash is, underneath, hooked up to three separate channels, whether you ever notice them or not. Think of a mail sorting...
>>><2>2>&1&>+3 - 1030 min
Error Handling and Traps
Every script you have written so far assumes things go right. A command that cannot find a file, a directory that does not exist, a typo in a...
Set -eSet -uSet -o pipefailTrap on EXITTrap on ERRCleanup functions - 1125 min
Debugging and Best Practices
At some point a script you wrote will do something you did not ask it to do. It will delete the wrong file, skip the loop you were sure it would run,...
Bash -xSet -xShellcheckSafe quotingNever parse ls[[ vs [+1 - 1260 min
Capstone: Server Bootstrap Script
A brand new server is a machine with nothing on it. Somebody has to install the web server, create the account you will log in with, put your SSH key...
Idempotent provisioningInstalling packagesCreating usersSSH key setupSystemd timersLogging+2
Learn Bash in your language
Every lesson, quiz, and tutor reply renders in your language. The AI tutor matches the language you ask in.
Roles that use Bash
See how hiring teams interview engineers on Bash, in production-like environments.
DevOps Engineer
Hire DevOps engineers who actually ship. Run live or take-home interviews in production-like Linux environments with Docker, Kubernetes, Terraform and CI/CD. See how they debug, automate, and work alongside AI.
See the interviewSite Reliability Engineer (SRE)
Hire SREs who actually run production. Live workspaces with metrics, logs, traces and a service that is starting to misbehave. We record every keystroke.
See the interviewInfrastructure Engineer
Hire infrastructure engineers who design systems your team can rely on. Interview them in real workspaces with Terraform, Ansible, cloud APIs and live failure scenarios.
See the interview