Although shell stores two basic types of data in the environment, there is basically no difference between the two types in bash.
Introduction
Although shell stores two basic types of data in the environment, there is basically no difference between the two types in bash.
The two data types are environment variables and shell variables.
Shell variables are a small amount of data stored by bash. Environment variables are other variables.
In addition to variables, shell functions also store some programming data, that is, aliases and shell functions.
========================================================== ======
Check environment
To understand the content stored in the environment, you need to use the set command or printenv program integrated in bash.
The difference is that the set command displays both shell variables and environment variables, while printenv only displays environment variables.
Because the content of the environment may be lengthy, it is best to redirect the output of these two commands to the less command in the form of pipelines.
For example
[Allyes_op @ allyes ~] $ Set
BASH =/bin/bash
BASH_ARGC = ()
BASH_ARGV = ()
BASH_LINENO = ()
BASH_SOURCE = ()
BASH_VERSINFO = ([0] = "3" [1] = "2" [2] = "25" [3] = "1" [4] = "release" [5] = "x86_64-redhat-linux-gnu ")
========================================================== ======
View the value of a single variable
[Allyes_op @ allyes ~] $ Echo $ BASH
/Bin/bash
[Allyes_op @ allyes ~] $
========================================================== ======
View aliases
[Allyes_op @ allyes ~] $ Alias
Alias l. = 'ls-d. * -- color = tty'
Alias ll = 'ls-l -- color = tty'
Alias ls = 'ls -- color = tty'
Alias vi = 'vim'
Alias which = 'Alias |/usr/bin/which -- tty-only -- read-alias -- show-dot -- show-tilde'
[Allyes_op @ allyes ~] $
========================================================== ======
Some interesting environment variables
EDITOR |
Program name used for text editing |
SHELL |
Shell name of the local machine |
HOME |
Path name of the local main directory |
LANG |
Defines the character set of the local language |
OLD_PWD |
Previous working directory |
PAGER |
Program name used for paging output |
PWD |
Current working directory |
USER |
User name |