How to Connect to Linux Wi-Fi from the Terminal: A Step-by-Step Guide

Working with the Linux operating system often requires interaction with the command line, especially when the graphical interface is unavailable or overloaded. Connecting to a wireless network — is one of the basic tasks faced by every user, whether a system administrator configuring a server or a developer working on a minimalist distribution. The terminal provides direct access to network interfaces, allowing for troubleshooting and managing connections with precision.

There are several proven methods for establishing a connection to a router. Modern distributions, such as Ubuntu, Fedora or Debian, use different network managers by default, which affects the choice of tools. The most common are NetworkManager (via nmcli utility), classic wpa_supplicant and a new standard NetplanUnderstanding how these tools work will allow you to feel confident in any environment.

In this article, we'll explore the most effective ways to activate Wi-Fi. You'll learn how to scan the airwaves, enter security passwords, and check signal quality without using a mouse. The key is to know the name of your network interface., since systems may assign them different designations, for example, wlan0 or wlp2s0.

Preparing the system and finding an adapter

Before starting the setup, you must ensure that the wireless module is physically enabled and recognized by the system kernel. It often happens that the interface is in a "soft block" or "hard block" state. For initial diagnostics, use the command ip link, which will show a list of all network devices.

If you don't see your wireless device in the list, you may be missing the necessary drivers. In Linux-based distributions Debian And Ubuntu You can check for firmware using the command dmesg | grep firmwareThe absence of error messages usually indicates that the equipment is operating correctly. It's also worth checking the lock status using the utility. rfkill.

⚠️ Attention: If the team rfkill list If the module shows a "Hard Blocked" status, software methods won't help. You'll need to find a physical switch on the laptop case or use a key combination (usually Fn + F-key with the antenna) to enable the module.

For a more detailed analysis, you can use the command lspci (for internal cards) or lsusb (for USB adapters). This will help determine the exact chipset model. Knowing the model is necessary if the standard drivers mac80211 do not work correctly.

📊 What type of Wi-Fi connection do you have?
Built-in laptop module
USB whistle
PCI card in a PC
Virtual machine
Other

Using NetworkManager (nmcli) for quick configuration

The easiest and most modern way to connect to Linux Wi-Fi from the terminal is to use a console client. NetworkManager, known as nmcliThis tool is preinstalled in most desktop distributions and allows you to manage connections as flexibly as a graphical interface. First, check the manager's status with the command nmcli general status.

To find available networks, perform a scan. Note that some systems require you to explicitly enable scanning mode. You can get a list of available access points as follows:

nmcli device wifi list

Once you've seen the list of networks and found your network name (SSID), you can initiate a connection. You'll need the network name and password. The command will create a new connection profile and automatically attempt to activate it.

☑️ Check before connecting via nmcli

Completed: 0 / 4

The syntax of the connection command is as follows:

nmcli device wifi connect "Network_Name" password "Your_Password"

If the connection is successfully established, the system will save the settings to the configuration file. This means that the next time you boot up or return to the router's range, the connection will be established automatically. To check your current IP address, use the command ip addr show.

Manual configuration via wpa_supplicant

In server Linux builds such as Ubuntu Server or Arch Linux, graphical add-ons may be missing. This is where wpa_supplicant — a background process responsible for WPA negotiation and encryption key management. This method requires manual configuration file creation.

The first step is to generate a hashed key from your password. This increases security, as the password isn't stored in plaintext in the configuration file. Use the utility wpa_passphrase:

wpa_passphrase "SSID_network" "Password" > /etc/wpa_supplicant/wpa_supplicant.conf

The resulting file contains a block network with parameters ssid And pskAfter creating the configuration, you need to start the daemon itself, specifying the interface and path to the configuration file. The process may take a few seconds to complete the handshake with the router.

Parameter Description Example of meaning
ssid Wireless network name "Home_WiFi"
psk Password hash or plaintext password "a1b2c3d4..."
key_mgmt Key Management Protocol WPA-PSK
proto Security protocol RSN

To start the process, use the command: wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf. Flag -B Runs the process in the background. After this, you need to obtain an IP address, as wpa_supplicant only authenticates the device but does not assign addresses.

What to do if wpa_supplicant does not connect?

A common issue is a conflict with other network managers. If you have NetworkManager running, it may block direct access to wpa_supplicant. In this case, either stop NetworkManager or use only its tools. Also, check whether your router supports the WPA3 standard, which may require additional configuration parameters, such as key_mgmt=SAE.

Setting up a static IP via Netplan

Modern versions Ubuntu (starting from 10/17) use Netplan as the primary network configuration tool. It works with YAML files, making the configuration readable and easily verifiable. Configuration files are typically located in the directory /etc/netplan/ and have an extension .yaml.

To configure Wi-Fi, you need to edit an existing file or create a new one. It's important to maintain indentation: YAML is space-sensitive. The configuration requires specifying a renderer (usually networkd for servers or NetworkManager for desktops) and interface parameters.

Configuration example for obtaining an address automatically (DHCP):

network:

version: 2

wifis:

wlan0:

dhcp4: true

access-points:

"Network SSID":

password: "WiFi_Password"

If required static IP address, the file structure will change. You need to explicitly specify the addresses, gateway, and DNS servers. This is often required for servers that require a permanent address for remote access.

⚠️ Warning: YAML syntax requires indentation (usually 2 or 4 spaces). Tabs are not allowed and will cause a parsing error. Always validate the file with the command netplan try before use, to avoid losing access to the server.

Obtaining an IP address and checking the connection

After successfully associating with an access point (via wpa_supplicant or Netplan settings), the device needs to obtain an IP address. In most modern distributions, this is handled by a daemon. dhcpcd or the built-in NetworkManager client. If you configured the network manually, you may need to launch the DHCP client manually.

Team dhclient is a standard for requesting an address from a router. It sends a broadcast request and receives network parameters in response. After executing the command, check the address assignment via ip addr.

To check the connection quality and internet availability, use the utility pingIt sends ICMP packets to a specified host and measures the response time. It's a basic diagnostic tool.

  • 📡 ping 8.8.8.8 — checking the physical connection to the outside world (Google DNS).
  • 🌐 ping google.com — checking the operation of the DNS resolver.
  • 📶 iwconfig — display of signal quality (Signal level) and noise level.
  • 🔍 traceroute — building a route for packets to find bottlenecks.

Troubleshooting and Common Mistakes

Even if you enter the commands correctly, the connection may fail. This is often due to driver issues or incompatible security protocols. If you see an "association lost" error message or an infinite wait for an address, check the system logs. journalctl -u NetworkManager or dmesg | tail will show the latest kernel events.

One of the common problems is protocol conflict. IPv6If your ISP or router doesn't support IPv6 correctly, the system may take a long time to obtain an address via this protocol, delaying the connection. In such cases, it is recommended to temporarily disable IPv6 in the interface settings.

It's also worth paying attention to power saving mode. Some Wi-Fi adapter drivers aggressively disable the module to save power, which leads to connection drops. You can disable this using the command iwconfig wlan0 power off or by creating a corresponding configuration file in /etc/NetworkManager/conf.d/.

In conclusion, managing Wi-Fi via the terminal gives you complete control over your network stack. Regardless of whether you're using nmcli for convenience or wpa_supplicant For minimalists, understanding these processes is a fundamental skill for working with Linux.

How do I know which driver is used for my Wi-Fi adapter?

Use the command lspci -k (for PCI devices) or lsusb -v (for USB). In the output, look for the line "Kernel driver in use." If the driver is not listed, it is not loaded or missing. You can also look dmesg | grep wlan to search for kernel module loading messages.

Why doesn't the nmcli command see my Wi-Fi networks?

Possible reasons: 1. The Wi-Fi adapter is turned off (check nmcli radio wifi). 2. The NetworkManager service is not running. 3. You are too far from the router. 4. The network is hidden (not broadcasting its SSID) - in this case, you need to create a connection manually, specifying the network name.

Is it possible to connect to Wi-Fi without a password via a terminal?

Yes, if the network is open, simply omit the password parameter in the nmcli command or leave the psk field blank in wpa_supplicant. However, keep in mind that data transmission on open networks is not encrypted and can be intercepted.

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

When using nmcli The password is saved automatically in a secure keyring or in a text config file, depending on the distribution. When using wpa_supplicant the password (as a hash) is stored in a file /etc/wpa_supplicant/wpa_supplicant.conf.