Last updated on August 27, 2020 by Dan Nanni
System Settings
→ Network
→ Network proxy
, which is cumbersome. Is there a more convenient way to change desktop's proxy settings from the command line?In Ubuntu desktop, its desktop environment settings, including system proxy settings, are stored in DConf database, which is a simple key/value store. If you modify any desktop properties using System Settings menu, the changes are persisted in the DConf database backend. There are GUI-based or non-GUI-based ways to modify DConf database on Ubuntu. While System Settings or dconf-editor
are graphical methods for accessing DConf database, gsettings
or dconf
are command-line tools that can modify the database.
Here is how to change system proxy settings from the command line using gsettings
.
The basic usage of gsettings
for reading and writing a particular Dconf setting is as follows.
To modify a DConf setting:
$ gsettings set <schema> <key> <value>
To read a DConf setting:
$ gsettings get <schema> <key>
The following commands will change HTTP proxy setting to my.proxy.com:8000
on Ubuntu desktop.
$ gsettings set org.gnome.system.proxy.http host 'my.proxy.com' $ gsettings set org.gnome.system.proxy.http port 8000 $ gsettings set org.gnome.system.proxy mode 'manual'
If you want to change HTTPS/FTP proxy to manual as well, use these commands:
$ gsettings set org.gnome.system.proxy.https host 'my.proxy.com' $ gsettings set org.gnome.system.proxy.https port 8000 $ gsettings set org.gnome.system.proxy.ftp host 'my.proxy.com' $ gsettings set org.gnome.system.proxy.ftp port 8000
To change Socks host settings to manual:
$ gsettings set org.gnome.system.proxy.socks host 'my.proxy.com' $ gsettings set org.gnome.system.proxy.socks port 8000
All these changes above are limited to the current Desktop user only. If you want to apply the proxy setting changes system-wide, prepend sudo
to gsettings
command. For example:
$ sudo gsettings set org.gnome.system.proxy.http host 'my.proxy.com' $ sudo gsettings set org.gnome.system.proxy.http port 8000 $ sudo gsettings set org.gnome.system.proxy mode 'manual'
If you are using proxy auto configuration (PAC), type the following commands to switch to PAC.
$ gsettings set org.gnome.system.proxy mode 'auto' $ gsettings set org.gnome.system.proxy autoconfig-url http://my.proxy.com/autoproxy.pac
Finally, to remove manual/automatic proxy setting, and revert to no-proxy setting:
$ gsettings set org.gnome.system.proxy mode 'none'
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.
Xmodulo © 2021 ‒ About ‒ Write for Us ‒ Feed ‒ Powered by DigitalOcean