How to Connect Wi-Fi via the Linux Terminal: An Expert's Guide

Managing network connections in Linux through a graphical interface often seems convenient, but true control over the system is only available when working from the command line. Terminal It allows you to diagnose problems that aren't visible in the GUI and connect to Wi-Fi on servers without a graphical shell. This is the skill that distinguishes a regular user from a system administrator.

In modern distributions such as Ubuntu, Debian or Fedora, the setup process may differ depending on the network manager you use. Most often, you'll encounter NetworkManager, Netplan or systemd-networkdUnderstanding how these tools work will give you confidence in any situation.

Even if the graphical interface freezes or won't load, knowing the commands for connecting to a wireless network will allow you to restore internet access and fix the configuration. We'll look at the most effective and up-to-date methods that will work reliably in 2026.

Preparing the environment and checking equipment

Before attempting a connection, you need to ensure that your wireless adapter is physically enabled and recognized by the operating system. Users often forget that some laptops have a hardware switch or function key that disables the radio module. Checking the interface status is the first step in any diagnostic.

To begin, run the command ip link or iw devto see a list of network interfaces. Wireless interfaces typically have names starting with wlan, wlp or wiIf you see the status NO-CARRIER or there is no interface, perhaps the driver is not installed or the device is blocked rfkill.

Use the utility rfkill list to check for blockages. If the wireless network is blocked by software, unblock it with the command sudo rfkill unblock wifiThis is a critical step that is often overlooked when trying to configure connection settings on a device that is already disconnected.

  • 📡 Team lspci | grep -i network will show the model of your Wi-Fi adapter, which is useful for searching for drivers.
  • 🔓 Make sure the status is in the output rfkill displayed as no for Soft and Hard blocks.
  • ⚙️ The interface must be in the state UP, which is checked through ip link show.

⚠️ Important: If you are using a virtual machine, make sure that USB device forwarding or wireless adapter emulation is enabled in the hypervisor settings, as standard NAT often works via Ethernet bridging.

Using NetworkManager (nmcli) to connect

The most common network management tool in desktop distributions is NetworkManagerIts console utility nmcli provides a powerful and relatively intuitive interface for working with Wi-Fi. It allows you to scan networks, save profiles, and manage connections without having to manually edit text-based configuration files.

First, scan for available networks around you by running the command nmcli dev wifi listYou'll see a list of available access points with their SSID, signal strength, and security. Find your network's name in the list to confirm its availability and signal strength.

To connect, use a command that combines the device, SSID, and password. The syntax is as follows:

sudo nmcli dev wifi connect "Network_Name" password "Your_Password"

Once successfully completed, the system will create a connection profile and automatically attempt to obtain an IP address via DHCPIf the connection is successful, you'll see the message "Connection successfully activated." This method is preferred by most users, as it's integrated into the system and preserves settings after a reboot.

  • 🔍 Scan: nmcli dev wifi rescan will update the list of networks if the one you need is not in the cache.
  • 💾 Saving: Profiles are saved in /etc/NetworkManager/system-connections/.
  • 🔄 Reconnect: Use the flag --now to immediately apply changes to your profile.

⚠️ Note: In some enterprise environments or older versions of NetworkManager, you may need to specify the device name (e.g. ifname wlan0), if there are several wireless adapters in the system.

📊 Which connection method do you use most often in Linux?
GUI (GNOME/KDE):nmcli (NetworkManager):wpa_supplicant Manual:Other

Setting up Wi-Fi via wpa_supplicant

In server environments or minimalist builds where NetworkManager is absent, the main instrument remains wpa_supplicantThis is a daemon that manages wireless connections and ensures security by handling the WPA/WPA2 authentication process. Working with it requires a deeper understanding of the process, but provides complete control.

First you need to create a configuration file, usually this is /etc/wpa_supplicant/wpa_supplicant.conf. It specifies the network parameters. To generate a hashed password (to avoid storing it in plaintext), use the utility wpa_passphrase.

Example of creating a config:

wpa_passphrase "MySSID" "MyPassword" | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf

After creating the configuration, you need to start the daemon itself, specifying the interface and path to the configuration file. The command looks like this: sudo wpa_supplicant -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf -B. Flag -B sends the process to the background. Then you need to obtain an IP address by running a DHCP client, for example, dhclient.

  • 🛡️ Security: Password hashing via wpa_passphrase hides the real key in the configuration file.
  • ⚙️ Flags: Parameter -i specifies the interface, and -c — path to the config.
  • 🌐 DHCP: No startup dhclient or dhcpcd After connecting, you will not receive an IP address.

This method is fundamental to understanding how wireless communication works in Linux. Many graphical shells and scripts are simply add-ons to the functionality. wpa_supplicant.

A modern approach with iwctl (iwd)

Project iwd (iNet Wireless Daemon) from Intel developers is positioned as a modern and lightweight replacement wpa_supplicantIt's faster, easier to use, and has a great interactive mode. In distributions like Arch Linux or new versions Ubuntu it becomes the de facto standard.

Launch the interactive client with the command iwctlYou will be taken to a shell with a prompt. [iwd]#This is where the commands become more human-oriented. First, list the devices with the command device list, then enable scanning for a specific device: station wlan0 scan.

After scanning, get a list of networks via station wlan0 get-networksTo connect, simply enter station wlan0 connect "SSID"The system will automatically request a password (Passphrase) in interactive mode, which is convenient and secure. The key difference with iwd is that there is no need to manually configure dhclient, as it is often integrated or started automatically via systemd.

  • 🚀 Speed: iwd scans and connects noticeably faster than legacy solutions.
  • 📱 Interactivity: Built-in CLI mode is convenient for quick manual configuration.
  • 🔒 WPA3: Best support for the latest security standards out of the box.

Comparison of network management tools

The choice of tool depends on your goals: whether you need a server without unnecessary dependencies or a user-friendly workstation. Understanding the differences will help you choose the right path for your Linux configuration.

Tool Main purpose Complexity Resource intensity
nmcli Desktops, full control Average High
wpa_supplicant Servers, basic connection High Low
iwctl (iwd) Modern systems, minimalism Low Very low
Netplan Configuration (Ubuntu Server) Average Low

As you can see from the table, for a typical user running Ubuntu or Fedora, nmcli remains the gold standard due to its predictability. However, for enthusiasts and administrators who value minimalism, the transition to iwd may be a pleasant discovery.

Please remember that Ubuntu Server often uses Netplan as a frontend for backends (NetworkManager or systemd-networkd). In this case, you edit YAML files in /etc/netplan/ and apply the changes with the command sudo netplan applyThis adds another level of abstraction, but standardizes the configuration.

Troubleshooting and Common Mistakes

Even if you enter the commands correctly, the connection may fail. Driver errors or IP address conflicts are common causes. First, check the system logs. dmesg | grep firmware or journalctl -u NetworkManager will help identify problems with loading kernel modules.

If you see an infinite wait for an IP address, the DHCP server may not be responding or is blocking the device by MAC address. Try assigning a static IP to test the connection: sudo ip addr add 192.168.1.50/24 dev wlan0. Also check if your firewall is blocking (ufw or iptables) DHCP requests.

Pay special attention to regional settings. Some adapters require a country code to unlock certain channels or signal strength. This is done using the command sudo iw reg set RU (or your country code). Without this, the router may simply not be visible.

⚠️ Please note: Interfaces and available Wi-Fi channels are regulated by the laws of each country. Incorrectly setting the region (for example, using power levels prohibited in your region) may result in fines or interference with critical infrastructure.

Frequently Asked Questions (FAQ)

How do I save my Wi-Fi password so I don't have to enter it every time?

When using nmcli The profile is saved automatically upon the first successful connection. For wpa_supplicant Make sure the configuration is written to a file and the daemon itself is started as a systemd service. iwd passwords are saved in /var/lib/iwd/.

Why does the nmcli command say "Secrets were required, but not provided"?

This means the network is password protected and you didn't pass one in the command. Add an argument password "your_password" to the end of the connection string or use an interactive prompt without specifying the password explicitly in the command history.

Is it possible to connect to Wi-Fi without root rights?

Usually no, since managing network interfaces requires privileges. However, if your user is added to the group netdev or configured via PolicyKit (pkexec), some operations may be available. The standard way is to use sudo.

How to connect to a hidden network (Hidden SSID)?

IN nmcli use the flag hidden yesThe command will look like this: nmcli con add type wifi ifname wlan0 con-name "MyHidden" ssid "SecretNet" wifi-sec.key-mgmt wpa-psk wifi-sec.psk "password" hidden yesThe scanner will not show the network name, so you need to enter it manually.