How to pop on Ubuntu! Install and use Tor (client) as an agent in OS or Linux Mint

Thor (Onion Router) Guide Internet communication through voluntary overlay network, the purpose is to protect users’ privacy and freedom. This article explains how to install the latest Tor client in Ubuntu 20.04, 19.10, 18.04 or 16.04 / Linux Mint 19.x. And 18.x, and use it as a proxy for various applications.

The following instructions include the setting steps Polyoxyethylene, If you want to use Tor in an application that does not support SOCKS5 proxy, please set the proxy manually if Torsock fails to start the application and configure Tor to use country-specific exit nodes (so you can specify your Which country / region should the IP come from), it is useful if you want to bypass the country / region inspection / censorship system and cannot afford a VPN (but if you can, please select the VPN option!).
This version is for Ubuntu 16.04 / Linux Mint 18.x, Ubuntu 18.04, 19.10 and 20.04 / Linux Mint 19 (and 19.x) and higher, and Ubuntu-based Linux distributions such as Pop! _OS, basic OS, and Ubuntu or Linux Mint flavors, such as Linux Mint MATE or Kubuntu, Xubuntu, Ubuntu MATE, etc.
Ubuntu versions earlier than 16.04 / Linux Mint earlier than 18.x do not use systemd, so some of the content in this article does not apply to such old versions.
Tor does not prevent the online service from determining that you are using Tor, so remember this! It should be used for privacy rather than anonymity. If you only need to use Tor’s web browser, please use the Tor browser based on Firefox ESR, it is very easy to use and contains everything you need. This article is for using the Tor client with other applications. Don’t confuse Tor (client) with Tor browser, they are two different things (in terms of their role)!

On Ubuntu / Pop! _Install Tor and optional Privoxy in OS or Linux Mint

I. On Ubuntu / Pop! Install Tor in OS or Linux Mint
Tor packages in Ubuntu repositories are usually not updated frequently, so it is recommended that you use the official Tor repository.
From installation apt-transport-httpsTo download the repository key using https repository and curl:

sudo apt install apt-transport-https curl

Then use the following command on Ubuntu / Pop! Add the Tor repository (and its key) to _OS:

sudo -i

echo "deb $(lsb_release -cs) main" > /etc/apt/sources.list.d/tor.list

curl | gpg --import

gpg --export A3C4F0F979CAA22CDBA8F512EE8CBC9E886DDD89 | apt-key add -

apt update


For Linux Mint, please use the same command as above, but please replace it with $(lsb_release -cs) In the first command to use the Ubuntu version code, your Linux Mint version is based on that version. For Linux Mint 19 (and 19.x), use bionic, And for Linux Mint 18.x xenial.
Now you can install Tor, tor-geoipdb (In order to be able to use exit nodes for specific countries), torsocks (An easy to modify application library) and (Make sure you have the latest repository signing key package):

sudo apt install tor tor-geoipdb torsocks

two. (Optional) Install Privoxy and configure it for use with Tor
Privoxy is a non-cached web proxy. If you plan to use Tor with applications that only support HTTP proxies (not SOCKS5 proxies), you can use it with Tor.
Go on Ubuntu / Pop! _ To install Privoxy in OS or Linux Mint, please use:

sudo apt install privoxy

To use Privoxy with Tor, you need to edit it /etc/privoxy/config Configuration file with text editor, for example Nano (as root):

sudo nano /etc/privoxy/config

In this configuration file, paste the following lines to the end of the file (you can use the Nano command line text editor by pressing to the end of the file Ctrl + W Followed by Ctrl + VWithout changing anything else:

forward-socks5 / localhost:9050 .

There is a space at the end of the line, then a dot, this is not a typo.
Then save the file and exit (To save the file using the Nano command line text editor, press Ctrl + O, Then Enter; Quit use Ctrl + X).
Now, you need to restart Privoxy:

sudo systemctl restart privoxy

On Ubuntu / Pop! _Using Tor and Privoxy in OS or Linux Mint

I. Use Tor through the torso
To easily start the application and make it use Tor, you can use torsocks, Can be used with GUI and command line programs. This library ensures secure handling of DNS requests and explicitly rejects any traffic other than TCP from the applications used.
For example, to start Spotify using the torso, use:

torsocks spotify

To test it, run the following command to obtain your real IP address:


(in case curl Not installed, you can use the following methods to install: sudo apt install curl)
Then run the same command, but use tosocks:

torsocks curl

The torsocks command should return a different IP because it is run through the Tor proxy.
If an error occurs, the Tor service may not be running. It should start automatically during installation, but if it is not installed, you can start it with the following command:

sudo systemctl start tor

However, there is a problem with the torso-unable to start some applications. For example, running torsocks firefox Or torsocks google-chrome Did nothing. In this case, you need to manually enter the Tor SOCKS5 proxy in the application you want to use-see below. Enter proxy address manually
Once Tor and Privoxy are installed, the following proxy information can be used in the application network / proxy settings (you only need to set one of the two):

  • SOCKS5 proxy: use localhost As a proxy host / IP, and 9050 As a port
  • HTTP proxy (Privoxy needs to be installed and configured according to instructions): Use localhost As a proxy address, 8118 As a port

Use SOCKS5 proxy as much as possible, or, if the application does not support it, use a regular HTTP proxy.
You can also use Tor as a system-wide agent. For example in Gnome System Settings > Network, Click Network Proxy, Set the proxy to ManualAnd then use localhost As a sock host 9050 As a port:</code></span>“Border =” 0 “data-original-height =” 784 “data-original-width =” 1085 “height =” 462 “src =” /aKaP7PYWmEID7htoecBqPR2wNnTXrPuZQCLcBGAs/s640/gnome-network-proxy-settings-tor.png “title =” Gnome proxy settings Tor “width =” 640 “</a><br /> Please note that Chromium-based web browsers (Google Chrome, Opera, Vivaldi, etc.) do not allow proxy settings in their settings, but should use system-wide proxies. How to change the IP address given by Tor<br /> If you need to change the IP address provided by Tor, the easiest way is to reload the Tor service as follows:</p><pre class=sudo systemctl reload tor

This command will reload the Tor configuration and let Tor set up a new circuit to provide you with a new IP address.
Use the following command to check the IP address torsocks curl Command IV. How to configure Tor to use country-specific exit nodes (choose which country / region the new IP should come from)
To be able to specify country-specific exit nodes in Tor, tor-geoipdb The software package needs to be installed. The package is already mentioned in the instructions above, so it should already be installed, but if you have installed Tor and skipped the installation instructions in this article, I think I will mention it.
To use Tor to change the IP to a specific country / region, you need to edit Tor /etc/tor/torrc Configuration file as root:

sudo nano /etc/tor/torrc

Add the following two lines to the file without making any other changes:

StrictNodes 1

Replace COUNTRY_CODE ISO3166 country code with 2 letters, for example us In the U.S, de Germany, etc. You can find a list of country codes Here. You can also separate multiple countries with commas as follows: {country1},{country2},{country3}, E.g {be},{pl},{ca}. You need to specify the country between the braces: {}.
When finished, save the file and exit (To save the file using the Nano command line text editor, press Ctrl + O, Then Enter; Quit use Ctrl + X), And then reload the Tor configuration using the following command:

sudo systemctl reload tor