Linux set command
The Linux set command is used to configure the shell.
The set command can configure the execution mode of the shell, and can be set according to different needs.
Syntax
set [+-abCdefhHklmnpPtuvx]
Parameter Description:
- -a Mark modified variables for export to environment variables.
- -b Make aborted background programs immediately report their execution status.
- -C Redirected output files cannot overwrite existing files.
- -d Shell uses a hash table by default to memorize used commands to speed up execution. Using the -d parameter cancels this.
- -e If a command returns a value other than 0, the shell exits immediately.
- -f Disable the use of wildcards.
- -h Automatically record the location of functions.
- -H Shell Can use "!" plus
to execute commands recorded in history. - -k All arguments given to a command are treated as environment variables of that command.
- -l Record the variable names of for loops.
- -m Use monitor mode.
- -n Only read commands without actually executing them.
- -p Enable priority mode.
- -P After enabling the -P parameter, symbolic links are replaced with actual files or directories when executing commands.
- -t Exit the shell after executing the subsequent command.
- -u Display an error message when an undefined variable is used during execution.
- -v Display the input values read by the shell.
- -x After executing a command, first display the command and its arguments.
- +
Cancel a parameter previously enabled by set.
Example
Display environment variables
# set
BASH=/bin/bash
BASH_ARGC=()
BASH_ARGV=()
BASH_LINENO=()
BASH_SOURCE=()
BASH_VERSINFO=([0]="3" [1]="00" [2]="15" [3]="1" [4]="release" [5]="i386-redhat-linux-gnu")
BASH_VERSION='3.00.15(1)-release'
COLORS=/etc/DIR_COLORS.xterm
COLUMNS=99
DIRSTACK=()
EUID=0
GROUPS=()
G_BROKEN_FILENAMES=1
HISTFILE=/root/.bash_history
HISTFILESIZE=1000
HISTSIZE=1000
HOME=/root
HOSTNAME=hnlinux
HOSTTYPE=i386
IFS=$' '
INPUTRC=/etc/inputrc
KDEDIR=/usr
LANG=zh_CN.GB2312
LESSOPEN='|/usr/bin/lesspipe.sh %s'
LINES=34
L
MAIL=/var/spool/mail/root
MAILCHECK=60
OLDPWD=/home/uptech
OPTERR=1
OPTIND=1
OSTYPE=linux-gnu
PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/root/bin:/opt/crosstools/gcc-3.4.6-glibc-2.3.6/bin
PIPESTATUS=([0]="2")
PPID=26005
PROMPT_COMMAND='echo -ne "
Linux Command Reference