🪟

WSL

Windows Subsystem for Linux

🚀 What is WSL?
WSL (Windows Subsystem for Linux) lets you run a Linux environment directly on Windows, unmodified, without the overhead of a traditional virtual machine or dual-boot setup. Perfect for developers who need Linux tools on Windows.
Native Performance
🔄
File Sharing
🖥️
GUI Apps
🐳
Docker Support
💻
VS Code Integration

Installation Steps

1
Enable WSL Feature
dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart
Enable WSL feature through DISM (requires admin privileges)
2
Enable Virtual Machine Platform
dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
Required for WSL 2 functionality
3
Restart Computer
Restart-Computer
Restart to apply the feature changes
4
Download Linux Kernel Update
https://aka.ms/wsl2kernel
Download and install the WSL2 Linux kernel update package
5
Set WSL 2 as Default
wsl --set-default-version 2
Configure WSL 2 as the default version for new distros
6
Install Linux Distribution
wsl --install -d Ubuntu
Install your preferred Linux distribution from Microsoft Store

Essential WSL Commands

⚙️
Basic Operations
wsl
Start default Linux distribution
wsl -l -v
List installed distributions with versions
wsl -d <DistroName>
Start specific distribution
wsl --shutdown
Shutdown all running distributions
wsl --status
Show WSL status information
📥
Installation & Management
wsl --install
Install WSL and default Ubuntu distribution
wsl --install -d <Distro>
Install specific distribution
wsl --list --online
Show available distributions online
wsl --unregister <Distro>
Uninstall distribution and delete data
wsl --update
Update WSL to latest version
🔧
Configuration
wsl --set-version <Distro> 2
Convert distribution to WSL 2
wsl --set-default <Distro>
Set default distribution
wsl --set-default-version 2
Set default version for new installs
wsl --terminate <Distro>
Force stop specific distribution
wsl --mount <Disk>
Mount physical disk in WSL
📁
File System Access
\\wsl$\Ubuntu\home\user
Access WSL files from Windows Explorer
cd /mnt/c/Users
Access Windows files from WSL
explorer.exe .
Open current WSL directory in Windows Explorer
code .
Open current directory in VS Code
wsl --exec <command>
Execute Linux command from Windows
💾
Backup & Export
wsl --export <Distro> <FileName>
Export distribution to tar file
wsl --import <Distro> <InstallLocation> <FileName>
Import distribution from tar file
wsl --export Ubuntu backup.tar
Example: Export Ubuntu to backup.tar
wsl --import Ubuntu-Clone C:\WSL backup.tar
Example: Import backup as new distribution
🐛
Troubleshooting
wsl --version
Show WSL version information
wsl --debug-shell
Open debug shell for troubleshooting
wsl --system
Launch system distribution
Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
Check if WSL feature is enabled

🐧 Popular Linux Distributions

Ubuntu
wsl --install -d Ubuntu
wsl --install -d Ubuntu-22.04
Red Hat Enterprise
wsl --install -d RHEL
Available via Microsoft Store
openSUSE
wsl --install -d openSUSE-42
wsl --install -d openSUSE-Leap-15.4
Debian
wsl --install -d Debian
Stable and lightweight option
Kali Linux
wsl --install -d kali-linux
Security and penetration testing
Alpine
wsl --install -d Alpine
Minimal and security-oriented

🔗 Windows Integration Features

📝
VS Code Integration
Seamless development with Remote-WSL extension. Edit Linux files directly in VS Code.
📁
File System Access
Access Windows files from Linux (/mnt/c) and Linux files from Windows Explorer.
🐳
Docker Desktop
Run Docker containers natively in WSL 2 with better performance than Hyper-V.
💻
Windows Terminal
Modern terminal with tabs, profiles, and seamless WSL integration.
🖥️
GUI Applications
Run Linux GUI apps with WSLg (WSL GUI) support in Windows 11.
🔗
Cross-Platform Commands
Execute Linux commands from Windows and Windows commands from Linux.

💡 WSL Pro Tips

Use WSL 2
WSL 2 offers better performance, full system call compatibility, and Docker support
Store Files in Linux
Keep project files in the Linux filesystem (/home/user) for better performance
Configure Memory Limits
Create .wslconfig file to limit memory usage: [wsl2] memory=4GB
Use Windows Terminal
Windows Terminal provides the best WSL experience with multiple tabs and customization
Install VS Code Remote Extension
Remote-WSL extension allows seamless development in WSL from VS Code
Set Up Git Credentials
Use Git Credential Manager to share Git credentials between Windows and WSL
Enable Systemd
Add [boot] systemd=true to /etc/wsl.conf for systemd support in WSL 2
Regular Backups
Export your WSL distributions regularly to avoid data loss during updates