Install Kali Linux Desktop on Windows 10 with WSL2
Linux in Windows 10 with Kali Linux Desktop – Win-KeX (“Windows Kali Desktop EXperience”), starting with feature update 2004, there is Win-KeX, an XFCE GUI on the Windows desktop.
Win-KeX provides a Kali Desktop Experience for Windows Subsystem for Linux (WSL 2) with the following features that support two dedicated modes.
Win-KeX window mode kex –win is the classic appearance in a window for the Kali Linux desktop.
Win-KeX SL mode kex –sl provides the seamless integration of Kali Linux into the Windows desktop with the Windows Start menu below and the Kali panel at the top of the screen. All applications start in their own windows that use the same desktop as Windows applications.
Win-KeX Features
Win-KeX SL Seamless
Sound support
Support multiple sessions
Run Win-KeX as root
Shared clipboard cut and paste content between Kali and Windows Apps
Installation
PowerShell as an administrator and run the command.
1 2 |
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux |
Restart the computer.
Run the rows from PowerShell as an administrator.
1 2 3 |
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart dism.exe /online /enable-feature /featurename:Microsoft Windows subsystem Linux /all /norestart |
Restart the computer.
Then download Windows Subsystem for Linux 2 (WSL 2) and run the Update Setup Wizard. Download the latest package here and choose WSL2 Linux kernel update package for x64 machine.
Run again from the PowerShell as an administrator.
1 2 |
wsl --set-default-version 2 |
Install Kali Linux from the Microsoft Store.
Kali Linux is a Debian-based Linux distribution that mainly includes penetration testing and digital forensics. Kali Linux is primarily aimed at professional and advanced users.
Now complete the initial setup and start Kali Linux.
Install Win-KeX
Win-KeX from the terminal as follows.
1 2 |
sudo apt update && sudo apt install -y kali-win-kex |
Start Win-KeX
Win-KeX can be run in window mode or Seamless mode. Win-KeX in window mode as follows.
1 2 |
kex --win |
Start Win-KeX in Seamless – Sameless mode.
1 2 |
kex --sl |
Win-KeX Start Examples
1 2 3 4 5 6 7 |
kex - Desktop full screen kex --win - Desktop Window kex --sl - Desktop Seamless Mode kex --sl -s - Desktop Seamless Mode with Sound kex --sl --wtstart - KeX server and win-kex client in terminal kex --esm - KeX desktop in native RDP windows |
Prerequisite for Win-KeX
The Visual C++ Redistributable packages are required to run Win-KeX, if not already installed, the packages can be downloaded here. Install the Universal C Runtime x86 (vc_redist.x86.exe) and x64 (vc_redist.x64.exe). Kali Linux requires Windows 10 version 2004 or later, and the Windows subsystem for Linux – WSL 2.
To use Win-KeX, a computer with Intel virtualization function VT-x is required. The BIOS provides the operating system with the virtualization function, for which you activate the Intel (R) Virtualization Technology in the UEFI BIOS settings.
Linux Shell in Windows Terminal
Also now is a good time to mention the Windows Terminal, if not already installed, it is worth doing it now.
Windows Terminal can be installed from the Windows Store.
Windows Terminal is a multi-tabbed command-line frontend for Windows 10. The shell of Kali Linux – ZSH can be used with Windows Terminal.
Kali Linux Sources Link kali.org
Troubleshooting
If VcXsrv is trying to start Win-KeX in Seamless Mode, an error is issued by VcXsrv:
A fatal error has occurred and VcXsrv will now exit.
In the log, it’s the last lines in /tmp/win kexsl_user.log:
1 2 3 4 5 |
winMultiWindowXMsgProc - Fatal error 1 on xcb connection winClipboardIOErrorHandler! winClipboardProc - setjmp returned for IO Error Handler. (II) Server terminated successfully (0). Closing log file. |
here you can try to start Win-KeX with sudo:
1 2 |
sudo kex --sl --wtstart -s |
A solution also brought the deletion of the logs under /tmp.
1 2 |
sudo rm -f /tmp/*.log |
And stop the KeX server with the –stop and –kill option.
1 2 3 |
sudo kex --stop sudo kex --kill |
After that, the start of kex as a normal user became possible.
1 2 |
kex --sl --wtstart -s |
Also, a Win-KeX reinstallation can fix the error:
1 2 3 4 5 6 |
sudo kex --stop sudo kex --kill sudo apt-get purge kali-win-kex sudo apt-get install kali-win-kex sudo apt-get install dbus-x11 |
The Win-KeX help can also be useful.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
kex --help Win-Kex 2.5 provides a GUI desktop experience for Kali Linux in Windows Subsystem for Linux 2 (WSL 2) Usage: kex <mode> <command> <parameters> Fashion: --esm : Launch KeX desktop in a dedicated window using Windows native RDP --sl : Seemlessly integrate KeX into the Windows desktop --win : Launch KeX desktop in a dedicated window Command: [none] : start KeX server and launch KeX client --start : start kex server --start-client : start kex client --stop : stop kex server --status : show kex server status --kill : stop kex server and kill all related processes --passwd : set kex server password --wtstart : start kex server and launch win-kex client in Windows Terminal session --start-sound : start Windows sound server --stop-sound : stop Windows sound server --help : display help --version : display version Parameter: -i : Use container IP address instead of "localhost" -m : Optimized for Multiscreen (Win mode only) -s : Sound support Examples: kex -s : Start KeX server in window mode and launch KeX client with sound support kex --sl -s : Start KeX in seemless mode and launch KeX client with sound support sudo kex : Start KeX server as root in window mode and launch KeX client</parameters></command></mode> |