Export: Set custom variables to system environment variables (valid in current shell)
Function Description:Set or display environment variables.
Syntax:Export
[-FNP] [variable name] = [variable setting value]
Note:When executing a program in shell, shell provides a set of environment variables. Export allows you to add, modify, or delete environment variables for subsequent programs. The effect of export is only true for this login operation.
Parameters:
-FIt indicates the function name in [variable name.
-NDeletes a specified variable. The variable is not actually deleted, but is not output to the execution environment of subsequent commands.
-PList all environment variables that the shell assigns to the program.
Input export in shell to output the current variable. You can also use
Export target = arm-Linux-this command sets the environment variable,
Export Path = $ path:/.../bin.
When executing a script, a new sub-shell is created to inherit the environment in the parent shell.
But the variables defined in the sub-shell cannot be taken back to the parent shell.
/Etc/EnvironmentIs to set the entire system environment, and/etc/ProfileIs to set the environment for all users, the former has nothing to do with the login user, the latter is related to the login user.
If the same variable is in the user environment (/etc/Profile) And system environment (/etc/Environment) There are different values, which should be based on the user environment.
In addition, you can set environment variables in/etc/profile. The differences are as follows:
/Etc/profile: This file sets the environment information for each user in the system. When the user logs on for the first time, this file is executed.
And collect shell settings from the configuration file in the/etc/profile. d directory.
/Etc/bashrc: execute this file for every user running bashshell. When bash shell is opened, the file is read.
~ /. Bash_profile: each user can use this file to enter the shell information dedicated to his/her use. When a user logs on,
The file is executed only once! By default, it sets some environment variables to execute the user's. bashrc file.
~ /. Bashrc: This file contains bash information dedicated to your bashshell. When you log on and every time you open a new shell
The file is read.
~ /. Bash_logout: execute this file every time you exit the system (exit bashshell.
In addition, the variables (global) set in/etc/profile can act on any user ~ The variables (local) set in/. bashrc can only inherit the variables in/etc/profile. They are "Parent-Child" relationships.
~ /. Bash_profile is interactive and login to run in bash.
~ /. Bashrc runs in bash in interactive non-login mode.
Generally, the two settings are roughly the same, so the former usually calls the latter.