LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   How to add a new path to a global .bashrc? (https://www.linuxquestions.org/questions/linux-general-1/how-to-add-a-new-path-to-a-global-bashrc-752923/)

msardejnai 09-05-2009 11:58 AM

How to add a new path to a global .bashrc?
 
My account's .bashrc is linked to a global bashrc I guess by following code:
"if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi"

This is the only thing in my .bashrc, and tried to add a new path to it by adding PATH=/new/path:/another/new/path. But this caused my bash path to be lost. I couldn't run any basic command after that.

How can I add a new path to my .bashrc?

colucix 09-05-2009 12:03 PM

Have you used the export statement? It should be something like:
Code:

export PATH="/new/path:/another/new/path:${PATH}
Carefully check the syntax and if in doubt post the entire content of the actual ~/.bashrc, as it is now.

Edit: I've just seen you've corrected your original post. Now it looks like the problem is that you did not included the original PATH in your statement. Look at my example and try to reproduce it exactly. It should work. Take in mind that you can always execute basic commands giving the full path on the command line. For example use:
Code:

/bin/vi ~/.bashrc
to edit and correct your initialization file.

msardejnai 09-05-2009 12:04 PM

Huh! I solved it.

I added the default path "$PATH:" to the beginning of the new path. The new line must be like this:

PATH=$PATH:/new-path:/another-new-path

msardejnai 09-05-2009 12:06 PM

Thanks yeah it works!

catkin 09-05-2009 12:23 PM

Quote:

Originally Posted by msardejnai (Post 3671088)
Huh! I solved it.

I added the default path "$PATH:" to the beginning of the new path. The new line must be like this:

PATH=$PATH:/new-path:/another-new-path

That means that any executable files in the directories listed in the original $PATH will be used instead of executables in /new-path and /another-new-path with the same name. If that's what you want then no problem; often people want their own versions of commands instead of the usual ones in which case they need to use export PATH=/new-path:/another-new-path:$PATH


All times are GMT -5. The time now is 01:01 AM.