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
:
PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>
2. searching
search all PATH value
export
check PATH environment variable
echo $PATH
listing all set environemnt variables
set
in the home folder
ctrl h
find all Hidden files (name begin with .)open
.bashrc
and editopen
.bashrc
by commandvim ~/.bashrc
3. adding
temporarily adding
export NAME=VALUE
examples:
export JAVA_HOME=/opt/openjdk11
export PATH=/usr/local/nginx/sbin/:$PATH
adding /usr/local/nginx/sbin/ index adding to the environment temporarily
current user adding permanent
vim ~/.bashrc
add
export PATH="/usr/local/nginx/sbin/:$PATH"
at the end of the filesource ~/.bashrc
all users adding permanent
vim /etc/profile
add
export PATH="/usr/local/nginx/sbin/:$PATH"
at the end of the filesource /etc/profile
4. deleting
unset VARIABLE_NAME
examples:
unset JAVA_HOME