How to Set up a VPN on Linux in 2021 – Maximize Your Privacy on Any Flavor of Linux!

In comparison to other operating systems, Linux appears to be a more privacy-friendly option. However, you still need a VPN to prevent digital tracking and safeguard your privacy. That's why we'll show you the easiest ways to set up a VPN on Linux in 2021.

There are many ways to install a VPN on Linux, but it all comes down to three methods. You can use a Linux VPN app supplied by your VPN service, use Terminal to set up an OpenVPN connection, or use Ubuntu’s Network Manager.

We strongly believe that staying away from general descriptions is crucial when writing installation guides like this one. That’s why we’ll focus on a recommendation based on our hands-on experience, and that would be none other than ExpressVPN. This truly is the best VPN available right now, and this applies to Linux users as well.

Of course, this isn’t where your options end, as our list of the best VPNs for Linux proves. However, keep in mind that VPNs come with different installation methods, so it’s always best to turn to your VPN for installation instructions if you pick something other than ExpressVPN.

Your VPN subscription allows you to maintain several simultaneous connections. So, we offer you our VPN installation guides for other platforms as well, as you can see below.

Step-by-Step Instructions - 3 Easy Methods to Set up a VPN on Linux in 2021

We present to you the 3 different methods to install a VPN on Linux in 2021:

Method #1: Use a Native Linux VPN Application

For this method, you need a VPN that provides a Linux application. Our recommendation is to use ExpressVPN, as it comes with applications for Ubuntu, Fedora, Arch, and other Linux distributions (for both 32- and 64-bit).

So, here’s how to set up a Linux VPN by using native software.

  • First and foremost, make sure to have a valid VPN subscription. If you haven't done so already, proceed to subscribe to ExpressVPN using the provided link.
  • Once you sign-up for a new account, you’ll get to access your account on ExpressVPN’s website. Open its home page, click on "My Account," and supply your credentials. Then, click on the "Set Up Other Devices" button. Then, choose "Linux" on the left side and pick your Linux distribution on the right. Download the corresponding file to your computer. Make sure to keep this page open, as we’ll need the information found here soon enough.
ExpressVPN Manual Configuration Setup Information
  • Now, you need to use the Command Line (Terminal) interface. You first need to open the package you’ve just downloaded. By default, the file will be in your Downloads folder (accessible via the "cd Downloads/" command). Now, open the file using the "sudo dpkg -i [installer filename]" command (for Ubuntu, Mint, and Debian distributions). You can use the "sudo yum install [installer filename]" for Fedora and related distributions.
Download ExpressVPN Ubuntu Linux Procedure
Image Courtesy of ExpressVPN.
  • Then, open a new Terminal window and run the "expressvpn activate" command to activate the VPN application. You’ll be asked for an activation code, so go back to ExpressVPN’s website (the page you left open in the background) and paste the activation code found there. You’ll also be asked to send anonymous data like crash reports.

That’s it! You’re now free to use ExpressVPN’s command line-based app. To connect to the nearest server based on your location (or the previously used server), use the "expressvpn connect" command. To disconnect, go with "expressvpn disconnect."

Connecting to Individual Server ExpressVPN Linux
Image Courtesy of ExpressVPN.

As you can imagine, you can also connect to other ExpressVPN servers. For this purpose, you can check out the available servers using the "expressvpn list" or "expressvpn list all" commands.

If you’d like to connect to a particular server, enter the "expressvpn connect [LOCATION CODE]" as in "expressvpn connect nyc." You can also connect to a specific country, for which you can use the following command: "expressvpn connect Germany."

ExpressVPN Access Codes Linux
Image Courtesy of ExpressVPN.

Finally, we also recommend using the "man expressvpn" command if you’d like to reveal all of ExpressVPN’s commands. This is where you’ll learn how to check the status of your VPN connection, switch to a different VPN protocol, and more.

Method #2: Set up a Linux VPN via Terminal (OpenVPN)

This method requires you to use a VPN that supports the OpenVPN protocol. Once again, we recommend using ExpressVPN for this purpose. Feel free to use the provided link to subscribe to ExpressVPN, and then check out the steps found below.

Here’s how to install and activate OpenVPN on your Linux computer, and then connect to any VPN server.

  • First, you need to obtain your OpenVPN configuration files. This means you need to access your user account dashboard on ExpressVPN’s website (once you subscribe to the VPN, that is). Then, click on "Set Up Other Devices" and pick "Manual Configuration."
ExpressVPN OVPN Files Selection
  • Check if OpenVPN is selected on the right-hand side. Now, this is where you’ll find your OpenVPN username and password, so make sure to keep this page open until the end of this process. Take a look below as well, which is where you’ll find individual OpenVPN files for ExpressVPN's servers. Feel free to download any file based on the server you’d like to connect to later on.
  • Now, we need to install OpenVPN. Use the "sudo apt-get install -y openvpn" command. Then, enter the configuration screen by using the "sudo openvpn --p /etc/openvpn/update-resolv-conf --down /etc/openvpn/update-resolv-conf --script-security 2 --config" command. This is for Ubuntu Linux, while other distributions can use the "sudo openvpn --config" command.
OpenVPN Linux Installation
Image Courtesy of ExpressVPN.
  • Finally, you need to drag and drop the recently downloaded OVPN file onto the Terminal window. The path will be automatically captured.

To connect to a server, you need to press "Enter" once the path (described above) is loaded. You’ll see a string of commands, and the final one should say "Initialization Sequence Completed," which means your VPN connection is live now.

To disconnect, simply exit the Terminal window. Keep in mind that the Terminal window must be open as long as you wish to use your VPN. You’re free to minimize the window, but don’t close it.

Method #3: Configure a Linux VPN via Ubuntu Network Manager

Ubuntu’s Network Manager is a handy utility for controlling your Web connectivity. As such, it supports installing and managing VPN connections. However, keep in mind that you need an OpenVPN-powered VPN for this purpose, and we highly recommend ExpressVPN.

Here’s how to set up a VPN on Linux via Network Manager.

  • We’ll assume that by now, you have your ExpressVPN credentials. So, go ahead and download the required VPN configuration files. This is done by logging into your account on ExpressVPN’s website and then clicking on "Set Up Other Devices." A new page should open, where you need to select "Manual Configuration" and then take a look at the right side of the page.
  • At the top, you should see your OpenVPN username and password, so make sure to keep this page open until we’re done with this process. Then, take a look below, and you’ll see a list of servers offered by ExpressVPN. Pick any server that you’d like to use and click on its name. This will download an OVPN file to your computer.
  • Also, make sure to scroll down until you see the "Optional" card, from where you can download a ZIP file. Make sure to download this file, as we’ll need these certificates and keys.
  • Once you unzip the file you’ve downloaded, launch a new Terminal session. Now, run the "sudo apt-get install -y network-manager-gnome" command. Once you install the Network Manager, you’ll see its icon on your desktop bar notification area. Click on this icon and select "Edit Connections."
Linux Gnome VPN Command
Image Courtesy of ExpressVPN.
  • A new window will appear. You need to click on the "Add" button and then select "Import a saved VPN configuration." Finally, click on the "Create" button, and you’ll get to pick the OVPN file you’ve previously downloaded. Then, you’ll need to manually import the User Certificate (client.crt), CA Certificate (ca2.crt), and Private Key (client.key) files from the previously unzipped file.
OpenVPN Preferences Linux
Image Courtesy of ExpressVPN.
  • Using this same window, make sure to set "Authentication Type" to "Password with Certificate (TLS)" and then input your OpenVPN username and password (from ExpressVPN’s website).
  • Click on "Advanced" and select the "General" tab. Enter "1195" in the field that says "Use custom gateway port." Also, make sure to check the following fields: Use LZO data compression; Use customer tunnel maximum transmission unit (1500); Use custom UDP fragment size (1300); Restrict tunnel TCP maximum segment size; Randomize remote hosts.
  • Using the "Security" tab, select "AES-256-CBC" for the cipher, and "SHA-525" for the HMAC authentication. Then, click on the "TLS Authentication" tab.
TLS Authentication Linux Network Manager
Image Courtesy of ExpressVPN.
  • Using this tab, check the box next to "Use additional TLS authentication" and then select the "ta.key" file from the ZIP archive you’ve previously downloaded. Set "1" for "Key Direction."

That’s it! You are now free to connect to your VPN server by clicking on the Network Manager icon. Go to "VPN Connections," and your newly added server should be waiting. Also, keep in mind that you can repeat the procedure explained above to add additional servers.

Finally, we've reached the end of our guide on how to set up a VPN on Linux. As you can see, Linux users have several installation methods to pick, depending on the level of complexity you seek. If you encounter any problem along the way, feel free to post a comment below – and we’ll do our best to assist you in a timely manner.



How to Watch MasterChef Season 12: Back to Win Online From Anywhere

MasterChef is returning for its twelfth season, which will be an all-star season where contestants will be returning for a second chance...

How to Watch The Great American Tag Sale With Martha Stewart Online From Anywhere

Are you ready to see the fabulous Martha Stewart in a great American tag sale? This new show will premiere soon, and...

How to Watch Expedition Unknown Season 10 Online From Anywhere

Discovery's 'Adventure Wednesday' lineup is back this summer, and viewers will be treated to all-new episodes of the reality television series Expedition...
For a better user experience we recommend using a more modern browser. We support the latest version of the following browsers: For a better user experience we recommend using the latest version of the following browsers: Chrome, Edge, Firefox, Safari