There are quite a few things going on there ;-).
Via Apps (add/remove programs), I've removed WSL. I just found Windows Subsystem Linux in the list and clicked "uninstall".
When I go to cmd and type "bash", it puts me in Debian.
It's a bit of an odd situation, at least on Windows 10. This occurs because there are actually two installations of WSL:
The first is what's called the "in box" version of WSL. Up until recently, this was the only WSL. It's shipped with Windows and enabled in the Turn Windows Features on or off settings. Under Windows 10 (but not Windows 11), it's actually required as a dependency of the other version ...
Which is the application package version of WSL. This is now the primary way to install WSL, and when you uninstalled it from the Add or remove programs settings, this is what was removed. After it was removed, however, the older version still remained (and took over).
Neither of these is the Debian WSL distribution itself. That's a separate installation. Confused yet? ;-)
So you really should reinstall WSL from the Microsoft Store to make sure you have the latest.
I use wsl --install --distribution Debian and end up with a version of Debian that won't start. If I type wsl in cmd, it just goes directly back to cmd:
If I type Debian
, same thing.
But if I type bash
, I get kicked into a Debian install
That is odd - wsl
and bash
should do the same thing, just with the wsl
command providing more options. However, the bash
command is deprecated in WSL, so I can't say for sure what's happening here.
A wsl -l -v
might show more than one distribution installed, but even that wouldn't account for exactly what you are seeing.
If you really do want to uninstall a distribution, as @Ramhound mentioned in the comments, you can use:
wsl --unregister <distro>
where I cannot change my root password and have forgotten my root password.
If someone knows how to reset the root password, let me know. Of course, wsl ~ -u root -e chsh
gives me a password prompt, but I don't know the password so that's useless.
It sounds like you are looking for the passwd
command rather than chsh
. The former changes the password, the later the default shell for a user.
That said, there is no initial password for root
in most Linux distributions nowadays. Your initial non-root user should be added to sudoers
(again by default, even when not using WSL). This is something that the WSL distribution installers do for you. Having a root password is considered a bad security practice, since it gives root the ability to login without accountability or logging.
If you need to reset your user password (so that you can sudo
), you can do that quite easily from PowerShell:
wsl -l -v # Confirm distribution name
wsl ~ -u root -d <distro> -e passwd <username>
If you don't know the default username, it's usually UID 1000, so you can find it (again from PowerShell) with:
wsl id -un 1000
Again, add the -d <distro>
if needed.
Of course, wsl ~ -u root -e chsh
gives me a password prompt, but I don't know the password so that's useless.
I will say that's odd, though. chsh
as a root user doesn't ask for a password on my Debian installation under WSL. That's the case even if I (pathologically) set a root password.
wsl --unregister Debian
before trying to reinstall Debian?wsl -u root -e passwd
.