Reinstalling a WSL Disto

This post is a guide on how to reinstall WSL (Windows Subsystem for Linux) via command. This may be useful if you are looking to clear down and start a up fresh WSL instance, treating it as a throw-away environment. You should have any WIP code backed up to Git before running this.

To remove a WSL distribution and its data, run wsl --unregister <distro-name>, amend the statement with the name of the distribution, which you can see by running wsl -l.

You can also uninstall each of your WSL Linux distro apps on your machine via the Microsoft Store. This blog post shows examples of the command-line way.

The following is included here:
# List Installed WSL Distros
# Uninstall a WSL Distro
# Install Ubuntu on WSL

List Installed WSL Distros

We need to know the WSL distribution name which we want to remove. Run the following to show the currently installed Linux Distributions on your system:

wsl -l

Unregister/Uninstall a WSL Distro

Caution: Once unregistered, all data, settings, and software associated with that distribution will be permanently lost. Reinstalling from the store will install a clean copy of the distribution. (MS Docs).

The following command will uninstall a WSL Distro:

wsl --unregister <distro-name>

Install Ubuntu WSL

My previous blog post covers installing Ubuntu 20.04 on WSL. It includes how to install Ubuntu via command or the Microsoft Store.

We run the .exe file when doing this via command, entering the username/password details when prompted.


Comments

Leave a Reply

Your email address will not be published. Required fields are marked *