Session and utilities

The set command

With no arguments, shows every shell variable. It also changes shell behaviour options.

Syntax

set | set -e | set -x

Most useful options

-eAborts the script on the first error
-xShows each command before running it (debug)
-uErrors on undefined variables

Copy-ready examples

$ setSee the shell variables

You can try them in the browser terminal: it does not touch your computer.

Typical mistakes

  • set -e in a script is powerful but can abort on errors you did not expect.

Related commands

FAQ

Which option is essential in scripts?

Many use set -euo pipefail to fail fast on any problem.

Learn to actually use it

The basic Linux course takes you from zero to console fluency with 24 self-grading lessons.

Start the free course