Windows 10 version 2004 and later include the enhanced Windows Subsystem for Linux 2 (WSL2). The enhanced WSL2 offers many enhancements over the original WSL including the ability to access a Linux GUI and it includes a full Linux kernel. Refer to our article on How To Enable WSL2 on Windows 10 to get started if you haven’t setup WSL2 yet. This is a prerequisite to this article. Once you have WSL2 installed, proceed to the following steps to install Kali Linux and Win-Kex.
Install and Setup Kali Linux
- Once you have WSL2 installed, head over to the Microsoft Store and install the latest version of Kali Linux
- Now that you have Kali Linux installed, run it for the first time
- You’ll be prompted to create a username and password
- Get the latest updates by running:
sudo apt update sudo apt full-upgrade
By default, the Windows Store version of Kali Linux is a minimum install. If you want to install most of the useful Kali tools, run:
sudo apt install -y kali-linux-large
Possible Errors
If you are not able to install Kali Linux from Microsoft Store and you’re getting the error 0x80073D05 try to restart your computer and try the installation again from the Microsoft Store.
If you are not able to install Kali Linux from the Microsoft Store and you get the WslRegisterDistribution failed with error 0x8007019e:
- Right-Click Start and go to Run
- Type appwiz.cpl and run
- Click on Turn Windows Features On or Off
- Check Windows Subsystem for Linux
- Restart your computer and try the installation again
Install Kali Win-Kex GUI
While in Kali, run:
sudo apt install -y kali-win-kex
Win-Kex supported three modes and you can try each one based on your needs:
Windowed Mode:
kex --win -s
Enhanced Session Mode (with sound support and an ARM workaround:
kex --esm --ip -s
Seamless Mode (with sound support):
kex --sl -s
Possible Errors
If you get the error “Failed to execute child process ‘dbus-launch’ (no such file or directory)” when trying to run Kali Linux Win-Kex, verify you have dbus-x11 installed by running:
sudo service xrdp stop sudo apt-get install dbus-x11 sudo service xrdp start
Then you might need to kill and restart win-kex
sudo kex stop sudo kex kill sudo kex --sl --wtstart -s
Windows Terminal
We highly recommend you use the Windows Terminal app from the Microsoft Store. This lets you have tabbed interfaces and can easily switch between Command Prompt, Powershell, Azure Cloud Shell and all of the various versions of Linux you have installed with WSL2.
- Click on the Down Arrow, then go to Settings
- Within the Profiles > Defaults > List brackets, you can add new profiles, including your new Kali Linux Win-Kex environment
- To add the windowed mode, add:
{ "guid": "{55ca431a-3a87-5fb3-83cd-11ececc031d2}", "hidden": false, "icon": "file:///c:/users/username/pictures/icons/kali-icon.png", "name": "Win-KeX", "commandline": "wsl -d kali-linux kex --wtstart -s", },
- To add the seamless mode, add:
{ "guid": "{55ca431b-3a87-5fb3-83cd-11ececc031d2}", "hidden": false, "icon": "file:///c:/users/username/pictures/icons/kali-icon.png", "name": "Win-KeX", "commandline": "wsl -d kali-linux kex --sl --wtstart -s", },
- To add the session mode, add:
{ "guid": "{55ca431c-3a87-5fb3-83cd-11ecedc031d2}", "hidden": false, "icon": "file:///c:/users/username/pictures/icons/kali-icon.png", "name": "Win-KeX", "commandline": "wsl -d kali-linux kex --esm --wtstart -s", },
- Save the file and restart the Windows Terminal app and you should see your new entries in the down arrow
You can download the Kali menu icon here and save it into the folder referenced in the “icon” entries above.
Shutting Down Kali Linux
To completely shutdown your WSL2 Kali Linux, you can run this command to view if a session is currently running:
wsl -l -v
Then you can run this command to terminate the session (replace “kali-linux” with the name of your linux instance):
wsl -t kali-linux
Final Thoughts
If you have any questions or issues running Kali Linux in WSL2, or using Win-Kex please leave a comment below.