How to Set Proxy in an Ubuntu Terminal?

Yes, because companies like to use proxy but I needed to access the Internet from my Ubuntu running on a VirtualBox.

Just a few steps and access can be established:

  1. Edit the /etc/environment file with your favorite editor
  2. Add the following lines
http_proxy="http://myproxy.server.com:8080/"
https_proxy="http://myproxy.server.com:8080/"
ftp_proxy="http://myproxy.server.com:8080/"
no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com"
HTTP_PROXY="http://myproxy.server.com:8080/"
HTTPS_PROXY="http://myproxy.server.com:8080/"
FTP_PROXY="http://myproxy.server.com:8080/"
NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com"

Logout and login again.

Apt does not obey the environment variables so we need to set up the proxy setting:

  1. Edit the /etc/apt/apt.conf file with your favorite editor
  2. Add the following line:
Acquire::http::proxy "http://myproxy.server.com:8080/";

HTTP proxy is enough most of the times to download packages and updates.

That’s all.

Cheers.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.