How to Use a Proxy on the Command Line?

I can set my proxy username and password along with proxy settings in the proxy ui but these settings do not work on the command line. How can I use apps such as wget & ping on the command line with a proxy?

Example Details:

  • username: 1234
  • pass: linux
  • proxy: proxy
  • port: 8080
1

3 Answers

The general scheme for the proxy URL is user:password@host:port

You can set the environment variable http_proxy, https_proxy, ftp_proxy, socks_proxy or all_proxy

In a bash shell, type this:

export http_proxy=""

To persist this configuration, you can add it to /etc/environment or /etc/bash.bashrc, /etc/profile or to an individual user /home/user/.bashrc

4

To set Network proxy settings one can use gsettings

gsettings changes the configuation files at DConf, which is the core settings for Ubuntu network proxy settings that you see in GUI by going to Network > Network Proxy

Here is an example

gsettings set org.gnome.system.proxy.http host ''
gsettings set org.gnome.system.proxy.http port 0
gsettings set org.gnome.system.proxy.http host ''
gsettings set org.gnome.system.proxy.http port 0
gsettings set org.gnome.system.proxy.ftp host ''
gsettings set org.gnome.system.proxy.ftp port 0

#Setting the Dynamic socks proxy 
gsettings set org.gnome.system.proxy.socks host 'localhost'
gsettings set org.gnome.system.proxy.socks port 1111

#Setting Mode 
gsettings set org.gnome.system.proxy mode 'manual'

You can't use proxies in the traditional sense with Ping. Ping works using the ICMP protocol.

HTTP proxies will only work with HTTP traffic. You can proxy most traffic in most programs using a SOCKSify-wrapper. The "dante-client" package provides a socksify. I used this one on other occasions:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest