Find the answer to your Linux question:
Results 1 to 3 of 3
Hey all, I am trying to add a path to my PATH variable on redhat linux and seem to be having problems. I can set the path variable like this: ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Feb 2013
    Posts
    1

    altering PATH variable


    Hey all, I am trying to add a path to my PATH variable on redhat linux and seem to be having problems. I can set the path variable like this:

    PATH=$PATH:/my/dir
    export PATH

    and that works fine but its not a permanent fix. Also, that only works for the current terminal session. If I try and open another terminal session I would have to retype in the commands. I have read I need to change my ~/.bash_profile file but that file does not exist. I created the file in the ~ directory and added the two lines above but when I log out and log back in, the PATH variable is not changed. Any help would be great!

  2. #2
    Linux Engineer hazel's Avatar
    Join Date
    May 2004
    Location
    Harrow, UK
    Posts
    1,195
    Try putting it into .bashrc. You might find this article useful.
    "I'm just a little old lady; don't try to dazzle me with jargon!"

  3. #3
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    Location
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    Posts
    11,444
    What hazel suggests will work, but isn't optimal. It is best to put the in your ~/.bash_profile instead:
    Code:
    export PATH="${PATH}:/my/dir"
    File names that start with a dot are "invisible", which is probably why you don't see it normally. ~ is your home directory (accessible also with the $HOME environment variable). In any case, if bash is your default shell, then you MUST have the following files in your home directory:

    1. .bash_history
    2. .bash_logout
    3. .bash_profile
    4. .bashrc

    Just for my information, what distribution+version of Fedora/RedHat are you running?
    Sometimes, real fast is almost as good as real time.
    Just remember, Semper Gumbi - always be flexible!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •