This is a definitive, automated installation script for Realtek RTW89 series Wi-Fi drivers, specifically optimized and tested for Kali Linux. The script was developed after extensive troubleshooting and combines all successful installation steps into a single, reliable solution.
The script automates the complete installation process:
- System Preparation: Updates Kali Linux and installs all required dependencies
- Source Download: Clones the latest RTW89 driver source code
- Intelligent Compilation: Automatically detects and patches known compilation errors
- Clean Installation: Performs manual driver installation to avoid installer bugs
- Bug Fixes: Corrects known driver filename issues
- Driver Activation: Loads and verifies the newly installed driver
This script supports Realtek RTW89 series Wi-Fi adapters, including:
- RTL8851BE (Primary target)
- RTL8852AE
- RTL8852BE
- RTL8852CE
- Other RTW89 series adapters
- Kali Linux (2023.x or newer recommended)
- Root/sudo access (required for driver installation)
- Active internet connection (for downloading dependencies and source code)
- Minimum 1GB free disk space
Before running the script, verify your Wi-Fi adapter:
lspci | grep -i wireless
# or
lsusb | grep -i realtek
# Navigate to your desired directory
cd ~/Downloads
# Download the script
wget https://raw.githubusercontent.com/Ns81000/Realtek-RTW89-Wi-Fi-Driver/main/install_wifi_final.sh
# Make it executable
chmod +x install_wifi_final.sh
# Clone the entire repository
git clone https://github.com/Ns81000/Realtek-RTW89-Wi-Fi-Driver.git
cd Realtek-RTW89-Wi-Fi-Driver
# Make the script executable
chmod +x install_wifi_final.sh
- Copy the script content from
install_wifi_final.sh
- Create a new file:
nano install_wifi_final.sh
- Paste the content and save
- Make executable:
chmod +x install_wifi_final.sh
# Run with sudo privileges
sudo ./install_wifi_final.sh
- Open Terminal in Kali Linux
- Navigate to the script directory:
cd /path/to/script/directory
- Execute the script:
sudo ./install_wifi_final.sh
- Follow the on-screen prompts
- Reboot when installation completes:
sudo reboot
- Updates package repositories
- Upgrades existing packages
- Installs build-essential, git, kernel headers
- Installs firmware-realtek package
- Removes any existing RTW89 directories
- Clones fresh source code from lwfinger/rtw89
- Prepares compilation environment
- Attempts initial compilation
- Auto-detects common compilation errors
- Automatically patches known issues in
mac80211.c
- Recompiles with fixes applied
- Creates proper system directories
- Copies compiled drivers to system location
- Fixes filename bugs (renames rtw_.ko to rtw89.ko)
- Updates module dependencies
- Loads the rtw89_8851be driver
- Verifies driver is active
- Provides success confirmation
- Error-Resilient: Continues execution even if intermediate steps fail
- Intelligent Patching: Automatically fixes known compilation issues
- Clean Installation: Bypasses problematic automated installers
- Comprehensive Logging: Color-coded output for easy troubleshooting
- Safety Checks: Validates root privileges and system compatibility
/lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw89/
βββ rtw89core.ko
βββ rtw89pci.ko
βββ rtw898851be.ko
βββ [other driver files]
The script automatically fixes this common compilation error:
// Original (causes error):
static void rtw89_ops_stop(struct ieee80211_hw *hw
// Patched (works correctly):
static void rtw89_ops_stop(struct ieee80211_hw *hw, bool changed)
Solution: Ensure you're running with sudo:
sudo ./install_wifi_final.sh
Solution: Update package lists and install missing dependencies:
sudo apt update
sudo apt install build-essential git
Solution: Free up disk space:
sudo apt autoremove
sudo apt autoclean
Solution: Install kernel headers for your specific kernel:
sudo apt install linux-headers-$(uname -r)
Solution:
- Reboot your system:
sudo reboot
- Check if firmware is properly installed:
sudo apt install firmware-realtek
- Verify driver is loaded:
lsmod | grep rtw89
Problem: Kernel updates remove custom-installed drivers as they're tied to specific kernel versions.
Solution: Reinstall the driver after any kernel update:
# 1. Remove old driver files
sudo rm -rf /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw89/
# 2. Run the installation script again
sudo ./install_wifi_final.sh
# 3. Reboot
sudo reboot
Prevention: After every apt upgrade
that includes kernel updates, remember to reinstall this driver.
# Check if driver is loaded
lsmod | grep rtw89
# Check Wi-Fi interfaces
ip link show
# Check NetworkManager status
systemctl status NetworkManager
# View kernel messages
dmesg | grep rtw89
- Reboot your system (highly recommended)
- Enable Wi-Fi in network settings
- Connect to your wireless network
Critical Notice for Dual Boot Users: If you're running Kali Linux in a dual boot configuration with another operating system (Windows, macOS, or another Linux distribution):
Before booting into Kali Linux:
- If you previously booted into your other operating system
- Completely shutdown your computer (don't use restart)
- Wait for 1 minute after shutdown
- Then boot into Kali Linux
Why this is necessary:
- Other operating systems may leave the Wi-Fi hardware in an inconsistent state
- A complete shutdown ensures proper hardware reset
- The 1-minute wait allows capacitors to discharge completely
- This prevents driver initialization conflicts
Symptoms if you skip this step:
- Wi-Fi adapter not detected
- Driver loads but no networks visible
- Intermittent connection issues
- Hardware appearing as "disabled" in system settings
apt upgrade
or apt dist-upgrade
), you must reinstall this driver. Kernel updates will remove the custom-installed Wi-Fi driver.
After kernel updates:
- Delete old driver:
sudo rm -rf /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw89/
- Run installation script again:
sudo ./install_wifi_final.sh
- Reboot:
sudo reboot
After reboot, verify installation:
# Check loaded modules
lsmod | grep rtw89
# Check available interfaces
iwconfig
# Test connectivity
ping -c 4 google.com
To remove the installed driver:
# Remove driver files
sudo rm -rf /lib/modules/$(uname -r)/kernel/drivers/net/wireless/realtek/rtw89/
# Update module dependencies
sudo depmod -a
# Reboot
sudo reboot
If you encounter problems:
- Run the script with verbose output
- Collect system information:
uname -a
andlspci
- Include full error messages
- Specify your Kali Linux version
- Kali Linux Documentation: kali.org/docs
- RTW89 Driver Source: lwfinger/rtw89
- Project Repository: Ns81000/Realtek-RTW89-Wi-Fi-Driver
- Kernel Headers: packages.debian.org
- Read this entire README
- Try the troubleshooting steps
- Check if your hardware is supported
- Verify you're using a supported Kali version
This script is provided as-is for educational and practical purposes. The underlying RTW89 driver source code follows its original license terms.
- Backup your system before running the script
- This script modifies system kernel modules
- Test in a virtual machine first if possible
- Use at your own risk on production systems
Made with β€οΈ for the Kali Linux community