Proxy server is a device at the edge of a private network which relays the Internet traffic to and back from the Internet. It hides the private network from being directly communicated over the Internet adding a layer of security and privacy. It also acts as a content filter controlling the type of web sites the employees are allowed to visit and blocking the inappropriate and malicious ones.
In order to communicate through the Internet the Linux system needs proxy settings telling the location of proxy server and its listening port along with authentication credentials if they are set. In order to that add the http_proxy, https_proxy, ftp_proxy, socks_proxy environment variables to /etc/environment file.
The syntax to be followed is
No need to escape the metacharacters(*!^$.@) if they’re in your password as the environment variables are not interpreted by the shell but are directly read from the file.
Here’s what my /etc/environment looks like
deepak@linux:~$ cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games" http_proxy="http://deepakd:Secr3t@192.168.1.1:3128/" https_proxy="https://deepakd:Secr3t@192.168.1.1:3128/" ftp_proxy="ftp://deepakd:Secr3t@192.168.1.1:3128/" socks_proxy="socks://deepakd:Secr3t@192.168.1.1:3128/"
Now enforce the new environment variables and make them permanent using source command which reads the file specified and executes what’s inside them.
deepak@linux:~$ source /etc/environment
Verify the proxy settings using echo command:
deepak@linux:~$ echo $http_proxy http://deepakd:Secr3t@192.168.1.1:3128/