Control shell options, positional parameters and debugging with a single builtin. 01.05.2026 | reading time: 2 min The shell builtin `set` is a small control center: it lists variables, toggles error and debug behavior, and assigns positional parameters, all of which shape how scripts run and fail. See it in action Examples you can run to see behavior: enable trace printing with `bash -c 'set -x; echo hi'` which emits a trace line then prints "hi"; enforce fail-fast with `bash -c 'set -euo pipefail; false; echo still'` which does not print "still" because the script exits on the failing command; set positional parameters with `bash -c 'set -- a b c; echo $1 $2 $3'` which prints "a b c". Options, meanings and caveats `set -e` causes exit on errors but has exceptions inside conditionals and pipelines, `set -u` treats unset variables as errors, `set -x` enables execution tracing, and `set --` assigns positional parameters; remember that `pipefail` is a bash extension and that `set` is a builtin that affects only the current shell process. When to use it Use `set -euo pipefail` at the top of scripts to catch mistakes early, use `set -x` temporarily to debug tricky logic, and use `set --` to normalize arguments inside wrapper scripts or test harnesses; disable options with `set +e` or `set +x` when you need finer control. Related helpers Complement `set` with `trap` to run cleanup on exit, with `env` to launch a controlled environment, and with `exec` when you want to replace the shell process for precise behavior and resource control. Wrap-up and next steps Mastering `set` tightens script reliability and simplifies debugging; experiment with short examples and read your shell's manpage to catch dialect differences, and consider deepening your Linux skills through certification such as CompTIA Linux+ or LPIC-1 with intensive exam preparation at bitsandbytes.academy. Join Bits & Bytes Academy First class LINUX exam preparation. scripting utilities processes troubleshooting