How to use Kali Linux in Windows with WSL 2?
Last Updated :
18 Sep, 2020
The Windows Subsystem for Linux lets developers run a GNU/Linux environment including most command-line tools, etc. direct on Windows, unmodified, without the overhead of an ordinary virtual machine or dual-boot system.
Uses of WSL:
- Pick your preferred GNU/Linux distributions from the Microsoft Store.
- Run basic command-line tools, for example, grep, sed, awk, or other ELF-64 doubles.
- Run Bash shell and GNU/Linux command-line applications like tmux, emacs, SSHD, MySQL, and also could use the language compilers.
- Summon Windows applications utilizing a Unix-like command-line shell.
- Summon GNU/Linux applications on Windows.
WSL 2
WSL 2 is another form of the Windows Subsystem for Linux engineering that controls the Windows Subsystem for Linux to run ELF64 Linux binaries on Windows. Its essential objectives are to build file system execution, just as including full framework call compatibility. This new design changes how these Linux binaries associate with Windows and your PC’s equipment, yet at the same time gives a similar client experience as in WSL 1 (the current broadly accessible version).
Requirements For WSL 2:
- WSL 2 is only accessible in Windows 10, Version 1903, Build 18362, or higher.
- On the off chance that you are on Windows 10 form 1903 or 1909 ensure your minor build number is 1049 or higher.
- Running Windows 10, refreshed to version 2004 or higher, version 19041, for ARM64 systems.
- WSL 2 will work with VMWare 15.5.5+ and VirtualBox 6+.
Verifying the System Compatibility:
Step 1: Hold on the Windows logo key (on the keyboard) + R to open the run dialogue, and then type in the following command and select OK.
winver

Step 2: If your OS builds version is not compatible, then we have to update the Windows.
Step 3: For updating, Click on the Windows logo in the bottom left corner of your screen and then type in the following command and press enter:
check for updates
Step 4: Now, select the “Check for updates” option from the menu listed, and then a dialog box will appear.

Step 5: Click on the “Check for Updates” button on the screen, and after successful completion of the update, “restart” your machine. But, if you don’t get any information regarding the update then, after doing a restart/s you will be prompted an update.
Setting up WSL:
Step 1: Click on the Windows logo in the bottom left corner of your screen and then type in the following command:
powershell
Now, when the list appears in the menu, Right-Click on the “Windows Power Shell” option and chooses “Run as administrator”.

Step 2: Now, once the Power Shell is opened and ready to use, type the following command and hit enter:
Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

Step 3: Restart your machine.
Step 4: After the restart, again run the “Windows PowerShell” in the administrator mode, and then type in the following command:
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart

Step 5: Now, type in the next command:
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart

Step 6: Now, again restart your machine.
Step 7: In order to update the kernel packages visit https://aka.ms/wsl2kernel, download the kernel package and install the same.
Step 8: In order to activate WSL 2 execute the following command in Windows Powershell running the same in administrator mode.
wsl --set-default-version 2
Installing and Setting up Kali Linux CLI:
Step 1: Hit the Windows logo button on your keyboard, and then type in the following command and then, choose the “Microsoft Store” option from the menu.
microsoft store
Step 2: Once the Microsoft store opens, search for “Kali Linux” in the search bar.
Step 3: On the Kali Linux page, click on the “Get” option in order to download the Kali Linux app.
Step 4: Once the Kali Linux app is downloaded, close the Microsoft-Store.

Step 5: Click on the Windows logo in the bottom left corner of your screen and then type in the following command and press enter:
Kali Linux
Step 6: After opening the Kali Linux app, the distribution will be installed in few seconds completely.

Step 7: Then, type in the credentials that you want to set in for the login purpose. Now, you will be able to use the Kali Linux easily in the command-line prompt and also execute the basic commands without an error.
Note: The base image does not contain any tool, or a graphical interface in order to keep the image small, however, it can be downloaded and installed via “apt” commands easily.
Setting Up Kali Linux(GUI):
Step 1: Open the Kali Linux app and login with your credentials.
Step 2: Type in the following command and hit enter:
sudo apt update && sudo apt upgrade -y


Step 3: After the successful completion of the above command, type the following command and hit Enter:
sudo apt upgrade && sudo apt install kali-win-kex -y
Step 4: Now, once the above command is completed installing, then type in the following:
kex


This will initiate the process to open up the GUI environment of the Kali Linux distribution installed.
Important:
1. Now, whenever we have to close the GUI opened, then we will press the “fn” key with “f8” in order to select the “exit viewer” option.
2. Then, after exiting the viewer type in the following command in order to completely close the running services:
kex stop

3. Thereafter, whenever we want to start the GUI Kali Linux environment then we will firstly open the Kali Linux app, and then type in the following commands by sequence: [or else you will get an error.]
kex stop [In any case you forgot to stop the kex services running before.]
kex
Note: The above GUI setup will work on Kali Linux versions 2020.3 or later.
Similar Reads
How to use Kali Linux in Windows with WSL 2?
The Windows Subsystem for Linux lets developers run a GNU/Linux environment including most command-line tools, etc. direct on Windows, unmodified, without the overhead of an ordinary virtual machine or dual-boot system. Uses of WSL: Pick your preferred GNU/Linux distributions from the Microsoft Stor
5 min read
How to Use Linux Commands in Windows with Cygwin
Cygwin is a collection of tools that provide a Linux Operating System's terminal look, feel, and some of its basic functionality for users of Windows OS who want to have a go over the basic commands of Linux without worrying about installing a Linux OS. To use this tool, first of all, we need to dow
3 min read
How to Use wpscan in Kali Linux?
Wpscan is a vulnerability scanning tool, which comes pre-installed in Kali Linux. This scanner tool scans for vulnerabilities in websites that run WordPress web engines. The wpscan tool itself isnât a malicious tool, as it is only for reconnaissance against a particular site. However, a skilled hack
3 min read
How to run Linux GUI apps on Windows with WSLg?
In this article, we will see how you can install your favorite Linux GUI application on your Windows PC/Laptop. For this, we will use WSLg. WSLg which stands for Windows Subsystem for Linux GUI is an open-source project that enables the support for running Linux GUI applications on Windows in a full
2 min read
Dual Boot Kali Linux with Windows
Sometimes we came across situations like when we want to start learning Linux and command line stuff but using Linux as a main Operating System without having a basic idea of it is not a good option. So in order to do that we may install the same alongside windows. And choose which Operating System
4 min read
How to Hack WPA/WPA2 WiFi Using Kali Linux?
"Hacking Wifi" sounds really cool and interesting. But actually hacking wifi using Kali Linux practically is much easier with a good wordlist. But this world list is of no use until we don't have any idea of how to actually use that word list in order to crack a hash. And before cracking the hash we
3 min read
How to take a Screenshot in Kali Linux
Kali Linux is a Debian-based distribution with a strong focus on penetration testing, ethical hacking, digital forensics, and more. The project is maintained by Offensive Security. Unlike Debian which focuses on servers and desktop usage, Kali has a strong focus on Cyber security. With lots of prein
5 min read
MOSINT - OSINT Tool for Emails in Kali Linux
MOSINT is a free and open-source tool available on GitHub. This tool is free means you can download and use this tool free of cost. MOSINT is used for reconnaissance on email addresses. MOSINT is used for information gathering of the target email. This tool helps you gather information about the tar
2 min read
How to Install Kali Linux with Persistence on USB Drive?
Kali Linux is a strong and adaptable penetration system testing platform. If users are persistent, they can install it on a USB drive directly and carry a fully functional and customizable environment in their pocket to use. This persistent USB configuration is a really useful tool, whether to inves
4 min read
How to Install sqlsus on Kali Linux?
Sqlsus tool is an automated cyber security tool developed in the Perl Language which has the capability of detecting SQL Injection and Takeover the access of the database if the web application is vulnerable. Sqlsus tool is a command-line-based tool so you can pass the flags or tags in the command i
2 min read