取消的命令:
unset http_proxyI'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 on a Linux or Unix-like systems?
Linux and UNIX-like systems has environment variable called http_proxy. It allows you to connect text based session and/or applications via the proxy server. All you need is proxy server IP address (URL) and port values.
| Tutorial details | |
|---|---|
| Difficulty | Easy (rss) |
| Root privileges | |
| Requirements | None |
| Estimated completion time | 5m |
Set http_proxy shell variable on Linux/OS X/Unix bash shell
Type the following command to set proxy server:
$ export http_proxy=
$ export http_proxy=
$ export http_proxy=
If the proxy server requires a username and password then add these to the URL. For example, to include the username foo and the password bar:
$ export http_proxy=
$ export http_proxy=
$ export http_proxy=
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=
OR
export http_proxy=
Save and close the file.
A note about enabling proxy access to a specific user
To enable proxy access for a specific user, add the lines user shell profile. For the default bash shell, the profile is the file .bash_profile. For example, enable proxy access for a specifc user called vivek, type:
$ vi $HOME/.bash_profile
OR
# vi /home/vivek/.bash_profile
Append the following line:
export http_proxy=
Save and close the file.
How do I use password protected proxy server using various command line options?
You can simply use wget command as follows:
$ wget --proxy-user=USERNAME --proxy-password=PASSWORD
Lynx command has the following syntax:
$ lynx -pauth=USER:PASSWORD
Curl command has following syntax:
$ curl --proxy-user user:password
