The Straight Dope

Go Back   Straight Dope Message Board > Main > General Questions

Reply
 
Thread Tools Display Modes
  #1  
Old 09-27-2007, 08:20 AM
VunderBob VunderBob is offline
Mostly harmless
Charter Member
 
Join Date: Oct 2002
Location: The VunderLair
Posts: 13,285
How do I permanently change the PATH in Linux?

Another n00b Linux question: how do I make a permanent change to the PATH in Linux?

I can do the PATH=<change>:$PATH bit just fine, but it only lasts as long as that terminal session. SETENV apparently is not a valid Bash command. There has to be a startup file somewhere that holds the environment data, but I'm clueless where to find it. Help, please...
Reply With Quote
Advertisements  
  #2  
Old 09-27-2007, 08:23 AM
muldoonthief muldoonthief is offline
Member
 
Join Date: Jul 2003
Location: North of Boston
Posts: 6,275
Quote:
Originally Posted by VunderBob
Another n00b Linux question: how do I make a permanent change to the PATH in Linux?

I can do the PATH=<change>:$PATH bit just fine, but it only lasts as long as that terminal session. SETENV apparently is not a valid Bash command. There has to be a startup file somewhere that holds the environment data, but I'm clueless where to find it. Help, please...
In your /home/username/ directory, look for '.bashrc' or '.bash_profile' - note the dot in front of each name, which means a normal "ls" won't show them, you'll have to do "ls -a". They each get run whenever you login, so add your "PATH=$PATH:/added_path" command there.
Reply With Quote
  #3  
Old 09-27-2007, 08:24 AM
VunderBob VunderBob is offline
Mostly harmless
Charter Member
 
Join Date: Oct 2002
Location: The VunderLair
Posts: 13,285
Quote:
Originally Posted by muldoonthief
In your /home/username/ directory, look for '.bashrc' or '.bash_profile' - note the dot in front of each name, which means a normal "ls" won't show them, you'll have to do "ls -a". They each get run whenever you login, so add your "PATH=$PATH:/added_path" command there.
Thanks.
Reply With Quote
  #4  
Old 09-27-2007, 08:37 AM
Derleth Derleth is offline
Guest
 
Join Date: Apr 2000
Note that this only changes things for scripts you run under your normal login ID. If you want scripts run under other login IDs (such as root) to see the changed path, put the line in /etc/profile. You will need to use sudo to edit the file.

Never do normal stuff logged in as root. In fact, never log in as root at all. Log in as a normal user and use sudo to do stuff only root can do.
__________________
"Ridicule is the only weapon that can be used against unintelligible propositions. Ideas must be distinct before reason can act upon them."
If you don't stop to analyze the snot spray, you are missing that which is best in life. - Miller
I'm not sure why this is, but I actually find this idea grosser than cannibalism. - Excalibre, after reading one of my surefire million-seller business plans.
Reply With Quote
  #5  
Old 09-27-2007, 03:16 PM
Earthworm Jim Earthworm Jim is offline
Guest
 
Join Date: May 2000
Quote:
Originally Posted by muldoonthief
In your /home/username/ directory, look for '.bashrc' or '.bash_profile' - note the dot in front of each name, which means a normal "ls" won't show them, you'll have to do "ls -a". They each get run whenever you login, so add your "PATH=$PATH:/added_path" command there.
You may want to export that as well. export makes sure it's set in inherited envs. With bash you can do
export PATH=/new/path:${PATH}

or put them on separate lines
PATH=/new/path:${PATH}
export PATH

Last edited by Earthworm Jim; 09-27-2007 at 03:17 PM.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 Off
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 10:33 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Send questions for Cecil Adams to: cecil@chicagoreader.com

Send comments about this website to: webmaster@straightdope.com

Terms of Use / Privacy Policy

Advertise on the Straight Dope!
(Your direct line to thousands of the smartest, hippest people on the planet, plus a few total dipsticks.)

Publishers - interested in subscribing to the Straight Dope?
Write to: sdsubscriptions@chicagoreader.com.

Copyright © 2013 Sun-Times Media, LLC.