Enabling Wi-Fi in Ubuntu via the Command Line: From Beginner to Pro

Transition to an operating system Linux often involves learning new methods of network management. Unlike Windows, where connecting to the internet usually occurs automatically or through a clear graphical interface, Ubuntu Sometimes situations arise where the graphical shell fails to load or drivers require manual activation. It's in these situations that knowing how to enable Wi-Fi on Ubuntu via the terminal becomes a critical skill for any user.

The command line provides more flexible tools for diagnosing and managing network interfaces, allowing you to resolve issues that can't be resolved using standard settings. You'll have full control over the connection process, see detailed error information, and force the startup of necessary services. This is especially useful for server versions of the system or when working with remote machines via SSH.

In this guide we will cover the basic utilities such as nmcli And ip, and we will also touch upon issues of driver installation. Most modern Wi-Fi adapters are supported by the Linux kernel by default, but some Broadcom or Realtek models may require separate installation of proprietary packages. Being prepared for manual configuration will save you hours of searching for solutions online.

Diagnosing the status of a wireless adapter

Before attempting to connect to the network, you need to ensure that the system can even see your wireless equipment. Often, the problem isn't with the settings, but rather that the Wi-Fi module is physically disabled or blocked at the kernel level. The first step should always be checking the device's presence in the list of available interfaces.

To get complete information about network devices, use the utility ip, which replaced the outdated one ifconfig. Enter the command ip link and carefully study the output. Wireless interfaces usually have names starting with wl, For example, wlp2s0 or wlan0If you only see lo (loopback) and eth0 (wired), then the system did not detect the adapter.

It is also worth checking the radio module blocking status using the utility rfkillSometimes users accidentally press a function key on the keyboard, disabling wireless modules, and it is impossible to enable them programmatically without removing this lock. The command rfkill list will show the status of all wireless devices and indicate whether they are blocked by software (soft block) or hardware (hard block).

  • 📡 Team lspci | grep -i network will show whether the system sees the Wi-Fi card at the PCI bus level.
  • 🔒 The "Hard blocked: yes" status means that the adapter is disabled by a physical switch or Fn key combination.
  • 📶 No interface in the output ip link often indicates a lack of drivers.
  • ⚡ Reloading the kernel module may temporarily solve the problem of the device disappearing.

⚠️ Attention: If in the output rfkill If you see "Hard blocked," no software commands will help until you flip the physical switch on the laptop case or press the corresponding key on the keyboard.

Understanding the current state of the adapter is the foundation of successful setup. Without a clear understanding of whether it sees Ubuntu If your equipment is damaged, further steps may be pointless. Please devote sufficient time to this step to rule out hardware issues.

Installing and updating network drivers

If diagnostics show that the wireless adapter is not detected or is not working correctly, the problem is most likely with the drivers. In the Linux world, drivers are often built directly into the kernel, but for some chipsets, especially Broadcom And Realtek, proprietary modules are required. The lack of internet access complicates the task, as the driver needs to be downloaded, but there's no network connection.

In this situation, a temporary connection via an Ethernet cable or using a USB modem from an Android smartphone in USB tethering mode can help. Once network access is restored, you need to update your package lists and install any missing components. For Broadcom, this is often the package bcmwl-kernel-source, and for others - linux-firmware.

sudo apt update

sudo apt install --reinstall linux-firmware

sudo apt install bcmwl-kernel-source

After installing the drivers, be sure to reboot the system or kernel module for the changes to take effect. Sometimes driver It installs but does not load automatically and requires manual intervention via modprobeChecking kernel logs using dmesg | grep firmware will help identify firmware loading errors.

What to do if the driver is not in the repositories?

If the default Ubuntu repositories don't contain a driver for your card, try searching for one on the manufacturer's website or using the DKMS utility to compile the module from source code. This requires the build-essential and linux-headers packages.

  • 🛠 Utility additional-drivers can automatically find and suggest suitable proprietary drivers.
  • 📦 Package linux-firmware Contains microcode for a huge number of network cards.
  • 🔄 Team sudo modprobe -r module And sudo modprobe module Reloads the driver without rebooting the OS.
  • 📂 Driver source codes can often be found on GitHub in community repositories.

Installing the correct drivers solves 90% of connection issues. Don't neglect updating your system kernel, as new versions Linux kernel Support for modern equipment is improved.

Managing connections via Network Manager (nmcli)

The most convenient and modern way to manage network in Ubuntu is the command line utility for Network Manager, known as nmcliIt allows you to perform all the same actions as the graphical interface, but with greater detail and automation capabilities. It's a fundamental tool every administrator should know.

First, check the network management status with the command nmcli general statusIf the status is "disconnected" or "connecting," the service is running. To see a list of available wireless networks, use the scan command.

nmcli dev wifi list

Once you see your network in the list, you can initiate a connection. You'll need the network name (SSID) and password. If the network name contains spaces, enclose it in quotation marks. The system will automatically create a connection profile and attempt to obtain an IP address via DHCP.

☑️ Connection algorithm via nmcli

Completed: 0 / 5

Connection profile management is another strong point nmcliYou can save settings for different networks, edit DNS parameters, or set a static IP address. All changes are saved in configuration files and apply after rebooting or restarting the network service.

⚠️ Attention: When entering a password in the terminal, characters are not displayed on the screen for security reasons. This is normal system behavior; simply enter your password blindly and press Enter.

Usage Network Manager Preferred for desktop versions of Ubuntu, as it integrates with the graphical environment. If you change settings via the terminal, they will immediately be reflected in the graphical interface if it's running.

Setting up a network using Netplan

In modern versions of Ubuntu, especially in server editions, the utility is used by default Netplan for network configuration. It works with YAML configuration files, making settings transparent and easily portable between servers. Although for home use nmcli more convenient, knowledge of Netplan is necessary to work with servers.

Netplan configuration files are usually located in the directory /etc/netplan/ and have an extension .yamlBe sure to create a backup copy of the file before editing. YAML syntax is indentation-sensitive, so use spaces instead of tabs, otherwise the system will return an error when applying the configuration.

network:

version: 2

renderer: networkd

wifis:

wlan0:

dhcp4: true

access-points:

"MyHomeWiFi":

password: "SuperSecretPassword"

After making changes to the file, you need to apply the configuration with the command sudo netplan applyIf the syntax is correct, the network will reconnect according to the new rules. If there is an error, Netplan will report it, and you can correct the file without losing access to the system (if connecting via the console).

📊 Which network setup method do you prefer?
Graphical Interface (GUI)/Network Manager (nmcli)/Netplan (YAML)/Wpa_supplicant/Other
  • 📄 Configuration files are located in /etc/netplan/ and are called, for example, 01-network-manager-all.yaml.
  • ⚠️ Indentation in YAML files is critically important—one extra space breaks the entire configuration.
  • 🔍 Team netplan try will apply the settings and roll them back after 120 seconds if you lose the connection.
  • 📡 Renderer networkd used for servers, and NetworkManager for desktops.

Netplan provides a powerful and flexible network management solution, ideal for automated deployments. However, for ad hoc connections on a laptop, it may seem overly complex compared to nmcli.

Alternative method: Wpa_supplicant

For those cases when Network Manager is not installed or a minimalistic approach is required, the utility is used wpa_supplicantThis is a low-level daemon that directly interacts with the wireless card driver. It's the "heavy artillery" that runs on virtually any Linux distribution.

The manual connection process involves several steps: creating a configuration file with a password hash, starting the daemon, and obtaining an IP address via dhclientThis method requires more steps, but provides a complete understanding of how the authentication process works in WPA/WPA2 networks.

wpa_passphrase "SSID" "PASSWORD" | sudo tee /etc/wpa_supplicant/wpa_supplicant.conf

sudo wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf

sudo dhclient wlan0

Usage wpa_passphrase Allows you to securely generate a configuration file without storing the password in cleartext (it is converted to a hash). This is an important security aspect, especially if the configuration file can be read by other users of the system.

Parameter Description Example of meaning
-B Run in the background (daemonize) Process flag
-i Interface name wlan0, wlp2s0
-c Path to the configuration file /etc/wpa_supplicant.conf
dhclient IP Utility (DHCP) Address request

Although the method with wpa_supplicant While it may seem cumbersome for everyday use, it's indispensable when debugging connection issues and needing to rule out the influence of add-ons like Network Manager. Understanding this process makes you a true Linux networking expert.

Solving common connection problems

Even with the correct settings, errors can still occur. A common issue is address conflicts or incorrect DNS settings, which can cause the network to be connected but websites to not open. First, check if you're receiving an IP address using the command ip addr showIf the address starts with 169.254.x.x, which means the DHCP server did not respond.

It's also worth paying attention to power saving settings. Some Wi-Fi drivers disable the adapter by default to save power, which can lead to connection drops. You can disable this through the Network Manager configuration or by creating a file in /etc/pm/power.d/.

Logging is your best friend when troubleshooting. Team journalctl -u NetworkManager -f This will allow you to see in real time what's happening with the network service when you attempt to connect. Authentication errors or driver issues will be clearly displayed.

⚠️ Attention: Command line interfaces and package names may differ between Ubuntu versions (e.g., 20.04 LTS vs. 24.04). Always check the syntax against the official documentation for your distribution version.

Keep in mind that problems may not only be on the client side. Check if your router has MAC address filtering enabled, which could block a new device even if the password is entered correctly. You can find out your card's address using the command ip link.

FAQ: Frequently Asked Questions

Why does the sudo command require a password but doesn't show asterisks when entered?

This is standard security behavior in Linux. By obscuring character input, the system prevents attackers looking over your shoulder from learning the length of your password. Simply type your password blindly and press Enter.

How do I find out the name of my Wi-Fi interface?

Enter the command ip link or iwconfigWireless interfaces usually start with the letters "wl", for example, wlp3s0 or wlan0Older systems can simply use wlan0.

Is it possible to create a hotspot via terminal?

Yes, it is possible with the help of nmcliThe command looks something like this: nmcli dev wifi hotspot ifname wlan0 ssid "MyHotspot" password "password123"This will create a hotspot that other devices can connect to.

What to do if Wi-Fi is slow after installing Ubuntu?

Often, the problem lies with drivers or power-saving mode. Try disabling power-saving for Wi-Fi in the Network Manager configuration. Also, make sure you're using a modern Linux kernel version that better supports your hardware.

Mastering the command line for Wi-Fi management in Ubuntu opens new horizons for working with the operating system. You're no longer dependent on the vagaries of the graphical interface and can quickly diagnose and fix problems of any complexity. Regular practice of these commands will reinforce your skills and make working with Linux comfortable and efficient.