Linux Environment Variables – Storage, Change, and Safety

12.04environment-variables

I am trying to configure a build from source an old version of gcc on my dev machine. The documentation highlight several environment variables that need to be changed in order to do this. I was wondering how to do this and also where linux stores them and if a system restart is required for any changes to be registered??

Best Answer

The Global environment variables of your system are stored in /etc/environment.
Any changes here will get reflected throughout the system and will affect all users of the system. Also, you need a Reboot, for any changes made here to take effect.

User level Environment variables are mostly stored in .bashrc and .profile files in your Home folder. Changes here only affect that particular user. Just close and open the terminal for configuration changes to take place.

Edit : If you don't want to Reboot or restart your terminal, you can make use of the source command.
Eg. source /etc/environment or source .bashrc