One of the best features that Windows 10 has been able to include has been the Windows Subsystem for Linux, or WSL. Thanks to it, it is possible to install, almost natively, any Linux system and use its programs and tools from CMD or PowerShell, as if we were doing it from a real Linux terminal. In addition, there are even projects that seek to bring us a graphical interface, such as Win-KeX from Kali Linux, which allows us to run the programs, with their GUI, as if they were more Windows windows.
Kali Linux is one of the most complete ethical hacking distributions that we can find. This distro is based on Debian and brings to all users a large collection of ethical and security hacking programs with which to carry out all kinds of security tests and audits.
The usual thing is to have Kali Linux installed on a computer, or carry it on a USB memory to load it when we need to use it. We can even have it in a virtual machine ready to start it when we need to make use of it. However, thanks to the Windows Subsystem for Linux, we can give a twist to the way of using Kali, being able to have all its tools always at hand thanks to WSL.
What does Kali Linux offer us on Windows and what do we need?
Kali Linux on WSL can work in three ways. The first one is the classic one, that is, accessing all its tools and programs from Bash with CMD. The second is Window Mode, which allows us to run a Kali Linux graphical interface in a new window, like a virtual machine. And the third, and more interesting, is Seamless Mode, a mode that places the Kali taskbar at the top of our desktop and allows us to open programs in windows that run alongside those of our main Windows.
In addition to those three modes of operation, Kali Linux on Windows 10 also supports sound, has a root session, and supports multiple user sessions at the same time. It even allows us to share the clipboard when copying and pasting between Windows and Kali applications.
In order to use it, all we will need is to have the 2004 version of Windows 10 (or later) installed on our computer. We will explain how to enable WSL (if we don’t already have it) and how to get everything else up and running.
We can do everything from CMD or from PowerShell, although we recommend installing Windows Terminal, since it is much faster and more convenient to use.
Get started: activate and configure the Windows Subsystem for Linux
The first thing we have to do is activate WSL in Windows 10. As it is an optional feature, it is disabled by default. Therefore, we must activate it, together with Hyper-V and the virtualization functions of our CPU, before we can install this distro on it.
There are several ways to do this. One of them is to do it from the section to add or remove optional Windows features, and the other from the terminal. We are going to see this second method, which is faster. To do this, we will open a PowerShell window, with Administrator permissions, and we will execute the following command in it:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
We restart the computer, and when we are back at the desktop, we reopen the CMD window with Administrator permissions to execute the following two commands:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Now we restart the computer again, and we have almost everything ready. Before continuing, the next step will be to manually update the Linux Kernel (necessary to be able to use WSL2), which we can download from this web page.
Now we only have to activate WSL2 by default for the Linux instances that we enable. We can easily do this by running the following command, again, in a PowerShell window.
wsl --set-default-version 2
And ready. We already have WSL 2 ready to install Kali Linux.
Install Kali Linux on Windows 10
We already have our Windows ready to be able to install distros on it through WSL. Therefore, the next step will be to download the distro from the Microsoft Store.
Once installed, we execute it and we will have to complete, first of all, the initial configuration wizard. This wizard may take a few minutes to complete, and during it we will have to enter the session data (username and password) and that’s it.
When the configuration process is finished we will be able to see a bash terminal. Everything is ready. Or almost everything.
Prepare to use Kali graphical mode in Windows 10
The first thing we should do once we have the distro installed and ready is to update it. To do this, we will simply execute the following command in bash that will be in charge of updating the software lists and, incidentally, downloading all the available updates.
sudo apt update && sudo apt upgrade
Now, the next step will be to install Win-KeX. This is the tool that will allow us to run a graphical environment above WSL to be able to use Kali as if we were using it on a real PC. To do this, we will execute the following command.
sudo apt update && sudo apt install kali-win-kex
WSL will take care of downloading all the necessary packages, installing them and configuring them. The process may take a while, and all this will occupy about 2 GB of space on our computer.
When it’s over, we’ll have everything ready. We can now start using Kali in graphical mode in Windows 10.
How to use Linux in graphical mode on Windows
Open Kali in windowed mode
In windowed mode, Kali will run her desktop within a single window. All Linux will be isolated (in terms of elements) from Windows windows and elements. It is the closest way to mounting it in a virtual machine.
To open it in this mode, the command we must execute is:
kex --win -s
We can open the options menu in this way with the F8 key.
Open Kali in Seamless mode
If what we want is to see the Kali windows as if they were Windows windows on the desktop, and their bar at the top, then the command that we must execute in the terminal is the following:
kex --sl -s
In this way we can use Linux and Windows applications at the same time on a single desktop. Two operating systems in one!
Don’t use WSL anymore? Uninstall Linux
If we have already tired of using this distro on Windows 10, and we want to free up the space it occupies (which is not little), what we can do is uninstall the distro. Just as we have downloaded it as if it were just another app, from the Microsoft Store, we can delete it from the PC like any other program.
Kali Linux will appear among the applications installed in Windows in the Settings> Applications section. All you have to do is select it, choose the option to uninstall it, and voila. In just a few moments we will have our system erased from the PC, with the space it occupied free.
And if we want to use it again later, we can install it again without problems, although, yes, we will have to configure it again.