Skip to main content
added 102 characters in body
Source Link
lucasvc
  • 222
  • 2
  • 9

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

Although this askubuntu accepted answer states

If the kernel version => 4.19, it's WSL Version 2.

Any other options/ideas?

Addendum: github/WSL repo has the issue #4555.

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

Although this askubuntu accepted answer states

If the kernel version => 4.19, it's WSL Version 2.

Any other options/ideas?

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

Although this askubuntu accepted answer states

If the kernel version => 4.19, it's WSL Version 2.

Any other options/ideas?

Addendum: github/WSL repo has the issue #4555.

added 178 characters in body
Source Link
lucasvc
  • 222
  • 2
  • 9

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

Although this askubuntu accepted answer states

If the kernel version => 4.19, it's WSL Version 2.

Any other options/ideas?

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

Although this askubuntu accepted answer states

If the kernel version => 4.19, it's WSL Version 2.

Any other options/ideas?

added options i have already found
Source Link
lucasvc
  • 222
  • 2
  • 9

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any different environment variable that could identify thisreliable mechanism to check the version?

What I found?

Environment and "interop"

I have looked but I could not find any environmentThe only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

Maybe checking disk type or similar couldThat variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be possible?an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any different environment variable that could identify this?

I have looked but I could not find any environment difference.

Maybe checking disk type or similar could be possible?

You can check which version is each installed distribution with the command,

wsl -l -v

as this superuser question states.

But is it possible to know the WSL version (1 or 2) from inside the Linux installation?

Is there any reliable mechanism to check the version?

What I found?

Environment and "interop"

The only difference in environment variables, is that WSL 2 has one named WSL_INTEROP that version 1 has not.

That variable points to a path special file.

Kernel version

This reddit post reply points to use the following command,

uname -r | tr '[:upper:]' '[:lower:]'

WSL 1 output:

4.4.0-19041-microsoft

WSL 2 output:

5.4.72-microsoft-standard-wsl2

Could this be an option except the replies given,

Probably better not to go with a kernel check as you can build and install your own kernel, and some people would strip that out.

added details
Source Link
lucasvc
  • 222
  • 2
  • 9
Loading
Source Link
lucasvc
  • 222
  • 2
  • 9
Loading