Get all your news in one place.
100’s of premium titles.
One app.
Start reading
Windows Central
Windows Central
Technology
Richard Devine

How to completely remove a Linux distro from the Windows Subsystem for Linux (WSL)

WSL.

In recent years, setting up the Windows Subsystem for Linux (WSL) on both Windows 10 and Windows 11 has become significantly more straightforward. The tool has now reached version 1.0 and is widely available through the Microsoft Store, in addition to other installation methods based on GitHub and terminal commands.

One of the significant advantages of Windows Subsystem for Linux (WSL) is the ability to configure a complete Linux distribution and seamlessly incorporate it into your Windows workflow. Unlike a traditional virtual machine, WSL interacts directly with your Windows installation. If any issues arise, you can easily reset it and begin anew.

But how do you actually remove a Linux distro installed in WSL? On the face of things, you might think you just have to uninstall the "app" for the particular distro you installed, but that's only half of the battle. If you simply do this then you'll still have an entire file system left behind. And it's not possible for custom distros installed from outside the Microsoft Store. 

Here's how to completely remove a Linux distro from WSL.

How to completely remove a Linux distro from WSL

Checking installed WSL distros and their current state using PowerShell. (Image credit: Windows Central)

Indeed you can simply right-click and uninstall Ubuntu, Debian, or any of the other Linux distros you might have set up on WSL. Installing them is as easy as downloading from the Microsoft Store, and removing them is as easy as any other Store app. Alternatively, you can do the same with winget in the terminal if you're a fan of using the Windows Package Manager.

But this doesn't completely remove all traces. Data and the file system created will be left behind, so for that, you need to instruct WSL to remove it in the terminal. So do the uninstalling of the app second, ideally.

Here's what you need to do.

  1. Open up PowerShell.
  2. To get the exact name for the distro you want, enter wsl -l -v.
  3. Enter into the terminal wsl --unregister .

The unregister option will tell WSL to completely destroy all traces of the file system and any data contained within it. So, for example, if you wanted to remove an installation of Debian your command would look like this:

wsl --unregister Debian

It's case-sensitive, too, and has to be exact, which is why it's a good idea to run the second step first. Ubuntu, for example, has a number of different versions, and you may well need to be specific to a version number, such as Ubuntu 20.04. Though this will depend on which package you installed in the first instance.

This process should remove any associated file systems, but it's worth opening up File Explorer and having a look just to make sure. WSL file systems are easily accessed from the sidebar, and if anything is left behind you can manually delete it.

Backing up and importing to WSL

Exporting your WSL distros to a backup only takes a single command and a couple of minutes.  (Image credit: Windows Central)

While WSL can be disposable, it's also a good idea to back up your installations so if you do get rid of one you can get back to where you were a little easier.

Backing up is a pretty straightforward process that involves exporting to a .tar file. Our guides on exporting and importing Linux installs in WSL will take you through the process step by step, but the main commands you need are as follows:

wsl --export  

wsl --import    

The process doesn't take too long, and it's particularly useful if you plan on making frequent changes to your WSL installs.

Sign up to read this article
Read news from 100’s of titles, curated specifically for you.
Already a member? Sign in here
Related Stories
Top stories on inkl right now
One subscription that gives you access to news from hundreds of sites
Already a member? Sign in here
Our Picks
Fourteen days free
Download the app
One app. One membership.
100+ trusted global sources.