Changing the default distribution in Windows Subsystem for Linux (WSL) allows you to specify which installed Linux environment automatically launches when you type ‘wsl’ in Command Prompt or PowerShell. This is especially useful if you have multiple distributions installed and prefer to set one as your primary environment for convenience. Whether you’re switching from Ubuntu to Debian or any other distribution, this guide will walk you through the process step-by-step, ensuring a smooth transition to your preferred Linux experience on Windows.
What You’ll Need
- Windows 10 (version 1903 or later) or Windows 11
- WSL installed and at least two Linux distributions installed
- Access to Command Prompt or PowerShell with administrator privileges (recommended but not required)
Step-by-Step
- Open PowerShell or Command Prompt: Launch your preferred terminal with administrator rights for best results. You can do this by right-clicking the Start menu and selecting ‘Windows PowerShell (Admin)’ or ‘Command Prompt (Admin)’.
- Check installed WSL distributions: Type
wsl -l -vand press Enter. This command lists all installed distributions along with their version (WSL 1 or 2) and current default setting. - Identify your target distribution: From the list, note the exact name of the distribution you want to set as default, for example, ‘Debian’ or ‘Ubuntu-20.04’.
- Set the new default distribution: Enter the command
wsl --set-defaultreplacing<DistributionName>with the name you noted earlier. For example,wsl --set-default Debian. - Verify the change: Run
wsl -l -vagain to confirm that the default distribution now has an asterisk (*) next to it, indicating it is the current default. - Test your setting: Simply type
wsland press Enter; it should now open your chosen distribution automatically. - Optional – set default for specific WSL version: If you want to specify WSL 2 or WSL 1 for your default, use
wsl --set-default-version 2orwsl --set-default-version 1accordingly.
Common Mistakes
- Using incorrect distribution names: Always double-check the exact name from the
wsl -l -voutput. - Forgetting to run commands with administrator privileges: Some commands may require elevated rights to execute properly.
- Not updating WSL: Ensure your Windows and WSL are up to date to support all features and commands.
- Trying to set default to a distribution that isn’t installed: Confirm installation with
wsl -l -v.
Tips
- Use meaningful distribution names: When installing multiple Linux distros, assign recognizable names for easier management.
- Update your distributions regularly: Keep your Linux environments current for security and feature improvements.
- Use WSL 2 if possible: WSL 2 offers better performance and compatibility, and you can set it as default with
wsl --set-default-version 2. - Create shortcuts: For quick access, create desktop shortcuts pointing directly to your preferred distribution.
Troubleshooting
If changing your default distribution does not work as expected, try the following steps:
- Recheck your commands: Ensure you typed
wsl --set-default <DistributionName>correctly, including capitalization and spelling. - Update WSL: Run
wsl --updateto make sure you’re on the latest version, especially if you encounter command errors. - Restart your PC: Sometimes, changes require a reboot to take effect properly.
- Reinstall the distribution: If issues persist, uninstall and reinstall the distribution, then set it as default again.
- Check WSL version: Confirm you’re using WSL 2 if needed, by running
wsl -l -v.
Frequently Asked Questions
Can I change the default distribution without admin rights?
Yes, but it’s recommended to run PowerShell or Command Prompt with administrator privileges for full control and to avoid permission issues.
How do I set a specific distribution to WSL 2?
Use wsl --set-version <DistributionName> 2. To make it default, run wsl --set-default-version 2.
What if the distribution I want isn’t listed?
Ensure it is installed correctly. You can install new distributions via the Microsoft Store or manually import them.
How do I revert to WSL 1?
Use wsl --set-version <DistributionName> 1 for the specific distribution, then set it as default if needed.
Can I have multiple default distributions?
No, only one distribution can be set as default at a time. However, you can specify which to launch explicitly using wsl -d <DistributionName>.
Will changing the default affect existing scripts?
Yes, scripts that rely on a specific distribution may need adjustment if the default changes.
By following this guide, you can easily switch your default Linux environment in WSL, streamlining your workflow and ensuring quick access to your preferred distribution whenever you launch WSL.
Related
- How to Change a TXT File to CFG in Windows 11
- How to Change Port Settings in Windows Live Mail Easily
- How to Change a File Type on Windows 11 Easily