wsl.exe installs, runs, backs up, moves and repairs every Linux distro on Windows 11. This WSL cheat sheet groups its flags by the job at hand and adds the two files people get wrong: .wslconfig on the Windows side and /etc/wsl.conf inside each distro.
The commands follow Microsoft’s WSL documentation and the WSL 3.0.5 release of November 2026: install and update, wsl --list -v, --set-version, --export and --import, --shutdown, --mount and --manage, then the config keys and the errors behind most broken installs.
WSL cheat sheet: wsl.exe commands by task
Every row below is a flag listed in the wsl --help text of WSL 3.0.5, the stable release Microsoft published on 3 November 2026. Microsoft’s basic commands page still lists only part of that help, so options such as --manage, --cd and --export --format come from the help text itself. Run the install, update, mount and --manage rows from an elevated PowerShell or Windows Terminal tab, because they change Windows features or attach disks; the rest work in a normal tab.
Install, update and uninstall
| Command | What it does |
|---|---|
wsl --install | Enable WSL and install the default Ubuntu distro |
wsl --install --no-distribution | Enable WSL only, add distros later |
wsl --install -d Debian | Install a named distro from the online list |
wsl --install -d Ubuntu-24.04 --name dev | Install a second copy under your own name |
wsl --install --from-file C:\images\distro.wsl | Install a distro from a local .wsl or tar file |
wsl --install -d Debian --no-launch | Install without opening the first-run shell |
wsl --update | Update WSL to the latest stable release |
wsl --update --pre-release | Move to the latest pre-release build |
wsl --version | Show WSL, kernel, WSLg and Windows versions |
wsl --status | Show the default distro and default version |
wsl --uninstall | Remove the WSL package from Windows |
List distros and check versions
| Command | What it does |
|---|---|
wsl --list --verbose | Installed distros with state and WSL version (wsl -l -v) |
wsl --list --online | Distros you can install by name (wsl -l -o) |
wsl --list --running | Only distros that are running now |
wsl --set-default Debian | Make Debian the distro plain wsl opens (-s) |
wsl --set-version Debian 2 | Convert one distro between WSL 1 and WSL 2 |
wsl --set-default-version 2 | Version new installs get |
Open a shell or run one command
| Command | What it does |
|---|---|
wsl | Open the default distro in the current folder |
wsl ~ | Open the default distro in your Linux home |
wsl -d Debian | Open a specific distro |
wsl -d Debian -u root | Open it as another user |
wsl --cd /var/log | Start in a Linux path (a Windows path also works) |
wsl -e uname -r | Run a program directly, no shell |
wsl -- ls -la /etc | Pass the rest of the line to the default shell |
wsl --shell-type login | Start a login shell (standard, login or none) |
wsl --system | Shell into the hidden system distro (WSLg) |
Stop distros and the VM
| Command | What it does |
|---|---|
wsl --terminate Debian | Stop one distro (-t) |
wsl --shutdown | Stop every distro and the WSL 2 VM |
wsl --shutdown --force | Stop even while an operation runs (can lose data) |
Back up, clone and remove
| Command | What it does |
|---|---|
wsl --export Debian D:\backup\debian.tar | Export a distro to a tar file |
wsl --export Debian D:\backup\debian.tar.gz --format tar.gz | Export compressed (tar, tar.gz, tar.xz, vhd) |
wsl --export Debian D:\backup\debian.vhdx --vhd | Export the ext4 disk image itself (WSL 2) |
wsl --import Debian2 D:\WSL\debian2 D:\backup\debian.tar | Create a new distro from a tar export |
wsl --import Debian2 D:\WSL\debian2 D:\backup\debian.vhdx --vhd | Create a distro from a copy of a .vhdx |
wsl --import-in-place Debian2 D:\WSL\debian2\ext4.vhdx | Register an existing ext4 .vhdx where it sits |
wsl --unregister Debian2 | Delete the distro and all of its files |
Manage disks and storage
| Command | What it does |
|---|---|
wsl --manage Debian --move D:\WSL\debian | Move a distro’s disk to another folder |
wsl --manage Debian --resize 200GB | Change the virtual disk’s maximum size (WSL 2.5+) |
wsl --manage Debian --set-sparse true | Let the .vhdx give freed space back to Windows |
wsl --manage Debian --set-default-user harrison | Change the user the distro logs in as |
wsl --manage Debian --compact | Compact the distro’s virtual disk |
wsl --mount \\.\PHYSICALDRIVE1 --partition 1 | Attach a partition of a physical disk (admin) |
wsl --mount \\.\PHYSICALDRIVE1 --bare | Attach the disk without mounting a filesystem |
wsl --mount D:\disks\data.vhdx --vhd --name data | Mount a .vhdx at /mnt/wsl/data |
wsl --unmount \\.\PHYSICALDRIVE1 | Detach one disk (no argument detaches all) |
Stop the distro with wsl -t Debian before any --manage disk option: WSL refuses --move, --resize and --set-sparse on a running distro. Two rows deserve a warning before you copy them. wsl --unregister asks no question and keeps no recycle bin copy, so export first if there is anything in that distro you want. And the old wslconfig.exe, bash.exe and lxrun commands still appear in forum answers, but Microsoft lists them as deprecated, so use the wsl form from these tables instead.
Which .wslconfig and wsl.conf settings matter?
For most people, two .wslconfig keys matter: memory and processors, because they cap how much of the PC the WSL 2 VM can take. .wslconfig lives at %UserProfile%\.wslconfig and applies to every WSL 2 distro, while /etc/wsl.conf lives inside one distro and only changes that distro. .wslconfig does not exist until you create it. The Ubuntu that wsl --install sets up ships an /etc/wsl.conf that already turns systemd on. A missing or malformed .wslconfig simply means WSL starts with its defaults.
.wslconfig keys ([wsl2] section)
| Key | Default and meaning |
|---|---|
memory=8GB | RAM cap for the VM; default 50% of Windows RAM |
processors=4 | vCPUs; default all logical processors |
swap=4GB | Swap size; default 25% of RAM, 0 disables it |
swapFile=D:\\wsl\\swap.vhdx | Swap file path; default %Temp%\swap.vhdx |
networkingMode=mirrored | Network mode; default nat |
dnsTunneling=true | Resolve DNS through Windows; default true |
firewall=true | Apply Windows firewall rules to WSL; default true |
autoProxy=true | Reuse the Windows proxy settings; default true |
localhostForwarding=true | Reach WSL ports on localhost (NAT mode); default true |
guiApplications=false | Turn WSLg off; default true |
nestedVirtualization=true | KVM inside WSL; default true |
vmIdleTimeout=60000 | Milliseconds before an idle VM stops |
defaultVhdSize=1099511627776 | Max disk size for new distros; default 1 TB |
Paths in .wslconfig need doubled backslashes, which is why the rows above write D:\\wsl\\swap.vhdx. Two more keys sit under [experimental]: autoMemoryReclaim (disabled, gradual or dropCache, the current default) and sparseVhd=true, which makes newly created disks sparse. A minimal file that caps a laptop at 8 GB and four cores looks like this:
notepad $env:USERPROFILE\.wslconfig
Add the section header and the two keys, then save the file:
[wsl2]
memory=8GB
processors=4
Nothing changes until the VM restarts. Run wsl --shutdown, open the distro again and check the new limit with free -h and nproc.
/etc/wsl.conf keys (per distro)
| Key | Default and meaning |
|---|---|
[boot] systemd=true | Run systemd as PID 1; on by default in the Ubuntu that wsl --install adds |
[boot] command=service ssh start | Run a command as root at distro start |
[user] default=harrison | Login user; needed after wsl --import |
[automount] root=/mnt/ | Where Windows drives appear; default /mnt/ |
[automount] options=metadata | Keep Linux permissions on /mnt/c files |
[automount] enabled=false | Stop mounting Windows drives; default true |
[network] hostname=wsl-ubuntu | Distro hostname; default the Windows name |
[network] generateResolvConf=false | Keep your own /etc/resolv.conf |
[interop] appendWindowsPath=false | Drop Windows folders from Linux $PATH |
[interop] enabled=false | Block running .exe files from Linux |
[time] useWindowsTimezone=true | Follow the Windows time zone; default true |
The file is plain INI, so the section header goes on its own line above the key. Edit it as root from inside the distro:
sudo vim /etc/wsl.conf
This example turns on systemd, sets the login user and keeps Windows folders out of the Linux $PATH, which speeds up tab completion noticeably on a PC with a long Windows path:
[boot]
systemd=true
[user]
default=harrison
[interop]
appendWindowsPath=false
Microsoft’s docs describe an “8 second rule”: a change is only read once the distro has fully stopped, which takes about 8 seconds after you close every shell. You don’t have to wait. wsl --terminate <distro> applies a wsl.conf change to one distro, and wsl --shutdown applies a .wslconfig change to the whole VM.
How do you check whether a distro runs WSL 1 or WSL 2?
Run wsl -l -v and read the VERSION column: it shows 1 or 2 for every installed distro, next to whether it is Running or Stopped, with an asterisk marking the default. New installs get WSL 2 unless someone ran wsl --set-default-version 1, so a 1 in that column usually means an old distro carried over from an earlier Windows 10 setup.
wsl -l -v
To convert, stop the distro and pass its exact name from that list. The conversion copies the whole filesystem into a new virtual disk, so it takes longer the more you have installed:
wsl --set-version Debian 2
Keep WSL 1 only for a distro that mostly works on files under /mnt/c, where WSL 1 avoids the cross-VM file access cost. Docker, systemd, GPU access, WSLg, --mount and the disk options of --manage (--move, --resize, --set-sparse, --compact) need WSL 2; --manage --set-default-user works on both.
How do you back up, clone or move a WSL distro?
Use wsl --export to back up and wsl --import to restore or clone, and use wsl --manage --move when you only want the disk on another drive. Export writes a tar file by default; --format tar.gz or tar.xz trades export time for a smaller file, and --vhd copies the ext4 disk image as it is. Stop the distro first so nothing writes to it during the export:
wsl --terminate Ubuntu-24.04
wsl --export Ubuntu-24.04 D:\backup\ubuntu-2404.tar.gz --format tar.gz
Importing that file under a new name gives you an independent copy, which is the quickest way to test an upgrade without touching your working distro. The install folder is where WSL creates the new ext4.vhdx:
wsl --import ubuntu-test D:\WSL\ubuntu-test D:\backup\ubuntu-2404.tar.gz
An imported distro logs in as root, because the import knows nothing about the user the first-run setup created. Set [user] default= in its /etc/wsl.conf or run wsl --manage ubuntu-test --set-default-user harrison, then terminate it once. The same export and import pair is how we move Fedora and RHEL images into WSL in our RHEL and Fedora on WSL guide.
When should you use wsl –shutdown instead of –terminate?
Use wsl --shutdown after editing .wslconfig, when the VM holds RAM you want back, or when networking inside WSL is stuck; use wsl --terminate for everything that concerns one distro. Shutdown stops the whole WSL 2 VM, so every open distro shell goes with it. Terminate leaves the VM and the other distros running.
Before either, check what is running so you know what you are about to stop:
wsl --list --running
The VM also stops on its own: vmIdleTimeout defaults to 60000 ms, so about a minute after the last distro stops, Windows gets its memory back without any command. WSL containers with wslc run in their own session VM that .wslconfig does not apply to, and Microsoft’s container settings page stops one with wslc system session terminate rather than a wsl command.
How do you mount a disk or VHD in WSL?
wsl --mount attaches a whole physical disk or a .vhdx to the WSL 2 VM, and it needs an elevated terminal. Microsoft’s mount page lists four limits. Check them before you plan a setup around it:
- The terminal runs as administrator, or the mount is refused.
- The disk is not in use by Windows and is not the Windows system disk.
- The disk is internal: USB sticks, flash drives and SD card readers are not supported.
- The filesystem is one the WSL kernel supports natively, such as ext4; NTFS goes through
/mnt/c-style drvfs instead.
Find the disk path from PowerShell first. The DeviceID column gives the \\.\PHYSICALDRIVE name that --mount expects:
Get-CimInstance -Query "SELECT * from Win32_DiskDrive"
A .vhdx is simpler, and it is also how you read files out of a distro export without importing it. Export with --vhd first, then mount the copy; --name sets the folder under /mnt/wsl/:
wsl --export Ubuntu-24.04 D:\backup\ubuntu-2404.vhdx --vhd
wsl --mount D:\backup\ubuntu-2404.vhdx --vhd --name oldubuntu
Run wsl --unmount with the same path when you are done. Without a path it detaches every mounted disk at once.
Common WSL errors and their fixes
Most WSL failures come down to a missing Windows feature, virtualization switched off in firmware or a damaged virtual disk. The messages below are quoted from Microsoft’s WSL troubleshooting and disk space pages, with what owners added in the Ask Ubuntu and WSL GitHub threads for the same codes.
Error 0x80370102: “The virtual machine could not be started because a required feature is not installed.”
WSL 2 cannot start its VM. Turn on virtualization (Intel VT-x or AMD-V) in the firmware, enable the Virtual Machine Platform feature and reboot. If WSL runs inside a VM, the host has to expose virtualization to it. Also check that the hypervisor is set to start with Windows:
bcdedit /enum | findstr -i hypervisorlaunchtype
If that prints Off, run bcdedit /set hypervisorlaunchtype Auto from an elevated prompt and reboot. When Windows 11 itself runs as a Hyper-V guest, an answer on the Ask Ubuntu thread for 0x80370102 pairs that bcdedit switch on the host with Set-VMProcessor -ExposeVirtualizationExtensions $true on the stopped VM.
WslRegisterDistribution failed with error 0x8007019e
The Windows Subsystem for Linux optional feature is not enabled. Run wsl --install --no-distribution from an elevated terminal, or tick Windows Subsystem for Linux in Turn Windows features on or off, then reboot and install the distro again.
“WSL 2 requires an update to its kernel component”
This shows up as error 0x1bc (0x800701bc) on old inbox installs of WSL, often after wsl --set-default-version 2. Run wsl --update to move to the Store-delivered WSL, which carries its own kernel, and check the result with wsl --version.
“An error occurred mounting the distribution disk, it was mounted read-only as a fallback.”
The distro’s ext4.vhdx has filesystem errors, usually after a forced shutdown or a full host disk. Shut WSL down, attach the disk bare, run e2fsck on it and detach it, then start the distro again:
wsl --shutdown
wsl --mount D:\WSL\debian\ext4.vhdx --vhd --bare
wsl --system -u root lsblk
wsl --system -u root e2fsck -f /dev/sdc
wsl --unmount D:\WSL\debian\ext4.vhdx
Microsoft’s disk space page runs a bare wsl sudo e2fsck, which starts your default distro. If that default is the broken one, WSL tries to attach the same .vhdx twice. That is what a Debian owner hit in WSL issue #10169 (Wsl/Service/CreateInstance/MountVhd/0x80070020, file in use). The block above uses --system -u root, suggested in that thread, which runs e2fsck in the hidden system distro; -u root matters, because without it e2fsck stops at “Permission denied”. It worked for the person who suggested it. It failed for the reporter with the same 0x80070020, and another installed distro fixed their disk: wsl -d Ubuntu -u root e2fsck -f /dev/sdc. Microsoft’s disk space page warns about this too: with a single distro installed, you may need to add a second one for the repair. Use the device that lsblk shows as the newly attached disk in place of /dev/sdc.
Error 0x8000FFFF: unexpected failure
Microsoft’s fix list for this one is generic: run the terminal as administrator, then wsl --update and wsl --shutdown, and repair Windows with sfc /scannow and DISM /Online /Cleanup-Image /RestoreHealth if it persists. Collect wsl --version and wsl -l -v before you open an issue, since the WSL issue template asks for both.
WSL health checklist
Run through these on a new PC or after a big Windows update; each one takes a single command from the tables above, and together they catch most of the problems in the error section before they bite:
wsl --versionreports the current stable WSL release.wsl -l -vshows VERSION 2 for every distro you use daily..wslconfigcapsmemoryon a PC with 16 GB of RAM or less.- Imported distros log in as your user, not root.
- Every distro you care about has a recent
wsl --exportfile.
For the Windows side of the same desk, our PowerShell cheat sheet, the CMD commands cheat sheet and the wslc cheat sheet cover the commands around WSL, and the full flag list lives in Microsoft’s basic commands for WSL page.