I have Windows Subsystem for Linux, but I don't know which version I have, and many things won't work in version 1. How do I check my version?
-
3@Rinzwind You are welcome to join with me requesting such at https://github.com/microsoft/WSL/issues/4555 – K7AAY Sep 30 '19 at 18:07
-
2From that thread, it looks like the following bash command works: `uname -r | grep Microsoft > /dev/null && echo "WSL1"`. -- It's a pretty adhoc way to detect it, but it will print "WSL1" if that's what you're running. – BrainSlugs83 Aug 12 '20 at 23:23
-
5@BrainSlugs83 Extremely fragile but works for me! In WSL1, `uname -r` ends with `-Microsoft`, in WSL2, it ends `-microsoft-standard` ... lower case "m"! – Arthur Tacca Aug 14 '20 at 09:09
-
1@Rinzwind Any questions regarding WSL, including how to install it, are on-topic, in my opinion. – Flimm Aug 24 '20 at 09:15
-
@Flimm not if the answer lies outside of wsl. As soon as someone mentions powershell it IS off topic We are NOT supposed to know anything that is a tool in Windows. – Rinzwind Aug 24 '20 at 09:25
-
1@Rinzwind If the question is on-topic, then so are the answers to that question. If someone asks how to create a bootable Ubuntu USB stick on Windows, then that question is on-topic, and so are all the answers to it, even if the answers mention unetbootin.exe . Same thing with WSL. – Flimm Aug 25 '20 at 13:36
-
I would at least expect `wsl --version` to be available... – MC Emperor Oct 01 '20 at 07:51
-
Check the File Version in the Details tab of the Properties of C:\Windows\System32\Wsl.exe - if it is less than 10.0.19041.x then it is WSL1. – Oliver Slay Sep 05 '22 at 09:17
5 Answers
At a Windows 10 command prompt, run
ver. Is the next-to-last numeric group version 18917 or higher? If so, it is possible you have WSL 2 but not yet verified. Go on to step A or B.
If you do not see Windows version 18917 or higher, you have version 1.
This illustrates the result when the OS is Build 16299:A. Open Windows PowerShell or cmd and enter the command
wsl -l -v. If version 2 is installed properly, you will see the version number. If you don't see a version number, or if you see an error message (Thank you, Cornea Valentin) you have version 1 (you may also see a version number '1' which could indicate that you're running v1 - see here). Uninstall it then reinstall it as per https://scotch.io/bar-talk/trying-the-new-wsl-2-its-fast-windows-subsystem-for-linuxB. From the WSL shell prompt, run
unameoruname -r. If the kernel version >= 4.19, it's WSL Version 2.
Why is this relevant?
WSL 1 was based on Microsoft's Linux-compatible kernel interface, a compatibility translation layer with no Linux kernel code.
WSL 2 was redesigned with a Linux kernel running in a lightweight VM environment, and innovators have found many more things they can do with WSL 2.
Windows 10 Version 2004 (build 19041.153 & later) enhances WSL2 further; see https://devblogs.microsoft.com/commandline/wsl2-will-be-generally-available-in-windows-10-version-2004/ and https://winaero.com/blog/wsl2-will-ship-with-windows-10-version-2004-with-kernel-updates-via-windows-update/ .
-
35
-
5I needed to use uname -r to see the kernel version, but the kernel version ended up being 4.4.0, which I'm pretty sure means WSL 1. – Keara Jun 12 '20 at 15:27
-
16
-
5For me, `wsl -l -v` prints the usage info (i.e. doesn't work), but `wsl -l --verbose` prints the verbose list as intended. `systeminfo.exe` gives me `OS Version: 10.0.19041 N/A Build 19041`. – drkvogel Aug 10 '20 at 14:35
-
1According to [Microsoft](https://docs.microsoft.com/en-us/windows/wsl/install-win10) and a [Microsoft blogger](https://devblogs.microsoft.com/commandline/wsl-2-support-is-coming-to-windows-10-versions-1903-and-1909/#how-do-i-get-it), we can also get WSL2 on (1903 or 1909) build 18362.1049, due to a new backport. That helps those of us in companies that don't yet have build 18917, which is mentioned in the answer above. – Marcus Aug 28 '20 at 21:38
-
2
-
-
1As of Dec 2020, typing `wsl -l -v` returns `VERSION 1` for me with `Ubuntu 20.04`. Nice fix for the newer Ubuntu v1. Cool! – Kyle Vassella Dec 15 '20 at 15:57
-
-
-
your answer contradicts itself - I am seeing a version number from the first test, suggesting it's version 2, but my kernel is lower than what you say is needed for version 2. – Rebroad May 01 '21 at 09:00
- Open PowerShell
- Check the version with
wsl -l -v - If at version 1, then update the version with
wsl --set-version Ubuntu-20.04 2
Note: Changing the version of a running OS will terminate it.
The name of the OS need not be Ubuntu-20.04 for you. Please select the actual name listed in wsl -l -v
If you are not able to update to version 2, then you may not be on the WSL 2 Kernel. This can be downloaded from Microsoft.
- 103
- 2
- 3,829
- 4
- 23
- 27
-
Note on point 3, running it will instantly kill currently running instances of the OS selected, eg all instances of Ubuntu-20.02 in this case. – zshift Aug 22 '20 at 21:40
-
-
6@Jack, Having only one version of ubuntu, 18.04, I noticed that "wsl --set-version Ubuntu 2" worked for me without specifying the version. I suspect that's always the case. – Angelo Aug 28 '20 at 01:05
-
-
Simply run `wsl --status` as shown here: https://www.youtube.com/watch?v=bRW5r7TK6KM – Benny Code Jan 22 '22 at 23:40
In the WSL version I was running, I just typed uname -r to which I got the result
5.4.72-microsoft-standard-WSL2
So, I can say that its WSL2, so you can try running uname -r and check.
- 135
- 1
- 5
-
1That will work as long as you are running the stock kernel, but it could be named differently if you use a custom kernel. Also, for reference, WSL1 kernels are something like "4.4.0-22000-Microsoft" (without the "-standard-WSL2"). I seem to recall that 4.x releases on WSL2 were just "-microsoft-standard" (without the "-WSL2), but I could be wrong. – NotTheDr01ds Nov 27 '21 at 18:27
-
-
1
Programmatically:
# Multiline
wsl.exe -l -v |
iconv -f utf16 |
egrep "\b${WSL_DISTRO_NAME}\s+Running" |
tr -d '\r' |
sed 's/.*\([[:digit:]]\)[[:space:]]*/\1/'
Will return 1 or 2.
Line-by-line, this:
Executes
wsl.exe -l -vto return the full list of all distributions you might have installedRuns it through
iconvto fix its malformed UTF16 output. You don't normally see the problem unless you try to grep it (or pipe it to something likehexdump -C), but you have to clean it up before you can grep it.Matches the current instance (via
$WSL_DISTRO_NAME) lineRemoves the DOS line ending
Finds the version number in the line and outputs it
Thanks to this Super User answer for the concept.
This will work as long as Interop is enabled for WSL.
If Interop isn't enabled, then a fallback method is to check /proc/cmdline:
/proc/cmdlineon WSL1 isBOOT_IMAGE=/kernel init=/init/proc/cmdlineon WSL2 isinitrd=\initrd.img panic=-1 pty.legacy_count=0 nr_cpus=16
So:
grep -q "^BOOT_IMAGE" /proc/cmdlinereturns success on WSL1 but error on WSL2grep -q "^initrd" /proc/cmdlinereturns success on WSL2 but error on WSL1
This currently works (and has for the last year, at least), but could change in the future if either the WSL1 or WSL2 architecture changes in some way. However, I expect that the /proc/cmdline is likely always going to differ between WSL1 and WSL2 and can be programmatically parsed to determine the current version.
- 15,380
- 6
- 51
- 79
If you happen to be running Docker for Windows and you have WSL 1, then if you enter docker in the terminal for your WSL, you'll see the message The command 'docker' could not be found in this WSL 1 distro., which is a very clear confirmation.
- 223
- 2
- 7
