set
shell builtinLinux/Unix
The set command is one of the most frequently used commands in Linux/Unix-like operating systems. set Set or unset shell options and positional parameters
Quick Reference
Command Name:
set
Category:
shell builtin
Platform:
Linux/Unix
Basic Usage:
set [options] [arguments]
Common Use Cases
Syntax
set [options] [arguments]
Options
Option | Description |
---|---|
-a |
Mark variables for export when modified |
-b |
Report termination of background jobs immediately |
-e |
Exit immediately if a command exits with non-zero status |
-f |
Disable filename generation (globbing) |
-h |
Remember the location of commands as they are looked up |
-k |
All assignment arguments are placed in the environment for a command |
-m |
Enable job control |
-n |
Read commands but do not execute them (syntax check) |
-o option |
Set a shell option by name |
-p |
Turn on privileged mode |
-t |
Exit after reading and executing one command |
-u |
Treat unset variables as an error when substituting |
-v |
Print shell input lines as they are read |
-x |
Print commands and their arguments as they are executed |
- |
Reset all options and disable special shell handling |
-- |
Signals the end of options; remaining arguments become positional parameters |
Examples
How to Use These Examples
The examples below show common ways to use the set
command. Try them in your terminal to see the results. You can copy any example by clicking on the code block.
# Basic Examples Basic
set -e