How to Enable WiFi in Ubuntu Using the Terminal: A Complete Guide

Working in the operating system Ubuntu Often, the user needs not only a graphical interface but also an understanding of how to manage network connections via the command line. Situations where the graphical interface freezes, drivers fail to load automatically, or you're working on a server version without a GUI are common. Being able to quickly activate a wireless connection via the console is becoming a critical skill for any administrator or advanced user.

In this article, we'll cover every step in detail, from diagnosing adapter status to configuring complex network settings. You'll learn how to use powerful utilities. NetworkManager And ip for complete control over your connection. This knowledge will give you confidence even in the most challenging network situations.

Before entering commands, ensure you have physical access to the computer or remote access via SSH if the connection is lost. We'll cover both standard scenarios and solutions for common driver and lockup issues.

Diagnosing the status of a wireless adapter

The first step is always to check whether the system can see your wireless equipment. Often, the problem isn't with the network settings, but rather that the adapter is blocked at the hardware or software level. First, check the list of network interfaces to determine which one is responsible for Wi-Fi.

Use the command ip link or an older but informative one ifconfig -ato get a list of all interfaces. Look for names starting with wl, For example, wlo1 or wlan0If such an interface is not listed, this may indicate a lack of drivers or a physical disconnection of the module.

ip link show

An important diagnostic tool is the utility rfkill, which controls radio module locks. It displays the status of WiFi, Bluetooth, and other wireless technologies. If you see the status hard blocked, this means that the adapter is turned off by a physical switch on the laptop case or a key combination.

⚠️ Attention: If the status shows hard blockedSoftware commands won't help. You'll need to find a physical switch on the device's body or use the function keys (usually Fn + F-key with antenna) to unlock it.

For detailed information about locks, enter the command rfkill list allThis will list all radio devices and their current status. If WiFi is blocked by software (soft blocked), you can remove this block with one command.

rfkill list all

After analyzing the list, if a software block is detected, it must be removed. The command sudo rfkill unblock wifi Forcefully unblocks wireless interfaces. Afterwards, check again to ensure the status has changed to "no."

📊 What block status have you encountered most often?
Hard blocked (physical)
Soft blocked (software)
There was no blocking
I don't know how to check

Managing connections via NetworkManager (nmcli)

In modern distributions Ubuntu The main tool for network management is NetworkManagerIts console utility nmcli Provides extensive functionality, allowing you to do everything you can do in the graphical interface, but with greater flexibility. This is the recommended method for most users.

To get started, you need to make sure the network manager itself is running and the WiFi control switch is enabled. Even if the adapter isn't blocked via rfkill, the radio module may be disabled in NetworkManager itself. You can check the status with the command nmcli radio wifi.

If the output shows "disabled", enable the module with the command nmcli radio wifi onThis action is equivalent to pressing the WiFi slider in the upper right corner of the screen. Once the module is enabled, the system will begin scanning for available networks.

nmcli radio wifi on

The next step is to search for available access points. The command nmcli dev wifi list will display a table of all visible networks with their SSID (name), signal strength (SIGNAL), channel and security status. In the column BARS The signal quality is displayed graphically.

Once you find the desired network in the list, you can initiate a connection. For open networks, simply specify the name, but for secured networks, you'll need a password. The command syntax requires specifying the interface if there are multiple, but the system often automatically selects the correct one.

☑️ Check before connection

Completed: 0 / 4

To connect to a secure network, use the following syntax, substituting your credentials. Please note that the password is passed via the command line, so it may be saved in the command history, which is a potential security risk on shared computers.

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

Manually configuring IP address and DNS

In most cases, IP address and DNS server settings are configured automatically via the protocol DHCPHowever, in corporate networks or with specific provider requirements, manual registration of a static IP address may be required. This can be done through nmcli, creating a new connection.

Creating a new connection profile with a static IP requires specifying the address, subnet mask, gateway, and DNS servers. This is a more complex operation than a simple connection and requires attention to detail to avoid losing network access.

Let's look at an example of creating a connection named "MyStaticWiFi." We'll specify the network SSID, addressing method manual and the required network parameters. Replace the values ​​with those relevant to your infrastructure.

sudo nmcli con add type wifi con-name "MyStaticWiFi" ifname wlo1 ssid "HomeNet" ip4 192.168.1.50/24 gw4 192.168.1.1

sudo nmcli con modify "MyStaticWiFi" ipv4.dns "8.8.8.8 1.1.1.1"

sudo nmcli con modify "MyStaticWiFi" ipv4.method manual

sudo nmcli con up "MyStaticWiFi"

⚠️ Important: When setting up a static IP, make sure the address you select is not already in use by another device on the network and is within the correct range for your subnet. Incorrect gateway (gw4) will result in no internet access.

You can check your current IP addressing settings using the command ip addr show or nmcli con showThe output will show the assigned address, broadcast address, and DNS information. If the settings were applied successfully, you should receive a ping response to the gateway.

To return to automatic address acquisition (DHCP), you need to change the method to auto and delete manually entered addresses. This is often necessary when moving a laptop from the office to home.

sudo nmcli con modify "MyStaticWiFi" ipv4.method auto

sudo nmcli con modify "MyStaticWiFi" ipv4.addresses ""

sudo nmcli con down "MyStaticWiFi"

sudo nmcli con up "MyStaticWiFi"

Why do you need a static IP?

A static IP is necessary for port forwarding, setting up remote access to a home server, network printers, or when the router is configured to filter by MAC and IP addresses. Under normal circumstances, DHCP is more convenient.

Working with drivers and kernel modules

One of the most common reasons for the lack of WiFi in Ubuntu is the lack of proprietary drivers or a conflict of kernel modules. The Linux kernel contains many open-source drivers, but for some chipsets (especially Broadcom and some Realtek) closed binary drivers are required.

You can check which driver is used for your wireless device using the utility lspci (for internal cards) or lsusb (for USB whistles). Team lspci -k | grep -A 3 -i network will show detailed information about the network controller and the kernel driver used.

lspci -k | grep -A 3 -i network

If the "Kernel driver in use" line is empty, the driver is not loaded. Ubuntu has a mechanism for installing additional drivers through the package manager. The utility ubuntu-drivers can automatically find and suggest suitable drivers for your hardware.

Running the command ubuntu-drivers autoinstall It will scan your hardware, compare it against a database of known proprietary drivers, and install the necessary packages. After installation, a system reboot or at least a kernel module reload is often required.

Analysis of tables and network parameters

To gain a deeper understanding of how your connection is working, it's helpful to understand the parameters displayed by diagnostic utilities. Below is a table of the main parameters you might encounter in command output. nmcli or iwconfig, and their meaning.

Parameter Description Normal value
ESSID Wireless network name (SSID) Your network name in quotation marks
Mode Adapter operating mode Managed (client)
Frequency Channel frequency 2.4 GHz or 5 GHz
Link Quality Connection quality Close to 100% or 70/70
Bit Rate Connection speed Depends on the standard (n/ac/ax)

Mode Managed means that your card is acting as a client, connecting to an access point. Mode Ad-Hoc used for computer-to-computer connection, and Monitor Required for traffic analysis and security audits. For regular internet access, Managed is required.

Parameter Link Quality can be presented in different formats depending on the utility. iwconfig it is often a fraction (for example, 54/70), and in nmcli — percentage or number of bars. Poor connection quality leads to high pings and disconnections.

Solving common problems

Even with the correct settings, connection issues may still occur. A common cause is a conflicting configuration file, especially if you previously configured the network through /etc/network/interfaces in older versions of Ubuntu, and now use NetworkManager.

Check the configuration file /etc/network/interfacesIf there are active entries for your WiFi interface, they can intercept control from NetworkManager. On modern systems, this file should only contain a line for localhost, unless you're using the classic ifupdown.

auto lo

iface lo inet loopback

Another issue may be power saving. The WiFi adapter may go into sleep mode and not wake up, resulting in connection drops. You can disable this feature in the NetworkManager configuration by creating a file /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf.

⚠️ Note: Interfaces and configuration methods may vary depending on the Ubuntu version and desktop environment used (GNOME, KDE, XFCE). Always check the official documentation for your specific distribution version.

If all else fails, try restarting the network management service completely. This often "shakes up" the system and resets any frozen daemons. Use the command sudo systemctl restart NetworkManager.

Frequently Asked Questions (FAQ)

How can I find the password for a saved WiFi network in the terminal?

Passwords are stored in connection configuration files. You can find them in the directory /etc/NetworkManager/system-connections/. The files have access rights only for root, so use sudo cat FileName. Look for the line psk or password.

What to do if nmcli command is not found?

Utility nmcli included in the package network-managerIf it's missing, you may have a minimalist version of the system installed. Install the package with the command sudo apt update && sudo apt install network-manager.

How to switch between 2.4GHz and 5GHz?

When connecting via nmcli you can specify the parameter band. Use band a for 5 GHz and band bg for 2.4 GHz For example: nmcli dev wifi connect "SSID" password "pass" band a.

Why is WiFi slow after turning it on via terminal?

The channel or channel width may not be optimal. Try rebooting your router. Also, check if your WiFi adapter's power saving mode is enabled, which could limit performance.