Q. I'm behind a squid proxy server. How do I access internet via proxy server when I use wget, lynx and other utilities from a shell prompt?
A. Linux / UNIX has environment variable called http_proxy. It allows you to connect text based session / application via the proxy server. All you need is proxy server IP and port values. This variable is almost used by all utilities such as elinks, lynx, wget, curl and others.
Set http_proxy shell variable
Type the following command to set proxy server:
$ export http_proxy=http://server-ip:port/
$ export http_proxy=http://127.0.0.1:3128/
$ export http_proxy=http://proxy-server.mycorp.com:3128/
How do I setup proxy variable for all users?
To setup the proxy environment variable as a global variable, open /etc/profile file:
# vi /etc/profile
Add the following information:
export http_proxy=http://proxy-server.mycorp.com:3128/
Save and close the file.
How do I use password protected proxy server?
You can simply use wget as follows:
$ wget --proxy-user=USERNAME --proxy-password=PASSWORD http://path.to.domain.com/some.html
Lynx has following syntax:
$ lynx -pauth=USER:PASSWORD http://domain.com/path/html.file
Curl has following syntax:
$ curl --proxy-user user:password http://url.com/
You should follow me on twitter here or grab rss feed to keep track of new changes.
Featured Articles:
- 30 Handy Bash Shell Aliases For Linux / Unix / Mac OS X
- Top 30 Nmap Command Examples For Sys/Network Admins
- 25 PHP Security Best Practices For Sys Admins
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- Linux: 20 Iptables Examples For New SysAdmins
- Top 20 OpenSSH Server Best Security Practices
- Top 20 Nginx WebServer Best Security Practices
- 20 Examples: Make Sure Unix / Linux Configuration Files Are Free From Syntax Errors
- 15 Greatest Open Source Terminal Applications Of 2012

- My 10 UNIX Command Line Mistakes
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- The Novice Guide To Buying A Linux Laptop











{ 26 comments… read them below or add one }
For password protected proxies, I know it sometimes work directly included in http_proxy variable (ok it’s not so secure but it can make the work easier) :
$ export http_proxy=http://user:password@server-ip:port/
Great work. This worked for me. Thanks.
thank you , It is working fine :)
It is really correct?
export export http_proxy=http://proxy-server.mycorp.com:3128/
You have typed one more “export”. So you have to type only this
export http_proxy=http://proxy-server.mycorp.com:3128/
Slavko,
It was a typo. The faq has been updated.
Hi
I tried this, but still, I cannot ping google or any other site from within the shell.. it says ‘destination host unreachable’..
I’m using Redhat Enterprise 2.4..
Any idea what might be going wrong?
Thanks
Pravin
Until and unless you put the DNS server it won’t ping
Very Good Man!
Thanks!
above is good for for text based but for a simple linux user using firefox how can b a proxy server can b used like fedora core 8
proxy setting syntax:
export http_proxy=http://:@:/
export ftp_proxy=http://:@:/
it works for ishtiyaq :)
export http_proxy=http://user:pasword@proxy-server.mycorp.com:port/
export ftp_proxy=http://user:pasword@proxy-server.mycorp.com:port/
Is there support for excluding sites or a regex from using the proxy?
It seems that there is options for some commands, but is there a centralized option?
I.E. something like:
export no_http_proxy=*.ibm.com,10.0.0.0\24,…
wanna no can i download from a server which has a block on downloads by using linux
Hi My case is little different because my user name is domain\username
export http_proxy=http://domain\user:pasword@proxy-server.mycorp.com:port/
i try above way but didn’t work it.Can any one help me about
use:
export http_proxy=”http://user:password@proxy-ip:port”
I think the previous people forgot to put the quotes.
And another question, what if I have a proxy server enabled using the above command and want to remove it? What command do I have to use?
Hey People,
I got a doubt. My password is have a special character ‘@’. Due to this the character before the ‘@’ in my password are ignored. Can anyone include ‘@’ in your password and let me know if that works.
Thanks,
SP
Hi SP,
I am also facing same problem .If you are out of this problem .
Can you tell me the way to work it out.
Thanks
srinu
If you have a domain and you have a \ you have to escape it since \ it self is an escape char. You should do this:
export http_proxy=http://domain\\user:pasword@proxy-server.mycorp.com:port/
hi,
seems like for proxy
Only below setting is working
export http_proxy=
Hello!
I need to configure complete internet access behind a proxy.
I can access 80 port, but i need 443 and all ports for Skype for example.
Thanks for anyone who can help me.
Thanks
you can use ‘https_proxy’ with the same settings if you need proxy over https
you can also use ‘ftp_proxy’ if needed, as well
Hi guys,How can i remove the proxy from elinks?i was accessing a server that needed validation and that worked fine,then when i went to a no proxy server,i couldint access interned due to earlier proxy setting,please help me with the command or file to remove the proxy settings.
I just curious and my password doesn’t work because it has a character ‘@’ it generates error says unable to resolve host address especially using wget. How do i overcome it?Thanks
cd /etc
sudo gedit bash.bashrc
once gedit opens the file in text form,goto the end and type the following,edit if already exists:
export http_proxy=http://:@:8080/
export ftp_proxy=http://:@:/
example: lets say your username is simpson , password is bartrocks, the proxy server for your connection is http://10.1.1.32 ,port address is 8080, then to set up http proxy you have to write:
export http_proxy=http://simpson:bartrocks@10.1.1.32:8080/
Then Save and exit as you do for text files.Close and reopen the terminal and now you can use tools like wget to download web-pages from terminal :)
cd /etc
sudo gedit bash.bashrc
once gedit opens the file in text form,goto the end and type the following,edit if already exists:
export http_proxy=http://username:password@proxyserveraddress:8080/
export ftp_proxy=http://username:password@serveraddress:port/
example: lets say your username is simpson , password is bartrocks, the proxy server for your connection is http://10.1.1.32 ,port address is 8080, then to set up http proxy you have to write:
export http_proxy=http://simpson:bartrocks@10.1.1.32:8080/
Then Save and exit as you do for text files.Close and reopen the terminal and now you can use tools like wget to download web-pages from terminal :)