Determining your Windows Subsystem for Linux (WSL) version is a crucial first step when troubleshooting, upgrading, or simply understanding your environment. Knowing whether you’re running WSL 1 or WSL 2, and the specific build number, can greatly assist in diagnosing compatibility issues and ensuring optimal performance. This guide provides a straightforward, step-by-step approach to checking your WSL version, along with common pitfalls, helpful tips, and troubleshooting advice.
What You'll Need
- A computer running Windows 10 (version 1903 or higher) or Windows 11.
- WSL installed and configured. If not, you’ll need to enable the "Windows Subsystem for Linux" optional feature in Windows Features and install a Linux distribution from the Microsoft Store.
- Basic familiarity with using the Command Prompt or PowerShell.
Step-by-Step
- Open Command Prompt or PowerShell: You can search for "cmd" or "PowerShell" in the Windows search bar and select the application. PowerShell is generally recommended as it offers more advanced features.
- Execute the `wsl --version` command: In the Command Prompt or PowerShell window, type the following command and press Enter:
This command will display detailed information about your WSL installation, including the version, kernel version, and other relevant details.wsl --version - Interpret the Output: The output will provide several pieces of information. The most important is the "WSL version." This will indicate whether you are running WSL 1 or WSL 2. It will also display the kernel version being used. For WSL 2, it will show the version of the Linux kernel.
- (Optional) Check the Distribution Version: While `wsl --version` provides information about the WSL infrastructure, it doesn't directly show the version of your installed Linux distribution (e.g., Ubuntu, Debian). To check the distribution version, launch your Linux distribution (e.g., by clicking its icon in the Start menu) and then open a terminal within that distribution. Then, use the appropriate command for your distribution. For example:
- Ubuntu/Debian: `lsb_release -a`
- Fedora: `cat /etc/redhat-release`
- openSUSE: `cat /etc/os-release`
Common Mistakes
- Typing the Command Incorrectly: Ensure you type `wsl --version` exactly as shown. Typos are a common cause of errors.
- Running the Command Outside of Command Prompt/PowerShell: The `wsl` command is a command-line utility and will not work correctly when executed directly from File Explorer or other applications.
- Expecting a Simple Version Number: The `wsl --version` command provides a lot of detail, not just a single version number. Make sure you're looking at the correct section of the output ("WSL version").
- Confusing WSL Version with Distribution Version: Remember that the WSL version refers to the version of the WSL infrastructure itself, not the version of your Linux distribution. They are distinct but related.
Tips
- Use PowerShell for Advanced Features: PowerShell offers more robust scripting capabilities than Command Prompt. If you plan on automating WSL tasks, PowerShell is recommended.
- Keep WSL Updated: Regularly update your WSL installation to benefit from bug fixes, performance improvements, and new features. You can update WSL using the command `wsl --update`.
- Check for Windows Updates: WSL often relies on underlying Windows components. Ensure your Windows operating system is up-to-date to avoid compatibility issues.
- Note the Kernel Version: The kernel version displayed by `wsl --version` can be useful for troubleshooting kernel-related problems.
- Document Your WSL Configuration: For complex setups, it’s helpful to document your WSL version, distribution version, and any custom configurations you've made.
Troubleshooting
- "wsl" is not recognized as an internal or external command: This usually indicates that WSL is not properly installed or configured. Verify that the "Windows Subsystem for Linux" optional feature is enabled in Windows Features. Also, ensure that your Linux distribution is installed and accessible from the Start menu. Restarting your computer can sometimes resolve this issue.
- Incorrect Output: If the output appears garbled or incomplete, try running the command again. If the problem persists, try restarting your computer or reinstalling WSL.
- WSL 2 Not Detected: If you believe you should be running WSL 2 but the output shows WSL 1, you may need to convert your distribution to WSL 2. Use the command `wsl --set-version
2` (e.g., `wsl --set-version Ubuntu 2`). Note that this conversion can take some time and may require significant disk space. - Kernel Panic or Other Errors: If you encounter kernel panics or other errors within your WSL environment, the kernel version displayed by `wsl --version` can be a clue. Try updating WSL using `wsl --update` or consider reverting to an older kernel version if possible.