When you want to add a new value to the PATH
system variable, you most likely add a new line to ~/.bashrc
or ~/.bash_profile
files.
For example, if you want to add /opt/netbeans/bin
to PATH
, you must add this line to the end of ~/.bashrc
file:
export PATH=$PATH:/opt/netbeans/bin
Let's break this line down.
export PATH
- Here we refer to the PATH
variable
=
- We want to assign it a new value using the =
operator
(The rest of the string is the value that will be stored in the PATH
)
$PATH
- We assign the variable PATH
to the value that was in the variable before the current command
:
- We add a separator for the new value
/opt/netbeans/bin
- And add a new value to the PATH
You must see all of your refers to the PATH
variable in the ~/.bashrc
or ~/.bash_profile
files and make sure that you expand -
export PATH=$PATH:/opt/netbeans/bin
and not overwrite like this -
export PATH=/opt/netbeans/bin
the PATH
variable
You must make sure, in every reference to the PATH
you use $PATH:
and your additional value after it
If it doesn't work, you may do something like this:
- Make sure, there is something like the next variable in
/etc/environment
file and it never redefined in this file:
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games"
- Add missing paths from the above
PATH
variable to your PATH
variable located in the /etc/environment
Before testing after each change in files don't remember to update your configs.
For example for ~/.bashrc
file:
source `~/.bashrc`
cat /etc/environment
?