Explain:
The main storage is data related to the operating environment of the system.
Range:
Code settings: The current shell and all child shells of the current shell are in effect
Config file: Effective in all shells
Grammar:
Declaration variables:
Export variable name = variable Value
View all variables:
Env
To delete a variable:
unset variable Name
Important variables:
PATH:
A. Path to the system Lookup command
B. Write your own executable file if placed in a folder under the path, you can directly execute
C. In fact, the command complement of Linux is also in the directory of path to find the command
D. Extending the PATH range (temporary change): Path= "$PATH":/root/xiaol/sh
Example:
Custom variable Name
[Email protected] ~]# Name=xiaol
Environment variable Age
[Email protected] ~]# export age=18
To promote a custom variable sex to an environment variable
[Email protected] ~]# Sex=man
[[email protected] ~]# export sex
Use set to view all variables, including the custom and environment
[[Email protected] ~]# Set | grep name; Set | grep age; Set | grep sex
Name=xiaol
Age=18
Sex=man
Use env to view environment variables
[Email protected] ~]# env | grep name; env | grep age; env | grep sex
Age=18
Sex=man
Turn on the child shell
[Email protected] ~]# bash
View current shell status
[Email protected] ~]# Pstree
INIT─┬─AUDITD───{AUDITD}
├─crond
├─dhclient
├─login───bash
├─master─┬─pickup
│└─qmgr
├─5*[mingetty]
├─RSYSLOGD───3*[{RSYSLOGD}]
├─smbd───smbd
├─sshd───sshd───bash───bash───pstree
└─UDEVD───2*[UDEVD]
Use set to view all variables, including the custom and environment
[[Email protected] ~]# Set | grep name; Set | grep age; Set | grep sex
Age=18
Sex=man
Use env to view environment variables
[Email protected] ~]# env | grep name; env | grep age; env | grep sex
Age=18
Sex=man
Exit Child shell
[Email protected]t ~]# exit
View current shell status
[Email protected] ~]# Pstree
INIT─┬─AUDITD───{AUDITD}
├─crond
├─dhclient
├─login───bash
├─master─┬─pickup
│└─qmgr
├─5*[mingetty]
├─RSYSLOGD───3*[{RSYSLOGD}]
├─smbd───smbd
├─sshd───sshd───bash───pstree
└─UDEVD───2*[UDEVD]
Delete environment variable age
[Email protected] ~]# unset age
Use env to view environment variables
[Email protected] ~]# env | grep name; env | grep age; env | grep sex
Sex=man
[Email protected] ~]#
Environment variables in Linux