4

I have Windows 10 (build 19042.1110) installed on my PC, and I wanted to install Ubuntu 20.04 using WSL (Windows Subsystem for Linux). So I enabled the WSL. However, I've not used the Microsoft Store to download Ubuntu: I downloaded the distribution directly from here (the .appx file)

Then, I followed these instructions and everything went fine. I created an account with password on Ubuntu, and did the updates/upgrades with apt get update and apt get upgrade.

Then I wanted to uninstall the distribution, but now I can't find it in the app&features panel nor in the start menu. If I search for "ubuntu" or "linux" on the start menu, I find nothing. I think this is due to the fact that I've not used the Microsoft Store.

How can I uninstall the distribution? I'd like to go back to how things were before installing Ubuntu. I've thought of using a system restore point, but I think this is unnecessary.

I've run the command wsl --list --verbose to check and I got this:

  NAME             STATE          VERSION
* Ubuntu-20.04     Stopped        1

While the command Get-AppxPackage | Where-Object { $_ -like "*Ubuntu*" } didn't output anything.

Also, I found this, don't know if that's my case. However, the same page in my native language suggests using lxrun /uninstall /full for builds before the 1709 (16299) build, while for later builds it suggests using the Remove-AppxPackage cmdlet (which I don't know the syntax of).

Ramhound
  • 44,080

1 Answers1

-2

You can use below script to uninstall Linux distros from system

# Uninstall Linux distributions installed on asset

$packages = Get-AppxPackage -AllUsers | Where-Object {($.Name -like 'Ubuntu' -or $.Name -like 'Debian' -or $.Name -like 'Fedora' -or $.Name -like 'Kali' -or $.Name -like 'Suse' -or $.Name -like 'Arch' -or $.Name -like 'Alpine' -or $.Name -like 'openSUSE') -and $_.Name -notlike 'Microsoft.Windows.Search'}

if ($packages.Count -gt 0) {

Write-Host "Linux distributions found:"

$packages | Select-Object -Property Name, Publisher, Version | Write-Host

foreach ($package in $packages){

Remove-AppPackage $package

}

Write-Host "Linux distributions removed completely with their files"

} else {

Write-Host "No Linux distributions found." 

}