Objective
When using Apt-get or git pull or wget, you often consider using a proxy server for reasons of domestic network limitations.
At this point, you need to set up the proxy at the command line without affecting the system's proxy settings.
Method
You can set up a proxy server in three ways
Method One
Run the command directly in the terminal
Export http_proxy=http://proxyaddress:port
The benefit of this approach is simple and straightforward, and the impact surface is small (only valid for the current terminal).
Method Two
Write proxy address to shell configuration file
VI ~/.BASHRC
Add the following to the end of the file
Http_proxy=http://proxyaddress:portexport http_proxy
Then ESC: WQ Save the file and then execute it in the terminal
SOURCE ~/.BASHRC
Or exit the current terminal and start a terminal again.
The advantage of this approach is to permanently save the proxy server, the next time it can be used directly.
Method Three
Change the configuration of the appropriate tool, such as apt
sudo VI /etc/apt/apt.conf
Add the following line to the end of the file
" Http://proxyAddress:port "
Save the apt.conf file.
Added
If the proxy server needs to log in, you can write the username and password directly.
Http_proxy=http://Username:[email protected]:p ort
Set up and use a proxy server on the Linux command line