Linux command line to turn off proxy

22

25

Can you show me the command line to turn off proxy when I am using the command line terminal in Ubuntu?

Sean Nguyen

Posted 2010-10-05T16:55:44.417

Reputation: 635

where do you need to disable it? Proxy settings are application dependant, as far as I know. – Diskilla – 2010-10-05T17:27:16.707

Answers

28

As the other answer says there are some programs that don't look at the system at all you may have to set them up individually. For instance wget has a number of proxy options, that can be used to ignore or adapt the environmental proxy config during execution. Here are a number of areas in which the systems proxys can be set up.

  • How my system looks, note that you will have to change the specifed system configuration for you networking Environment.

Some Linux systems use /etc/environment

$ cat /etc/environment 
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games"
http_proxy="http://192.168.1.250:8080/"
ftp_proxy="ftp://192.168.1.250:8080/"
https_proxy="https://192.168.1.250:8080/"  

There is no uniform single set up other use env

$ env | grep -i proxy
NO_PROXY=localhost,127.0.0.0/8,127.0.1.1
http_proxy=http://192.168.1.250:8080/
FTP_PROXY=ftp://192.168.1.250:8080/
ftp_proxy=ftp://192.168.1.250:8080/
all_proxy=socks://192.168.1.250:8080/
ALL_PROXY=socks://192.168.1.250:8080/
HTTPS_PROXY=https://192.168.1.250:8080/
https_proxy=https://192.168.1.250:8080/
no_proxy=localhost,127.0.0.0/8,127.0.1.1
HTTP_PROXY=http://192.168.1.250:8080/  

I would check out the ~/.bashrc to have setting applied automatically on system start up.

$ man env
$ man set
$ # The file section near the end of the bash manual.
$ man bash 

FILES
       /bin/bash
              The bash executable
       /etc/profile
              The systemwide initialization file, executed for login shells
       /etc/bash.bashrc
              The systemwide per-interactive-shell startup file
       /etc/bash.bash.logout
              The systemwide login shell cleanup file, executed when  a  login
              shell exits
       ~/.bash_profile
              The personal initialization file, executed for login shells
       ~/.bashrc
              The individual per-interactive-shell startup file
       ~/.bash_logout
              The  individual  login shell cleanup file, executed when a login
              shell exits
       ~/.inputrc
              Individual readline initialization file

nelaaro

Posted 2010-10-05T16:55:44.417

Reputation: 9 321

17

Assuming you're talking about typical command-line software and an HTTP proxy:

Most command-line tools pick this up from the environment variable HTTP_PROXY, so prior to running a command:

unset HTTP_PROXY

There can be some variation between software/platforms, and you might need to unset http_proxy also.

Note that many programs store this information in their own config files, and are likely to ignore the environment, so you would have to address those on a case-by-case basis.

user235

Posted 2010-10-05T16:55:44.417

Reputation:

Seems to require reboot...? – Yan King Yin – 2019-09-25T03:31:40.917

6

You can set or unset all variables at once in bash:

$ export {http,https,ftp}_proxy="http://proxy-server:port"
$ unset {http,https,ftp}_proxy

$ export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
$ unset {HTTP,HTTPS,FTP}_PROXY

You can also add a shortcut to you ~/.bashrc:

# Set Proxy
function setproxy() {
    export {http,https,ftp}_proxy="http://proxy-server:port"
    export {HTTP,HTTPS,FTP}_PROXY="http://proxy-server:port"
}

# Unset Proxy
function unsetproxy() {
    unset {http,https,ftp}_proxy
    unset {HTTP,HTTPS,FTP}_PROXY
}

Don't forget to reload .bashrc:

$ . ~/.bashrc

or

$ source ~/.bashrc

More details at [S]hell Hacks.

Adriano P

Posted 2010-10-05T16:55:44.417

Reputation: 385

This is good answer, but I am afraid that there are more places in the system, when proxy settings needs to be changed: https://askubuntu.com/questions/664777/systemwide-proxy-settings-in-ubuntu.

– matandked – 2017-07-11T10:33:12.040

Every software may use its own proxy settings (like npm or apt, to name a few). So http_proxy covers most of them, but you need to check the documentation to be sure which one it uses. – Adriano P – 2017-07-12T15:16:08.307

3

If you are looking to change the proxy for GUI programs you may have some success if they use the "system" proxy settings from Gnome. These are the proxy settings settable from the Control Panel.

You can look at and then change the the current settings with gconftool:

$ gconftool-2 -a /system/http_proxy
  ignore_hosts = [localhost,127.0.0.0/8,*.local]
  authentication_user =
  authentication_password =
  use_authentication = false
  use_http_proxy = true
  port = 8080
  host = http://myproxy.mydomain.org/

To turn off the proxy - set use_http_proxy to false:

$ gconftool-2 -t bool -s /system/http_proxy/use_http_proxy false

You can check the results using the -a line from above. Alternatively to set a new proxy:

$ gconftool-2 -t string -s /system/http_proxy/host "http://newproxy.mydomain.org/"
$ gconftool-2 -t int -s /system/http_proxy/port 8088

Greg

Posted 2010-10-05T16:55:44.417

Reputation: 865

3

export http_proxy=

You can check to see if they are gone by running

echo $http_proxy

It should return a blank line

Andrew M.

Posted 2010-10-05T16:55:44.417

Reputation: 31

1

If all the things written above don't work:

  1. Go to System Settings.
  2. Go to Network.
  3. Go to network-proxy and even if the selected choice is "none", go to "manual" and remove all the saved proxies.
  4. Apply systemwide.

This worked for me!

Aditi Tayal

Posted 2010-10-05T16:55:44.417

Reputation: 21

1The OP asked specifically for a command line option. They might not have installed the GUI – Burgi – 2016-05-27T08:29:40.927

1

To disable all proxy variables in one line for your current session:

unset `env | grep proxy | cut -d= -f1`

aruuu

Posted 2010-10-05T16:55:44.417

Reputation: 111

0

You may delete all {http_proxy, https_proxy} etc from /etc/environment. just sudo gedit /etc/environment and then manually delete all those proxies and save.

Ranjeet Kumar Upadhyay

Posted 2010-10-05T16:55:44.417

Reputation: 1