To change an environment variable use the command:
VARNAME=value of variable
By convention, the variable name is given in upper case.
To make a temporary change the value of an environment variable enter the command:
VARNAME=value_of_variable
This value will remain until you logout from the system or exit from the shell you are working in.
To make other programs that use the variable aware of the new value enter the command:
export VARNAME
---------------------------------------
To make lasting changes to the value of an environment variable:
1. Use your editor to open the .bashrc file and add the line:
VARNAME=value_of_variable;export VARNAME
[or simply,
export VARNAME=value_of_variable]
for example
# add new directory to PATH
export PATH=$PATH:/home/weigang/MyScripts/
2. Save the file and leave the editor.
3. Enter the command:
source $HOME/.bashrc
This adds the new value to your working environment.
When you login, the BASH shell reads the .bashrc file each time you login or start a subshell.
VARNAME=value of variable
By convention, the variable name is given in upper case.
To make a temporary change the value of an environment variable enter the command:
VARNAME=value_of_variable
This value will remain until you logout from the system or exit from the shell you are working in.
To make other programs that use the variable aware of the new value enter the command:
export VARNAME
---------------------------------------
To make lasting changes to the value of an environment variable:
1. Use your editor to open the .bashrc file and add the line:
VARNAME=value_of_variable;export VARNAME
[or simply,
export VARNAME=value_of_variable]
for example
# add new directory to PATH
export PATH=$PATH:/home/weigang/MyScripts/
2. Save the file and leave the editor.
3. Enter the command:
source $HOME/.bashrc
This adds the new value to your working environment.
When you login, the BASH shell reads the .bashrc file each time you login or start a subshell.
Comments
Post a Comment
https://gengwg.blogspot.com/