Detecting the operating system that a program is running or being compiled on.
Questions tagged [os-detection]
26 questions
778
votes
22 answers
How to detect the OS from a Bash script?
I would like to keep my .bashrc and .bash_login files in version control so that I can use them between all the computers I use. The problem is I have some OS specific aliases so I was looking for a way to determine if the script is running on…

csexton
- 24,061
- 15
- 54
- 57
342
votes
3 answers
How to detect reliably Mac OS X, iOS, Linux, Windows in C preprocessor?
If there's some cross-platform C/C++ code that should be compiled on Mac OS X, iOS, Linux, Windows, how can I detect them reliably during preprocessor process?

eonil
- 83,476
- 81
- 317
- 516
331
votes
14 answers
OS detecting makefile
I routinely work on several different computers and several different operating systems, which are Mac OS X, Linux, or Solaris. For the project I'm working on, I pull my code from a remote git repository.
I like to be able to work on my projects…

samoz
- 56,849
- 55
- 141
- 195
60
votes
5 answers
Makefile that distinguishes between Windows and Unix-like systems
I would like to have the same Makefile for building on Linux and on Windows. I use the default GNU make on Linux and the mingw32-make (also GNU make) on Windows.
I want the Makefile to detect whether it operates on Windows or Linux.
For example…

Tom Pažourek
- 9,582
- 8
- 66
- 107
18
votes
1 answer
Is there a way to detect OS in fish shell akin to the OSTYPE variable in bash?
Right now I'm forced to resort to using uname to get the operating system name and it works. But in bash there is the OSTYPE environment variable that is automatically set and I was wondering if there is something similar.

RubenLaguna
- 21,435
- 13
- 113
- 151
12
votes
3 answers
Deprecated Javascript OS detection techniques
I was wondering why javascript os detection techniques like navigator.userAgent, navigator.appName, navigator.appVersion and navigator.platform are in process of being dropped from web…

ardoc
- 121
- 1
- 1
- 5
9
votes
5 answers
Get users OS and version number
I've spent a day on and off Googeling for this; no luck so far.
How can I get the users OS and version. Mine would me Mac OS X 10.6.4, the spare PC in the office would be Windows XP SP3. You see what I'm getting at.
I've seen a million and one…

PaulAdamDavis
- 1,574
- 3
- 16
- 19
8
votes
2 answers
tell if make is running on windows or linux
Is there a way to know in makefiles if GNU make is running on a linux OS or a windows OS?
I've built a bash script that generates a makefile for building my app and it works fine on my Debian machine. I want to try to build it on MinGW/MSYS, but the…

Gianni Pisetta
- 293
- 1
- 2
- 8
6
votes
7 answers
How to check website viewer's operating system?
I'm running Ubuntu 8.04 and I recently received the following error when visiting a website:
Please return to www.site.com with a computer running Windows 98, 2000, Me, NT, or XP.
How does the website know which OS I'm running? Is it only via…

MCS
- 22,113
- 20
- 62
- 76
5
votes
2 answers
How to detect Android OS from a Python script?
I am running a python script in a termux environment on an Android device and I would like to be able to detect that the OS is Android.
The traditional approaches don't work:
>>> import platform
>>> import sys
>>>…

ccpizza
- 28,968
- 18
- 162
- 169
4
votes
1 answer
Is there methods to detect Windows-11 vs Windows-10 in Firefox browser?
Currently,
On Windows-11 devices I'm getting navigator.userAgent value as Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.5060.134 Safari/537.36 Edg/103.0.1264.77 which is same as Windows-10.
To…

Rahul Sahu
- 49
- 3
3
votes
1 answer
Is OS detection possible with GLib?
Is it possible to determine on which platform (GNU/Linux, Win32, OS X) my Vala app is running?

tpimh
- 446
- 2
- 9
- 23
2
votes
3 answers
Determining the visitor's OS in PHP
I am trying to get the OS of the visitor in PHP(Codeingiter). I tried https://github.com/serbanghita/Mobile-Detect. It worked for me 70% of the time. But still it's not detecting accurately. A good amount of Android traffic is not detected as mobile…

Maneesh M S
- 332
- 1
- 4
- 20
2
votes
1 answer
Is there a way to distinguish Android Arm os from the Android x86 os in JavaScript?
To detect the Android OS, we could search the navigator.userAgent string for the 'Android' key word.
However, my question is how to detect whether it's an Android Arm device or an Android X86 device?

Fiona
- 904
- 1
- 8
- 17
2
votes
3 answers
Operating sytem detection for CSS hacks (aka need a "PC only" CSS hack)
I don't like Microsoft's font rendering.
I've created a site for a client and the last unticked box on my debugging list is the biggest. (it's not 'live' yet btw so please ignore any other bugs - http://baked-beans.tv/bb)
I'm using font-family to…

RGBK
- 2,048
- 5
- 35
- 55