Kali Linux on WSL2 Installation and Simple Configuration Guide
After Windows was updated to version 2004, it officially enabled WSL2 support. This time it's a complete Linux system running in a Hyper-V virtual machine, which can be called a real Linux. Could it be that Windows is about to become the best Linux distro? The actual experience is pretty decent, though there are quite a few minor issues. If you like tinkering, give it a shot—it still helps a lot with improving the development experience on the Windows platform~ Kali on WSL2 Installation Guide Upgrade the System First check your current system version. Press Win+
目录15 个章节

After Windows was updated to version 2004, it officially enabled WSL2 support. This time it's a complete Linux system running in a Hyper-V virtual machine, which can be called a real Linux. Could it be that Windows is about to become the best Linux distro?
The actual experience is pretty decent, though there are quite a few minor issues. If you like tinkering, give it a shot—it still helps a lot with improving the development experience on the Windows platform~
Kali on WSL2 Installation Guide
Upgrade the System
First check your current system version. Press Win+R, type winver, and you can see the current system version:

If it's not version 2004, you need to upgrade the system to version 2004. Microsoft says there is a push update, but it's hit or miss. If you can't find the update, please download the official “Update Assistant” (易升) tool yourself to check for updates.
Enable the Linux Subsystem
After upgrading to version 2004, you can start installing the system. If the Linux subsystem is not enabled, you need to enable it first.
PS: Since WSL2 uses a Hyper-V virtual machine, enabling it will conflict with VMware and VirtualBox. This can be resolved by upgrading VMware and VirtualBox to versions that support Hyper-V.
Open PowerShell with administrator privileges and enter the following command to enable the Linux subsystem:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
A restart is required afterward.
Enable Virtualization
Open PowerShell with administrator privileges and enter the following commands:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Restart the system
Download the WSL2 Linux Kernel
Download link: https://aka.ms/wsl2kernel
Install it after downloading.
Set the Default Subsystem Version to WSL2
Open PowerShell with administrator privileges and enter the following command:
wsl --set-default-version 2
Install Kali Linux
Open the Microsoft Store, search for and install Kali Linux.

After installation, choose “Launch”, and it will start extracting and installing. Then enter a username and password and you're done.
Upgrade an Existing System to WSL2
If you already have WSL installed, you can upgrade it directly to WSL2.
Open PowerShell with administrator privileges and enter the following command:
wsl --set-version kali-linux 2
Install the Win-Kex Toolkit
The Win-Kex toolkit is a graphical toolkit provided by Kali for running on Windows. It lets you run a GUI in WSL in a one-click, foolproof way.
Enter the following command in the Kali command line to install:
sudo apt update && sudo apt install kali-win-kex
After installation, you can start the graphical interface with the following commands:
cd ~
kex
The first time you start it, you'll be asked to enter a new password. This password is saved as the kex password.
Note that you need to switch the current directory to the home directory before starting kex, otherwise it won't be able to get the key.
Simple Configuration
Install Kali Linux Toolkits
- Install the standard toolkit
sudo apt install kali-linux-default
- Install the large toolkit (about 7–8 GB)
sudo apt install kali-linux-large
Configure a Windows Terminal Shortcut

Opening it from the command line every time is too much hassle. You can configure a shortcut in Windows Terminal, and next time you can open Kex's graphical interface from this dropdown menu.
Open the Windows Terminal configuration file and add the following configuration items:
{
"guid": "{55ca431a-3a87-5fb3-83cd-11ececc031d2}",
"hidden": false,
"name": "Win-KeX",
"commandline": "wsl kex wtstart",
},
{
"guid": "{55ca431a-3a87-5fb3-83cd-11ececc031d2}",
"hidden": false,
"icon": "file:///c:/users/<windows user>/pictures/icons/kali-menu.png",
"name": "Win-KeX",
"commandline": "wsl kex wtstart",
"startingDirectory" : "//wsl$/kali-linux/home/<kali user>"
},
After that, click the “Win-Kex” menu item to launch the graphical interface directly.


PS: After entering the fullscreen graphical interface, press F8 to open the context menu.
Fix the Unable to Connect to the Network Issue
- Create a file: /etc/wsl.conf.
- Put the following lines in the file
[network]
generateResolvConf = false
- In a cmd window, run wsl --shutdown
- Restart WSL2
- Create a file: /etc/resolv.conf. If it exists, replace existing one with this new file.
- Put the following lines in the file
nameserver 8.8.8.8
Repeat step 3 and 4. You will see git working fine now.
- Repeat step 3 and 4. You will see git working fine now.
Referenced from: https://github.com/microsoft/WSL/issues/4285
Fix the kex Unable to Start Issue
The error message is as follows:
unable to connect to socket: No connection could be made because the target machine actively refused it. (10061)
The Chinese prompt is something like the remote host actively refused
The solution is to run kex stop in bash, then restart kex.
Reference: https://unix.stackexchange.com/questions/605309/not-able-to-initialize-gui-for-kali-linux-in-wsl-2
References
_EOF_
Kali Linux on WSL2 Installation and Simple Configuration Guide
- 本文作者:
- 程序设计实验室
- 版权声明:
- 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
相关文章
使用EarTrumpet代替windows默认的音量调节功能
Windows 默认的音量调节功能挺弱的,要分别调节各个应用的音量得进入二级菜单,麻烦得很。有了这个功能就很方便了
2025-01-26 · Windows · 约 1 分钟
2024年,提升Windows开发和使用体验实践 - 终端&命令行篇
哼,Windows终端重灾区?用scoop装软件,Starship美化,但WinSW自启还是垃圾。啧,又一个scoop-search替代原版,gow补齐Unix工具,gsudo模拟sudo,但proxychains有点奇怪。哦,blessed-contrib仪表盘?只是好玩罢了,不如用erdtree看目录。
2024-03-05 · Windows · 约 1 分钟
Windows设置Pageant开机自动启动并且加载秘钥
场景 用Linux的时候ssh和git这些很方便,因为只要一次ssh-add就可以一劳永逸,以后需要认证的时候ssh-agent会帮我们搞定,不需要输入秘钥的密码。 其实Windows也可以实现这种生产力解放,就是用putty附带的工具里的Pageant。 Pageant主要负责和服务器端进行身份验证,但是每次在启动Pageant后都需要手动的加载秘钥文件,本文就是要介绍让Pageant开机自动加
2021-12-18 · Windows · 约 1 分钟
Win10的Linux子系统也能运行图形程序
前言 之前写了一篇在Win10中安装Linux子系统的文章,虽然Linux子系统既实用又方便,不过有些同学可能会觉得只有命令行挺无聊的,所以今天分享一个运行图形程序的方法,经过试用效果还是不错的。 本文将带领你一步一步在Win10的子系统里安装运行Gimp(PS:Gimp是Linux上的PS,功能还是灰常强大滴),还有其他一些Linux的图形化软件。 准备工作 Linux子系统必备的哈,这个不用多
2021-12-18 · Windows · 约 1 分钟
讨论
共 0 条加载评论中…