Amazon Cyber Monday deals See deals →ad

Mets Minor League Blog

Music theory, instruments and musicians

Mets Minor League Blog

Music theory, instruments and musicians

Uninstall WSL Through PowerShell: Step-by-Step Guide

You can uninstall Windows Subsystem for Linux (WSL) from PowerShell, but removing the WSL engine is different from deleting a Linux distribution. A distribution can contain files you want to keep, and unregistering it permanently deletes its WSL data. Before you start, decide whether you want to remove one distribution, WSL itself, or both. The steps below show how to check what is installed, back up anything important, and remove the components safely.

What You’ll Need

  • A Windows 10 or Windows 11 account with administrator access. You can inspect distributions without elevation, but uninstalling Windows features requires an elevated PowerShell window.
  • PowerShell or Windows Terminal. To open an elevated session, search for PowerShell or Terminal, right-click it, and select Run as administrator.
  • Enough free disk space for a backup if you plan to export a Linux distribution. An export file can be large, so choose a drive with room for your distribution’s data.
  • A clear decision about whether to keep your Linux files. Unregistering a distribution erases its filesystem, including files in its Linux home directory.

Step-by-Step

  1. Check your WSL installation and distribution names. Open PowerShell and run:
    wsl --list --verbose
    wsl --status

    The first command lists registered distributions and indicates whether each uses WSL 1 or WSL 2. Names might look like Ubuntu, Debian, or Ubuntu-24.04; use the exact spelling shown in your output in later commands. The status command reports general WSL information. If the list is empty, there may be no registered distributions to remove, even if WSL components are still installed.

  2. Back up any Linux files you want to keep. To export a distribution to a tar archive, replace Ubuntu with its exact listed name and choose a suitable destination:
    wsl --export Ubuntu D:\Backups\Ubuntu-backup.tar

    Wait for the command to finish, then check that the file exists and has a plausible size. An export is a backup of that distribution’s Linux filesystem; it does not back up Windows files stored outside the distribution, such as files in your Windows Documents folder. If you only need a few files, you can copy them to a Windows location before removing the distribution instead. Keep the export somewhere safe and do not store your only copy inside the distribution you are about to delete.

  3. Stop running WSL processes. In PowerShell, run:
    wsl --shutdown

    This stops running distributions and the WSL virtual machine. Save work in Linux applications first: shutdown closes their processes, so unsaved changes can be lost. If a distribution remains busy, close its terminals and applications, run the command again, and allow a few moments for shutdown to complete.

  4. Decide whether you are removing distributions as well as WSL. If your goal is to remove a particular Linux distribution and its stored data, run the following with its exact name:
    wsl --unregister Ubuntu

    This permanently deletes that distribution’s WSL filesystem. It is not a temporary removal and does not merely uninstall a terminal shortcut. Repeat the command only for distributions you intend to erase. If you want to keep a distribution’s data, do not unregister it unless you have verified a usable export and understand that you may need to import that archive later. To remove only the WSL platform, skip this step; do not delete distributions just because you are uninstalling the engine.

  5. Run the WSL uninstall command. In an elevated PowerShell window, first check whether your installed WSL version supports the command:
    wsl --help

    If the help output lists --uninstall, run:

    wsl --uninstall

    Follow any prompt and wait for the operation to finish. This removes the WSL application or platform components managed by that command. If PowerShell reports that the option is unknown, your WSL version may be older or installed through a different Windows component. Continue to the fallback below rather than repeatedly trying the unsupported command.

  6. Use the installed-package fallback if needed. If WSL was installed as a package and wsl --uninstall is unavailable, check whether Windows Package Manager can identify it:
    winget list WSL

    If the results show the WSL package and its ID, use that exact ID in the uninstall command. On systems where the listed ID is Microsoft.WSL, for example, run:

    winget uninstall --id Microsoft.WSL

    Review the package name and any confirmation prompt before proceeding. Package IDs can differ as installation methods and versions change. If no WSL package appears, do not guess an ID; use the Windows optional-feature method in the next step or check Installed apps in Windows Settings.

  7. Disable the Windows features only if you want them removed. Some installations use the optional feature named Windows Subsystem for Linux. WSL 2 also uses Virtual Machine Platform. To check their state, run these commands in elevated PowerShell:
    Get-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
    Get-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform

    If a feature is enabled and you want it disabled, run the corresponding command:

    Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux -NoRestart
    Disable-WindowsOptionalFeature -Online -FeatureName VirtualMachinePlatform -NoRestart

    Run only the commands for features you have decided to remove. Virtual Machine Platform may be used by other software, including virtual machines or other Windows features, so do not disable it automatically just to remove a WSL distribution. Windows may require a restart before the change takes effect.

  8. Restart and verify the result. Restart Windows if an uninstall or feature-change prompt requests it. After restarting, open PowerShell and run wsl --list --verbose and wsl --status. If the goal was only to remove a distribution, confirm it no longer appears. If the goal was to uninstall WSL, check whether the WSL command or application is still present and use the troubleshooting steps below if it is. A remaining optional feature does not necessarily mean a Linux distribution is still installed.

Common Mistakes

  • Confusing unregistering with uninstalling. wsl --unregister deletes one distribution and its data; it does not uninstall every WSL component. Conversely, uninstalling the WSL engine is not the same as choosing which distribution data to erase.
  • Running the wrong distribution name. The name must match the output of wsl --list --verbose. A display name seen in a shortcut may not be the exact registered name.
  • Skipping the backup. After unregistering a distribution, its files are not normally recoverable through WSL. Export first if you might need them later, and verify the archive before deleting the original.
  • Disabling Virtual Machine Platform without checking other uses. Other virtualization tools or Windows features may depend on it. Remove it only when you are confident nothing else on the PC needs it.
  • Assuming every command works on every Windows version. The available uninstall options depend on how WSL was installed and how current it is. Check command help and installed-feature state instead of treating an error as a reason to run unrelated removal commands.

Tips

  • Write down the distribution names and decide which ones to keep before running any destructive command. If you have multiple distributions, export each one you may want to restore.
  • Keep backups outside WSL, preferably on a different drive or in a secure backup location. A file saved only inside a distribution will disappear when that distribution is unregistered.
  • If your goal is just to free disk space, identify the large distribution first. Removing every WSL feature may be unnecessary; deleting an unused distribution may be enough, but it also deletes that distribution’s data.
  • Use an elevated PowerShell session for feature changes, and read confirmation messages carefully. Commands that change optional features may report that a restart is needed even when they finish successfully.
  • If you may reinstall WSL, save your export archive and note which distribution and WSL version you used. That makes it easier to import or recreate the environment later.

Troubleshooting

PowerShell says that wsl is not recognized. WSL may already be removed, or the command may not be available in that Windows installation. Check Installed apps and Windows optional features. If you expected WSL to be present, install or enable it through supported Windows tools rather than downloading an unknown executable.

wsl --uninstall is an unrecognized option. This usually means the installed WSL command does not support that option. Run wsl --help to see available commands, then use winget list WSL to check for an installed package. If it is not listed, inspect the optional features with Get-WindowsOptionalFeature. You can also remove a listed WSL app through Windows Settings under Apps and Installed apps.

A feature command says access is denied. Close the current window, reopen PowerShell using Run as administrator, and try again. On a managed work or school computer, policy may prevent changes; contact the administrator rather than trying to bypass the restriction.

Windows asks for a restart or reports a pending operation. Save your work and restart the computer before checking again. Do not repeatedly issue feature-disable commands while Windows is waiting for a restart. After booting, rerun the feature query to see whether its state changed.

A distribution still appears after removing WSL. Check its exact name with wsl --list --verbose. If the distribution itself is what you want gone, unregister it while the WSL command is still available. If it is already unavailable, check Installed apps for a separately installed Linux distribution and remove that app through its normal uninstall option. Do not delete WSL folders manually unless you have a verified backup and know exactly what the folder contains.

Frequently Asked Questions

Does uninstalling WSL delete my Linux files?
Do not assume your files will be preserved or removed in a particular way by every uninstall method. Explicitly export any data you want to keep. wsl --unregister definitely deletes the named distribution’s filesystem.

Can I remove Ubuntu but keep WSL?
Yes. Use wsl --list --verbose to find the exact distribution name, then run wsl --unregister Ubuntu with that name. This deletes Ubuntu’s WSL data but leaves the WSL platform available for other distributions.

Can I uninstall WSL without restarting Windows?
You can run the uninstall commands without restarting in some cases, but disabling Windows optional features can require a restart to finish. If Windows requests one, restart before treating the removal as complete.

Should I disable Virtual Machine Platform too?
Only if you want it removed and no other software or Windows feature depends on it. WSL 2 uses it, but it is a separate optional feature and may be useful for other virtualization needs.

How do I restore a distribution from an export?
After reinstalling or enabling WSL, use wsl --import with a chosen distribution name, an installation folder, and the tar file you exported. For example, check wsl --help for the correct syntax on your version and choose a folder with enough space.

Uninstall WSL Through PowerShell: Step-by-Step Guide
Scroll to top