Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Detect BashOnWindows from Bash script #844

Closed
timmontague opened this issue Aug 9, 2016 · 3 comments
Closed

Detect BashOnWindows from Bash script #844

timmontague opened this issue Aug 9, 2016 · 3 comments

Comments

@timmontague
Copy link

Is there a documented method for a Bash script to detect if it's running on "Ubuntu on Windows" vs native Ubuntu?

It looks like grepping /proc/version for the string "Microsoft" would work, but it could potentially have false positives.

For reference, these are the contents of /proc/version on my machines:

  • Ubuntu on Windows:
    Linux version 3.4.0-Microsoft ([email protected]) (gcc version 4.7 (GCC) ) #1 SMP PREEMPT Wed Dec 31 14:42:53 PST 2014
  • Native Ubuntu:
    Linux version 4.4.0-31-generic (buildd@lgw01-16) (gcc version 5.3.1 20160413 (Ubuntu 5.3.1-14ubuntu2.1) ) #50-Ubuntu SMP Wed Jul 13 00:07:12 UTC 2016

My Windows build number: Microsoft Windows [Version 10.0.14393]

@benhillis
Copy link
Member

I would suggest /proc/sys/kernel/osrelease

Duplicate of #423

@timmontague
Copy link
Author

Thank you!

@matthewpersico
Copy link

How about uname -r which does the same thing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants