Monday, November 23, 2009

Change Proxy Settings on linux using shell commands

You can change the proxy settings for current session by executing following command. Which changes the environment variable "http_proxy". If you want, you can do it for ftp as well (ftp_proxy).
export http_proxy="http://NewProxy_address:Port"

Assume my proxy run on machine on port 808, then this settings will be
export http_proxy=""

Personal Experience

Recently, I installed Ubuntu server 8.04 and while the installation I set proxy settings wrong manner. In that case, installation guide give the format of "http://[[[user]:[passowrd]@serverIP]:[port]]" to enter proxy settings. Since I was using my proxy server in a windows machine, I had problem of giving username@server:port format. I gave it http://janaka@, but it is only necessary to give So I needed to permanently change it. If you only used above command, it will not be there when you reboot the linux os. Because it is just changing the current environmental variable "http_proxy".
Using following changes you could permanently change the settings.
If you wanted to add it for any user add export http_proxy="" on ~/.bashrc file.
 vi ~/.bashrc

If you want to do it for current user, add export http_proxy="" on /etc/rc.local.
vi /etc/rc.local
The File will look like below.
And then change the execution bit to execute this script while loading.
chmod u+x /etc/rc.local

Now it should be working.

1 comment: