Connecting to Wi-Fi via a terminal in Ubuntu It may seem like a daunting task for beginners, but in practice, it's one of the most reliable ways to configure a network—especially when the graphical interface is unavailable or malfunctioning. Unlike the traditional network icon in the taskbar, the command line gives you full control over connection settings, allows you to diagnose problems, and even connect to hidden networks without any fuss.
This article is suitable for both users Ubuntu 22.04 LTS and newer, as well as those who work with older versions like 18.04 or 20.04We'll cover not only the basic connection commands, but also the nuances of working with drivers and encryption. WPA3, as well as common mistakes like "Device not readyIf you've ever encountered a situation where Wi-Fi suddenly disappeared after a system update or isn't detected at all, you'll find solutions here.
Before moving on to the commands, make sure that your Wi-Fi adapter is physically turned on (on some laptops there is a separate button or key combination for this, for example Fn + F2). Also check if the hardware switch on the device body is blocking the connection.
1. Checking the availability of a Wi-Fi adapter in the system
The first step is to make sure that Ubuntu your Wi-Fi module can be seen at all. To do this, use the command ip a or iwconfig, which displays all network interfaces. In the output, look for a device with a name like wlan0, wlp3s0 or similar (prefix w (indicates a wireless adapter).
If there are no wireless interfaces listed, the problem may be due to missing drivers. In this case, run:
lspci -knn | grep -iA3 net
This command will show all network devices, including Wi-Fi, as well as information about the drivers used (line Kernel driver in use). If the driver is not loaded or is marked as UNCLAIMED, its installation will be required.
⚠️ Note: On some laptops with hybrid adapters (e.g. Intel AX200 + Bluetooth) Wi-Fi may not be detected until the proprietary drivers are installed. For Broadcom-chips often require proprietary software from the repository restricted.
- 🔍 There is no interface
wlan*? Check if the adapter is enabled in BIOS/UEFI or disabled in power saving settings. - 🔌 The adapter is present but inactive? Try to enable it with the command
sudo ip link set wlan0 up(replacewlan0to your interface). - 🚫 Driver missing? Install it via
sudo ubuntu-drivers autoinstallor manually for a specific model.
2. Scanning available networks and obtaining information
If the adapter is recognized by the system, the next step is to scan the air for available networks. This utility is used for this. iwlist or more modern iwThe first one provides a detailed conclusion, the second one is compact and structured.
Run the command:
sudo iwlist wlan0 scan | grep ESSID
This command will display only the network names (ESSID). To see the full information (including channel, signal strength and encryption type), remove the part | grep ESSIDFor the utility iw the syntax will be like this:
sudo iw dev wlan0 scan | less
In the output, please note the following parameters:
- 📡
signal— signal level (the higher the value indBm, the better). - 🔒
RSN/WPA— encryption type (for example,WPA2-PSKorWPA3-SAE). - 📶
channel— network channel (may be useful for manual configuration).
| Parameter | Description | Example of meaning |
|---|---|---|
ESSID |
Wi-Fi network name | "MyHomeWiFi" |
Mode |
Operating mode (access point or client) | Master or Managed |
Frequency |
Channel frequency in GHz | 2.412 (channel 1) |
IE: WPA Version |
Security protocol version | 1 (WPA) or 2 (WPA2) |
If the scan returns an empty list, try:
- Restart the adapter:
sudo ip link set wlan0 down && sudo ip link set wlan0 up. - Make sure there are active networks in the coverage area (check on your phone or other device).
- Check if scanning is blocked
rfkill(see next section).
3. Unlocking the Wi-Fi adapter (if it is disabled by software)
IN Ubuntu The service is responsible for blocking wireless devices rfkillIf the adapter is physically turned on, but the system does not see it or returns the error "Operation not possible due to RF-kill", check the blocking status:
rfkill list
In the output, look for the line with your Wi-Fi adapter. If it says Soft blocked: yes or Hard blocked: yes, unlock your device:
sudo rfkill unblock wifi
⚠️ Attention: Hardware lock (Hard blocked: yes) This means that the adapter is physically disabled—either by a button on the case or in the BIOS. In this case, unlocking it viarfkillwon't help.
After unlocking, reboot the adapter:
sudo systemctl restart NetworkManager
If the problem persists, check if there is a conflict NetworkManager with other network services (eg wpa_supplicant (in manual mode). To do this, follow these steps:
sudo systemctl status NetworkManager
The status should not contain errors like “Failed to start» or port conflicts.
4. Connect to an open and secure Wi-Fi network
To connect to the network via the terminal in Ubuntu the utility is used nmcli (part of the package NetworkManager) or wpa_supplicant for manual configuration. We will consider both options, since nmcli easier for beginners, and wpa_supplicant gives more control.
Method 1: Connecting via nmcli
If NetworkManager active (checked by command systemctl is-active NetworkManager), use:
nmcli dev wifi connect "NETWORK_NAME" password "PASSWORD"
Replace NETWORK_NAME And PASSWORD to the current values. For an open network (without a password), skip the parameter password:
nmcli dev wifi connect "FreeWiFi"
To specify a specific interface (if there are several), add the flag ifname:
nmcli dev wifi connect "NETWORK_NAME" password "PASSWORD" ifname wlan0
Method 2: Manual connection via wpa_supplicant
If NetworkManager disabled or not working, configure the connection manually:
- Create a configuration file for
wpa_supplicant:sudo nano /etc/wpa_supplicant/wpa_supplicant.conf - Add a network configuration block to the file (example for
WPA2-PSK):network={ssid="NETWORK_NAME"
psk="PASSWORD"
key_mgmt=WPA-PSK
} - Connect to the network:
sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf - Request an IP address from the router:
sudo dhclient wlan0
For networks with WPA3 replace key_mgmt=WPA-PSK on key_mgmt=SAEIf the network is hidden, add the line scan_ssid=1.
Ping to the router: ping 192.168.1.1|IP address check: ip a show wlan0|Internet access test: ping google.com|View routes: ip route
-->
5. Connecting to a hidden Wi-Fi network
Hidden Networks (hidden SSID) do not broadcast their name on air, so connecting to them requires an explicit indication SSID and additional parameters. In nmcli the syntax will be like this:
nmcli dev wifi connect "HIDDEN_NETWORK_NAME" password "PASSWORD" hidden yes
For wpa_supplicant add the line to the configuration file scan_ssid=1:
network={ssid="HIDDEN_NETWORK_NAME"
psk="PASSWORD"
key_mgmt=WPA-PSK
scan_ssid=1
}
If the connection fails, try:
- 🔄 Specify the network channel manually (find it by scanning on another device and add the line
channel=6in the blocknetwork). - 📡 Make sure that the router is actually broadcasting the network in stealth mode (sometimes the problem is on the access point side).
- 🔧 Check if a firewall is blocking the connection (
sudo ufw status).
⚠️ Attention: Some routers with "AP Isolation" enabled may block new devices from connecting, even if the password is correct. In this case, temporarily disable this option in the router settings.
6. Troubleshooting common errors
Even if you enter the commands correctly, connecting to Wi-Fi via the terminal can still result in errors. Let's look at the most common ones and how to resolve them.
| Error | Possible cause | Solution |
|---|---|---|
Device not ready |
The adapter is not initialized or is disabled. | sudo ip link set wlan0 up or check rfkill |
Connection activated, but no IP address |
The DHCP server is not issuing IP addresses. | Launch sudo dhclient wlan0 or check your router settings |
Authentication failed |
Incorrect password or encryption type | Check the case of the password and the parameter key_mgmt V wpa_supplicant |
No such device |
Interface wlan0 does not exist |
Check the interface name via ip a |
If there is no internet access after connecting, but the IP address has been received, check:
- Default routes:
ip route(there should be a line withdefault via). - DNS servers:
cat /etc/resolv.conf(if empty, addnameserver 8.8.8.8). - Firewall:
sudo iptables -L(there should be no rulesDROPfor outgoing traffic).
What should I do if Wi-Fi stops working after updating the kernel?
After updating the kernel Ubuntu It may "forget" the modules for the Wi-Fi adapter. Try:
1. Reboot the system.
2. Reinstall the driver: sudo apt install --reinstall linux-firmware.
3. Roll back to the previous kernel version via GRUB (hold down while booting) Shift).
4. Check kernel logs for errors: dmesg | grep -i firmware.
7. Automatic connection at system boot
To Ubuntu connected to Wi-Fi automatically at startup, it is enough to connect successfully once through nmcli — NetworkManager saves settings in /etc/NetworkManager/system-connections/. For manual configuration (for example, if you are using wpa_supplicant) add it to startup:
sudo systemctl enable wpa_supplicant
Then edit the file /etc/wpa_supplicant/wpa_supplicant.conf, adding the line:
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
To obtain IP automatically, add to /etc/network/interfaces:
auto wlan0iface wlan0 inet dhcp
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
After this, reboot the system or restart services:
sudo systemctl restart networking wpa_supplicant
8. Additional tips and optimization
If Wi-Fi is unstable (drops, low speed), try the following settings:
- 📶 Change channel: If the router automatically selects a channel, manually set it to a less busy one (for example,
1,6or11for 2.4 GHz). - 🔄 Disabling power saving: Some adapters reduce performance to save battery life. Disable these:
sudo iw dev wlan0 set power_save off - 🛡️ Updating drivers: For adapters Realtek or Broadcom Install the latest drivers from the repository:
sudo apt install firmware-realtek - 🌐 Using 5 GHz: If your adapter supports
802.11ac, connect to a network at a frequency of 5 GHz for higher speed (specified in the router settings).
The following commands are useful for diagnosing problems:
dmesg | grep -i wifi— kernel logs related to Wi-Fi.journalctl -u NetworkManager- magazinesNetworkManager.iwconfig wlan0— current adapter status (signal level, transmission errors).
If you frequently connect to different networks, save configuration templates in separate files (for example, /etc/wpa_supplicant/home.conf, work.conf) and switch between them using symbolic links.
FAQ: Frequently asked questions about setting up Wi-Fi in Ubuntu
My Wi-Fi adapter isn't detected at all. What should I do?
First, check if the device is detected at the BIOS/UEFI level. If so, but in Ubuntu he is not there:
- Install the proprietary driver package:
sudo ubuntu-drivers autoinstall. - For adapters Broadcom You may need to disable open drivers:
sudo modprobe -r b43and download proprietary ones. - Check if the adapter is disabled in the power saving settings:
sudo rfkill unblock all.
If the adapter is external (USB), try connecting it to a different port.
How do I connect to a WPA3-Enterprise Wi-Fi network (e.g. at a university)?
For networks with authentication 802.1X (For example, eduroam) use:
nmcli connection add type wifi con-name "eduroam" ifname wlan0 ssid "eduroam"nmcli connection modify "eduroam" wifi-sec.key-mgmt wpa-eap
nmcli connection modify "eduroam" 802-1x.eap peap
nmcli connection modify "eduroam" 802-1x.identity "YOUR_LOGIN"
nmcli connection modify "eduroam" 802-1x.password "YOUR_PASSWORD"
nmcli connection up "eduroam"
For TTLS replace peap on ttlsCheck with your network administrator for the authentication type.
Is it possible to connect to Wi-Fi without NetworkManager?
Yes, with the help of wpa_supplicant And dhclient (as described in section 4). You can also use iw to manually specify parameters:
sudo iw dev wlan0 connect "NETWORK_NAME" key 0:PASSWORD
But this method is less reliable and does not save settings after reboot.
How to reset all network settings in Ubuntu?
To reset to factory settings:
- Delete all saved connections:
sudo rm /etc/NetworkManager/system-connections/*. - Reset
NetworkManager:sudo systemctl restart NetworkManager. - For
wpa_supplicantdelete config:sudo rm /etc/wpa_supplicant/wpa_supplicant.conf. - Reboot the system.
After this, all networks will have to be configured again.
Why is Wi-Fi speed slower in Ubuntu than in Windows?
This is a common issue related to drivers or power saving settings. Try:
- Disable adapter power saving:
sudo iw dev wlan0 set power_save off. - Update the driver to the latest version (especially relevant for adapters) Intel And Realtek).
- Switch to kernel
lowlatency(if you usegeneric). - Check if your router is limiting bandwidth for Linux devices (sometimes this is done through MAC filtering).