Reputation: 4511
I want to add multiple path in $path variable like java path and php path . how to do that in linux?
I am doing something in bash_profile like :
PATH=$JAVA_HOME/bin:$PATH:/usr/java/jdk1.7.0_45/bin/:$AWS_AUTO_SCALING_HOME/bin
Upvotes: 61
Views: 143336
Reputation: 957
If you're on a Mac, the best way in my opinion would be following Chamindu's answer with a slight tweak. using nano or vim whichever you prefer, but I'll use nano as it's easier for most people.
nano ~/.bash_profile
to open bash profile.FLUTTER="/Users/MyUsername/development/flutter/bin"
VSCODE="/Applications/Visual Studio Code.app/Contents/Resources/app/bin"
PATH=$PATH:$FLUTTER:$VSCODE
export PATH
control + x
on your keyboard to exit.Y
to save your changes.source ~/.bash_profile
to refresh your bash profile/environment variables.Now you can navigate to any directory and call the files in your path.
Note:
FLUTTER
and VSCODE
for your variable names of choice.sudo
if you're not using the admin account.Upvotes: 4
Reputation: 1
sudo CPATH=/usr/include/linux/:/usr/src/linux-headers-5.17.0-1-common/include/linux/ vmware-modconfig --console --install-all
Upvotes: 0
Reputation: 306
sudo gedit /etc/profile
to open system path fileVARIABLE_NAME1=/your/path/to/location1
VARIABLE_NAME2=/your/path/to/location2
PATH=$PATH:$VARIABLE_NAME1:\$VARIABL3_NAME2
export PATH
Upvotes: 3
Reputation:
One way to add multiple executables to the $PATH variable is:
export PATH=/path/to/executable1:\
/path/to/executable2:\
/path/to/executable3:\
/path/to/executable4
If a $PATH
already exists in .bash_profile
, and you want them to take precedence over executables (like java and php), you can do:
export PATH=$PATH:/path/to/executable1:\
/path/to/executable2:\
/path/to/executable3:\
/path/to/executable4
If the path to any executable contains whitespaces, add the part / ... executableX
in quotes.
Once you're done making changes in your bash_profile
, source the file in a terminal session so that changes are effective immediately:
source .bash_profile
Upvotes: 6
Reputation: 121
Set the $PATH
environment variable to include the directory where you installed the bin directory with shell scripts and two consecutive export entries as in example.
Example:
export ANT_HOME=/path/to/ant/dir
export PATH=${PATH}:${ANT_HOME}/bin:${JAVA_HOME}/bin
To make them permanent entries update the bash_profile file.
Upvotes: 12
Reputation: 310983
$PATH
can have several paths separated by a colon (:
). E.g.:
export PATH=/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/myuser/bin
Upvotes: 115