A command to confirm that linux is running on WSL
There are many cases where it's useful to programmatically check whether linux is "regular" linux or WSL linus. E.g., in Python calling `sys.platform` just returns `linux`, not `linux-wsl` or something like this. It'd be helpful if there were a command line argument that could reliably confirm that the platform is WSL.
Dana Myers commented
Perhaps naively, I'd ask what the use case(s) is for this; in other words, what will an application do with the knowledge? Having a single 'flag' like this leads applications to infer perhaps a large set of assumptions - assumptions that may not remain valid under newer builds of WSL. If specific features are involved, then specific flags would be much better.
Pavel A commented
To check if you are running on WSL:
1. uname -r | grep "Microsoft" && echo "Welcome to Microsoft Linux"
2. cat /proc/version_signature | grep "Microsoft" && echo "Welcome to Microsoft Linux"
3. mount|grep "C:" && "Welcome to Microsoft Linux again"
Paul Marquess commented
Agree that we need an official way to know that your code is running in WSL.
I currently do this by testing for the presence of the string "Microsoft" in "/proc/version".
This seems to be a good place to start...