How to use apt-get with a proxy on Debian/Ubuntu

Linux, Unix .... All free/open source operating systems

How to use apt-get with a proxy on Debian/Ubuntu

Postby The_Ace » Tue Oct 26, 2010 5:27 pm

Here's a little tip for Debian and Debian based distro (Ubuntu.Mint/Mepis, etc.) users on how to use apt-get when your PC is using a proxy server to access the net.
This is useful for office or school environments where the PCs has access to the internet only via a proxy server and not NATed. Usually, in this type of senario, you cannot install packages using the standard sudo apt-get install package_name as there's no direct access to the net.

This can be fixed by setting the proxy details in /etc/bash.bashrc file like this :
From the command line, run :
Code: Select all
sudo echo "export http_proxy=http://username:password@proxyserver.net:port/" >> /etc/bash.bashrc
Its extremely important that you use >> and not a single > !!
If a single > was used, it will overwrite the /etc/bash.bashrc and you will lose the command line!

For example :
If the proxy server is 192.168.1.100 on port 8080 and there's no user name or password the code will be :
Code: Select all
sudo echo "export http_proxy=http://192.168.1.100:8080/" >> /etc/bash.bashrc
If the proxy server is 192.168.1.100 on port 8080 and username is ProxyUser and password is ProxyPass the code will be :
Code: Select all
sudo echo "export http_proxy=http://ProxyUser:ProxyPass:192.168.1.100:8080/" >> /etc/bash.bashrc
After this, close the command terminal and open a new one and the setting is applied. Now you can install or update applications using apt-get.
Just to recap: I come in peace, I mean you no harm and you all will die
User avatar
The_Ace
Wiz
Wiz
 
Posts: 223
Joined: Fri Dec 18, 2009 3:12 am
Has thanked: 1 time
Have thanks: 2 time

Re: How to use apt-get with a proxy on Debian/Ubuntu

Postby mdmg » Tue Oct 26, 2010 7:11 pm

Thanks Ace!
User avatar
mdmg
Pro
Pro
 
Posts: 320
Joined: Tue Nov 10, 2009 11:48 pm
Has thanked: 23 time
Have thanks: 3 time


Return to Nix

Who is online

Users browsing this forum: No registered users and 1 guest

cron