๐ A step-by-step guide to installing, configuring, and using Windows Subsystem for Linux (WSL) โ including essential commands, Windows/Linux integration, and useful advanced features.
๐ Table of Contents
- What is WSL?
- Step 1 โ Enable WSL Features
- Step 2 โ Check Your WSL Installation
- Step 3 โ Update WSL
- Step 4 โ List Installed Linux Distributions
- Step 5 โ See Available Distributions
- Step 6 โ Install a Linux Distribution
- Step 7 โ Uninstall a Distribution
- Step 8 โ Change the Default Distribution
- Step 9 โ Launch and Switch Between Linux Distributions
- Step 10 โ Exit and Shut Down WSL
- Step 11 โ Access Windows Drives from Linux
- Step 12 โ Use Windows Commands from Linux
- Step 13 โ Run Windows Applications from Linux
- Step 14 โ Use VS Code with WSL
- Step 15 โ Open the Current Linux Directory in Windows Explorer
- Step 16 โ Run Linux Commands from Windows
- Step 17 โ Kali Linux Tweaks
- ๐ง Command Cheat Sheet
- ๐ Official Documentation
๐ง What is WSL?
Windows Subsystem for Linux (WSL) allows you to run a Linux environment directly on Windows without needing to set up a traditional dual-boot system or a separate full virtual machine.
With WSL, you can:
- ๐ง Run Linux distributions such as Ubuntu or Kali Linux.
- ๐ป Use Linux commands directly from Windows.
- ๐ช Run Windows commands and applications from Linux.
- ๐ Access Windows files from Linux.
- ๐ ๏ธ Use development tools such as VS Code with a Linux environment.
- ๐ Move between Windows and Linux workflows easily.
This guide is based on the commands and workflow in the accompanying WSL notes, expanded into a beginner-friendly Dev.to tutorial.
โ๏ธ Step 1 โ Enable WSL Features
Before using WSL, make sure the required Windows features are enabled.
1. Open Windows Features
On Windows:
- Press
Win + R. - Type:
optionalfeatures
- Press Enter.
- In Turn Windows features on or off, enable:
- โ Virtual Machine Platform
- โ Windows Subsystem for Linux
- Click OK.
- Restart your PC when Windows asks you to.
๐ก Why are these features required?
Windows Subsystem for Linux provides the Windows component required to run Linux environments.
Virtual Machine Platform provides virtualization support used by WSL 2.
๐ A restart is important after enabling these Windows features.
๐ Step 2 โ Check Your WSL Installation
Open PowerShell or Windows Terminal and run:
wsl --status
What does it do?
wsl --status displays information about your WSL installation and configuration.
It is useful when you want to quickly check whether WSL is installed and see relevant version/configuration information.
Example
wsl --status
If WSL is working correctly, Windows will display information about the current WSL configuration.
๐ Step 3 โ Update WSL
To update WSL to the latest available version, run:
wsl --update
What does it do?
The command checks for and installs available updates for WSL.
Recommended workflow
If you are setting up WSL on a new machine, it is a good idea to update WSL before continuing:
wsl --update
๐ฆ Step 4 โ List Installed Linux Distributions
To see Linux distributions installed on your Windows system:
wsl --list
You may also use:
wsl -l
What does it do?
It lists the Linux distributions currently installed under WSL.
For example, you might have:
Ubuntu
kali-linux
๐ข Show Currently Running Distributions
Use:
wsl --list --running
or:
wsl -l --running
What does it do?
This shows only the Linux distributions that are currently running.
This is useful when you have several distributions installed and want to know which ones currently have active WSL instances.
๐ Show Detailed Distribution Information
Use:
wsl --list --verbose
or:
wsl -l -v
What does it show?
The verbose list provides additional information about installed distributions, including their WSL version and whether they are currently running.
This is particularly useful for checking whether a distribution is using WSL 1 or WSL 2.
๐ Step 5 โ See Available Distributions
To see Linux distributions that can be installed through WSL, run:
wsl --install --online
You may also use:
wsl --list --online
Depending on your Windows/WSL version, the output will show distributions available for installation.
๐ก Why use this command?
Instead of guessing distribution names, you can first check the names Windows recognizes.
For example, a distribution may have a specific identifier that should be passed to the installation command.
๐ฅ Step 6 โ Install a Linux Distribution
Once you know the distribution name, install it with:
wsl --install -d <distribution-name>
For example:
wsl --install -d Ubuntu
Or, if the available distribution is listed under another identifier:
wsl --install -d kali-linux
โ ๏ธ Administrator privileges
The setup notes recommend running PowerShell as an Administrator for the installation process.
To do that:
- Open the Start menu.
- Search for PowerShell.
- Right-click PowerShell.
- Select Run as administrator.
- Run the WSL installation command.
๐๏ธ Step 7 โ Uninstall a Distribution
There are two approaches mentioned in the notes.
Method 1 โ Windows Settings
You can uninstall a Linux distribution through:
Settings โ Apps โ Installed apps
Find the distribution you want to remove and uninstall it.
Method 2 โ Use the WSL Command
You can unregister a distribution with:
wsl --unregister <distribution-name>
Example:
wsl --unregister Ubuntu
โ ๏ธ Important
wsl --unregister removes the WSL distribution and its associated Linux filesystem/data.
Therefore, do not use this command unless you are sure you want to remove that distribution and its data.
โญ Step 8 โ Change the Default Distribution
If you have multiple Linux distributions installed, you can choose which one launches when you run:
wsl
Use:
wsl --set-default <distribution-name>
For example:
wsl --set-default kali-linux
๐ง How does this work?
Suppose you have:
Ubuntu
kali-linux
If Ubuntu is the default, running:
wsl
opens Ubuntu.
If you change the default:
wsl --set-default kali-linux
then:
wsl
will open Kali Linux instead.
๐ Step 9 โ Launch and Switch Between Linux Distributions
Launch the default distribution
Simply run:
wsl
This launches your default WSL distribution.
Launch a specific distribution
Use:
wsl -d <distribution-name>
Example:
wsl -d Ubuntu
or:
wsl -d kali-linux
๐ก Why is this useful?
You can keep multiple distributions installed and launch the one you need without changing the default distribution.
๐ช Step 10 โ Exit and Shut Down WSL
Exit the current Linux shell
Inside Linux, run:
exit
This exits the current Linux shell and returns you to the Windows terminal.
๐ก The command exits the current shell; it does not necessarily mean every WSL distribution on your system has been shut down.
๐ Shut down all WSL instances
From Windows, run:
wsl --shutdown
What does it do?
It shuts down all currently running WSL distributions.
This can be useful when:
- ๐ You need to restart WSL completely.
- ๐งน You want to release resources.
- ๐ ๏ธ You are troubleshooting WSL behavior.
๐ฏ Shut down a specific distribution
Use:
wsl --terminate <distribution-name>
Example:
wsl --terminate Ubuntu
Difference between the two
| Command | Purpose |
|---|---|
wsl --shutdown |
Stops all running WSL distributions |
wsl --terminate Ubuntu |
Stops only the specified distribution |
๐ Step 11 โ Access Windows Drives from Linux
Windows drives are available inside Linux through /mnt.
For example, the Windows C: drive can be accessed as:
/mnt/c
The D: drive can be accessed as:
/mnt/d
You can navigate to a Windows drive with:
cd /mnt/c
Example
cd /mnt/c
ls
This lets you view files and folders on the Windows C: drive from Linux.
๐ง Understanding the Path
Windows:
C:\
WSL/Linux:
/mnt/c
Windows:
D:\
WSL/Linux:
/mnt/d
The drive letter is converted into a Linux-style path under /mnt.
๐ช Step 12 โ Use Windows Commands from Linux
One of the most useful WSL features is the ability to execute Windows commands directly from your Linux shell.
The notes demonstrate this by adding .exe to Windows commands.
For example:
ifconfig.exe
or:
ping.exe
The Windows executable is launched from the Linux environment.
๐ง The basic idea
Instead of:
Windows command
you can invoke the Windows executable:
Windows command.exe
This creates a convenient bridge between Linux and Windows.
๐ Step 13 โ Run Windows Applications from Linux
WSL can also launch Windows applications.
For example, the notes use Windows Notepad:
notepad.exe document.txt
This launches Notepad and opens the specified file.
Why is this useful?
You can combine:
- ๐ง Linux command-line tools
- ๐ช Windows desktop applications
in the same workflow.
For example:
notepad.exe document.txt
allows a Windows GUI application to be launched directly from your Linux terminal.
๐ป Step 14 โ Use VS Code with WSL
WSL can be integrated with Visual Studio Code.
The notes describe the workflow as:
code demo.py
This allows you to open a file from the Linux environment in VS Code.
Recommended setup
- Install Visual Studio Code on Windows.
- Install the WSL extension in VS Code.
- Open your WSL terminal.
- Navigate to your project.
- Run:
code demo.py
๐ง Why the WSL extension matters
The WSL integration allows VS Code to work with your Linux environment rather than treating the project as an ordinary Windows-only project.
This is especially useful for software development because you can use Linux tooling while keeping the Windows VS Code interface.
๐ Step 15 โ Open the Current Linux Directory in Windows Explorer
From inside your Linux terminal, run:
explorer.exe .
What does . mean?
In Linux:
.
means:
the current directory
Therefore:
explorer.exe .
means:
Open the current Linux directory using Windows Explorer.
Example
cd ~/projects
explorer.exe .
Windows Explorer will open the current location.
๐ง Step 16 โ Run Linux Commands from Windows
WSL also works in the opposite direction.
You can execute Linux commands directly from a Windows terminal by prefixing the command with:
wsl
For example:
wsl cat demo.txt
How does it work?
Windows runs:
wsl
and passes the remaining command to the Linux environment.
So:
wsl cat demo.txt
runs the Linux command:
cat demo.txt
without requiring you to manually enter the Linux shell first.
๐ ๏ธ Step 17 โ Kali Linux Tweaks
If you are using Kali Linux, the notes mention:
kali-tweaks
What is it used for?
kali-tweaks provides a way to configure and customize aspects of a Kali Linux installation.
You can explore the available options from the tool itself.
Run:
kali-tweaks
and follow the interactive menus.
๐ก This section is specific to Kali Linux. The command may not be available in other Linux distributions.
๐ฅ WSL's Windows โ Linux Integration
One of the biggest advantages of WSL is that Windows and Linux can work together.
Here is the basic relationship:
๐ช Windows
โ
WSL
โ
๐ง Linux
You can:
๐ง Linux โ Windows
Run Windows commands:
ping.exe
Run Windows applications:
notepad.exe document.txt
Open Windows Explorer:
explorer.exe .
Launch VS Code:
code demo.py
๐ช Windows โ Linux
Run Linux commands from Windows:
wsl cat demo.txt
This two-way integration is what makes WSL particularly convenient for development workflows.
๐ง Command Cheat Sheet
โ๏ธ Installation & Updates
| Command | Purpose |
|---|---|
wsl --status |
Show WSL status/configuration information |
wsl --update |
Update WSL |
wsl --install --online |
Show distributions available for installation |
wsl --install -d <distro> |
Install a specific distribution |
๐ฆ Distribution Management
| Command | Purpose |
|---|---|
wsl --list |
List installed distributions |
wsl --list --running |
List running distributions |
wsl --list --verbose |
Show detailed distribution information |
wsl --set-default <distro> |
Set the default distribution |
wsl --unregister <distro> |
Remove/unregister a distribution |
๐ Starting & Stopping
| Command | Purpose |
|---|---|
wsl |
Launch the default distribution |
wsl -d <distro> |
Launch a specific distribution |
exit |
Exit the current Linux shell |
wsl --shutdown |
Shut down all WSL instances |
wsl --terminate <distro> |
Terminate one distribution |
๐ช Windows โ Linux Integration
| Command | Purpose |
|---|---|
cd /mnt/c |
Access the Windows C: drive |
explorer.exe . |
Open the current directory in Windows Explorer |
notepad.exe document.txt |
Open a file in Windows Notepad |
ping.exe |
Run the Windows ping executable from Linux |
code demo.py |
Open a file in VS Code |
wsl cat demo.txt |
Run a Linux command from Windows |
๐งช Example: A Simple WSL Development Workflow
Here is a practical example combining several commands from this guide.
1๏ธโฃ Check WSL
From PowerShell:
wsl --status
2๏ธโฃ Update WSL
wsl --update
3๏ธโฃ Check installed distributions
wsl --list --verbose
4๏ธโฃ Start Ubuntu
wsl -d Ubuntu
5๏ธโฃ Navigate to a Windows project directory
cd /mnt/c/Users/<your-username>/Desktop
6๏ธโฃ Create or access your project
cd my-project
7๏ธโฃ Open the project in VS Code
code .
8๏ธโฃ Open the same directory in Windows Explorer
explorer.exe .
This workflow demonstrates how Windows and Linux can work together without constantly switching environments.
๐งฉ Useful Mental Model
If you are new to WSL, remember these three rules:
Rule 1 โ Windows drives live under /mnt
C:\ โ /mnt/c
D:\ โ /mnt/d
Rule 2 โ Windows .exe programs can be launched from Linux
notepad.exe
explorer.exe .
Rule 3 โ Linux commands can be launched from Windows using wsl
wsl <linux-command>
For example:
wsl cat demo.txt
Once these three concepts become familiar, WSL becomes much easier to understand.
โ ๏ธ Important Notes
- ๐ Some WSL installation operations may require an Administrator PowerShell.
- ๐ Restart Windows after enabling the required Windows features.
- ๐๏ธ Be careful with
wsl --unregisterbecause it removes the selected distribution and its data. - ๐ง
kali-tweaksis intended for Kali Linux. - ๐ป For VS Code + WSL development, install the WSL extension in VS Code.
- ๐ Windows drives are commonly accessed through
/mnt/<drive-letter>from Linux. - ๐
wsl --shutdownaffects all running WSL distributions, whilewsl --terminate <distro>targets one distribution.
๐ Official Documentation
For the latest and most authoritative information, always refer to Microsoft's official WSL documentation.
๐ฅ๏ธ WSL GUI Applications
Microsoft's WSL GUI applications guide:
https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps
๐ WSL Basic Commands
Microsoft's WSL basic commands documentation:
https://learn.microsoft.com/en-us/windows/wsl/basic-commands
๐ WSL is actively maintained, so command behavior and supported features can change over time. The official Microsoft documentation should be treated as the final reference for current behavior.
๐ Conclusion
WSL provides a powerful bridge between Windows and Linux.
With just a few commands, you can:
- ๐ง Install and manage Linux distributions.
- ๐ Update and troubleshoot WSL.
- ๐ฆ Run multiple distributions.
- ๐ช Access Windows files from Linux.
- ๐ป Run Windows applications from Linux.
- ๐ง Run Linux commands from Windows.
- ๐ Use VS Code with a Linux development environment.
- ๐ Open Linux directories directly in Windows Explorer.
The most important commands to remember are:
wsl --status
wsl --update
wsl --list --verbose
wsl --install -d <distribution-name>
wsl --set-default <distribution-name>
wsl
wsl -d <distribution-name>
wsl --shutdown
wsl --terminate <distribution-name>
And from inside Linux:
cd /mnt/c
explorer.exe .
notepad.exe document.txt
code demo.py
Happy Linux-ing on Windows! ๐ง๐ป๐
Top comments (0)