How can I permanently add a path to my bash profile?

3

Possible Duplicate:
How do I set PATH and other environment variables?

I would like to put the path of a binary in my bash profile which is not present in the usual location like /usr/bin or /sbin. For example, if the following is the path of the binary:

/path/to/bin

How would I put this path permanently in my bash profile so that every time I login I don't need to specify the path of the binary?

thetna

Posted 2011-08-18T13:49:48.970

Reputation:

Question was closed 2011-08-19T12:22:49.710

possible duplicate of How do I set PATH and other environment variables?, especially this answer which would explain the syntax.

– slhck – 2011-08-18T16:46:39.957

Answers

5

You should edit your ~/.bashrc or .bash_profile, and add something like:

export PATH=$PATH:/path/to/bin

Oliver Charlesworth

Posted 2011-08-18T13:49:48.970

Reputation: 972

I did the same but i am not seeing the path after running the command $PATH from terminal. Do i need to do restart? Is there any command for it? – None – 2011-08-18T13:54:30.767

You need to start a new shell. To have an immediate effect, you can also type source ~/.bashrc (or simply . ~/.bashrc). – None – 2011-08-18T13:55:12.013

type source ~/.bashrc to get it to update the PATH immediately. – arunkumar – 2011-08-18T13:56:03.563

the bash profile is only read when you login to that terminal. Start a new terminal, and echo $PATH should be correct. – Simon Elliston Ball – 2011-08-18T13:56:17.843

I am getting following error bash: export: `=/usr/local/bin:/usr/bin:/bin:/path/to/bin not a valid identifier.Even $PATH does not show the path i have added. – None – 2011-08-18T14:00:31.453

@thetna: Please double-check that the code you've added is exactly as I've typed above. In particular, check the $! – None – 2011-08-18T14:04:08.303

@Oli I checked it many times.Got the same. – None – 2011-08-18T14:06:27.463

@thetna: Then I don't know. The code above is valid! – None – 2011-08-18T14:10:45.420

1Make sure this bit ->PATH=$PATH:/path/to/bin<- has no spaces in it. – Linker3000 – 2011-08-18T14:39:39.420

Or better: Edit your question to show (paste) the contents of your .bashrc (or at least a few lines containing your edit). – JRobert – 2011-08-18T16:01:03.537