Installing WSL and Importing Linux Distributions

Newbie Spellweaver
Joined
Jun 5, 2023
Messages
39
Reaction score
64

STEP 0 — Download the distributions

Before importing, download the `.tar.xz` files of the Linux distributions (CentOS 7, Debian 11, and Debian 12) from Google Drive:

Save the files in an easy-to-access directory, such as `C:\Downloads\WSL`.

For more information about installing WSL, check Microsoft’s official documentation:

---

STEP 1 — Installing WSL

Open PowerShell as Administrator and run:

powershell
Install WSL and the default distribution
wsl --install

Check the installed version
wsl --version

Set WSL 2 as default (faster and more modern)
wsl --set-default-version 2


If the command complains about permissions or requires a restart, follow the instructions. Don’t panic—this is normal.

To make sure everything is working:

powershell
wsl -l -v


---

STEP 2 — Creating folders for your distributions

powershell
mkdir C:\WSL\CentOS7
mkdir C:\WSL\Debian11
mkdir C:\WSL\Debian12


Think of this as creating “little homes” for each Linux distribution to live in.

---

STEP 3 — Importing the `.tar.xz` files

powershell
CentOS 7
wsl --import CentOS7 C:\WSL\CentOS7 C:\Downloads\WSL\wsl-centos-7-master.tar.xz --version 2

Debian 11
wsl --import Debian11 C:\WSL\Debian11 C:\Downloads\WSL\wsl-debian-11-master.tar.xz --version 2

Debian 12
wsl --import Debian12 C:\WSL\Debian12 C:\Downloads\WSL\wsl-debian-12-master.tar.xz --version 2


Replace the path with the actual directory where you downloaded the files. Now each distro is ready to run on WSL.

---

STEP 4 — Running your distributions

powershell
wsl -d CentOS7
wsl -d Debian11
wsl -d Debian12


Each command opens a different distribution directly in Windows.

---

STEP 5 — Commands to play around with WSL

powershell
List all distributions
wsl -l -v

Change the version of a distro
wsl --set-version <DistroName> 2

Set default distro
wsl --set-default <DistroName>

Export distro (backup)
wsl --export <DistroName> C:\path\to\backup.tar

Remove distro
wsl --unregister <DistroName>

Run a specific command without opening the shell
wsl -d <DistroName> -- <command>

Open distro as root
wsl -d <DistroName> -u root


You can run Linux commands directly from Windows, like magic.
​
 
Back