Learn How to Set Your $PATH Variables Permanently in Linux

If You Appreciate What We Do Here On TecMint, You Should Consider:

  1. Stay Connected to: Twitter | Facebook | Google Plus
  2. Subscribe to our email updates: Sign Up Now
  3. Get your own self-hosted blog with a Free Domain at ($3.95/month).
  4. Become a Supporter - Make a contribution via PayPal
  5. Support us by purchasing our premium books in PDF format.
  6. Support us by taking our online Linux courses

We are thankful for your never ending support.

Marin Todorov

I am a bachelor in computer science and a Linux Foundation Certified System Administrator. Currently working as a Senior Technical support in the hosting industry. In my free time I like testing new software and inline skating.

Your name can also be listed here. Got a tip? Submit it here to become an TecMint author.

RedHat RHCE and RHCSA Certification Book
Linux Foundation LFCS and LFCE Certification Preparation Guide

You may also like...

11 Responses

  1. Ashwini P B says:

    Whenever I open the terminal in Linux, I get a new blank page, but to continue from where I had stopped, what should I do?

  2. Anu Shibin says:

    Hi Marin,

    This works. But I need this to work automatically every-time my machine boots up. Now I have to run the source ~/.profile every time I restart. Is there any way to do this automatically?

  3. Kushagra says:

    I have vxargs.py script in directory “/home/csgrads/kumar392/RESILIO“. However when I try to add the directory “/home/csgrads/kumar392/RESILIO” to the path it gives an error – Bad : modifier in $ (/).

    I used the command mentioned by you, i.e. export PATH=$PATH:/home/csgrads/kumar392/RESILIO.

    Can you please help.

  4. kevin says:

    what about the process that running in crontab, which files should I add “export PATH” ??

  5. Tomatreides says:

    Great post!

    You can also use /etc/environment to set PATH environment variable, but it does not support variable expansion.

    • Erik says:

      Thank you “tomatreides” for this comment. It just solved a problem I have had more more than one week.

      We had this odd problem on a CentOS 7.3.1611 box where we installed Java 1.7.0_80, not upgraded or updated Java but a fresh install. What we noticed was that the PATH seems to have been ruined by something, but we could not figure out by what or how. You just solved that!

      Our theory is that the Java installation wrongfully puts its stuff in the “/etc/environment”-file and that then completely ruins the PATH variable since the PATH then contain “$PATH” and “$JAVA_HOME” instead of its expanded content.

      The fix is to move the Java related content from the “environment” file into a new file in the folder: “/etc/profile.d/”. Using the files “/etc/profile” or “/etc/bashrc” or any other system wide file is not recommended. Using e.g. “~/.bash_profile” or “~/.bashrc” or any other user specific file is also not recommended. The files in “/etc/profile.d/” are also not affected if you update the OS. So this is imho where this type of things should have been done in the first place (Oracle, are you listening?).

      Maybe there is a better way to solve this, but this works for us. I hope this helps anyone else who have the same problem. If you want to know more please reply to this comment and I will be more than happy to help you.

  6. Amit says:

    Nice article .. If we need to use java on ubuntu then what are the parameters we should use? or on which file.
    Any help will be appreciated!!

  7. sahil says:

    thanks its a very informative ..

  8. David says:

    Great post and great blog!!!
    In my PATH I have some variables repeated, e.g., /usr/local/bin

    I’ve never had issues with that, so I think that it should not be so important to have duplicates, am I wrong?

    • Kyle says:

      The path is resolved with the first match. If you have identically named executables then the specific order of the paths are important and you might find unexpected behavior when there are duplicate or out of sequence entries.

  9. Rodolfo says:

    you should include fishshell

Got something to say? Join the discussion.

Your email address will not be published. Required fields are marked *