Setting up WiFi on Linux via the console: a step-by-step guide

Faced with the lack of a graphical interface after installing the operating system, many Linux users are at a loss. Often, network card drivers don't load automatically, or you're working on a server that simply doesn't have a GUI. In such situations, connecting to the internet via the command line becomes the only available solution for downloading updates or drivers.

Modern distributions offer several powerful tools for managing wireless connections. We'll look at the most up-to-date methods that work on Ubuntu, Debian, Fedora And Arch LinuxMastering these skills will allow you to restore network access even in critical situations when the graphical shell is unresponsive.

Before you begin, make sure the physical WiFi switch on your laptop is enabled. You'll also need to know the exact name of your network and its password. For desktop computers, you may need an external USB adapter compatible with Linux.

Diagnostics and preparation of network equipment

The first step is always to check the presence and status of the wireless interface. The system should "see" your device, even if it can't connect yet. This is done using the utility ip or older ifconfig, which can still be found in old manuals.

Run the command ip link in the terminal. In the list, you should find a device with a name starting with wlan or wlp, For example, wlan0 or wlp2s0If there is a status next to the name NO-CARRIER or DOWN, which means the interface is disabled either programmatically or physically.

To enable the interface, use the command ip link set wlan0 up, replacing wlan0 to your device's name. If the status doesn't change after turning it on, the kernel module may be blocked or proprietary firmware files may need to be installed.

  • 🔍 Check the presence of the adapter with the command lspci | grep -i network for PCI cards or lsusb for USB whistles.
  • 📡 Make sure the interface is not in the "Hard blocked" state using the utility rfkill list.
  • 🔄 If the adapter is blocked, remove the blocking with the command rfkill unblock wifi.

It's important to understand the difference between software and hardware locks. Software locks can be removed with a command, while hardware locks require a physical action—pressing a key on the laptop. Ignoring this point is a common cause of setup failures.

Using the iwctl utility (NetworkManager)

In modern distributions such as Ubuntu 20.04+, Fedora And Manjaro, the utility has become the de facto standard iwctlIt provides a simple interactive interface, similar to working with a regular shell, but specialized for WiFi.

Run the utility by entering in the terminal iwctlIf the system asks for a password, enter it. Inside the shell, commands become simpler and more understandable. First, check the status of the devices with the command device list.

⚠️ Attention: If the team iwctl not found, make sure the package is installed networkmanager And iwdIn some minimalist builds, they need to be installed separately via a live USB.

Next, you need to scan for available networks. Select your device and launch the scanner. You can then display a list of found access points and select the one you need.

[iwd]# device wlan0 scan

[iwd]# station wlan0 get-networks

Once the list appears, find your network's SSID. To connect, enter the command station wlan0 connect NetworkNameThe system will automatically prompt you for a password (Passphrase) if the network is secure. The password entry is hidden behind asterisks for security.

📊 Which Linux distribution do you use most often?
Ubuntu/Debian
Arch/Manjaro
Fedora/CentOS
Other (Gentoo, Slackware)

Classic method via wpa_supplicant

Utility wpa_supplicant This method has been a fundamental component of WiFi in Linux for many years. It works on virtually any distribution, including the oldest and most specialized embedded systems. This method requires creating a configuration file.

First, you need to generate a hashed password for your network so you don't have to store it in plaintext (although this isn't strictly necessary for a home network). Use the command wpa_passphrase "SSID" "password"The output will be a configuration block that you need to copy.

Create or edit a configuration file /etc/wpa_supplicant/wpa_supplicant.confPaste the generated block there. Make sure the file's permissions are restricted, as it contains sensitive data.

Parameter Description Example of meaning
ctrl_interface Path to the control socket DIR=/var/run/wpa_supplicant
update_config Allow config updates 1
ssid Wireless network name "Home_WiFi"
psk Password hash or password "complex_password_hash"

After configuring the file, you need to start the daemon. The command wpa_supplicant -B -i wlan0 -c /etc/wpa_supplicant/wpa_supplicant.conf will start the process in the background. Then you need to get the IP address via dhclient wlan0 or dhcpcd wlan0.

This method is good for its versatility, but is less convenient for frequently switching between networks, since it requires editing a text file each time.

Management via nmcli (Network Manager CLI)

For those who prefer power NetworkManager in text mode, there is a utility nmcliIt allows you to manage connections, devices, and even create new profiles without accessing the graphical shell. It's standard for most enterprise servers running RHEL and CentOS.

Unlike iwctlThere is no interactive mode by default; all commands are entered on one line. To see a list of available WiFi networks, enter nmcli device wifi listYou will see a table with the SSID, signal strength, and security status.

Connecting to the network is accomplished with a single, concise command combining the network name and password. This makes the method ideal for automation scripts.

nmcli device wifi connect "NetworkName" password "YourPassword"

If the connection is successful, NetworkManager will create a profile that will automatically activate when the network comes into range. You can manage profiles: delete old ones, change priorities, or edit DNS settings.

  • 📝 View all saved connections: nmcli connection show.
  • ❌ Deleting a profile: nmcli connection delete "ProfileName".
  • 🔄 Reconnect: nmcli connection up "ProfileName".

Peculiarity nmcli The key is that it works with "connections" rather than just devices. This allows for storing multiple configurations for a single physical adapter.

Troubleshooting drivers and modules

Often, the problem with WiFi is not a settings issue, but a missing driver. The Linux kernel contains many drivers, but some chips (especially Broadcom and Realtek) require proprietary firmware.

Check if the driver module is loaded using the command lsmod | grep -i wifi or by chip name. If the module is not found, try loading it manually via modprobe. For example, modprobe iwlwifi for Intel or modprobe b43 for old Broadcom.

⚠️ Note: Interfaces and package names may vary depending on the distribution version. Always consult the official documentation for your specific Linux environment before installing system packages.

If a driver requires firmware, the system usually writes about it in a log file. dmesgLook for lines with the word "firmware" or "failed." This will indicate the missing file. You can download it from the repository. linux-firmware and put in /lib/firmware.

In some cases, it may be necessary to disable power saving for the WiFi adapter, as aggressive settings can lead to connection drops or failure to turn on. This is done through kernel module parameters in the file /etc/modprobe.d/.

Setting up static IP and DNS

After successfully connecting to the access point, your computer receives an IP address automatically via DHCP. However, for servers or specific tasks, you may need to static IPThis provides a permanent address for remote access.

If you use NetworkManager (through nmcli), configuring a static address is done by modifying the connection profile. You need to specify the "manual" method, address, mask, gateway, and DNS servers.

For configuration via wpa_supplicant or iwctl A separate DHCP client daemon is often used, such as dhcpcd or systemd-networkd. IN systemd-networkd a file is created /etc/systemd/network/20-wireless.network, where the parameters are specified.

[Match]

Name=wlan0

[Network]

Address=192.168.1.100/24

Gateway=192.168.1.1

DNS=8.8.8.8

Using a public DNS such as Google (8.8.8.8) or Cloudflare (1.1.1.1) can speed up domain name resolution and improve security by preventing ISP DNS spoofing.

After making changes to the network daemon configuration files, you must restart the service or reconnect the interface for the new settings to take effect.

Checking the connection and diagnostics

The final step is to check the connection quality. Simply seeing the WiFi icon or "connected" status isn't enough. You need to ensure the channel is stable and the data transfer rate is fast.

Use the utility ping to check the availability of the gateway and external resources. The command ping -c 4 8.8.8.8 will send 4 packets to the Google server. Zero packet loss is a good sign.

For a more in-depth diagnosis of signal level and channel quality, use the command iwctl (station status) or iw dev wlan0 linkPay attention to the signal level, expressed in dBm. Values ​​closer to 0 (for example, -40 dBm) indicate an excellent signal, while values ​​below -80 dBm indicate a very weak signal.

  • 📉 Signal -30...-50 dBm: Ideal, you are close to the router.
  • 📶 Signal -60...-70 dBm: Good, stable connection.
  • ⚠️ Signal -80...-90 dBm: Unstable, interruptions are possible.

It is also useful to check your internet speed using console utilities, for example speedtest-cli, if installed. This will help understand the actual channel throughput under current conditions.

How to connect to a hidden network (Hidden SSID)?

To connect to a network that is not broadcasting its SSID, wpa_supplicant.conf you need to add a line scan_ssid=1 inside the network block. In nmcli the command will look like this: nmcli device wifi connect "SSID" password "PASS" hidden yesThis will force the adapter to actively search for a specific network.

What to do if you forgot your WiFi password in Linux?

If you've connected to the network before, the password is saved in the configuration. For NetworkManager, see the file in /etc/NetworkManager/system-connections/ (root privileges required). For wpa_supplicant - file /etc/wpa_supplicant/wpa_supplicant.conf. Look for the line psk="...".

Is it possible to share WiFi from a Linux laptop?

Yes, it's possible. NetworkManager has a hotspot creation feature. Via the console: nmcli device wifi hotspot ssid "MyHotspot" password "password123"The adapter must support Master mode (AP mode).