I am using Ubuntu 14.04 . I want to change the http proxy settings from the command line. This should be equivalent to changing in the GUI(All Settings->Network->Network Proxy) and clicking the button Apply System Wide. I don't want to restart/logout the system as I am planning to change the settings dynamically from a script(bash).

  • askubuntu.com/questions/175172/…. In the comment of the answer, it says to do sudo service network manager restart.
    – Ramesh
    Aug 26, 2014 at 15:57
  • @Ramesh it doesn't work. I already went through that question.
    – ma08
    Aug 26, 2014 at 15:59

3 Answers 3


From what I understand, setting proxies system-wide via that GUI does three things:

  1. Set the corresponding values in the dconf database.
  2. Set the values in /etc/environment.
  3. Set the values in /etc/apt/apt.conf.

1 and 3 take effect immediately. /etc/environment is parsed on login, so you will need to logout and login for that to take effect. (Note that this is login proper, not merely running a login shell.) The following script should be equivalent (assuming http/https proxies):

#! /bin/bash

gsettings set org.gnome.system.proxy mode manual
gsettings set org.gnome.system.proxy.http host "$HTTP_PROXY_HOST"
gsettings set org.gnome.system.proxy.http port "$HTTP_PROXY_PORT"
gsettings set org.gnome.system.proxy.https host "$HTTPS_PROXY_HOST"
gsettings set org.gnome.system.proxy.https port "$HTTPS_PROXY_PORT"

sudo sed -i.bak '/http[s]::proxy/Id' /etc/apt/apt.conf
sudo tee -a /etc/apt/apt.conf <<EOF
Acquire::http::proxy "http://$HTTP_PROXY_HOST:$HTTP_PROXY_PORT/";
Acquire::https::proxy "http://$HTTPS_PROXY_HOST:$HTTPS_PROXY_PORT/";

sudo sed -i.bak '/http[s]_proxy/Id' /etc/environment
sudo tee -a /etc/environment <<EOF

Even though it requires a re-login for PAM to apply /etc/environment everywhere, in a current shell you can still extract the values in that file:

export http_proxy=$(pam_getenv http_proxy)
  • @ma08 What's the output of gsettings get org.gnome.system.proxy mode; gsettings get org.gnome.system.proxy.http host; gsettings get org.gnome.system.proxy.http port;?
    – muru
    Aug 26, 2014 at 20:15
  • Now I get the problem, when I run the script as normal user, the warning appears (process:9662): dconf-WARNING **: failed to commit changes to dconf: Could not connect: Connection refused for each command in gsettings. If I run it as root, it works fine but the the output of the above commands(get) are the changed ones only in the root but not in the normal user.
    – ma08
    Aug 26, 2014 at 20:21
  • Aaarghh.. The damn script is littered with bugs. That's three I have had to fix. :/ In the second sudo tee, note that the file name is /etc/environment and not /etc/apt/apt.conf. You might have to delete the garbage entries in apt.conf.
    – muru
    Aug 26, 2014 at 20:27
  • The problem seems to be the warning I said in the comment earlier.
    – ma08
    Aug 26, 2014 at 20:30
  • 2
    Thank you, your script works and that answer in the link helped to get over that error. I should have done the debugging myself. Thanks a lot.
    – ma08
    Aug 26, 2014 at 20:39

I made a tool, ProxyMan, to simplify the entire task. You can download it from this link.

Also, you can have a look at the code if you are more interested to know the backend functioning. Download the zip file,extract them, go to the location of extracted files in terminal and following commands would help you:

  • bash main.sh: to set and unset proxy.
  • bash proxy_check.sh: to check your current proxy settings.
  • 1
    This is an awesome little tool! Saved me a ton of work!
    – Gh0sT
    May 17, 2018 at 13:48

I think this should avoid headaches:

Proxy Settings Video

An excelent tutorial, running in python. Setting Simple and Authenticated Proxy Settings in Ubuntu 12.04/12.10/13.04/13.10/14.04/14.10 and above 100% Working.

Solution 1 The system must be installed "python " . With the interpreter running the command : Command: "sudo python setproxy.py [ Proxy_Server ] [ proxy_port ] [ PROXY_USER ] [ proxy_password ]"

Video: https://www.youtube.com/watch?v=eBtzKa-dvJg

[ Proxy_Server ] : proxy.test.ts
[ Proxy_port ] : 8080
[ PROXY_USER ] : domainuser
[ Proxy_password ] : " the_password "

Solution 2: commands:

"Sudo apt- get install python- support"
"Sudo apt- get install ntlmaps "

Fill in the fields as appropriate:

- Proxy server
- Proxy port
- User
- Password
  • 2
    To make this into a good answer, you should at the very least outline the steps. Sep 15, 2016 at 22:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .