Installing and configuring a USB WiFi adapter on Linux

Transition to an operating system Linux Often encounters the problem of no wireless connection immediately after installing a distribution. Unlike Windows, where drivers are often built into the system or downloaded automatically, in a Linux environment you may need to manually configure your hardware. This is especially true for external devices. USB WiFi adapters, which may be based on chipsets not supported by the kernel by default.

The situation is aggravated by the fact that without network access it is impossible to download the necessary packages to launch the Wi-Fi module itself. Realtek, MediaTek Other manufacturers sometimes don't provide open-source drivers in their repositories. However, knowing the exact chipset model and having basic terminal skills, you can activate your internet connection in just a few minutes.

In this article, we'll cover the process of device identification, searching for up-to-date drivers, and compiling them. You'll learn how to bypass closed-loop restrictions and ensure stable network operation. The key is to not panic when you see a black terminal screen, as it's a powerful tool for managing your system.

Adapter chipset identification

The first and most critical step is to determine the exact chipset model installed inside your USB device. The name on the adapter housing (e.g., TP-Link Archer T2U) often says nothing about the internals, since the manufacturer can change components in different revisions. For Linux, it's the Device ID and the controller model.

Connect the adapter to a USB port and open a terminal. Enter the command lsusb, which will list all connected USB devices. Find the line corresponding to your adapter in the list and note the identifiers Vendor ID And Product ID. The command will also be useful lshw -C network, which will show more detailed information about network interfaces, including the driver status (marked as UNCLAIMED, if the driver is not installed).

⚠️ Attention: If the command output lsusb If the device is shown as "Realtek 802.11n WLAN Adapter" without a specific ID, this may mean that the adapter has entered reset mode or requires a mode switch via usb_modeswitch.

Write down the received data, since it is based on the chipset model (for example, RTL8812AU, MT7610U) you'll be looking for the driver source code. It often happens that different versions of the same adapter have different chipsets, so blindly installing the driver "by model name" can lead to compilation errors or malfunction.

📊 What chipset does your adapter have?
Realtek
MediaTek
Ralink
Atheros
Don't know

Preparing the system and installing dependencies

Before you begin compiling or installing drivers, you need to make sure that all the necessary build tools are installed on your system. On Debian/Ubuntu-based distributions (such as Mint, Kali, Zorin) for this you will need a package build-essential, which contains the GCC compiler and other utilities. Without them, the driver installation process will be impossible.

Also critically important is the presence of kernel header files (linux-headers) that match your current kernel version. If the versions don't match, the module won't be able to integrate into the system. To install the basic toolchain on Debian-like systems, use the command:

sudo apt update

sudo apt install build-essential git dkms linux-headers-$(uname -r)

For distributions based on Red Hat (Fedora, CentOS, RHEL) the commands will differ. You need to use a package manager here. dnf or yumMake sure you're connected to the internet via an Ethernet cable or share your internet connection from your smartphone via a USB modem (RNDIS mode), as WiFi isn't working yet.

☑️ Preparing the environment

Completed: 0 / 1

After installing the packages, it's recommended to reboot the system to ensure the new kernel headers are correctly picked up. This will prevent potential errors when building modules in the next step.

Finding and installing drivers for Realtek

Chipsets from the company Realtek are the most common in budget USB adapters, but also the most problematic in terms of support on Linux. Official drivers are often missing from the main repository, so third-party, but trusted, repositories on GitHub are used. The most popular and stable source is the repository rtl88xxau-aircrack-ng or rtl8812au from Morris.

The installation process typically involves cloning the repository, building the module, and registering it in the system. Below is a general procedure for most Realtek adapters:

  • 📂 Clone the driver repository: git clone https://github.com/aircrack-ng/rtl8812au.git
  • 📂 Go to the driver folder: cd rtl8812au
  • 🔨 Run the installation: sudo ./dkms-install.sh

Script dkms-install.sh automatically compiles the module for the current kernel version and registers it in the kernel's dynamic module support system (DKMS). This ensures that when the Linux kernel is updated, the driver will be rebuilt automatically, and you won't have to repeat the procedure manually.

What to do if the installation script is not found?

Some older driver versions may not have the ./dkms-install.sh script. In this case, use the sudo make install command, but you'll have to reinstall the driver when updating the kernel.

If your adapter is based on the newer 8814 or 8822 series chipsets, the process may differ. Always check README.md The file is in the repository, as it contains specific commands for specific models. Selecting the wrong repository will result in the module simply not loading.

Chip-based devices MediaTek (formerly Ralink) often have better support in the Linux kernel out of the box, but older models or specific features (such as access point mode) may require package installation. firmware-misc-nonfree (in Debian/Ubuntu) or linux-firmwareThese packages contain binary firmware files required for the hardware to operate.

To install firmware on Debian/Ubuntu, run:

sudo apt install firmware-misc-nonfree

On Fedora/CentOS the command will look like this:

sudo dnf install linux-firmware

After installing the packages, you need to run the command sudo modprobe mt7601u (or another one that matches your model, for example rt2800usb) to force the module to load. If a list of networks appears in the upper right corner, the driver is working. In some cases, you may need to disable Secure Boot in the BIOS, as it can block third-party kernel modules from loading.

⚠️ Note: MediaTek modules often conflict with built-in kernel modules. If the system no longer recognizes the adapter after installing the drivers, try removing the built-in module with the command sudo rmmod mt7601u before loading a new one.

A tool is available for advanced users. mt76, which is a modern driver for MediaTek chips. It provides better stability and support for new WiFi standards, but requires a more recent Linux kernel (version 4.19 or higher).

Troubleshooting connection and DKMS issues

Even after successful compilation, situations may arise where the system doesn't detect wireless networks. Often, the problem lies in the module being loaded, but the network interface being blocked or not enabled. Use the command ip link to check the status of interfaces. If the interface (usually wlan0 or wlp...) marked as DOWN, raise it with the command sudo ip link set wlan0 up.

Technology DKMS (Dynamic Kernel Module Support) plays a key role in driver support. It allows modules to be rebuilt automatically when the kernel is updated. To check the DKMS status, use the command dkms statusIf your driver is not on the list, it will not survive the system update.

The table below lists common chipsets and their corresponding packages or repositories:

Chipset Typical device Repository/Package Support status
RTL8812AU TP-Link Archer T4U aircrack-ng/rtl8812au Stable
RTL8821AU TP-Link Archer T2U morrownr/8821au-20210702 Stable
MT7610U TP-Link Archer T2U Nano linux-firmware In the core
RTL8188EU TP-Link TL-WN722N v2/v3 aircrack-ng/rtl8188eu Requires a patch

It is also worth checking whether the utility is blocking the network. rfkillEnter . rfkill listIf you see the status Soft blocked: yes, unlock the adapter with the command sudo rfkill unblock wifiThis is a common problem after an improper shutdown of the laptop.

Diagnostics and stability testing

After setting up, you need to make sure the connection is stable. Use the utility iwconfig or iw dev to view signal quality and noise levels. Pay attention to the parameter Link Quality And Signal levelIf the signal is weak (-80 dBm or lower), try repositioning the adapter or using a USB extension cable, as metal PC cases can shield the signal.

To monitor the data transfer process in real time, use the command watch -n 1 iw dev wlan0 link. It will show the current connection speed (tx bitrate) and signal strength. If the speed fluctuates constantly, there may be interference from neighboring networks or microwave ovens.

⚠️ Caution: Some USB ports (especially USB 3.0) can interfere with the 2.4 GHz band. If you're using a dual-band adapter, try connecting it to a USB 2.0 port or use an extension cable to move the antenna away from the computer case.

Checking system logs via dmesg | grep firmware or journalctl -k This will help identify hidden driver loading errors. If you see messages about CRC errors or timeouts, this may indicate a faulty USB device or a power shortage.

FAQ: Frequently Asked Questions

Why did WiFi stop working after updating the Linux kernel?

This happens if the driver was installed manually without using DKMS. When updating the kernel, the old module becomes incompatible with the new kernel version. Solution: Reinstall the driver or make sure you're using a repository that supports DKMS.

How do I know if my adapter supports Monitor Mode?

Use the command iw listIn the output, find the "Supported interface modes" section. If the word "monitor" appears there, the chipset and driver support this mode. This is important for security professionals.

Is it possible to install a driver without internet access?

Yes, but it's more complicated. You'll need to download the driver source code and all dependencies (.deb or .rpm archives) on another computer with internet access, transfer them to the Linux machine via a flash drive, and install them locally using the command dpkg -i or similar.

Why is my Realtek 8812au adapter running slow?

Often, the problem is that the wrong driver is loaded (for example, rtl8821au instead of 8812au) or the driver doesn't support 80 MHz channel width. Try different repositories, such as morrownr's, which are optimized for speed.