How to set up Kali Linux with GUI on WSL2 (Windows 11)
This article is a quick guide to setting up Kali Linux on Windows 11 with WSL2
What is WSL (Windows Subsystem for Linux)?
Windows Subsystem for Linux (WSL) is a feature of Windows that allows you to run a Linux environment on your Windows machine, without the need for a separate virtual machine or dual booting. WSL is designed to provide a seamless and productive experience for developers who want to use both Windows and Linux at the same time.WSL 2 is the default distro type when installing a Linux distribution. WSL 2 uses virtualization technology to run a Linux kernel inside of a lightweight utility virtual machine (VM). Linux distributions run as isolated containers inside of the WSL 2 managed VM. Linux distributions running via WSL 2 will share the same network namespace, device tree (other than
/dev/pts
), CPU/Kernel/Memory/Swap, /init
binary, but have their own PID namespace, Mount namespace, User namespace, Cgroup namespace, and init
process. WSL 2 increases file system performance and adds full system call compatibility in comparison to the WSL 1 architecture. Learn more about how WSL 1 and WSL 2 compare.
Individual Linux distributions can be run with either the WSL 1 or WSL 2 architecture. Each distribution can be upgraded or downgraded at any time and you can run WSL 1 and WSL 2 distributions side by side. See the Set WSL version command. (source: learn.microsoft.com)
Step 1: Make sure Virtualization is enabled
Before we begin setting up WSL, we first need to make sure Virtualization is enabled from BIOS/UEFI settings. If you are not sure how to enable this, I would recommend to do a google-search specifically for your computer as accessing the BIOS/UEFI settings varies for different computers.Step 2: Setting up WSL
First we need to run the command prompt (CMD) as Administrator. Once inside the CMD, we will run the command --install
then hit enter.Once WSL is installed, we will need to do a system reboot. After the reboot, a terminal will open with a prompt to continue the installation for Ubuntu which is the default OS that gets downloaded with the WSL installation. When the Ubuntu installation is finished, we will then be able to install the Kali Linux OS for WSL2 and set up a graphical user interface (GUI).
During the installation, we will be prompted to set up a username and password for the Ubuntu OS. Once everything is set up, we should see the Ubuntu terminal with the username we set up earlier. We can now go ahead and close that terminal.
When we install operating systems with WSL, they will show up in the Windows Start Menu as regular apps. That is one way to boot straight into the desired OS's terminal without having to run any WSL commands on Windows CMD. Even though there is a GUI for Ubuntu on WSL2 on Windows 11, in this guide we will only focus on the Kali Linux installation and GUI set-up.
Step 3: Installing Kali Linux in WSL
Normally for installing any Linux Distributions under WSL, we would run the CMD and use the commandswsl --list --online
(to list the available distributions) and then wsl --install -d {distribution-name}
to install the desired OS. However, for Kali Linux specifically it is recommended to install via the Microsoft Store as the installation available under the WSL options is not the current one and would cause major problems after the installation (at least at the time of writing this article).
From the Windows Start Menu, we can type "store" and click on the Microsoft Store app. Once in the store app, we can search for Kali Linux and install it this way. Once the Kali Linux app is downloaded we can find it in the Windows Start menu and click on it to continue the installation. Similarly to setting up the Ubuntu OS, we will be prompted to type in a username and password for the Kali Linux.
When the installation is finished, we are in the Kali terminal and ready to start setting up the GUI.
Step 4: Setting up GUI for Kali Linux
As with any fresh installation of an OS, the first thing we would want to do is update and upgrade the packages to their latest version. For this we can run the combined commandsudo apt update ; sudo apt upgrade ; sudo apt autoremove
. When the updates are finished, we can go ahead and install the kex tool which will enable us to run Kali with a GUI. To install kex, we can run the command sudo apt install kali-win-kex -y
. During the kex installation we will be prompted to chose a language for the GUI, we can select English and continue the installation. Finally, once the kex installation is complete, we can now boot into the Kali machine using the GUI. In order to do this, we need to run the following command into our Kali terminal (if we want to have working audio with the kex GUI, the
-s
parameter needs to be added at the end of the command). kex --win
The first time the kex command is used on the kali terminal, we will be prompted to set up a password. To avoid confusion between the Kali password and the kex password, we can set up the same one as long as it is a long and secure password. Once the GUI has started, we can exit the Kali terminal by closing it down or typing
exit
. There are two other modes for the kex GUI which you can view and try via the kex -h
command. Personally, I prefer the windowed mode which is also the default mode when starting kex. Lastly, by pressing
F8
while the mouse is hovering over the Kali screen, we get a menu from which we can enter Full-Screen mode as well as a few other options such as the button to disconnect and have the GUI close down.
Extra Information about WSL
When we install any apps on our WSL Distributions, they will show up in the Windows Start Menu and can be ran directly without needing to access the OS's terminal or GUI.In our Widows Folder Browser, now we have a new directory for all the Linux distributions that we have installed under the "My PC" and "Network" directories on the bottom of the left panel. Through there we can access directly the folders of the desired OS and copy files across Linux and Windows seamlessly.
Similarly, with WSL installations, we can now access our
C
drive (and any other drive) directly from within the OS without the need to initiate SSH connections as we would normally do when working with a VM. The C
drive can be found in the root directory within the folder mnt
. Resources:
Information on WSL and WSL2 from the Microsoft website.What is the Windows Subsystem for Linux?
Video tutorials on setting up Ubuntu and Kali on WSL2 by NetworkChuck
Kali Linux APPS on Windows in 5min (WSLg)
Linux on Windows......Windows on Linux