Home Download Pricing Affiliate Blog Help

How to Use a VPN on Linux: Command-Line Setup Guide and Client Recommendations

2026-09-24 · shanlian

How to Use a VPN on Linux: Command-Line Setup Guide and Client Recommendations

Linux users share a common habit—if you can type a command, you don't touch the mouse. But when it comes to VPNs, most tutorials start with "download such-and-such GUI client," which makes you shake your head. Setting up a VPN on Linux isn't that mysterious—the command line is actually cleaner and more controllable. Today let's talk about how to master VPNs on Linux, and also touch on how lightxtreme VPN performs in this area.

What VPN protocols are available on Linux?

Let's start with protocols. Linux isn't like Windows where you just install an exe and you're done—you need to check what the kernel supports. Currently there are three main options:

  • OpenVPN: The veteran player with the best compatibility. Almost all VPN providers support it. Config files are in .ovpn format and run very reliably from the command line.
  • WireGuard: The newcomer, already merged into the Linux kernel (version 5.6 and later). Fast, simple to configure—the config file is just a few dozen lines. Great for people who like to tinker.
  • IKEv2/IPsec: Common on mobile devices, but a bit more troublesome to configure on Linux, so fewer people use it.

If you're running Ubuntu 20.04 or later, the WireGuard module is already built into the kernel. That means you don't need to install any extra drivers—just write a config file and you're good to go. That's a lot less hassle than Windows.

Command-line OpenVPN setup: step by step

Let's assume you've already got a .ovpn config file from your VPN provider. Taking Ubuntu/Debian as an example, open a terminal:

  1. Install the OpenVPN client: sudo apt install openvpn
  2. Put the config file in /etc/openvpn/, for example client.ovpn
  3. Connect: sudo openvpn --config /etc/openvpn/client.ovpn
  4. To run it in the background, add the --daemon flag

Once connected, the terminal will output a bunch of logs. When you see Initialization Sequence Completed, that means it's working. To disconnect, just killall openvpn—simple and direct.

One thing to note: many .ovpn files contain certificates and keys, so remember to set permissions to 600 to prevent other users from reading them.

WireGuard is lighter and faster, with straightforward configuration

A WireGuard config file looks like this:

[Interface]
PrivateKey = your_private_key
Address = 10.0.0.2/32
DNS = 1.1.1.1

[Peer]
PublicKey = server_public_key
Endpoint = server_ip:51820
AllowedIPs = 0.0.0.0/0

Save it as /etc/wireguard/wg0.conf, then run sudo wg-quick up wg0 and you're done. To disconnect, use sudo wg-quick down wg0. The whole process takes less than ten seconds—much snappier than OpenVPN.

The downside of WireGuard is that it produces fewer logs, making troubleshooting harder when something goes wrong. But for everyday use it's genuinely fast—especially when streaming video or transferring files, the latency is noticeably lower.

lightxtreme VPN experience on Linux

lightxtreme VPN offers a command-line tool for Linux, supporting Ubuntu, Debian, CentOS, and other mainstream distributions. Installation is simple—there's a one-click script on the official website, or you can manually download the deb/rpm package.

Once installed, use shanlian connect to connect, shanlian status to check status, and shanlian disconnect to disconnect. If you don't want to memorize commands, it also supports config file import—just drag in the config provided by the server.

According to publicly available third-party speed test data (source: VPNMentor 2023 report), WireGuard protocol on Linux delivers average download speeds about 30%-40% higher than OpenVPN. lightxtreme VPN supports both protocols, so you can switch based on your network environment.

A few common pitfalls and how to fix them

Pitfall one: DNS leaks. After connecting to the VPN, use curl ifconfig.me to check whether your exit IP has changed. If it hasn't, your routing isn't going through the VPN. Check whether AllowedIPs is set to 0.0.0.0/0.

Pitfall two: kill switch. Linux doesn't have a system-level kill switch, but you can write iptables rules to automatically block all traffic when the VPN drops. There are ready-made scripts online—just search for "wireguard kill switch iptables."

Pitfall three: DNS conflicts between systemd-resolved and the VPN. This happens often on Ubuntu. The fix is to edit /etc/systemd/resolved.conf, change DNSStubListener to no, then restart the service.

So which one should you choose?

If you want stability and compatibility, OpenVPN won't let you down. If you want speed and simplicity, WireGuard is the better choice. lightxtreme VPN supports both, and its Linux client simplifies the configuration process considerably—great for people who don't want to tinker.

If you'd like to give it a try, head over to the lightxtreme VPN website to check out the Linux installation guide. The command line is one of those things—once you get comfortable with it, you'll never want to go back to clicking a mouse.

享受无限、高速和安全的浏览!立即保护您的隐私!

Get lightxtreme VPN
✓ 30-Day Money-Back