WSL — Manage Linux Distributions on Windows

Practical guide to WSL: install, start, back up and configure Linux distributions on Windows – including WSL 2, networking and filesystem access.

The Windows Subsystem for Linux (WSL) lets you run full Linux distributions directly on Windows – no dual boot and no traditional virtual machine. WSL 2 powers this with a real Linux kernel running in a lightweight, tightly integrated VM, so the filesystem, networking and your Windows programs all work together seamlessly. The wsl command is your control center: it installs distributions, starts and stops them, backs them up via export and tunes their resources. This guide walks you through the commands you actually reach for daily.

Install & Setup

wsl --install — Install WSL with the default Linux distribution (Ubuntu).

wsl --install

wsl --install -d <distro> — Install a specific Linux distribution.

wsl --install -d Debian

wsl --list --online — List available distributions for installation.

wsl --list --online

wsl --update — Update the WSL kernel to the latest version.

wsl --update

wsl --version — Show WSL version, kernel version, and WSLg version.

wsl --version

wsl --set-default-version 2 — Set WSL 2 as default for new distributions.

wsl --set-default-version 2

List & Status

wsl --list — List installed distributions.

wsl --list

wsl --list --verbose — List distributions with state, WSL version, and default.

wsl --list --verbose

wsl --list --running — List only currently running distributions.

wsl --list --running

wsl --status — Show WSL configuration and default distribution.

wsl --status

Start, Stop & Run

wsl — Start the default distribution.

wsl

wsl -d <distro> — Start a specific distribution.

wsl -d Debian

wsl -u <user> — Start as a specific user.

wsl -u root

wsl -e <command> — Execute a command in the default distribution.

wsl -e ls -la /home

wsl -d <distro> -e <command> — Execute a command in a specific distribution.

wsl -d Ubuntu -e cat /etc/os-release

wsl --shutdown — Shut down all running distributions and the WSL VM.

wsl --shutdown

wsl --terminate <distro> — Terminate a specific distribution.

wsl --terminate Ubuntu

Distribution Management

wsl --set-default <distro> — Set the default distribution.

wsl --set-default Debian

wsl --set-version <distro> 2 — Convert a distribution to WSL 2 (or 1).

wsl --set-version Ubuntu 2

wsl --unregister <distro>Destructive: Unregister a distribution and delete it along with all its data, irreversibly.

wsl --unregister Ubuntu

Import & Export

wsl --export <distro> <file> — Export a distribution as a .tar archive.

wsl --export Ubuntu ubuntu-backup.tar

wsl --export <distro> <file> --vhd — Export as a .vhdx virtual disk.

wsl --export Ubuntu ubuntu-backup.vhdx --vhd

wsl --import <name> <path> <file> — Import a distribution from a .tar archive.

wsl --import MyUbuntu C:\WSL\MyUbuntu ubuntu-backup.tar

wsl --import <name> <path> <file> --vhd — Import from a .vhdx virtual disk.

wsl --import MyUbuntu C:\WSL\MyUbuntu ubuntu-backup.vhdx --vhd

wsl --import-in-place <name> <file> — Register an existing .vhdx as a distribution.

wsl --import-in-place MyDistro C:\WSL\ext4.vhdx

Configuration Files

/etc/wsl.conf — Per-distribution settings (automount, network, user, boot).

[user]
default=myuser

[boot]
systemd=true

%USERPROFILE%\.wslconfig — Global WSL 2 settings (memory, CPU, swap, networking).

[wsl2]
memory=8GB
processors=4
swap=4GB

[boot] systemd=true — Enable systemd in wsl.conf (WSL 2, Windows 11).

echo -e '[boot]\nsystemd=true' | sudo tee /etc/wsl.conf

[automount] options = "metadata" — Enable Linux file permissions on Windows drives.

[automount]
options = "metadata,uid=1000,gid=1000,umask=022"

[network] generateResolvConf = false — Use custom DNS instead of auto-generated resolv.conf.

[network]
generateResolvConf = false

Filesystem & Interop

/mnt/c/ — Access the Windows C: drive from WSL.

ls /mnt/c/Users/

\\wsl$\<distro>\ — Access the WSL filesystem from Windows Explorer.

explorer.exe \\wsl$\Ubuntu\home\user

wslpath '<windows-path>' — Convert a Windows path to a WSL path.

wslpath 'C:\Users\me\Documents'

wslpath -w '<linux-path>' — Convert a WSL path to a Windows path.

wslpath -w /home/user/project

explorer.exe . — Open the current WSL directory in Windows Explorer.

explorer.exe .

cmd.exe /c <command> — Run a Windows command from within WSL.

cmd.exe /c 'echo %COMPUTERNAME%'

powershell.exe -c '<command>' — Run a PowerShell command from within WSL.

powershell.exe -c 'Get-Process | Select -First 5'

Networking & Disk

wsl hostname -I — Show the WSL IP address.

wsl hostname -I

wsl --mount <disk> --bare — Attach a physical disk to WSL 2.

wsl --mount \\.\PHYSICALDRIVE1 --bare

wsl --mount <disk> --partition <n> --type ext4 — Mount a specific partition with a filesystem type.

wsl --mount \\.\PHYSICALDRIVE1 --partition 1 --type ext4

wsl --unmount <disk> — Detach a mounted disk from WSL.

wsl --unmount \\.\PHYSICALDRIVE1

Conclusion

WSL makes Linux on Windows genuinely practical: a handful of wsl commands install, start and back up distributions, while WSL 2 delivers near-native performance thanks to its real kernel and lightweight VM. For everyday work you rarely need more than wsl --install, wsl -l -v, wsl -d <distro> and wsl --shutdown. Treat wsl --unregister <distro> with care, though: it deletes the distribution and all its data irreversibly – back it up first with wsl --export, and move it to another machine via wsl --import when needed. Finer details like memory limits, systemd or DNS are controlled centrally through .wslconfig and wsl.conf.

Further Reading

  • wslg – run Linux GUI apps under WSL 2 via WSLg
  • powershell – the Windows shell that drives and interacts with WSL
  • bash – the default shell in most WSL distributions