In RedHat-based Linux, login shell executes /etc/profile script when a user logs in. This script customizes environment variables for all users system-wide. The /etc/profile script also sources all .sh scripts placed in /etc/profile.d directory. Therefore, in order to set system-wide environment variables in RedHat-based Linux, you can create a custom file with .sh extension in /etc/profile.d as follows.
export http_proxy=http://my.proxy.com:8000 export https_proxy=http://my.proxy.com:8000
If the proxy requires authentication, you can specify username and password as well.
export http_proxy=http://username:email@example.com:8000 export https_proxy=http://username:firstname.lastname@example.org:8000
Set System-wide Environment Variables on Debian-based Systems
One caveat is that Debian-based systems do not use /etc/profile.d directory. Therefore, in order to set system-wide environment in Ubuntu or Debian, you can use /etc/environment instead.
For proxy with authentication:
Subscribe to Xmodulo
Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.
Did you find this tutorial helpful? Then please be generous and support Xmodulo!