How to change system proxy settings from the command line on ubuntu desktop?

How to Change System Proxy Settings from the Command Line on Ubuntu Desktop?

Changing the proxy on the Ubuntu server is useful since it helps you improve the network performance of the system. Further, it helps you control internet usage, prevent server crashes, and provide better security and faster page loading time. Although it is very easy to change the proxy settings for Ubuntu desktop using the GUI method while using the terminal if a user wants to change the proxy settings it might become an uncomfortable situation to close the terminal and switch to GUI just to change the proxy.

This article will present you with the command line method to change proxy settings on the Ubuntu desktop.

Change
Sponsored
Ubuntu Desktop Proxy Settings from the Command Line

To change the system proxy setting in Ubuntu by using the command line, we will use the gsettings. The gsettings is a command line tool which is used in Ubuntu to modify the database settings. gsettings in Ubuntu enable users to monitor or set keys for changes; It is used to manage applications’ settings

To change the proxy settings on the Ubuntu system, use the below-mentioned command to run the gsettings tool:

gsettings

How to change system proxy settings from the command line on ubuntu desktop? 1

Once the gsetting tool is started, you can easily change the proxy settings by following the syntax of the below-mentioned commands:

gsettings set org.gnome.system.proxy. host
gsettings set org.gnome.system.proxy.<proxy name> port <port number>

Now I will use the above commands to change the proxy settings for each; HTTP, HTTPS, FTP and Socks.

See also  HexChat IRC Client Discontinued By Releasing v2.16.2

For “HTTP” Proxy

HTTP proxy is used to identify suspicious web content that is coming from a non-trusted source. It is required in Ubuntu to protect the HTTP server from miscellaneous attacks. To set up the HTTP proxy settings, run the below-mentioned commands to determine the host (server name or IP) and port for HTTP:

gsettings set org.gnome.system.proxy.http host ‘192.168.18.67’

Note: Here, I have used the IP address as host but that is just an example IP.

How to change system proxy settings from the command line on ubuntu desktop? 2

The below-mentioned command determines the port for http proxy:

gsettings set org.gnome.system.proxy.http port 8000

How to change system proxy settings from the command line on ubuntu desktop? 3

To verify that the http proxy is changed/updated successfully;

echo $http_proxy

How to change system proxy settings from the command line on ubuntu desktop? 4

For “HTTPS” Proxy

Hypertext Transfer Protocol over Secure Socket (HTTPS) is basically a request protocol between server and clients to provide a secure transaction and communication for users. To determine the host for https proxy, run the below-mentioned command:

gsettings set org.gnome.system.proxy.https host ‘192.168.18.67’

How to change system proxy settings from the command line on ubuntu desktop? 5

After that determine the port for HTTPS by using the below-mentioned command:

gsettings set org.gnome.system.proxy.https port 8000

How to change system proxy settings from the command line on ubuntu desktop? 6

Then verify by using the below-mentioned command:

echo $https_proxy

How to change system proxy settings from the command line on ubuntu desktop? 7

For “FTP” Proxy

FTP proxy acts as a bridge/relay to transfer files between source and destination. Its performance is better for larger files than HTTP. To change the FTP proxy, run the below-mentioned commands to determine both the host and port on the Ubuntu system:

gsettings set org.gnome.system.proxy.ftp host ‘192.168.18.67’

How to change system proxy settings from the command line on ubuntu desktop? 8

gsettings set org.gnome.system.proxy.ftp port 8000

How to change system proxy settings from the command line on ubuntu desktop? 9

Sponsored

Then verify, by using the below-mentioned echo command

echo $ftp_proxy

How to change system proxy settings from the command line on ubuntu desktop? 10

For “Socks” Proxy

SOCKS proxy facilitates communication between servers by using a firewall, it supports routing any type of traffic generated by any program or protocol. Similar to all of the above, the socks proxy can also be changed with the gsetting tool and for that, use the below-mentioned commands:

gsettings set org.gnome.system.proxy.socks host ‘192.168.18.67’

How to change system proxy settings from the command line on ubuntu desktop? 11

gsettings set org.gnome.system.proxy.socks port 8000

How to change system proxy settings from the command line on ubuntu desktop? 12

For example;

echo $all_proxy

How to change system proxy settings from the command line on ubuntu desktop? 13

How to Change System Wide Proxy Settings?

All the above-mentioned commands will change the proxy setting for the current user, but if you want to imply same proxy changes system-wide then run all the commands with sudo to have administrative permission to change the system proxy:

sudo gsettings

How to change system proxy settings from the command line on ubuntu desktop? 14

Just to quote the example; here I have only changed the “http” proxy setting for the whole system. You can change your desired proxy settings for the complete system by following the same commands mentioned in the previous section just remember to use “sudo” with them:

sudo gsettings set org.gnome.system.proxy.http host ‘192.168.18.67’

How to change system proxy settings from the command line on ubuntu desktop? 15

sudo gsettings set org.gnome.system.proxy.http port 8000

How to change system proxy settings from the command line on ubuntu desktop? 16

How to Switch the Proxy Mode?

There are three proxy setting modes in the Ubuntu system and those are:

1: “Auto” mode

Run the below-mentioned commands to switch the proxy mode to “auto mode”, this is useful if you are using PAC (Proxy Auto-Config) in Ubuntu.

gsettings set org.gnome.system.proxy autoconfig-url http://my.proxy.com/autoproxy.pac

How to change system proxy settings from the command line on ubuntu desktop? 17

Switch to auto mode through the following command:

gsettings set org.gnome.system.proxy mode ‘auto’

How to change system proxy settings from the command line on ubuntu desktop? 18

2: “Manual” mode

The manual mode is used if you want to manually change each proxy settings as we did in the first two sections of this article.

gsettings set org.gnome.system.proxy mode ‘manual’

How to change system proxy settings from the command line on ubuntu desktop? 19

3: None

If you do not want any proxy changes being applied to your system then you can clear all proxy settings by using the below-mentioned command:

gsettings set org.gnome.system.proxy mode ‘none’

How to change system proxy settings from the command line on ubuntu desktop? 20

Conclusion

To change the system proxy setting in Ubuntu through the command line, the gsetting tool is used. All the proxy settings can be modified/changed with the gsetting tool. The command and syntaxes for each proxy setting are discussed in the above-mentioned guidelines. The proxy modes “auto”, “manual” and “none” are also discussed above along with commands for each mode.


Discover more from Ubuntu-Server.com

Subscribe to get the latest posts sent to your email.

Comments

No comments yet. Why don’t you start the discussion?

    Leave a Reply