Reputation: 391
For example, I type to the following command:
# PATH=$PATH:/var/test
# echo $PATH
........./var/test // working
# export PATH
Next, I open another bash shell session to test if the export works by typing the following command:
# echo $PATH
........ // not working as in I don't see /var/test path
Upvotes: 7
Views: 22009
Reputation: 8769
you have set the PATH
environment variable only for your current bash
session. You need to add the line PATH=$PATH:/var/test
into ~/.bashrc
so that it works for any bash
shell.
Just run the following command to put it into your rc
(run commands) file (rc files contain startup information for a command(initialization)):
echo "PATH=$PATH:/var/test" >> ~/.bashrc
More info: https://en.wikipedia.org/wiki/Run_commands
https://superuser.com/questions/789448/choosing-between-bashrc-profile-bash-profile-etc
export
ing a variable makes it available only in child processes spwaned/started from that bash shell.
As an example:
$ export var=abcd
$ sh
$ echo "$var"
abcd
$ exit
$ echo "$var"
abcd
$
sh
is the child process of bash
hence it gets the value of var
, since you open a new bash
which is a different process altogether it does get the PATH
value.
Upvotes: 14