background:
The Linux export command is used to set or display environment variables .
When a program is executed in the shell, the shell provides a set of environment variables. export can add, modify or delete environment variables for use by subsequent programs. The effect of export is limited to this login operation.
grammar:
export [-fnp][variable name]=[variable setting value]
Parameter Description:
-f represents the function name in [variable name].
-n deletes the specified variable. The variable is not actually deleted, it is just not output to the execution environment of subsequent instructions.
-p lists all environment variables assigned to the program by the shell.
Example:
List all current environment variables
# export -p //List the current environment variable values
Define environment variable assignments
# export MYENV=7 //Define environment variables and assign values
Add environment variable: saved in ~/.bash_profile by default, it will only take effect at that time, if you want it to take effect all the time, you must manually write it into the system environment variable /etc/profile
export KUBECONFIG="/etc/ kubernetes /admin.conf" //Add environment variables
env command to view the set environment variables
Delete: But it is only valid for this operation , and it still exists after reconnecting after exiting.
export -n KUBECONFIG="/etc/kubernetes/admin.conf"
Unset command deletion: it is also temporary and will only be valid in the current environment
unset KUBECONFIG
Remove completely:
The environment variables added by export are saved in ~/.bash_profile by default , and will be saved in /etc/profile of PATH unless manually specified to be added.
Find the line to be deleted in ~/.bash_profile and manually delete the variable
Then, source .bash_profile to take effect
Exit and reconnect for verification, it has been completely deleted.
-------------------------------------------------- -------No text below---------------------------------------- --------------
Note: For study only, record questions and reference, encourage each other!
Reference finishing article:
1. Export setting environment variables and deleting__Yong's blog-CSDN blog_export variables
2. How to delete the environment variables set by export in liunx- fuhaizi - Blog Garden
3. linux export lang command, Linux export command_Mindray Wedding Blog-CSDN Blog
4. How to delete the environment variable set by export in liunx - fuhaizi - 博客园