Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Some applications support proxy (http proxy or socks proxy), and some are not.

For browsers, I can specify proxy server in the preferences/options dialog, and other applications may be able to configure proxy servers in config files.

For general purpose, can I invoke a command using a specific proxy? Like following:

$ proxy-exec --type sock5 --server -- wget/ftp ...

I'm using Ubuntu Maverick.


In win32, it can be implemented by hijacking the socket dlls, maybe, I'm not familiar with Linux programming, but I guess it's possible in Linux. though.

share|improve this question

3 Answers 3

Most Linux commands that access the Internet look in the HTTP_PROXY, FTP_PROXY, and SOCKS_SERVER environment variables for proxy information. So, to do something like your example, just run:


The syntax for HTTP_PROXY and FTP_PROXY is slightly different:

export HTTP_PROXY=
export FTP_PROXY=

The default GNOME desktop environment included with Ubuntu's proxy settings has an Apply System-Wide button, which will automatically set those environment variables for you. Otherwise, you can add the export lines to your ~/.bashrc file to make them take effect at every login.

Unfortunately, wget doesn't support SOCKS at all. You can use curl, which is included with Ubuntu, to achieve many things that wget does. Unfortunately, it doesn't check SOCKS_SERVER, while it does check HTTP_PROXY (as does wget). To use curl to download this page with a SOCKS5 server (performing DNS resolution with that server) and save it as superuser.html, run this:

curl --socks5-hostname > superuser.html

If you want to make curl always use that SOCKS proxy, you could create a shell alias. Just add the following line to your ~/.bashrc:

alias curl='curl --socks5-hostname'

You will need to restart your terminal or run that line as if it were a command for the changes to take effect.

share|improve this answer
I've tried wget with SOCKS_SERVER, but it seems not work. wget only read proxy settings from /etc/wgetrc. I tried links, too, it's okay to specify links -socks-proxy <url>, but it's failed using export SOCKS_SERVER=...; links <url>. – Xiè Jìléi Mar 27 '11 at 4:55
@谢继雷: Unfortunately some programs don't read SOCKS_SERVER, though many popular ones like ssh do. Also, wget doesn't seem to support SOCKS at all. You can, however, use curl. I'll add information to my answer about that. – Patches Mar 27 '11 at 5:21
Also youtube-dl doesn't read SOCKS_SERVER, it reads http_proxy instead. And it doesn't support socks proxy. Umm... A list of programs and their supported proxy environ vars can be very helpful. – Xiè Jìléi Aug 13 '12 at 23:40
If you search BXR.SU, it doesn't look like anything supports SOCKS_SERVER at all, certainly not OpenSSH. It's most certainly only an option supported by the socksify utility from the security/dante package. – cnst Sep 5 at 8:04
wget(1) can support SOCKS proxy since version 1.4.0 (circa 1999) if build with --with-socks which is almost never the case in packaged versions. – bufh yesterday

Try proxychains.

It can be installed with apt-get. Then you'll need to create a config file in either of

1) ./proxychains.conf
2) $(HOME)/.proxychains/proxychains.conf
3) /etc/proxychains.conf **

and you'll be able to invoke another commands like proxychains wget - the connections will go through proxy. You can specify multiple proxies used at once or in random order.

For example:

➜  ssh -ND 4000 sockshost &
[1] 3446
➜  wget -q -O- | grep remote_addr
➜  cat proxychains.conf 
socks5 4000
➜  proxychains wget -q -O- | grep remote_addr

I stripped some HTML tags and IPs, but as you can see the proxy was used and the IP address did change.

share|improve this answer
Since the original proxychains is unmaintained, you can use proxychains-ng instead. – Denilson Sá Jun 18 at 13:37

wget does not support socks, curl works as Patches said:

curl --socks5-hostname

If you need wget you can install tsocks.

Install sudo aptitude install tsocks and setup:

$ sudo vim /etc/tsocks.conf
server =
server_type = 5
server_port = 8000


tsocks wget
share|improve this answer
torsocks seems to be the updated version of tsocks: – Ciro Santilli 六四事件 法轮功 包卓轩 Nov 15 at 10:03

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.