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

16
  • wsl --unregister Ubuntu should remove it. If that doesn't work, provide the output, for wsl --list --verbose as an edit to your question.
    – Ramhound
    Commented Jul 21, 2021 at 14:29
  • If the output to wsl --list --verbose is an empty list then you can simply delete the folder, since I am going to guess the reason you want to uninstall it, is because you were unable to figure out how to start it.
    – Ramhound
    Commented Jul 21, 2021 at 14:35
  • I don't recommend a wsl --unregister until we figure out if the appx is still installed. It probably can't hurt, but if the real goal is to "go back to how things were before installing Ubuntu", then it won't do that, since the Application itself would still be installed. Does a Get-AppxPackage | Where-Object { $_ -like "*Ubuntu*" } return any results? Commented Jul 21, 2021 at 15:22
  • 1
    Do you want to just uninstall the Ubuntu instance, or do you want to completely uninstall WSL? It's unclear to me why you don't have the "App" installed any longer (to be able to just use the normal Windows "Uninstall" functionality). Did you by chance do a wsl --import at any point? Anyway, since the App isn't there, do as @Ramhound suggested and wsl --unregister. If you want to completely uninstall WSL, see this answer. The Remove-AppxPackage isn't going to work for you since Get-AppxPackage indicates that it's not there. Commented Jul 23, 2021 at 15:06
  • 1
    @SuperFluo - If you want to remove the Ubuntu-20.04 instance just run the command wslconfig /unregister Ubuntu-20.04 in an elevated PowerShell prompt.
    – Ramhound
    Commented Jul 23, 2021 at 15:11

1 Answer 1

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

}
4
  • 1
    You've already given same answer here if those 2 questions are duplicate, flag them.
    – Toto
    Commented Apr 10, 2023 at 11:55
  • 1
    Alternatively, as it's not appropriate in the other question, delete that answer. Commented Apr 10, 2023 at 12:42
  • @Toto, since the other one has no accepted answer, it cant be used as a duplicate. Commented Apr 10, 2023 at 13:21
  • Why did you roll back my edit? I intended it to use syntax highlighting to make it easier to read. Commented Apr 13, 2023 at 18:53

Not the answer you're looking for? Browse other questions tagged .