Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I edit my .profile file to set a permanent value for my PATH variable?

Is there any other file that needs editing? (This is on CentOs 6.2)

share|improve this question

migrated from stackoverflow.com Jan 24 '13 at 1:52

This question came from our site for professional and enthusiast programmers.

    
Why did you close my question???? What's wrong with asking stuff that one doesn't knwo? – user1508893 Jan 23 '13 at 22:18
    
Stack Overflow is for questions about programming. You may have better luck with this question at unix.stackexchange.com. – KatieK Jan 24 '13 at 1:31

You'll probably want to do this in your shell's rcfile (.bashrc, .zshrc, etc.). You'll want to add something like the following:

export PATH=$PATH:/new/folder/path

if you are only looking to append a file path. Or you can get tricky with it and create a path file (for zsh I have a .zpath file). In there you can do something like:

PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"
export PATH

Now every time that file is sourced (source ~/.zpath for example) it will load those paths into your environment. You can add source ~/.zpath to your rcfile so this will happen every time you log in or create a new shell.

share|improve this answer
    
I don't want to append new values to PATH. I want to remove some values, and replace some others with new stuff. Should I just put export PATH= <new path> in my .bashrc file? (I put this in my .profile file, but it didn't seem to ahve any effect) – One Two Three Jan 24 '13 at 20:18
    
Yea, put that in your .bashrc. – mgoffin Jan 24 '13 at 20:39
    
Thanks! (I don't know how to mark your answer as the answer, though). (THere is supposed to be a check symbol, isn't there?) – One Two Three Jan 24 '13 at 20:41
    
Not entirely sure (I haven't asked any questions yet). I thought there was a check image under the upvote/downvote. – mgoffin Jan 24 '13 at 21:11
 - Go to /etc/profile 
Go to line # Path manipulation if [ "$EUID" = "0]; then
       pathmunge /sbin
       pathmunge /usr/sbin
       pathmunge /usr/local/sbin

   ***add your path like this- pathmunge /your/path

** or you change userid (0 is root) or add more conditions like

   if [ "$EUID" >= "0" ]; then
       pathmunge /sbin
       pathmunge /usr/sbin
       pathmunge /usr/local/sbin 
   ** to find your id type this command at prompt #id

And reboot the system

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.