Linux & OS Internals
Exit codes and set -euo pipefail
By default a Bash script keeps going after a command fails. Learn how three shell options affect error handling, where their limits are, and how to clean up.
What is in the lesson
- A real situation where this goes wrong
- How it works, step by step
- A walkthrough with commands you can run
- How it fails in production, and how to tell
- Three quiz questions with explanations
Read this lessonFree. No account needed.
More in Linux & OS Internals
- Your first shell script: shebang, variables and quotingBeginner · 5 min
A script is a list of commands saved in a file. Three habits, the shebang, variables and quotes, decide whether it works on any file name.
- if, for and while in BashBeginner · 5 min
Make a script decide and repeat: test a file, loop over services, read a file line by line, and avoid the unquoted test that breaks on empty values.
- Build a disk-and-service check script and schedule itBeginner · 5 min
Combine five earlier lessons into one working job: test disk and services, exit non-zero on trouble, log with timestamps, run it every five minutes.
- Capstone: diagnose a broken server: disk, port, DNS, permissionsBeginner · 6 min
Four faults hide behind one symptom. Work from the outside in, change one thing at a time, and let each fix reveal the next problem.
- From power-on to login: firmware, bootloader, kernel, systemdBeginner · 5 min
A server reboots after a kernel update and never answers SSH. Four different programs run before the login prompt, and the last line on the console tells you which one…
- Writing a systemd unit: ExecStart, Restart and dependenciesBeginner · 5 min
Your app runs from a terminal session, so it dies at reboot and nobody restarts it after a crash. A dozen lines of unit file fix both, and three details decide whether…