WSL uses the wrong distro because a specific distribution is set as the default via wsl --set-default, or because you are launching a session with an explicit name like wsl -d Ubuntu-20.04. To fix this, check your current default with wsl --list --verbose and reset it using the --set-default flag followed by the correct distribution name.
Understanding WSL Default Behavior
When you open a terminal in Windows, whether it is Command Prompt, PowerShell, or Git Bash, the system needs to know which Linux environment to launch if you simply typewsl without arguments. By design, WSL will always attempt to start the distribution that has been marked as the "default." This behavior is consistent across all command-line interfaces on Windows. If you have multiple distributions installed, such as Ubuntu, Debian, and Kali Linux, only one can hold this default status at any given time.
The confusion often arises when users install a new distribution but find that their old habits persist. For instance, if you previously used Ubuntu 18.04 as your primary workhorse and later installed Ubuntu 22.04, typing wsl might still drop you into the older version. This happens because the installation process does not automatically change the global default setting. You must explicitly tell WSL which distribution should be the entry point for future sessions.
Another common scenario involves mixing different types of shells. If you are accustomed to using bash directly from Windows Command Prompt, you might expect it to behave identically to typing wsl. However, bash may invoke a different subsystem or fallback mechanism depending on how Windows is configured. The most reliable way to ensure you are interacting with WSL specifically is to use the wsl executable provided by Microsoft. Understanding this distinction helps isolate whether the issue is with the distribution selection or the shell invocation method.
Checking Your Current Configuration
Before making changes, you need to see what WSL currently thinks the default is. The commandwsl --list --verbose (or its shorthand wsl -l -v) provides a comprehensive list of all installed distributions along with their states (Running, Stopped, etc.) and their assigned versions. Look at the output carefully. There isn't a column explicitly labeled "Default," but the system implicitly treats the first one listed in some contexts, or more accurately, the one specified by the internal registry key.
However, the most direct way to verify the active default is to run wsl and then check inside the Linux environment. Once inside, you can look at the prompt or run cat /etc/os-release to confirm which distribution you are actually using. If the output does not match what you intended, then the default setting is indeed incorrect. This diagnostic step confirms that the problem is not a corrupted installation but a configuration mismatch.
Changing the Default Distribution
Resolving the issue requires updating the default setting. This is done using thewsl --set-default command. You need to specify the exact name of the distribution you want to become the default. These names are case-sensitive and must match exactly what appears in the wsl --list output. For example, if you want Ubuntu 22.04 to be the default, you would run:
wsl --set-default Ubuntu-22.04
After executing this command, there is no confirmation message, but the change takes effect immediately for subsequent launches. Close your current WSL session and open a new one by simply typing wsl in your Windows terminal. You should now find yourself in the correct distribution. This method is permanent until you change it again, so choose wisely based on your daily workflow needs.
If you frequently switch between distributions for different projects, relying solely on the default might become cumbersome. In such cases, you might prefer to launch specific distributions by name. This approach bypasses the default setting entirely and ensures you always get the environment you requested.
Launching Specific Distributions
Instead of changing the global default, you can launch a specific distribution directly from the command line. This is useful when you need to perform tasks in a non-default environment. Use the-d or --distribution flag followed by the distribution name. For example:
wsl -d Debian
This command will open a shell session within the Debian distribution, regardless of what is set as the default. You can also combine this with other flags, such as running a specific command inside that distribution:
wsl -d Ubuntu-20.04 ls /home/user
This technique is particularly helpful for automation scripts or when you need to quickly verify something in a secondary distribution without switching your main workspace. It provides flexibility and reduces the cognitive load of remembering which distribution is currently set as the default.
Troubleshooting Persistent Issues
In rare cases, even after setting the default correctly, you might still encounter issues. One potential cause is conflicting configurations in user profile scripts. If your.bashrc or .profile contains commands that redirect execution or alter the environment unexpectedly, it might create the illusion that the wrong distro is running. Check these files for any unusual aliases or exec commands.
Another factor to consider is the integration level of WSL. Ensure that your Windows Subsystem for Linux feature is fully enabled and up to date. Sometimes, partial updates or glitches in the WSL kernel can lead to unpredictable behavior. Running wsl --update in an elevated Command Prompt or PowerShell can refresh the WSL components to their latest stable versions. This step often resolves underlying bugs that manifest as distribution selection errors.
For those managing complex setups, such as transferring installations to external drives, ensure that the paths and symlinks are correctly maintained. Issues like those described in guides for transferring WSL Ubuntu installation to USB can sometimes lead to path resolution problems that affect distro selection. Always verify that the storage location for your default distro is accessible and not corrupted.
Additionally, permission issues can sometimes masquerade as distro errors. If you encounter lock errors or file access denied messages, it might indicate that the distro is running in a restricted state. Referencing solutions for fixing WSL 'Failed to take /etc/passwd lock' errors can help resolve underlying system integrity issues that prevent proper initialization.
Finally, remember that GUI applications launched from WSL, such as those needed for tools like Burp Suite, rely on the correct distro being active. If your GUI apps fail to launch, double-check that your CLI is pointing to the right distribution, as compatibility layers differ between distros. See our guide on using Burp Suite within WSL for insights into maintaining consistent environments for graphical tools.
Frequently Asked Questions
How do I remove a WSL distribution?
You can uninstall a distribution using the wsl --unregister command followed by the distribution name. This removes the filesystem and settings, freeing up disk space, but it does not delete the WSL feature itself. Be aware that this action is irreversible without reinstalling the distribution.
Can I have two distributions as defaults?
No, WSL only supports one default distribution at a time. The wsl command without arguments will always launch this single default. If you need to use another distribution, you must either change the default or explicitly specify the distribution name using the -d flag.
Why does my WSL distro keep reverting to the old one?
This usually happens if you are not using the wsl command but instead invoking bash directly from Windows CMD or PowerShell. These shells may have their own legacy configurations. Always use the wsl executable to respect the WSL default setting.
Is it safe to change the default distro while others are running?
Yes, changing the default distribution does not affect currently running instances. You can have multiple distros running simultaneously in separate windows. The default setting only influences new sessions launched without explicit parameters.
What if I forget the exact name of my distribution?
Run wsl --list --verbose to see a complete list of all installed distributions. The names displayed there are the ones you should use with the --set-default or -d flags. Copying the name directly from this list prevents typos.