Kali Linux on WSL2

Kali Linux with GUI (Kex, WinKex) on Windows using Windows Subsystem for Linux 2

Date : August 24, 2020.

Gone are the days when VMWARE, Virtual Box was the preferred choice to run Linux on Windows.

With Windows Subsystem on Linux (WSL), developers can take advantage without installing/buying external software.

What is WSL ?

The Windows Subsystem for Linux lets developers run a GNU/Linux environment -- including most command-line tools, utilities, and applications -- directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual boot setup.

What is New in WSL 2 ?

WSL 2 is a new version of the architecture in WSL that changes how Linux distributions interact with Windows. WSL 2 has the primary goals of increasing file system performance and adding full system call compatibility. Each Linux distribution can run as WSL 1 or as WSL 2, and can be switched between at any time. WSL 2 is a major overhaul of the underlying architecture and uses virtualization technology and a Linux kernel to enable its new features.

Now, you can even run with Linux GUI.

Below are the steps to install/upgrade Kali distro on WSL and run with UI.

Step 1: Check WSL2 minimum requirement

Windows 10 64 bit

Power shell command to check Windows version

[System.Environment]::Is64OperatingSystem

WSL 2 is only available in Windows Builds 18917 or higher.

Power shell command to check Windows version

[System.Environment]::OSVersion.Version

Step 2 :: Enable WSL from Powershell (run as administrator)

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Restart computer

Step 3 :: Enable the Virtual Machine Platform from Powershell (run as administrator)

dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart and

Step 4 :: Enable the WSL from Powershell (run as administrator)

dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 5 : Install WSL 2 Linux Kernel

Download and install kernel from site

https://docs.microsoft.com/en-us/windows/wsl/wsl2-kernel

Step 6: set WSL default version as 2 from Powershell (run as administrator)

wsl --set-default-version 2

Step 7: Install Kali Linux

Go to Microsoft store, search for Kali Linux and install it.

Once installation is complete, start it through start > Kali Linux or using Windows Terminal

Create login user and exit

Step 8: Check wsl for Kali Linux from Powershell (run as administrator)

wsl -l -v

In case it is version 1, use below command to set it to version 2

wsl --set-version kali-linux 2

Step 9: Update Linux from Linux console

Start Kali Linux and run command

sudo apt update

sudo apt dist-upgrade

Step10: Install win-kex from Linux console

Option 1:

sudo apt install kali-win-kex

This process might take 2-3 GB of HDD space and 2-3 hours for installation.

Option 2:

Complete Kali installation

sudo apt install kali-linux-large

This process might take 9-10 GB of HDD space and 4-5 hours for installation

Step 10: Start using GUI based Kali Linux

You can start Kali from start menu.

Run command kex to start the UI

Win-Kex does this by launching a VNCServer with the Xfce desktop environment within the Kali Linux WSL instance. It starts TigerVNC Windows client and automatically passes the commands to connect to the VNC server.

Get more information by using kex help

Personal experience, instead of using Windows Terminal, runs Kali from Start menu

Ref:

https://www.kali.org/docs/wsl/win-kex/

https://docs.microsoft.com/en-us/windows/wsl/