57

I was fooling around a bit with the Linux/Bash subsystem for Win10.

But then I decided to stay with Cygwin for now. So I uninstalled it - or thought I did.

Now I've installed Cygwin and put its bin directory first in the PATH.

In cmd.exe , when I type bash , it will start the Cygwin's Bash.

But when I do Win+R and type bash, I still get the prompt:

Windows Subsystem for Linux has no installed distributions.
…bla-bla-bla…

How do I get rid of the Linux/Bash subsystem entirely, so it will instead pick up Cygwin's Bash from the PATH?

robinCTS
  • 4,327
  • 4
  • 20
  • 29
Rop
  • 1,171
  • 1
  • 8
  • 11
  • Does this answer your question? [Completely reinstall WSL](https://superuser.com/questions/1619233/completely-reinstall-wsl) – Matt Aug 07 '23 at 07:54
  • @Matt why vote to close the more upvoted question? One is Windows 10 specific, other one not necessarily, too. – Destroy666 Aug 07 '23 at 22:18
  • @destroy666 - For me this question sounded very similar as the other question, because the other question states "So I want remove WSL (= Windows Subsystem for Linux) as deeply as possible and reinstall WSL 2 from scratch" - reinstalling means that you have the choice again to choose a different distribution. – Matt Aug 08 '23 at 12:02

7 Answers7

63

If your OS has been upgraded to the Fall Creators Update, you should be able to issue the command wslconfig.

You could of course try uninstalling first by using the command lxrun /uninstall /full.

If its still there, you can try unregistering the distro:

  • First you need to know which distro is installed by using

    wslconfig /l
    
  • From the list choose the distro (e.g. Ubuntu) you want to uninstall and type the command

    wslconfig /u Ubuntu
    
robinCTS
  • 4,327
  • 4
  • 20
  • 29
Casey SV
  • 739
  • 1
  • 5
  • 4
  • 6
    lxrun was deprecated with the release of 1709, and wslconfig doesn’t exist before it, this could be a decent answer if it was improved to be specific. Author was using 1703 (or earlier) by the way. – Ramhound Jul 10 '18 at 03:15
  • Works as of Apr 2019. – Desik Apr 05 '19 at 16:12
  • 13
    I had to do a `wslconfig /u Legacy` to remove the Ubuntu that was shipped with Windows. – Kees C. Bakker May 06 '19 at 07:21
48

In order to disable WSL, one has to go back into

Control Panel -> programs-features -> turn on/off Windows features and deselect Windows Subsystem for Linux, and Save.

Rop
  • 1,171
  • 1
  • 8
  • 11
  • 2
    Note that this will remove all WSL installs. If you just want to remove one (such as because you installed WSL 2 and want to remove WSL 1), use `wslconfig` as described here: https://superuser.com/a/1337814/605884. For example, to uninstall the WSL 1 install, use `wslconfig /u Legacy` – Zags Mar 24 '21 at 22:49
  • This didn't work for me as the ticked checkbox was greyed out. Power-shell answer from Abraham did work however. – user65823 Sep 13 '21 at 08:54
  • I unregistered Ubuntu, then turned off Windows Subsystem for Linux, rebooted and turned it on again. To my surprise Ubuntu was still there afterwards (the user I created was shown on the prompt of the Linux shell). How to remove the distribution completely? – Matt Aug 08 '23 at 12:33
5

Edit - This would only work on Windows Server, not on Client OS.

Similar to what Rop suggested, but you can also use Powershell to completely remove the Windows Subsystem for Linux, with the advantage of not having to look for it in Control Panel. Note that you will have to run this as an administrator.

Remove-WindowsFeature Microsoft-Windows-Subsystem-Linux

List all the features available, filtering for Linux:

Get-WindowsFeature | Where-Object Name -like '*linux*' | Select-Object Name
Abraham
  • 176
  • 1
  • 5
  • 3
    FYI, OP asked for Win10; Remove-WindowsFeature doesn't work on client O/S `PS C:\Windows\system32> Remove-WindowsFeature -Name Microsoft-Windows-Subsystem-Linux Remove-WindowsFeature : The target of the specified cmdlet cannot be a Windows client-based operating system.` – DarkMoon Jun 22 '20 at 02:34
  • 1
    @DarkMoon, thank you for pointing that out. Edited to make that obvious to avoid causing heartache to anyone else. – Abraham Jun 22 '20 at 21:52
2

I combined removing Ubuntu-18.04

wslconfig /l 
wslconfig /u 'Ubuntu-18.04'

and with adding and launching Ubuntu-20.04 from the Windows store to successfully get WSL 2.0 running again it stopped working. I was getting

[process exited with code 4294967295] 

when I launched wsl 2.

Greenonline
  • 2,235
  • 11
  • 24
  • 30
David Dyck
  • 61
  • 4
2

Just a few notes for experimenters, but for Windows 10 client o/s, you can use the following:

 (Get-WindowsOptionalFeature -Online -FeatureName '*linux*') | Select-Object FeatureName

Then:

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

Or the analogue:

Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux

You can use other tooling to the same affect, such as dism.exe (as illustrated here: https://evidencen.com/wsl2/)

JustinC
  • 131
  • 3
2

I can't seem to get a clean uninstall of WSL. I had WSl2 installed and was having DNS problems so I wanted to uninstall everything and go back to WSL 1.

I turn off the feature, delete the distros, delete the "WSL update app", make sure HyperVisor and Windows Subsystem for Linux are disabled in "Programs and Features", and reboot.

It looks like it's uninstalled.

But then when I try to install the minimum WSL again (ie just enabling WSL in Windows Programs and Features, rebooting, and downloading a distro, when I launch the distro I get

"... WLS 2 requires an update to its kernel component.."

Why is it complaining about WSL2? I'm just trying to install WSL1? My guess is that there is some registry bit or something that still makes it look like I'm trying to use WSL 2.

Any ideas on how to get a truly clean uninstall of WSL so I can get back to version 1?

  • 2
    This is a question, not an answer. :) Incidentally it's the question I'm trying to find the answer for, so it would be great if someone would ask it. – Chaim Eliyah Oct 10 '21 at 18:41
1

Windows 10:

  • search: "optional features" (-> manage optional features)
  • second last entry on page: more windows features
  • second last entry: WSL
user1050755
  • 113
  • 4