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:
- Adding a bash script to /etc/profile.d
- Editing /etc/profile
- Editing /etc/bashrc
- Adding to root bashrc
- 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?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
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).
Method 2
Append the path to the file paths mentioned in the /etc/environment file.
This is loaded first before the local users directory .bashrc file is loaded so its the best place to set system wide vars.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0