LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 09-05-2009, 11:58 AM   #1
msardejnai
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Rep: Reputation: 0
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?

Last edited by msardejnai; 09-05-2009 at 12:01 PM.
 
Old 09-05-2009, 12:03 PM   #2
colucix
Moderator
 
Registered: Sep 2003
Location: Bologna
Distribution: CentOS 6.5 OpenSuSE 12.3
Posts: 10,498

Rep: Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956Reputation: 1956
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.

Last edited by colucix; 09-05-2009 at 12:06 PM.
 
Old 09-05-2009, 12:04 PM   #3
msardejnai
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Original Poster
Rep: Reputation: 0
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
 
Old 09-05-2009, 12:06 PM   #4
msardejnai
LQ Newbie
 
Registered: Sep 2009
Posts: 3

Original Poster
Rep: Reputation: 0
Thanks yeah it works!
 
Old 09-05-2009, 12:23 PM   #5
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Servers: Debian Squeeze and Wheezy. Desktop: Slackware64 14.0. Netbook: Slackware 13.37
Posts: 8,546
Blog Entries: 28

Rep: Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176Reputation: 1176
Quote:
Originally Posted by msardejnai View Post
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
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bashrc : setting path threaderslash Linux - Laptop and Netbook 3 04-03-2009 05:27 PM
set up java_home path in /home/user/.bashrc but use path in /usr/lib/java vitalstrike82 Slackware 4 01-13-2009 11:25 PM
Setting path: /etc/profile, /etc/bashrc or ~/.bashrc Swakoo Linux - General 1 08-07-2007 10:59 PM
how to implement .bashrc path on KVim??? Mathsniper Linux - General 0 04-02-2005 02:13 AM
modifying $PATH in bashrc gargamel237 Linux - Software 4 08-13-2003 12:10 PM


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

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration