Setting up apt-get to use a http-proxy

My university sets up proxy for campus network. Every time I restore my computer I have to set up proxy config for my computer OS in order to get connected to Internet.
To set up proxy config is very easy on Windows OS, but I always forget how to set proxy in Linux (ubuntu). So I write down methods to remind me.

  1. Temporary proxy session
    This is a temporary method that you can manually use each time you want to use apt-get through a http-proxy. This method is useful if you only want to temporarily use a http-proxy.
    export http_proxy="http://yourproxyaddress:proxyport"
    If you normally use sudo to run apt-get you will need to lgin as root first for this to work unless you also add some explicit environment settings to /etc/sudoer, e.g.
    Defaults env_keep = "http_proxy https_proxy ftp_proxy"

  2. APT configuration file method
    This method uses the apt.conf file which is found in your /etc/apt/ directory. This method is useful if you want apt-get to use a http-proxy permanently.
    On some installations there will be no apt-conf file set up. This procedure will either edit an existing apt-conf file or create a new apt-conf file.
    gksudo gedit /etc/apt/apt.conf
    Add this line to your /etc/apt/apt.conf file (substitute your details for yourproxyaddress and proxyport).
    Acquire::http::Proxy "http://yourproxyaddress:proxyport";
    Save the apt.conf file.

There is also a third method called BASH rc method. I didn't write down since I merely use it. You can see detail in references.

References
UbuntuCommunityAptGetHowto