Important Environment variables
There are many environment variables in the Linux system, we can use Env to view his
Variables are made up of fixed "variable names" and user-defined "variable values".
Variable name |
Role |
HOME |
User's home directory "Home" |
SHELL |
the current shell that's the program . |
Histsize |
History command record number of bars |
MAIL |
Mail Box File |
Lang |
Language data |
RANDOM |
Random numbers |
PS1 |
Bash prompt |
Histfilesize |
History number of command stores |
PATH |
Find the execution file in the current directory |
EDITOR |
Default text Editor |
View the user's home directory by variable:
[Email protected] ~]# echo $HOME
/root
[Email protected] ~]# Su-linuxs
[Email protected] ~]$ echo $HOME
/home/linuxs
Set a variable "Workdir" so that each user executes
"CD $WORKDIR" are logged into the/home/workdir directory.
[Email protected] ~]# mkdir-p/home/workdir
[Email protected] ~]# Workdir=/home/workdir
[Email protected] ~]# CD $WORKDIR
[Email protected] workdir]# pwd
/home/workdir
[Email protected] workdir]# Su-linuxs
Last Login:thu-17:26:01 CST on pts/0
[Email protected] ~]$ CD $WORKDIR
[Email protected] ~]$ echo "$WORKDIR"
[Email protected] ~]$ # because of the scope of the variable
So you can use the Export command to promote local variables to global variables.
Format: Export variable name [= Variable value]
[Email protected] linuxs]# export WOD
[email protected] linuxs]# su Linuxs
[Email protected] ~]$ echo "$WOD"
/home/workdir
[Email protected] ~]$ CD $WOD
[Email protected] workdir]$ pwd
/home/workdir
linux[Basic]-12-Important environment variables [01]