If you set a global proxy in Gnome (I'm not sure about other desktop environments), you'll notice that the terminal ignores it. Here's how to set a proxy for the terminal:
For a HTTP proxy, simply run the following command in a terminal:
For a secure connection (HTTPS), use:
Obviously, replace everything with your username, password, proxy ip and port. If the proxy does not require an username and password, you can skip the "YOUR_USERNAME:YOUR_PASSWORD@" part.
Here is an example. If you've set up TOR and you want to use it for the terminal, to set a HTTP and HTTPS proxy for the current terminal session, run:
export http_proxy='http://localhost:8118' export https_proxy='http://localhost:8118'
Note that if you close the terminal (or terminal tab where you've ran these commands), the proxy will not work anymore. To make these changes permanent, add these commands to your ~/.bashrc file.
How to check if the terminal proxy is workingTo see if the proxy you've just set actually works, run the following command (firstly, make sure you have curl installed: sudo apt-get install curl):
Yes, a funny domain name but it does the job =)
The above command should return your new IP (if you don't know your initial IP, firstly run the curl command, then set the proxy and finally run the curl command again to see if the proxy works).
Reset the proxy
If you want to unset a proxy, you can simply close the terminal or alternatively, run the following commands:
unset http_proxy unset https_proxy
Update: Using a SOCKS proxy in the terminal
To be able to use a SOCKS proxy in the terminal, you can use tsocks. To install tsocks in Ubuntu, use the following command:
sudo apt-get install tsocks
Then, to get a command to use a SOCKS proxy, precede the command by tsocks, like this (example):
Tsocks can be configured by editing its configuration file: /etc/tsocks.conf
tsocks apt-get update
See also: how to get GIT working behind a firewall (use it if the GIT port is blocked by your ISP/network admin).