WSL (Windows Subsystem for Linux) allows developers to run a GNU/Linux environment directly on Windows, unmodified, without the overhead of a traditional virtual machine or dualboot setup.
Installation & Setup (Run in PowerShell)
wsl --install # Install WSL with default Ubuntu distribution
wsl --install -d Debian # Install a specific distribution
wsl --list --online # List available distributions
wsl --update # Update the WSL Linux kernelManaging Distributions (Run in PowerShell/CMD)
wsl -l -v # List installed distributions and their WSL version
wsl --set-default Ubuntu # Set default distribution
wsl --set-version Ubuntu 2 # Convert distribution to WSL 2
wsl --shutdown # Terminate all running distributions and the WSL 2 lightweight utility VM
wsl -t Ubuntu # Terminate a specific distribution
wsl --unregister Ubuntu # Delete a distribution (Warning: Deletes all data!)File System Access
Accessing Windows files from WSL
Windows drives are mounted under /mnt/.
cd /mnt/c/Users/Username/DocumentsAccessing WSL files from Windows
Open File Explorer and type the following in the address bar:
\\wsl$Or type this inside your WSL terminal to open Windows Explorer in the current Linux directory:
explorer.exe .Networking
WSL 2 uses a virtualized network adapter. To get the IP address of your WSL 2 instance (from inside WSL):
ip addr show eth0 | grep -oP '(?<=inet\s)\d+(\.\d+){3}'To run Windows executables from inside WSL:
ipconfig.exe
ping.exe google.comAdvanced Configuration (.wslconfig)
You can configure global WSL 2 settings by creating a .wslconfig file in your Windows user profile folder (C:\Users\<YourUsername>\.wslconfig).
[wsl2]
memory=4GB # Limits VM memory to use no more than 4 GB
processors=2 # Makes the WSL 2 VM use two virtual processors
localhostForwarding=true # Allow connecting to WSL from Windows localhost