Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Adding stuffs to PATH in Linux

I have recently started off with Linux, and am having some confusion with how to set something to PATH, I went through many wikis, but things aren’t getting cleared, like I wanted to know what is the difference between putting things into the .bashrc file and /etc/environment file, and do we put the directory paths into the .bashrc file only, or is there some other file which we can use to mention our environment variables?

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Your options are: /etc/bashrc, /etcprofile, ~/.bashrc, ~/.profile`

The first two are generally not to be used as they are subject to change on system updates. If you must set global paths and environment (i.e. for every user) use /etc/bashrc.local or /etc/profile.local .

If you want to set env. variables for yourself/one user only then use ~/.bashrc or ~/.profile.
~/.profile is read for a login-shell only (according to the comments in mine:

# This file is read each time a login shell is started.
# All other interactive shells will only read .bashrc; this is particularly
# important for language settings, see below.

So shells you start by clicking on a Terminal icon will read ~/.bashrc.

As a rule I tend to put my global PATH modifications (i.e. for CUDA) into /etc/bashrc.local and anything that is only for me into ~/.bashrc.

Modifying PATH (and others) should be done by prepending to it via:
export PATH=<path>/<to>/<new SW binaries>:$PATH

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading