Delete WSL and return to initial state

The environment in wsl has been messed up so I will remove it and reinstall it. The goal is that when you reinstall, you will be prompted to determine your user name and password.

Uninstall the distribution from Windows “Apps and Features”. It deletes the app settings, but states that the documentation is not affected.

It was indeed removed. Next, install the software from the Microsoft Store.

After the installation is complete, when I start up WSL, the user settings screen does not appear, the previous user name is still there, and the installed data seems to be still there.

So, I try “Reset”, which is indicated as being able to delete the application.

However, in this case, the user settings screen does not appear and the previous status remains.

Next, we try to remove the WSL distribution using commands. By using the command prompt and PowerShell, we can perform more detailed operations.

First, display the list of currently installed WSL distributions. Enter the following command

wsl -l -v

This command will list all distributions and their versions installed on WSL.

This command will completely remove and initialize all data and settings for the selected distribution (in this case, Ubuntu). You will now be prompted for new user settings when you reinstall WSL.

wsl --unregister ubuntu

Now that you see that you are unregistered, start PowerShell again. This time you are now prompted to set a user name and password.

Having completely removed the user settings, the next step was to attempt a new installation from the command line.

wsl --install

I found the following

Uninstalling the distribution from Windows “Apps and Features” may retain the actual data and settings within the WSL virtual environment.

Therefore, to completely reset or uninstall the distribution, you must uninstall the specified distribution using wsl --unregister. When this command is used, WSL will remove all data and state from the specified distribution and initialize it.

Please share if you like it!
TOC