Jump to content

$PATH


Recommended Posts

I can't get my path variable to stick after reboot. I don't know how. I've been doing this to edit it:

 

$PATH=PATH:new/path
export $PATH

and it's not sticking after reboot. Anyone know what I'm doing wrong?

 

 

[moved from Software by spinynorman]

Link to comment
Share on other sites

The file to add the path globally for all users would be /etc/profile

You may have a section that looks similar to this:

if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /usr/games ; then

PATH=$PATH:/usr/games

fi

 

Add another section just below it that looks like this:

if [ "$UID" -ge 500 ] && ! echo ${PATH} |grep -q /new/path ; then

PATH=$PATH:/new/path

fi

 

If you just want it to affect one user, in that user's ~/.bash_profile, put this:

if ! echo ${PATH} |grep -q /new/path ; then

PATH=$PATH:/new/path

 

Just above:

export PATH

 

You will either have to log out and back in for the changes to take effect, or do this in a console as the user:

source /etc/profile

or

source ~/.bash_profile

 

After this, the path will remain until some other action may cause the system to edit one of those files.

 

P.S. I'm assuming you realize your example is a typo:

$PATH=PATH:new/path

export $PATH

 

was actually this:

PATH=$PATH:new/path

export PATH

Edited by Steve Scrimpshire
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...