Using Linux With WSL on Windows

Using WSL

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.

Open a terminal by searching for it in the start menu
Open a Terminal

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.

The WSL version, that is installed on your system. Here, the latest version of WSL is installed.
WSL Version Installed
🚧
For latest Windows 11 systems, WSL 2 is installed, when you install a distribution. If you want to enable WSL 1 support too in your system, first turn on the Windows Subsystem for Linux feature for your system. Search for Turn on Features in the start menu and enable it.

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.

List the distributions and the WSL version they are running in Windows terminal.
List installed distributions and details
πŸ’‘
If you want to run the WSL commands from within an installed WSL distribution, use 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.

If you are using WSL 2, the kernel name will mention it properly
WSL 2 with Kernel Details

Else, if the distribution is running WSL 1, you will be using the kernel 4.14, and won't specify WSL on the result.

System running with WSL 1 shows kernel 4.14 and also no mention of WSL
WSL 1 and an older kernel version

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
Checking the kernel version of installed WSL distributions from Windows terminal
Checking kernel version in Windows terminal

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>
Changing WSL version to One and Two
Changing WSL version

It will take some time to change, and once done you can run the below command to verify the version:

wsl -l -v