Last updated on November 22, 2020 by Dan Nanni
In RHEL-based Linux, login shell executes
/etc/profile script when a user logs in. This script customizes environment variables for all users system-wide. The script
/etc/profile also sources all the scripts placed in
/etc/profile.d directory. Therefore, in order to set system-wide environment variables in RHEL-based Linux, you can create a custom file with .sh extension in
/etc/profile.d as follows.
$ sudo vi /etc/profile.d/proxy.sh
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 protected]:8000 export https_proxy=http://username:[email protected]:8000
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
$ sudo vi /etc/environment
For proxy with authentication:
http_proxy=http://username:[email protected]:8000 https_proxy=http://username:[email protected]:8000
This website is made possible by minimal ads and your gracious donation via PayPal or credit card
Please note that this article is published by Xmodulo.com under a Creative Commons Attribution-ShareAlike 3.0 Unported License. If you would like to use the whole or any part of this article, you need to cite this web page at Xmodulo.com as the original source.