Set Path for all Users (Login and Non-login Shells)

7,730

Create a file named (say) anaconda.sh in /etc/profile.d/ with the contents:

PATH=/opt/anaconda3/bin:$PATH

The trailing ".sh" is important, as that is the syntax that /etc/profile uses to search for files to include. Bash will read /etc/profile at login. If you want a current shell/terminal to pick up the change, just run . /etc/profile.d/anaconda.sh.

If you encounter situations where a non-interactive shell needs it, you're left with ~/.bashrc (unless the calling environment uses --rcfile to override that behavior).

Share:
7,730

Related videos on Youtube

Audrey
Author by

Audrey

Updated on September 18, 2022

Comments

  • Audrey
    Audrey over 1 year

    Ok. So, I'm used to Ubuntu and CentOS more than redhat, so I'm hoping there's some obvious solution to this that I'm missing.

    I've installed Anaconda (Python). I've placed it in:

    /opt/anaconda3
    

    I would like for myself and all users to be able to have the following in their paths:

    /opt/anaconda3/bin
    

    I have googled around and have gained a lot of conflicting information about how to "properly" accomplish my mission.

    Stuff I have tried:

    1. Adding a bash script to /etc/profile.d
    2. Editing /etc/profile
    3. Editing /etc/bashrc
    4. Adding to root bashrc
    5. Editing user .bashrc

    All edits involved some form of:

    PATH=/opt/anaconda3/bin:$PATH
    

    or

    export PATH=/opt/anaconda3/bin:$PATH
    

    Option 2 yielded the addition of /opt/anaconda3/bin to the path for multiple users, but after terminal restarts still did not run the commands within bin (i.e. conda install, ipython notebook, etc.)

    Any ideas?