Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

5
  • 7
    Yum could very well be Red Hat, Scientific Linux, or Fedora. There was an apt command for Fedora mimiking Debian's. And so on. Just clasifying anything with yum as CentOS gives you a range of supported systems from Red Hat 4 to Fedora 18, that is some 8 years of Linux history right there. If you need to know if <foo> is supported, specifically check for <foo> instead of guessing based on (unreliable) distribution identification! Sure, it leads to something of the ilk of autotools, but that can't be helped (just thank $DEITY that the Unix wars are over). Commented Jan 18, 2013 at 3:21
  • @vonbrand indeed, it is as you say. i don't attempt to differentiate between sub-flavours. and the order i check in (hopefully) removes most tricky situations (RHEL with apt-get installed), although i didn't do a lot of research. if RHEL can have apt-get installed, and Ubuntu users have yum... well, you're just bang out of luck. Commented Jan 22, 2013 at 2:40
  • apt-get is also used by altlinux on rpm bazis, so this is the false answer Commented Mar 10, 2021 at 7:51
  • 1
    @МалъСкрылевъ I think my general point was: if you are only identifying the operating system in order to determine which package manager to run, then just check for the package manager. That's the "JavaScript" test-for-feature concept. FWIW, I have apt-get running here under cygwin (apt-cyg renamed). I should add that there entire concept of "test-for-feature" has worked for decades with configure and to an extent the more recent cmake build systems. Commented Mar 10, 2021 at 11:12
  • well of example when I run the script on my linux it will return "debian" what is wrong, please note it on our post Commented Mar 10, 2021 at 18:16