I want to know how the standard environment variables given by the Linux OS like PATH, HOME are set automatically. Which file(s) are these read from. There should be some file from which these variables are set when a particular user logs in.
I would like to add a few more details to what @cnicutar has already mentioned.
Environment variables including PATH
can be:
/etc/profile
is meant for system settings for Bourne & Bourne compatible shells. The behavior of /etc/profile
may vary across distributions.
For the latest Ubuntu distributions, it is recommended to use /etc/environment
for system-wide settings. It is not recommended to use /etc/profile
or /etc/bash.bashrc
as noted the Ubuntu help.
On Ubuntu machines, /etc/profile
is a shell script which sources the scripts in /etc/profile.d
and the system-wide bashrc
file in /etc/bash.bashrc
, whereas /etc/environment
is a text file consisting of variable assignments per line which are set into the system-wide environment.
For each user the values of environment variables including PATH
(for the shell) can also be manipulated through ~/.profile
, ~/.bash_profile
, ~./bash_login
, and ~/.bashrc
where ~
means the user's home directory, like /home/alex/
.
To see your current environment variables and their values, you can use printenv
.
You can refer to the following link for more details on environment variables on Ubuntu systems: https://help.ubuntu.com/community/EnvironmentVariables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With