WSL allows Windows users to run Linux natively on their computers. It’s a good tool for creating staging and development environments for different projects. However, over time, you might accumulate too many WSL distros in your device and want to uninstall WSL on your Windows 11 computer. However, doing so will delete all the data associated with the WSL distro.
This makes it an important skill to learn if you want to avoid unintended consequences. Before you commit to uninstalling a WSL distro from your Windows 11 computer, you must take into account many aspects. This guide will walk you through what WSL is, why you would want to install it, the steps of multiple ways to uninstall it, and some additional thing you might want to consider.
Step-by-step guide for uninstalling a WSL distro
Before proceeding
- Make sure you have full administrative privileges, especially for executing scripts and making changes to the device.
- Confirm which WSL distros are installed on your computer. To do that, follow steps 1-3 of this guide.
- Make a backup of your WSL data:
- Open the Start Menu, and search for Command Prompt.
- Right-click Command Prompt > Run as administrator > Yes.
- Type wsl –export <DistroName> [File path where you want to store the backup] and press Enter. For example, if you want to uninstall the Ubuntu distro, you have to type wsl –export Ubuntu [File path where you want to store the backup] then press Enter.
- Here is a sample file path: C:\Users\User1\Ubuntu.tar
- Ubuntu.tar is a sample file name. You can use whatever file name you want as long as you use the .tar extension.
Method 1: Uninstall via Command Prompt (CMD)
- Open the Start Menu, and search for Command Prompt.
- Right-click Command Prompt > Run as administrator > Yes.
- Type wsl –list and press Enter to list all the installed distros.
- Find the distro you want to uninstall, input wsl –unregister <DistroName>, and press Enter. For example, if you want to uninstall the Ubuntu distro, you have to type wsl –unregister Ubuntu and press Enter.
- The Linux distro and all its data should be permanently deleted from the computer now. You can close Command Prompt.
Method 2: Uninstall via PowerShell
While Command Prompt is useful for deleting WSL distros on individual devices, this might not be helpful at scale. If you’re managing multiple devices, it’s easier to use Remote PowerShell to run a script that will remove the WSL distro from multiple computers at the same time.
- Open the Start Menu, and search for Windows PowerShell.
- Right-click Windows PowerShell > Run as administrator > Yes.
- Type this script into Windows PowerShell (in this situation, “Ubuntu” is the sample name of the distro. Replace it with the name of the distro you want to uninstall in your devices:
$computers = Get-Content "C:\scripts\machine_list.txt"
foreach ($computer in $computers) {
Invoke-Command -ComputerName $computer -ScriptBlock {
wsl --unregister "Ubuntu"
}
}
- The Linux distro and all its data should be permanently deleted from all the devices you applied the script to. You can close Windows PowerShell.
Method 3: Uninstall via Windows Settings (GUI)
If you want to allow end users or non-IT staff to uninstall the WSL distro themself, this is the best option available for them. This can also be a method administrators can use if they prefer a graphical interface instead of scripting through Command Prompt or Windows PowerShell.
- Open the Start Menu > Settings.
- Go to Apps in the sidebar > Installed apps.
- Find the distro you want to uninstall.
- Click the ellipsis menu > Uninstall.
- Confirm when prompted.
Method 4: Group Policy (GPO) workaround
There is no specific group policy that will delete a WSL distro. However, you can disable WSL usage entirely.
- Press Win+R, type gpedit.msc in the text box, and click OK.
- Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Subsystem for Linux.
- Find the Allow WSL policy and double-click.
- Set it to Disabled > OK.
This won’t remove the WSL distro and its data from the computer, but it will prevent users from accessing it. If you want it deleted, use Command Prompt.
Additional considerations when uninstalling WSL distro
- If you’re managing multiple distros, make sure that you’re using the correct distro name when using wsl –unregister to avoid removing the wrong one.
- Using wsl –unregister will remove most of the data of the WSL files, but to be sure everything is deleted, go to File Explorer and type this into the address bar %USERPROFILE%\AppData\Local\Packages to check for residual files and folders.
- If you installed the distro via the Microsoft Store, uninstalling it via Settings is the quickest and most straightforward option for removing it.
What is a WSL distro?
Windows Subsystem for Linux (WSL) is a Linux distro. It allows you to run Linux environments using Windows computers. It gives you the best of both worlds, working both with distros that can only be found in the Microsoft Store and Linux distros that are available elsewhere.
With WSL, you can command-line programs like BASH and put files in isolated Linux file systems. It’s especially useful for testing and staging environments that work better for Linux instead of Windows.
Why uninstall a WSL distro?
There are a lot of reasons why you might want or need to uninstall a WSL distro. Freeing up storage space is the most straightforward reason. If you have duplicate distros or have finished using the WSL distro as a testing or development environment, then it’s more efficient to remove it from the computer.
It’s also an added layer of safety and security. If there are unauthorized WSL distro in a computer, then it’s essential to remove them as quickly as possible. And if it’s become corrupted or misconfigured, it might lead to unintended consequences for the device. It’s best to uninstall and reinstall the distro instead.
How to uninstall a WSL distro
There are many ways to uninstall a WSL distro from Windows 11. You can do it through Settings or through Command Prompt. If you’re dealing with multiple devices, you can also run a script through Windows PowerShell to delete it simultaneously on different computers. And if you have trouble accessing those options, you can also disable access to WSL entirely through Group Policies.