The SET command displays the current shell variables, including the current user variables; The env command displays the current user variables; the Export command displays the shell variables currently exported to the user variables. Each shell has its own unique variable (SET). This is different from the user variable. The current user variable has nothing to do with what shell you are using, No matter what shell you are using, for example, home, shell, and other variables, but shell variables are different from shell variables, such as bash_argc and bash. These variables are only displayed by set and are unique to bash, when the export does not add a parameter, it displays which variables are exported as user variables, because a shell variable can use the Export
"Export" is a user variable. (Note: This is from document 1)
Common Methods
Format: ENV
Print the environment variables of the current user.
Format: env-I name1 = value1 name2 = value2 <command-line>
Use the specified environment variable to execute the command line <command-line>.
Use Example 1 to compare ENV, set, and export
The SET command prints the most information, including user-defined functions, so that you can see it only when you use more.
[Root @ Web ~] # Env
Hostname = web
Term = Linux
Shell =/bin/bash
History Size = 1000
Ssh_client = 58.222.185.248 1113 22
Ssh_tty =/dev/pts/6
Ant_home =/opt/Apache/apache-ant-1.8.1
User = root
Ls_colors = NO = 00: fi = 00: di = 01; 34: Ln = 01; 36: Pi = 40; 33: So = 01; 35: BD = 40; 33; 01: Cd = 40; 33; 01: OR = 01; 05; 37; 41: MI = 01; 05; 37; 41: Ex = 01; 32 :*. cmd = 01; 32 :*. EXE = 01; 32 :*. COM = 01; 32 :*. BTM = 01; 32 :*. bat = 01; 32 :*. SH = 01; 32 :*. CSH = 01; 32 :*. tar = 01; 31 :*. tgz = 01; 31 :*. ARJ = 01; 31 :*. taz = 01; 31 :*. lzh = 01; 31 :*. zip = 01; 31 :*. z = 01; 31 :*. z = 01; 31 :*. gz = 01; 31 :*. bz2 = 01; 31 :*. bz = 01; 31 :*. TZ = 01; 31 :*. rpm = 01; 31 :*. cpio = 01; 31 :*. JPG = 01; 35 :*. GIF = 01; 35 :*. BMP = 01; 35 :*. xbm = 01; 35 :*. XPM = 01; 35 :*. PNG = 01; 35 :*. TIF = 01; 35:
Ssh_auth_sock =/tmp/ssh-amfuW25778/agent.25778
Mail =/var/spool/mail/root
Path =/usr/Kerberos/sbin:/usr/Kerberos/bin:/opt/Apache-ant-1.8.1/bin:/usr/Java/jdk1.6.0 _ 20/bin: /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
Inputrc =/etc/inputrc
Pwd =/root
Java_home =/usr/Java/jdk1.6.0 _ 20
Lang = zh_cn.gb18030
Ssh_askpass =/usr/libexec/OpenSSH/gnome-ssh-askpass
Shlvl = 1
Home =/root
LOGNAME = root
Cvs_rsh = SSH
Ssh_connection = 58.222.185.248 1113 218.23.142.44 22
Lessopen = |/usr/bin/lesspipe. sh % s
G_broken_filenames = 1
_ =/Bin/env
[Root @ Web ~] # Export
Declare-x ant_home = "/opt/Apache/apache-ant-1.8.1"
Declare-x cvs_rsh = "ssh"
Declare-x g_broken_filenames = "1"
Declare-x histsize = "1000"
Declare-x home = "/root"
Declare-x hostname = "Web"
Declare-x inputrc = "/etc/inputrc"
Declare-x java_home = "/usr/Java/jdk1.6.0 _ 20"
Declare-x lang = "zh_cn.gb18030"
Declare-x lessopen = "|/usr/bin/lesspipe. sh % s"
Declare-x LOGNAME = "root"
Declare-x ls_colors = "NO = 00: fi = 00: di = 01; 34: Ln = 01; 36: Pi = 40; 33: So = 01; 35: BD = 40; 33; 01: Cd = 40; 33; 01: OR = 01; 05; 37; 41: MI = 01; 05; 37; 41: Ex = 01; 32 :*. cmd = 01; 32 :*. EXE = 01; 32 :*. COM = 01; 32 :*. BTM = 01; 32 :*. bat = 01; 32 :*. SH = 01; 32 :*. CSH = 01; 32 :*. tar = 01; 31 :*. tgz = 01; 31 :*. ARJ = 01; 31 :*. taz = 01; 31 :*. lzh = 01; 31 :*. zip = 01; 31 :*. z = 01; 31 :*. z = 01; 31 :*. gz = 01; 31 :*. bz2 = 01; 31 :*. bz = 01; 31 :*. TZ = 01; 31 :*. rpm = 01; 31 :*. cpio = 01; 31 :*. JPG = 01; 35 :*. GIF = 01; 35 :*. BMP = 01; 35 :*. xbm = 01; 35 :*. XPM = 01; 35 :*. PNG = 01; 35 :*. TIF = 01; 35 :"
Declare-x mail = "/var/spool/mail/root"
Declare-x oldpwd
Declare-x Path = "/usr/Kerberos/sbin:/usr/Kerberos/bin:/opt/Apache-ant-1.8.1/bin: /usr/Java/jdk1.6.0 _ 20/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin: /usr/bin:/root/bin"
Declare-x Pwd = "/root"
Declare-x shell = "/bin/bash"
Declare-x shlvl = "1"
Declare-x ssh_askpass = "/usr/libexec/OpenSSH/gnome-ssh-askpass"
Declare-x ssh_auth_sock = "/tmp/ssh-amfuW25778/agent.25778"
Declare-x ssh_client = "58.222.185.248 1113 22"
Declare-x ssh_connection = "58.222.185.248 1113 218.23.142.44 22"
Declare-x ssh_tty = "/dev/pts/6"
Declare-x term = "Linux"
Declare-x user = "root"
[Root @ Web ~] # Set | more
Ant_home =/opt/Apache/apache-ant-1.8.1
Bash =/bin/bash
Bash_argc = ()
Bash_argv = ()
Bash_completion =/etc/bash_completion
Bash_completion_dir =/etc/bash_completion.d
Bash_lineno = ()
Bash_source = ()
Bash_versinfo = ([0] = "3" [1] = "2" [2] = "25" [3] = "1" [4] = "release" [5] = "i686-redhat-linux-gnu ")
Bash_version = '3. 2.25 (1)-release'
Colors =/etc/dir_colors
Columns = 132.
Cvs_rsh = SSH
Dirstack = ()
EUID = 0
Groups = ()
G_broken_filenames = 1
Histfile =/root/. bash_history
Histfilesize = 1000
History Size = 1000
Home =/root
Hostname = web
Hosttype = i686
Ifs = $ '\ t \ N'
Inputrc =/etc/inputrc
Java_home =/usr/Java/jdk1.6.0 _ 20
Lang = zh_cn.gb18030
Lessopen = '|/usr/bin/lesspipe. sh % s'
Lines = 41
LOGNAME = root
Ls_colors = 'no = 00: fi = 00: di = 01; 34: Ln = 01; 36: Pi = 40; 33: So = 01; 35: BD = 40; 33; 01: Cd = 40; 33; 01: OR = 01; 05; 37; 41: MI = 01; 05; 37; 41: Ex = 01; 32 :*. cmd = 01; 3
2 :*. EXE = 01; 32 :*. COM = 01; 32 :*. BTM = 01; 32 :*. bat = 01; 32 :*. SH = 01; 32 :*. CSH = 01; 32 :*. tar = 01; 31 :*. tgz = 01; 31 :*. ARJ = 01; 31 :*. taz = 01; 31 :*. lzh = 01; 31
:*. Zip = 01; 31 :*. z = 01; 31 :*. z = 01; 31 :*. gz = 01; 31 :*. bz2 = 01; 31 :*. bz = 01; 31 :*. TZ = 01; 31 :*. rpm = 01; 31 :*. cpio = 01; 31 :*. JPG = 01; 35 :*. GIF = 01; 35 :*. BMP
= 01; 35: *. xbm = 01; 35: *. XPM = 01; 35: *. PNG = 01; 35: *. tif = 01; 35 :'
Machtype = i686-redhat-linux-gnu
Mail =/var/spool/mail/root
Mailcheck = 60
Opterr = 1
Optind = 1
Ostype = Linux-GNU
-- More --