Jump to content

$PATH


Recommended Posts

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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...