I highly suggest you to install and use Windows Terminal that works with powershell, powershell core, command prompt, WSL, WSL2, …
Install WSL2 on Windows
Always check the latest Windows Subsystem for Linux Installation Guide for Windows 10
The new way
Starting from Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11, you can install wsl2 and ubuntu as default distro with just one command!!
The old way
- Open PowerShell as Administrator and run
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
- Now restart and update windows to get WSL2
- Running Windows 10, updated to version 1903 or higher, Build 18362 or higher for x64 systems.
- Running Windows 10, updated to version 2004 or higher, build 19041, for ARM64 systems.
- Please note if you are on Windows 10 version 1903 or 1909 you will need to ensure that you have the proper backport, instructions can be found here.
- Check your Windows version by selecting the Windows logo key + R, type winver, select OK. (Or enter the ver command in Windows Command Prompt). Please update to the latest Windows version if your build is lower than 18361. Get Windows Update Assistant.
- Enable the ‘Virtual Machine Platform’ optional component
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
- Install WSL2 Linux kernel update
- Restart and set WSL2 as your default version
wsl –set-default-version 2
If you see a message like
WSL 2 requires an update to its kernel componentfollow this link https://aka.ms/wsl2kernel and install the MSI from that page.
Install Kali Linux
- Install Kali Linux from Microsoft Store
- Run Kali Linux from start menu and configure it as requested
- Open again Kali Linux and install the desktop using win-kex
- sudo apt update && sudo apt full-upgrade -y
- sudo apt install kali-win-kex -y
- Now run kex and you’re ready to go
- kex (run a desktop and leave it running until you stop it)
- kex stop (to stop the current desktop)
- kex wtstart (to run a desktop connected to a windows terminal tab, when you close the tab the desktop will be killed, when you close the desktop, you can re-open it or kill)
- If you want a lot of more tool you can install the large edition of kali
- sudo apt install kali-linux-large
Move Kali to Different Hard Disk Drive
- wsl –terminate kali-linux
- wsl –export kali-linux “D:\kali-linux.tar”
- wsl –unregister kali-linux
- uninstall Kali Linux from start menu, right click, uninstall
- wsl –import kali-linux “D:\wsl\kali-linux” “D:\kali-linux.tar”
- wsl –set-default kali-linux
- open a terminal on kali
wsl -d kali-linux
- restores default user, creating this config file
sudo nano /etc/wsl.conf
- add the username you have configured the first time you installed kali linux before exporting it
- close the terminal
- wsl –terminate kali-linux
- reopen the terminal