/
/

How to Uninstall WSL Distro in Windows 11

How to Uninstall WSL Distro in Windows 11 blog banner image

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:
    1. Open the Start Menu, and search for Command Prompt.
    2. Right-click Command Prompt > Run as administrator > Yes.
    3. 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)

  1. Open the Start Menu, and search for Command Prompt.
  2. Right-click Command Prompt > Run as administrator > Yes.
  3. Type wsl –list and press Enter to list all the installed distros.
  4. 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.
  5. 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.

  1. Open the Start Menu, and search for Windows PowerShell.
  2. Right-click Windows PowerShell > Run as administrator > Yes.
  3. 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"

}

}

  1. 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.

  1. Open the Start Menu > Settings.
  2. Go to Apps in the sidebar > Installed apps.
  3. Find the distro you want to uninstall.
  4. Click the ellipsis menu > Uninstall.
  5. 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.

  1. Press Win+R, type gpedit.msc in the text box, and click OK.
  2. Navigate to Computer Configuration > Administrative Templates > Windows Components > Windows Subsystem for Linux.
  3. Find the Allow WSL policy and double-click.
  4. 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.

You might also like

Ready to simplify the hardest parts of IT?
×

See NinjaOne in action!

By submitting this form, I accept NinjaOne's privacy policy.

NinjaOne Terms & Conditions

By clicking the “I Accept” button below, you indicate your acceptance of the following legal terms as well as our Terms of Use:

  • Ownership Rights: NinjaOne owns and will continue to own all right, title, and interest in and to the script (including the copyright). NinjaOne is giving you a limited license to use the script in accordance with these legal terms.
  • Use Limitation: You may only use the script for your legitimate personal or internal business purposes, and you may not share the script with another party.
  • Republication Prohibition: Under no circumstances are you permitted to re-publish the script in any script library belonging to or under the control of any other software provider.
  • Warranty Disclaimer: The script is provided “as is” and “as available”, without warranty of any kind. NinjaOne makes no promise or guarantee that the script will be free from defects or that it will meet your specific needs or expectations.
  • Assumption of Risk: Your use of the script is at your own risk. You acknowledge that there are certain inherent risks in using the script, and you understand and assume each of those risks.
  • Waiver and Release: You will not hold NinjaOne responsible for any adverse or unintended consequences resulting from your use of the script, and you waive any legal or equitable rights or remedies you may have against NinjaOne relating to your use of the script.
  • EULA: If you are a NinjaOne customer, your use of the script is subject to the End User License Agreement applicable to you (EULA).