Ubuntu 15.04, how do I add these to the PATH

3.6k views Asked by At

I have the two following locations I want to add to the PATH of my system

/usr/bin/git & /usr/local/bin/cordova

How do I go about adding them? Not new to linux but new when it comes to editing the PATH.

Thanks :)

2

There are 2 answers

0
larsr On

You don't add files to the PATH, but rather directories. The exact syntax depends on which shell you are running. PATH contains directories separated by colon, :

If you are using bash, then you set the PATH variable like this:

export PATH=/usr/bin:/usr/local/bin:$PATH

to prepend the directories /usr/bin and /usr/local/bin to your PATH, while keeping the old values. However, I'd be surprised if /usr/bin and /usr/local/bin was not already in your path. Have you managed to unset the PATH variable?

For the change to be persistant, add the line above to the .bashrc file in your homedir. This file is executed by bash every time you start a new (interactive) shell.

0
Ana Eht On

if you use the export method, when you log off, next time that directory will not be in your PATH. To add path permanently get the current path by this command: echo $PATH This text file: .profile (it is a hidden file in your home directory, ctrl+H shows hidden files) should be edited in a text editor.

copy the current path put it here PATH="$HOME/bin:$PATH" but instead of what's inside " " , add the new path too, save, restart

the directory is added to you path.