Check and Switch WSL Version
Quickly learn about checking WSL versions and switching between them.
Currently, there are two versions of WSL available: WSL 1 and WSL 2. WSL 2 offers most of the eye-catching features, including Linux GUI app support, which is a great improvement over WSL 1.
To find out which WSL version you are using, run this command in the Windows terminal.
wsl --version
There is more to it and I'll be briefly discussing WSL versions and how you can switch between WSL versions.
Checking the WSL version
There are a couple of methods for getting the version of WSL you are running in your Linux distribution. Both of these include the command line. You can either use the built-in terminal or install and use PowerShell for Windows.
Check the installed WSL version
If you want to know what version of WSL is installed on your system, or check if WSL version 2 is installed, you can use the --version
option.
wsl --version
Or
wsl -v
This will print the WSL version along with some other information.
Check installed distributions and their WSL versions
Open the Windows terminal from the start menu. On the terminal, enter the following command:
wsl --list --verbose
OR
wsl -l -v
This will print all the installed distributions along with the WSL version they are running.
wsl.exe
in place of wsl
. That is, wsl -l -v
become wsl.exe -l -v
.Check WSL version using kernel version
While you are inside a WSL distribution, run:
uname -r
If you are using WSL 2, it will list the kernel as 5.15+ (as of now) and clearly states WSL 2.
Else, if the distribution is running WSL 1, you will be using the kernel 4.14, and won't specify WSL on the result.
The same uname
command can be run from a Windows terminal to check the version. But here, you need to specify the name of the distribution whose kernel you want to check.
wsl -d <distribution_name> uname -r
In the above command, the distribution_name
should be the same as the one appearing on the output of the wsl -l -v
command.
Bonus: Switch WSL versions
On your system, if the Windows Subsystem for Linux feature is turned on, you can switch between WSL versions. Normally, for a system with large projects, switching is not recommended, because of the difference in the underlying architecture.
So, if you are using Ubuntu with WSL 2/1, and want to change it to WSL 1/2, use:
wsl --set-version <Distribution_name> <version_number_needed>
It will take some time to change, and once done you can run the below command to verify the version:
wsl -l -v