How to set default distro using WSL2 on Windows 10

On Windows 10, you can install multiple Linux distributions using WSL2 (Windows Subsystem for Linux 2). The only caveat is that the first one you install will be the default automatically, which means that you cannot run your preferred distro with certain commands, such as wsl, out-of-the-box if you installed another distro before the one you like.

However, if you want to use another Linux distribution, WSL includes a command to set any distro you wish to as the new default on Windows 10.

In this guide, you will learn the steps to make your preferred distro the new default on Windows 10.

Set default Linux distro on WSL2

To set a Linux distro as the default on Windows Subsystem for Linux 2, use these steps:

.Windows_Software_Technology-Big-343{display:inline-block;width:300px;height:600px}@media(min-width: 500px){.Windows_Software_Technology-Big-343{width:300px;height:600px}}
  1. Open Start on Windows 10.

  2. Search for Command Prompt, right-click the top result, and select the Run as administrator option.

  3. Type the following command to view a list of all available distros and press Enter:

    wsl --list
    Quick tip: You can also write the command like this: wsl -l.
  4. Type the following command to set a distro as the new default and press Enter:

    wsl --setdefault DISTRO-NAME

    In the command, replace DISTRO-NAME for the name of the distro you want to set as default (see step No. 3).

    For example, this command makes the makes Kali Linux the default distro:

    wsl --setdefault Kali-linux
    WSL2 set default distro
    WSL2 set default distro
    Quick tip: You can also write the command like this: wsl -s Kali-linux.

Once you complete the steps, the distro you specified will be set as the new default, so when you run a command like wsl, Ubuntu will run by default.

.Windows_Software_Technology_ResLinks-343{display:inline-block;width:320px;height:50px}@media(min-width: 500px){.Windows_Software_Technology_ResLinks-343{width:200px;height:90px}}

Post a Comment