Ubuntu – How to set system-wide proxy address using shell script


I want to set system Proxy address through my Qt application. So i was wondering if i could write a script which can be executed by my application every time to change the proxy address.

I tried :

 #! /bin/sh 
 echo "# Generated by Application"

 export $1
 echo "Proxy Address ${1}

but this script was not successful. I think it was unable to execute "export" command.

Can anyone help me resolving this issue ?

Best Answer

  • Try this:

    #! /bin/sh
    echo "# Generated by Application"
    export http_proxy='http://$1/'
    export ftp_proxy='http://$1/'


    • your argument string($1) should be like this


    • If you do not use userid and password then argument string($1) should be


    • you can export https_proxy and socks_proxy if you need.
    • To see if your proxy is set or not use env | grep proxy

    To change system proxy using shell script try these:

    gsettings set org.gnome.system.proxy mode 'manual'
    gsettings set org.gnome.system.proxy.http enabled true
    gsettings set org.gnome.system.proxy.http host 'proxy.server.addr'
    gsettings set org.gnome.system.proxy.http port proxy_port

    If you have user authentication pass and id

    gsettings set org.gnome.system.proxy.http authentication-user 'user_id'
    gsettings set org.gnome.system.proxy.http authentication-password 'password'

    To use http_proxy for all other proxy

    gsettings set org.gnome.system.proxy use-same-proxy true

    To set bypass proxy for any host

    gsettings set org.gnome.system.proxy ignore-hosts "['localhost',  '', 'all', 'other', 'hosts']"