Linux & environment variables
1. Introduction
Linux’s environment variables stored in variable PATH, so can use
echo $PATH
to checkLinux’s environment variables separate by
:
1
PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>
2. searching
search all PATH value
1
export
check PATH environment variable
1
echo $PATH
listing all set environemnt variables
1
set
in the home folder
ctrl h
find all Hidden files (name begin with .)open
.bashrc
and editopen
.bashrc
by command1
vim ~/.bashrc
3. adding
temporarily adding
1
export NAME=VALUE
examples:
1
export JAVA_HOME=/opt/openjdk11
1
export PATH=/usr/local/nginx/sbin/:$PATH
adding /usr/local/nginx/sbin/ index adding to the environment temporarily
current user adding permanent
1
vim ~/.bashrc
add
export PATH="/usr/local/nginx/sbin/:$PATH"
at the end of the file1
source ~/.bashrc
all users adding permanent
1
vim /etc/profile
add
export PATH="/usr/local/nginx/sbin/:$PATH"
at the end of the file1
source /etc/profile
4. deleting
1 | unset VARIABLE_NAME |
examples:
1 | unset JAVA_HOME |