WSL Install
Requirements
1. You must be running Windows 10 version 2004 and higher (Build 19041 and higher) or Windows 11.
• For x64 systems: Version 1903 or later, with Build 18362.1049 or later.
• For ARM64 systems: Version 2004 or later, with Build 19041 or later.
2. An internet connection.
Check Whether your PC Meets the Requirements
1. Click on Search. Enter Settings. Click on Settings.
Check Whether your PC Meets the Requirements
2. Click on System.
Check Whether your PC Meets the Requirements
3. Scroll down and click on About.
Check Whether your PC Meets the Requirements
4. You can see we have a compatible CPU here. We have 32GB of RAM which is enough to run WSL.
Check Whether your PC Meets the Requirements
5. Scroll down and until you see the Operating System. Here you can verify we have a Windows 11 build
that falls within the recommended specifications. Both version and build are greater than what is
recommended.
Install WSL on Windows 11
1. Open up PowerShell and type the command wsl --install to install WSL. This will by default
install Ubuntu as the distro. You can specify the default distro using the following command
wsl --install -d <distribution name>
Install WSL on Windows 11
2. To list all the valid distibutions enter the command wsl --list --online
Install WSL on Windows 11
3. Once the installation is complete you will be required to restart your computer.
Install WSL on Windows 11
3. Your computer should restart and the WSL 2 installation should launch PowerShell and complete the
installation of Ubuntu. You need to set your username and password.
Install additional distributions on WSL
4. If you want to install more distributions after the initial install you can use the following command
wsl --install -d <distribution name> or you can open the Windows Store, and
search
for a distribution to download. We will install Kali Linux from the Windows Store. Search for Kali
Linux. On Search enter Microsoft Store and select the Microsoft Store.
Install additional distributions on WSL
Install additional distributions on WSL
5. We start by entering Kali Linux in the Windows Store Search Bar. Click on Kali Linux.
Install additional distributions on WSL
6. Click on Install to install Kali Linux for WSL.
Install additional distributions on WSL
7. Click on Open, to open Kali Linux in WSL.
Install additional distributions on WSL
8. It will take a few minutes to install before you’ll be prompted to create a username and password.
Update Kali Linux
1. We’ll run the command dpkg-query -l | wc -l , it first lists out all the packages and then it
counts the number lines, which corresponds to the number of installed packages. Compare this to a VM
running Kali Linux, and you’ll realize that this is a minimal install.
Update Kali Linux
2. We’ll run the command kali-tweaks this will give us an option to install additional tools for Kali
Linux.
Update Kali Linux
3. We’ll select Metapackages from the menu and press Enter.
Update Kali Linux
4. You’ll be asked to enter your password.
Update Kali Linux
5. From the menu I’ll select Kali’s default toolset and press Space to select it. Then press tab and enter.
Update Kali Linux
6. It’ll tell you this operation will require an extra 10.2GB of space. Press Y and Enter to continue.
Running Windows commands within WSL Linux
1. We’ll open the Ubuntu distro that installed with WSL. We use the command wsl -d Ubuntu-22.04
Running Windows commands within WSL Linux
2. You can run Windows commands by appending .exe. For instance, we can run the Windows command
ping.exe www.google.com this will ping google.com.
Running Windows commands within WSL Linux
3. Let’s open notepad, we can do so using the command notepad.exe <file name>
Running Windows commands within WSL Linux
4. As you can see it opened the file in Notepad.
Running Windows commands within WSL Linux
5. You can run the ipconfig command too as follows ipconfig.exe
Running Windows commands within WSL Linux
6. We want to open our file in Visual Studio Code which is installed on Windows. Run the command
code text.txt this will open the file in Visual Studio Code. You can type any message in there
and save it.
Running Windows commands within WSL Linux
Running Windows commands within WSL Linux
6. Let’s open this file with nano. We run the command nano text.txt and edit it.
Running Windows commands within WSL Linux
7. Press Ctrl + X to exit. Then press Y to save and enter to keep the name the same.
Running Windows commands within WSL Linux
8. You can open the current file location in the WSL Linux using the command explorer.exe .
Running Linux Commands in Windows
9. We will right click and click on Open in Terminal, which will launch a PowerShell terminal.
Running Linux Commands in Windows
1. You can run the cat command from Linux in Windows by using the command wsl cat text.txt
Running Linux Commands in Windows
2. Let’s grep the line with Kali in it wsl cat text.txt | wsl grep Kali
Running Linux Commands in Windows
3. You can run Linux commands on Windows by simply prefixing them with wsl
wsl <linux command> as you can see from the example below, it uses the default distribution
to
execute the command.
Running Linux Commands in Windows
4. I moved to my Documents directory in Windows 11. Then I run the command
wsl ls | wsl grep .txt I did this so I can see all the text files in that directory.
Where the WSL Linux distros are stored
1. When you click on the Linux Penguin on the sidebar, it takes you to where all your Linux distros are
stored. You can open the files from here as well.
Extra WSL Commands
1. You can use the command wsl --list in PowerShell, to see all the distributions installed. You can
also use the command wsl --list --verbose to get more information about the installed
distributions. You can see which are running currently.
Extra WSL Commands
3. To stop a WSL instance from running you can use the command
wsl --terminate <distribution name>
Extra WSL Commands
3. When you run wsl --list --verbose you will see an * next to it. The asterisk indicates that it
your default distro. When you run wsl --list the default distro will have default written next to it.
You can change you default distro by using the command wsl --set-default <distribution name>
Extra WSL Commands
3. When you run wsl --status you will see the default distro and the distribution version which is
WSL 2.
Extra WSL Commands
4. When you run wsl --status you will see the default distro and the distribution version which is
WSL 2.
Extra WSL Commands
1. You can find all your Windows files when you use the command cd /mnt/c this is the Windows
hard drive.
Running GUI apps in WSL
1. Any program that has a GUI can be launched from the command line and the GUI will open.
sudo <program with gui name>
Running GUI apps in WSL
2. Let’s install Firefox on the WSL Kali machine. We first update our repositories using the command
sudo apt update . We then run the commandsudo apt install firefox-esr
Running GUI apps in WSL
3. Once it is installed we run the command sudo firefox & . The ampersand in the command
launches Firefox as a process that runs in the background and leaves the terminal available for other
commands..
Installing & Using Kali-Win-Kex
1. Use the command sudo apt install kali-win-kex
Installing & Using Kali-Win-Kex
2. Press Y and press Enter.
Installing & Using Kali-Win-Kex
3. Once Kex completed installing we can run Kex by using the command kexthis launches a fully
functioning Kali Linux GUI. You will be asked to enter a password that must be at least 6 characters. Then
when asked about a view-only password press n and Enter
Installing & Using Kali-Win-Kex
You can access your GPU from WSL
1. Enter the command nvidia-smi . Kali Linux in WSL can see your GPU.
You can access your GPU from WSL
2. Let’s run the following commands in our Kali WSL. This will allow us to install the CUDA toolkit.
wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-
ubuntu/x86_64/cuda-keyring_1.0-1_all.deb
sudo dpkg -i cuda-keyring_1.0-1_all.deb
sudo apt update
You can access your GPU from WSL
3. Run the following command to install the CUDA Toolkit sudo apt-get install -y cuda
You can access your GPU from WSL
4. I copied a hash.hc22000 file to the Documents directory. I go to the directory in Kali and run the
command.
hashcat -a 3 -m 22000 hash.hc22000 ?d?d?d?d?d?d?d?d
You can access your GPU from WSL
5. The password cracked fairly quickly. This also allows you to do AI related tasks in WSL.
WSL Configuration Files
1. WSL has two types of configuration files:
1. Local Configurations - wsl.conf is used to configure local settings individually for each Linux
distribution running on WSL 1 or WSL 2.
2. Global Configurations - .wslconfig is used to set global configurations that apply to all installed
distributions running on WSL 2.
WSL Configuration Files
2. We are going to switch to our Ubuntu WSL instance (Kali Linux WSL doesn’t have a local config, but you
could create one. There’s a local file on the WSL machine which you can access in the /etc/wsl.conf. Let’s
run the command cat /etc/wsl.conf
. You can edit the contents of that file with any text
editor. Find documentation on configurations here: https://learn.microsoft.com/en-us/windows/wsl/wsl-
config
WSL Configuration Files
2. Use the command sudo nano /etc/wsl.conf to create the local WSL config file in Kali Linux.
This is created in Ubuntu by default. We require our WSL environment to use systemd if we want to add
a GUI.
WSL Configuration Files
3. From the information in the wsl.conf file you can see that WSL makes use by systemd by default in
Ubuntu. Systemd is a modern system and service manager for Linux operating systems, responsible for
managing and controlling the system's initialization process, services, and other essential tasks.
WSL Configuration Files
3. I previously mentioned that WSL has two configuration files: one for local settings (wsl.conf) and one for
global settings (.wslconfig). Now, we’ll create the global configuration file, which applies to all WSL 2
distributions on your Windows machine.
1. First, navigate to your user profile directory in PowerShell using: cd ~. This will take you to
C:\Users\<YourUsername>.
2. Open the current directory in File Explorer by running: explorer.exe .
3. In File Explorer, right-click, select New > Text Document, and rename it to .wslconfig. Be sure to save
the file with the .wslconfig extension and not .txt.
4. In the .wslconfig file, you can set global configurations. For example:
WSL Configuration Files
[wsl2]
memory=4GB # Limits memory usage to 4GB
processors=2 # Limits the number of CPU cores
swap=2GB # Sets the swap file size
localhostForwarding=true # Enables localhost forwarding
This file will work for all WSL 2 distributions since it’s the global configuration file. You can find more
configuration options and details in the official Microsoft documentation: WSL Configurations.
To give an example, you might want to assign less RAM to your WSL environments, as they default to using
50% of your system's RAM.
WSL Configuration Files
4. Configuration changes in WSL take effect only after the subsystem stops running completely, which
usually takes about 8 seconds after closing all instances of the distribution shell. To ensure changes are
applied, you can either wait for the subsystem to stop naturally (check with wsl --list --running) or force a
shutdown using wsl --shutdown or wsl --terminate <distroName>.
WSL Configuration Files
5. You can verify the changes running the following commands in the WSL environments:
• cat /proc/meminfo
• nproc
• free –h
WSL Configuration Files
Before global config changes, we had 32GB which is half of the system’s RAM.
WSL Configuration Files
After global config changes we have 4GB of RAM as specified in the global .wslconfig file.
WSL Installing a GUI (Can be done on any Linux)
1. Run the command sudo apt update && sudo apt upgrade .
WSL Installing a GUI (Can be done on any Linux)
2. Run the command sudo apt install xfce4 xfce4-goodies -y to install a graphical
user interface. .
WSL Installing a GUI (Can be done on any Linux)
3. Install XRDP with the following command sudo apt install xrdp
WSL Installing a GUI (Can be done on any Linux)
4. Start and enable the XRDP service using the commands sudo systemctl start xrdp and
sudo systemctl enable xrdp
WSL Installing a GUI (Can be done on any Linux)
5. Confirm that XRDP is running sudo systemctl status xrdp . Remember the port number
3389
WSL Installing a GUI (Can be done on any Linux)
6. Let’s add our user to the ssl-cert group sudo adduser <user> ssl-crt . Log out and back in
for the group changes to take effect.
WSL Installing a GUI (Can be done on any Linux)
7. Click on your search bar and search for Remote Desktop Connection. Click on Remote Desktop
Connection.
WSL Installing a GUI (Can be done on any Linux)
8. Open your Kali VM, and run the command ip a to see the IP Address of your Kali WSL instance.
WSL Installing a GUI (Can be done on any Linux)
9. Enter the IP Address of your WSL Machine followed by the port number: <wsl ip>:3389
WSL Installing a GUI (Can be done on any Linux)
10. Click on Yes to continue any way.
WSL Installing a GUI (Can be done on any Linux)
11. Enter your username and password. Then click OK.
WSL Installing a GUI (Can be done on any Linux)
12. Wait a moment for the Kali Linux GUI to load.
WSL Networking
1. I will run the command ipconfig you will see that the Windows IP address differs from the WSL IP.
WSL Networking
2. WSL is using a NAT connection. I can only ping it from my Windows host computer on my network. Use
the command ping <ip address of wsl instance> . Try it from another machine on
your network and it will fail.
WSL Networking
Different computer trying to ping the WSL instance on
192.168.0.184
WSL Networking
3. Let’s open the .wslconfig file and set the networkingMode to mirrored. I open PowerShell and run the
command notepad.exe .wslconfig in my C:\Users\<username> directory. I removed the
other settings.
WSL Networking
4. On my computer where I installed WSL 2 I enter Windows Defender Firewall in the Search Bar. Click on
Windows Defender Firewall to open it.
WSL Networking
5. Click on Advanced Settings.
WSL Networking
6. Click on Inbound Rules.
WSL Networking
7. Click on New Rule...
WSL Networking
8. Click on Port and press Next.
WSL Networking
8. Specify your port as port 3389 then click Next.
WSL Networking
9. Select Allow the connection then click Next.
WSL Networking
10. We’ll leave this on all profiles. You can unselect Public. Click Next.
WSL Networking
12. Name the rule WSL 3389 or whatever you want to and click Finish.
WSL Networking
13. On my other machine I will now start Remote Desktop and enter the host machine ip and port 3389 as
follows 192.168.0.184:3389 , then click Connect.
WSL Networking
13. Click on Yes to connect.
WSL Networking
14. Enter your username and password to login.
WSL Networking
15. Wait until the screen loads Kali Linux’s GUI.
WSL Backup File
1. We need will sometimes want to backup WSL environments. First, we need to know the name of the
environment which we want to export wsl --list --verbose
WSL Backup File
2. We want to export the kali-linux environment. The general syntax of the command to export a WSL
environment is wsl --export <backup name> <stored filename>.tar . We’ll use the
following commandkali-linux kali-linux.tar
wsl --export
WSL Backup File
2. To import the file on a computer without the
wsl --import <name of environment> <where it should be stored> <location of tar file>
wsl --import california c:\wsl .\kali-linux.tar
WSL Backup File
3. List the distributions to see if the new import is there.
wsl --list
Get more information
1. Website: https://www.youtube.com/davidbombal
2. Website: https://learn.microsoft.com/en-us/windows/wsl/