How to Connect WiFi in Linux via the Console: A Complete Guide

Working with Linux-based operating systems often requires interaction with the command line, especially when the graphical interface is unavailable or unstable. Connecting to WiFi Using a terminal may seem like a daunting task for a beginner, but it actually gives the administrator complete control over network settings and allows for low-level problem diagnosis. Unlike graphical utilities, console tools are faster and consume fewer system resources.

There are several basic ways to set up a wireless connection, depending on the distribution and network manager used. The most common tools are nmcli (NetworkManager), wpa_supplicant And iwd (Intel Wireless Daemon). Understanding the operating principles of each will allow you to feel confident in any environment, whether it's a bare-metal server or a desktop system with a minimal set of packages.

In this guide, we'll cover various connection methods in detail, focusing on command syntax and common configuration errors. You'll learn how to scan available networks, store encrypted passwords, and configure automatic connection at system boot. To work with most modern distributions, it is enough to know the basic set of nmcli commands, as it is the de facto standard.

Diagnostics and search for wireless interfaces

Before attempting to connect to the network, you must ensure that your wireless adapter is correctly detected by the system and the drivers are installed. The first step is always to check the interface status. Enter the command ip link or ifconfig -ato see a list of all network devices. Look for devices with names starting with wlan, wlp or wifi.

If the interface is displayed as DOWN, it needs to be activated. It often happens that the wireless module is blocked by software or hardware. To check for blockages, use the utility rfkill. Run the command rfkill listto see the status of all radio modules. If you see the status "Soft blocked: yes," you'll need to unlock it via the terminal.

⚠️ Note: If an interface is completely missing from the device list, this may indicate missing drivers or a physical fault with the adapter. In server environments, installing packages is often required. firmware-linux or specific firmware for Broadcom/Realtek.

To enable the interface, use the command ip link set wlan0 up (replace wlan0 with the name of your device). After that, repeat the check through ip link. Make sure the status has changed to UP And LOWER_UP, which indicates that the cable or radio module is physically ready for operation.

📊 Which Linux distribution do you use most often?
Ubuntu/Debian
CentOS/RHEL
Arch Linux
Gentoo/Other

Using NetworkManager (nmcli) to connect

Most modern distributions, such as Ubuntu, Fedora, and CentOS, have it installed by default. NetworkManagerThis is a powerful tool that allows you to manage connections via the command line using the utility nmcliThis method is preferred because it saves settings in configuration files and ensures automatic reconnection.

The first thing you need to do is scan for available networks within range. Command nmcli dev wifi list will display a list of available access points, indicating their SSID, operating mode, channel, and signal strength. If the list is empty, try refreshing it by scanning again in a few seconds or checking to see if the adapter is blocked.

nmcli dev wifi connect "Network_Name" password "Your_Password"

This command will attempt to create a new connection and immediately activate it. If the connection is successful, NetworkManager will save the connection profile. To reconnect in the future, simply enable the adapter, and the system will automatically select a known network. To manage profiles, use the command nmcli connection.

☑️ Check before connecting via nmcli

Completed: 0 / 4

It is important to note that nmcli Allows you to create various types of connections, including static IP and VPN. If you don't need to obtain an address automatically via DHCP, you can manually configure the settings after creating the connection. This is especially useful in corporate networks with strict security policies.

Setting up a connection via wpa_supplicant

For lighter systems or in cases where NetworkManager is not installed, a bundle is used wpa_supplicant And dhcpcd (or dhclient). This method requires manual editing of configuration files and provides a deep understanding of the WPA2 authentication process. It is often used on servers and embedded systems.

The main configuration file is usually located at /etc/wpa_supplicant/wpa_supplicant.confIt is recommended to create a backup copy before editing. A block must be added to this file. network with your network parameters. To generate a hashed password (to avoid storing it in plaintext), use the utility wpa_passphrase.

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

After adding the configuration, you need to start the daemon wpa_supplicant, specifying the interface and configuration file. At the same time, the DHCP client is launched to obtain an IP address. The process may appear as a sequence of commands running in the background.

Command/File Purpose Typical path
wpa_supplicant Authentication daemon /sbin/wpa_supplicant
wpa_supplicant.conf Network configuration /etc/wpa_supplicant/
dhcpcd DHCP client /sbin/dhcpcd
wpa_cli Interactive client /usr/bin/wpa_cli

To automate the process in systemd-based distributions, you can create a service or use wpa_actionHowever, for a one-time connection, it is enough to start the processes manually. Make sure you are using the correct driver interface, usually -i wlan0 -D wext or -D nl80211.

What to do if wpa_supplicant doesn't see the network?

If the network is hidden (Hidden SSID), add the scan_ssid=1 parameter to the network block of the configuration file. Also, check whether your adapter supports monitor mode, although this is rarely required for a regular connection.

A modern approach with iwctl (iwd)

Project iwd (Intel Wireless Daemon) is positioned as a modern replacement wpa_supplicantIt's lighter, faster, and has a simpler API. Distributions that use systemd-networkd often install it by default. iwdManagement is carried out through a utility. iwctl, which has an interactive mode and a command line mode.

Launch iwctl to enter the interactive shell. Inside, commands become simpler and more understandable. First, list the devices with the command device list, then turn on scanning through station wlan0 scanAfter receiving the list of networks with the command station wlan0 get-networks you can initiate a connection.

Connection syntax in iwd extremely laconic: station wlan0 connect"SSID"The system will prompt for a password if required, or it will use the saved data. After successful authentication, remember to exit the shell and launch the DHCP client, for example, dhcpcd wlan0, if it is not configured automatically via systemd.

⚠️ Note: Interfaces and commands may vary slightly between different iwd versions. If you're using a stable version of the distribution, please consult the manual. man iwctl for your version, since the syntax evolves faster than that of classic tools.

Advantage iwd The advantage lies in better support for modern WiFi standards and lower memory consumption. However, in corporate environments with full authentication (802.1x, EAP-TLS) wpa_supplicant remains a more flexible tool with a huge number of configuration options.

Troubleshooting and diagnostics

Even if you enter the commands correctly, connection errors may occur. A common problem is an IP address conflict or incorrect DNS settings. If you've received an IP address but the internet isn't working, try pinging an external resource, such as ping 8.8.8.8If the ping works, the problem is in the DNS.

To fix DNS, enter the servers manually in the file /etc/resolv.conf or configure them through your network manager. It's also worth checking the routing with the command ip routeMake sure the default gateway (default via) is specified correctly and points to your router.

In cases where the connection is constantly broken, system logs are useful. The command journalctl -u NetworkManager or dmesg | grep wifi This will help identify the causes of interruptions. These could be driver issues, a weak signal, or interference on the channel.

Automation and saving of settings

To avoid entering commands every time you boot, you need to configure services to start automatically. On systems with systemd, this is done via systemctl enable NetworkManager or systemctl enable wpa_supplicant@wlan0Make sure the service is marked as "enabled" and "active".

For wpa_supplicant It is also important to configure the configuration file correctly by adding the parameter ctrl_interface, so that external utilities can interact with the daemon. Storing cleartext passwords in config files is a security risk, so always use hashing via wpa_passphrase.

Regularly check for driver and kernel updates. Support for new WiFi 6 standards and improved stability for older adapters often come with Linux kernel updates. Keep up with your distribution's releases.

How do I find out which driver is used for my WiFi adapter?

Use the command lspci -k for PCI devices or lsusb -v For USB adapters, look for the line "Kernel driver in use" in the output. This will show the active kernel module, such as iwlwifi or ath9k.

Is it possible to connect to WiFi without root rights?

Typically, no, since configuring a network interface requires privileges. However, you can configure PolKit or add the user to the netdev/wheel group to allow specific sudo commands to run without a password.

What to do if nmcli command is not found?

This means NetworkManager is not installed. You need to either install the network-manager package through your distribution's package manager (apt, dnf, pacman) or use alternative methods like wpa_supplicant.