• printenv– Print Some or all of the environment variables
• set– set shell options
• export-Export the environment variables so that the program that is executed later knows.
• alias– create command aliases
1.shell Environment: The shell maintains a large amount of information in the shell session, known as the shell environment
What is the basic data type of 2.shell?
1) Shell variable: A small amount of data stored by bash.
2) Environment variables: all other data
Also stores some programmable data, named aliases and shell functions (involving shell scripts)
First, check the environment variables
The SET command can display both shell and environment variables, while printenv only displays environment variables.
1. Because the environment variable content list is quite long, it is best to pipe the output of each command to the less command:
[Email protected]:~$ printenv | Less will open a new file showing all the environment variables
The 2.printenv command can also list values for a specific variable:
[Email protected]:~$ printenv Userxiaohui
3. When you use a set command with no options and parameters, both the shell and environment variables are displayed, and the defined shell functions are displayed. Unlike the printenv command, the output of the set command is politely arranged in alphabetical order:
[Email protected]:~$ Set | Less
4. Use the echo command to view the contents of a variable
[Email protected]:~$ echo $HOME/home/xiaohui
5. If a member in the shell environment is not displayed either with the SET command or the PRINTENV command, the variable is an alias. Enter the alias command without parameters to view them
[Email protected]:~$ aliasalias Alert='\'s/^\s*[0-9]\+\s*//;s/[; &|] \s*alert$//' \') 'alias egrep='egrep--color=auto 'alias fgrep='fgrep--color=auto'... ...
Second, how to build the shell environment?
When we log into the system, we start the Bash program and read a series of configuration scripts called startup files that define the default shell environment that can be shared by all users.
Then read more of the startup files located in our own home directory, which define the user's personal shell environment.
The exact boot order depends on the type of shell session you want to run. There are two types of shell sessions: one is a logon shell session and the other is a non-logon shell session.
The logon shell session prompts the user for a user name and password; For example, we start a Virtual Console session. When we run a terminal session in GUI mode, the non-login shell session appears
A city the contents of the startup file
9. Shell Environment