The Coding Notebook
Memorable coding moments of a software engineer
Installing multiple WSL distros
Summary on installing multiple WSL distributions side-by-side.

# Intro
Installing the "Default" WSL distro can be done from the Microsoft store, but it is also possible to install additional WSLs, this is nice if you want a temporary sandbox or something like that.

This post is a summary from the great [StackExcahnge]( thread. The answers are from users [biswapriyo]( and [pleasemorebacon](

**IMPORTANT**: This method works only if you have the `wsl.exe` command (Windows 10 Build 18305 or above). If not try using [LxRunOffline](

# Get Ubuntu distro
First we need to download a rootfs tarball from Ubuntu, these are available [here](
Download the `ubuntu-x.x-server-cloudimg-amd64-wsl.rootfs.tar.gz` file (x.x used as version number). Make sure the file name has `amd64-wsl` and the file type is `.tar.gz`.

Then we can install it using the `wsl` command:
wsl.exe --import <Distribution Name> <Install Folder> <.TAR.GZ File Path>

# Add non-root user
By default, when running the newly installed distro, it will run with the `root` user, we don't want that. Lets add a "normal" user.

First run the disto:
wsl -d <Distribution Name>

Next add a new user and then add it to the sudo group
adduser <username>
adduser <username> sudo

Next we'll set this new user to be the default user when the distro starts, this should be done by editing the `/etc/wsl.conf` file (which doesn't exist yet).
vi /etc/wsl.conf

And add this section:

That's it, type `logout` to exit and `wsl --shutdown <Distribution Name>` to terminate it. And then when running the distro again via `wsl -d <Distribution Name>` it should use the newly added user...