Bash (Bourne Again SHell) is a Unix shell and scripting language created for the GNU project. It runs interactive commands and executes script files, and it is the default shell on many Linux distributions.
Why it matters
Bash scripts automate deployments, log rotation, backups, and health checks, and a cron job often calls one. Learning a few features, such as pipes, redirection, variables, and exit codes, covers most daily work.
A script reports success with exit code 0 and failure with any other value, which is how monitoring tools decide whether a job worked.
Example
#!/usr/bin/env bash
set -euo pipefail
if curl -fsS https://example.com > /dev/null; then
echo "site up"
else
echo "site down"
fi
set -euo pipefail makes the script stop on errors and unset variables.
Common mistakes
- Skipping
set -eso a failed step is ignored and the script keeps going. - Leaving variables unquoted, which breaks on spaces and wildcards.
- Using bash-only syntax in a script that starts with
#!/bin/sh.
Related
Get notified when this term updates
Plus occasional practical tips on uptime and monitoring, nothing else. Unsubscribe anytime.
This page is general information written by our editorial team and updated when documentation changes. Servers and providers differ, so test changes safely first. See our editorial policy and disclaimer.