Posted July 19Jul 19 π How to Install and Use a VPN on Linux Using Terminal (Step-by-Step Guide)If you prefer working from the command line or you're using a minimal Linux setup without a desktop environment, you can easily set up a VPN through the terminal. In this guide, weβll walk you through how to install and connect to a VPN using OpenVPNβone of the most trusted and widely used VPN protocols on Linux.π§° What You Need Before You StartTo use a VPN in Linux via the terminal, make sure you have:A Linux-based OS (like Ubuntu, Kali, Debian, Fedora, Arch, etc.)sudo privilegesA .ovpn file or OpenVPN configuration details from your VPN providerπ Step 1: Update Your SystemOpen your terminal and run:sudo apt update && sudo apt upgrade -yThis ensures your package manager is up to date (For Ubuntu/Debian-based distros)π¦ Step 2: Install OpenVPNFor Ubuntu/Debian:sudo apt install openvpn -yFor Fedora:sudo dnf install openvpn -yFor Arch Linux:sudo pacman -S openvpnπ Step 3: Get Your VPN Config FileMost VPN providers (like ProtonVPN, NordVPN, etc.) let you download a .ovpn file.Save this file to a folder, e.g., ~/vpn/:mkdir ~/vpnmv /path/to/your/file.ovpn ~/vpn/π Step 4: Connect to the VPNUse OpenVPN to connect:sudo openvpn --config ~/vpn/your-vpn-file.ovpnYou may be prompted to enter your VPN username and password depending on the provider.π Optional: Background Connection (Systemd Method)To run the VPN in the background using systemd:Copy your .ovpn file to /etc/openvpn/:sudo cp ~/vpn/your-vpn-file.ovpn /etc/openvpn/client.confStart the VPN:sudo systemctl start openvpn@clientEnable it on boot:sudo systemctl enable openvpn@clientTo disconnect:sudo systemctl stop openvpn@clientπ Check VPN StatusCheck if your VPN is running:curl ifconfig.meIt should return a different IP from your normal one.π§ Extra TipIf your VPN requires DNS configuration, you can use:sudo apt install resolvconfsudo systemctl enable resolvconfsudo systemctl start resolvconfThen configure your DNS servers in /etc/resolv.conf.
Create an account or sign in to comment