shiben.tech

WSL - Use it as a Pro

Saturday, 22 March 2025, 10:25 AM
# tech linux

WSL is a Microsoft's offering of Linux inside Windows and is actually pretty good. It can be installed very easily from Microsoft Store or from your command prompt using wsl.exe --update followed by wsl.exe --install. But you get no control where it is getting installed or if you want to manage instances of it. Let's look at doing this the pro way.

We will have to first download a WSL Package from the source. To install this, run the following command:

wsl.exe --import ubuntu_base "D:\path\to\installation-location\" "D:\path\to\downloaded-tar-file"

You can go to the location and verify the installation. Now use the following command to run it.

wsl.exe -d ubuntu_base

Lets say you want to make a copy of this installation. You can do so by "exporting" your installation to a tar file and then "importing" it to another installation, thereby making a copy.

wsl.exe --export ubuntu_base "D:\path\to\base-tar-file"
wsl.exe --import ubuntu_custom "D:\path\to\installation-location\" "D:\path\to\base-tar-file"

You can list all your instances at any point by running:

wsl.exe -l -v

Also you can shutdown a running WSL instance by doing the following:

wsl.exe --terminate ubuntu_custom

If you want to shutdown all of them at once, then:

wsl.exe --shutdown

Delete an installation by running the following:

wsl.exe --unregister ubuntu_custom

Follow the step-by-step instructions shown in this video to understand this thoroughly.

Now you are a pro and can brag to your friends about the 10 WSL instances you maintain for different purposes.