How to Set Up Wi-Fi on Linux: From Beginner to Pro

Transition to an operating system Linux is often accompanied by a desire to understand the intricacies of how the equipment works, and the first test is usually connecting to a wireless network. Unlike Windows, where the process is often hidden behind a graphical interface, in the world Open Source The user has a choice: use visual utilities or manage the connection through the terminal. Understanding these processes provides not only internet access but also control over network parameters unavailable in other systems.

Modern distributions such as Ubuntu, Fedora or Linux Mint, are equipped with powerful tools that automatically detect most adapters. However, the situation can be complicated by the lack of proprietary drivers or the need to configure a static IP address for server tasks. That's why it's important to know several configuration methods to stay online in any situation.

In this article we will discuss in detail how to set up Wi-Fi connection in a variety of ways, from graphical interfaces to the command line. You'll learn how to diagnose driver issues, manage network profiles, and which commands can help restore access if the graphical shell stops responding. Being comfortable working in the terminal is a skill that will significantly increase your efficiency.

Checking compatibility and installing drivers

Before attempting to connect to the router, ensure that the operating system "sees" your wireless adapter. It often happens that after installing the distribution, the Wi-Fi module fails to activate due to missing firmware or proprietary drivers. The first step should always be to diagnose the hardware to rule out hardware failure or complete incompatibility.

To check the list of network interfaces, use the command ip link or more detailed lspci for internal cards and lsusb for external USB swings. If you see a device marked Network controller, but without an active interface wlan0 or wlp2s0, which means the system needs additional help to start the device.

⚠️ Attention: If you are using a laptop with a hybrid graphics card or a specific module Realtek or Broadcom, standard kernel drivers may not work correctly. In such cases, manual compilation of modules from repositories is often required.

Many distributions have a utility for searching and installing missing software. For example, in Debian-like systems, the command sudo apt update The driver will update the package lists, after which you can use the additional driver manager. Automatic installation often solves 90% of problems with popular chipsets.

  • 🔍 Run the command lspci -k | grep -A 3 -i network to check the driver status.
  • 📦 Use sudo apt install firmware-linux-nonfree to download missing firmware.
  • 🔄 Reboot the system with the command sudo reboot after installing new kernel modules.
What to do if the adapter is not detected at all?

If the lspci and lsusb commands don't show the wireless device, check whether Wi-Fi is blocked by a hardware switch on the laptop case. It's also possible that the module is disabled in the BIOS/UEFI—go to the firmware settings and make sure the WLAN Controller is set to Enabled.

Configuration via graphical user interface (GUI)

For most users, especially beginners, the most convenient way remains using a graphical shell. In desktop environments GNOME, KDE Plasma or XFCE Network management is intuitive and similar to familiar operating systems. It's ideal for stationary workstations that don't require complex configuration.

The network icon is usually located in the system tray (upper or lower right corner of the screen). Clicking on it will display a list of available wireless networksSelect the desired one, enter the security password (usually WPA2/WPA3), and the system will automatically create a connection profile. All settings, such as obtaining an IP address via DHCP, are configured automatically.

If you need to set a static IP address, DNS or proxy, you need to go to the network settings. GNOME This is done through the settings menu, where you can switch the IPv4 method from "Automatic (DHCP)" to "Manual." The gateway address and name servers are also specified here, which is critical for corporate networks or local servers.

Parameter Description Example of meaning
IP Address Static device address 192.168.1.50
Netmask Subnet mask 255.255.255.0
Gateway Gateway (router) address 192.168.1.1
DNS Domain name servers 8.8.8.8, 1.1.1.1

The graphical interface also allows you to manage network priorities. If you frequently move between home and office, the system will automatically select a higher-priority network when it detects one. This is convenient, but can sometimes result in connecting to a weaker network if priorities are set incorrectly.

Network management via NetworkManager (nmtui)

When the graphical shell is unavailable, for example on a server or when the interface fails, the utility comes to the rescue nmtuiThis is a text interface that runs on top of the service. NetworkManager, which allows you to manage connections using the keyboard. It's available by default in most modern distributions.

To launch, simply enter the command sudo nmtui in the terminal. A menu with a blue border will open, where you can navigate with arrows and select with the Enter key. This universal solution, which works the same on any distribution where NetworkManager is installed.

Select "Edit a connection," then "Add," and select "Wi-Fi" as the profile type. In the SSID field, enter your network name or select one from the list of available ones. In the Security section, select the encryption type (usually WPA & WPA2 Personal) and enter the password. After saving the profile, you'll need to activate it.

  • 🖥️ Run the utility with the command sudo nmtui as superuser.
  • 📝 Select "Edit a connection" to create a new profile or edit an existing one.
  • ✅ Don't forget to select "OK" at the end of the options list to save your changes.
⚠️ Note: Changes made through nmtui, are applied immediately, but if the connection is already active, it may need to be reconnected. Use the command nmcli con down And nmcli con up to reboot the profile.

The advantage of this method is its stability and simplicity. You don't need to remember complex command syntax, as is the case with pure nmcliSimply follow the menu options. This is a great way to quickly set up a network on a remote server via SSH if the main cable has been disconnected.

Wi-Fi configuration via terminal (nmcli)

For those who value speed and automation, the tool nmcli The NetworkManager command-line interface is indispensable. It allows you to perform all the same actions as the graphical interface, but with a single line of code. This is especially useful for writing deployment scripts or performing quick diagnostics.

First, you need to scan the airwaves for networks. The command nmcli dev wifi list will display a table of available access points, indicating their signal strength, security, and channel. If the list is empty, the device may be blocked or disabled by software. In this case, run nmcli radio wifi on.

To connect to the network, use the command nmcli dev wifi connectIt requires an SSID and password. The syntax is simple: nmcli dev wifi connect "Network_Name" password "Your_Password"The system will attempt to create a new profile and activate it. If the connection is successful, you will see a message confirming device activation.

nmcli dev wifi connect"HomeWiFi" password"SuperSecretPassword123" ifname wlp2s0

In corporate environments, it is often necessary to specify additional parameters, such as a hidden SSID. To do this, add the flag hidden yes to the connection command. You can also specify an interface if there are several of them, using the parameter ifnameThis gives you complete control over which card connects to which network.

  • 📡 Scan: nmcli dev wifi rescan And nmcli dev wifi list.
  • 🔗 Connection: nmcli dev wifi connect SSID password PASS.
  • 🔒 Hidden Network: Add Option hidden yes to the connection command.

Setting up a static IP in Netplan (for servers)

In server distributions such as Ubuntu Server, the daemon is used by default NetplanIt differs from NetworkManager in that it is configured exclusively via YAML files. This ensures predictability and the ability to store settings in version control systems.

Configuration files are located in the directory /etc/netplan/. Usually there is a file there with a name like 00-installer-config.yaml or 50-cloud-init.yamlBefore editing, be sure to create a backup copy, as one indentation error will render the network inoperable.

In the YAML file you need to describe the renderer (usually networkd or NetworkManager), interface name and parameters. For Wi-Fi, the SSID name and password are specified in the section wifiIt is important to maintain a precise indentation structure, using spaces rather than tabs.

network:

version: 2

renderer: networkd

wifis:

wlp2s0:

dhcp4: no

addresses: [192.168.1.50/24]

gateway4: 192.168.1.1

nameservers:

addresses: [8.8.8.8, 1.1.1.1]

access-points:

"MyHomeNetwork":

password:"StrongPassword"

After making changes, apply the configuration with the command sudo netplan applyIf the syntax is correct, the network will reconfigure instantly. If an error occurs, the system will provide a detailed report detailing the specific YAML structure violation, allowing for quick correction.

⚠️ Warning: When configuring Netplan via a remote connection (SSH), there is a risk of losing access to the server if there is a configuration error. Always use the command netplan try, which will roll back the changes after 120 seconds if you do not confirm their success.

Diagnosing and resolving connection problems

Even with proper configuration, situations may arise where Wi-Fi is unstable or doesn't connect at all. Log analysis should be your first diagnostic tool. dmesg | grep wifi or journalctl -u NetworkManager will show the latest events related to the wireless module and indicate the reasons for failure.

A common problem is an address conflict or incorrect DNS settings. If you see a connection message but the pages don't open, try pinging the external IP, for example, ping 8.8.8.8If the ping works, the problem is name resolution, and it's worth checking the contents of the file. /etc/resolv.conf.

Power consumption is also worth paying attention to. Some drivers aggressively conserve power by disabling the adapter when idle, which leads to connection interruptions. You can disable this feature using the command sudo iwconfig wlan0 power off or by creating a corresponding configuration file in /etc/NetworkManager/conf.d/.

  • 📉 Check the signal level with the command iwconfig (Link Quality parameter).
  • 🛑 Reset network settings: sudo nmcli networking off and then on.
  • 🔍 Look for errors in the log: sudo grep -i wifi /var/log/syslog.

If all else fails, try completely deleting the saved connection profile and creating it again. Sometimes configuration files become corrupted or contain cached data that prevents a new connection from being established. As a last resort, reinstall the packages. network-manager And firmware can restore the system's functionality.

Frequently Asked Questions (FAQ)

How to find the password for a saved Wi-Fi network in Linux?

Passwords are stored encrypted in NetworkManager configuration files. To view the password in plaintext, use the command: sudo grep -r"psk=" /etc/NetworkManager/system-connections/However, the easiest way is to use nmcli: nmcli -s -g 802-11-wireless-security.psk connection show "Network_Name".

Why can't my Wi-Fi adapter see 5GHz networks?

This may be due to regional settings. Make sure that this is enabled in your router settings and in the system (parameter country_code in the kernel module cfg80211) the correct region is set. Some countries restrict the use of certain 5 GHz channels.

Is it possible to share Wi-Fi from a Linux laptop?

Yes, most modern distributions allow you to create a hotspot directly from the network settings. In the terminal, you can do this using nmcli, creating a connection of the type wifi-hotspotThis will turn your laptop into a router.

How do I switch between saved Wi-Fi networks?

Use the command nmcli connection up"New_Profile_Name"If the current connection is active, NetworkManager will automatically deactivate it and start a new one, provided that the adapter is free.