ML
    • Recent
    • Categories
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Linux: Finding What Distro We Are Using

    Scheduled Pinned Locked Moved IT Discussion
    linuxcentosrhelubuntususefedorasam linux administration
    11 Posts 6 Posters 2.7k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DashrenderD
      Dashrender
      last edited by

      I'm confused - wouldn't you have to know what distro you're using to run those commands.

      i.e. you can't run the

       cat /etc/gentoo-release
      

      command on Ubuntu, can you? and if you can, can you run it on another Linux family line?

      JaredBuschJ scottalanmillerS momurdaM 3 Replies Last reply Reply Quote 0
      • JaredBuschJ
        JaredBusch @Dashrender
        last edited by

        @Dashrender said in Linux: Finding What Distro We Are Using:

        I'm confused - wouldn't you have to know what distro you're using to run those commands.

        i.e. you can't run the

         cat /etc/gentoo-release
        

        command on Ubuntu, can you? and if you can, can you run it on another Linux family line?

        Of course you can. You simply get an error that there is no file.

        the command is cat the parameter is the path and file name.

        1 Reply Last reply Reply Quote 1
        • JaredBuschJ
          JaredBusch
          last edited by

          root@jaredweb:[~] $ cat /etc/gentoo-release
          cat: /etc/gentoo-release: No such file or directory
          root@jaredweb:[~] $ cat /etc/redhat-release
          CentOS Linux release 7.3.1611 (Core)
          root@jaredweb:[~] $
          
          
          1 Reply Last reply Reply Quote 1
          • scottalanmillerS
            scottalanmiller @Dashrender
            last edited by

            @Dashrender said in Linux: Finding What Distro We Are Using:

            I'm confused - wouldn't you have to know what distro you're using to run those commands.

            i.e. you can't run the

             cat /etc/gentoo-release
            

            command on Ubuntu, can you? and if you can, can you run it on another Linux family line?

            You have to know what to look for and look for it. Same with anything. How do you know that you are on Windows? You rely on look and feel, knowing ahead of time what it is. If you make a Linux desktop look just like Windows and answer to Windows commands, how would you determine that it is really Windows?

            It's harder than it sounds.

            You also have to know that it is Linux, what if it was AIX or HP-UX? At some point you just have to know what things look like and poke around.

            A simple solution for Linux machines is to do this...

            ls /etc/ | grep release

            1 Reply Last reply Reply Quote 0
            • scottalanmillerS
              scottalanmiller
              last edited by

              You can do this as well:

              cat /etc/*release
              

              And see the output of every file with the name all at once. But you might get more than you wanted.

              JaredBuschJ 1 Reply Last reply Reply Quote 1
              • thwrT
                thwr
                last edited by

                Most distros will also give you a hint when opening a session (SSH, bash, getty etc). But it's nice to see such a summary, thanks.

                1 Reply Last reply Reply Quote 2
                • JaredBuschJ
                  JaredBusch @scottalanmiller
                  last edited by

                  @scottalanmiller said in Linux: Finding What Distro We Are Using:

                  You can do this as well:

                  cat /etc/*release
                  

                  And see the output of every file with the name all at once. But you might get more than you wanted.

                  For exampels, CentOS 7 has 4 files that match.

                  root@jaredweb:[~] $ ls /etc/*release
                  /etc/centos-release  /etc/os-release  /etc/redhat-release  /etc/system-release
                  

                  It would output this disaster

                  root@jaredweb:[~] $ cat /etc/*release
                  CentOS Linux release 7.3.1611 (Core)
                  NAME="CentOS Linux"
                  VERSION="7 (Core)"
                  ID="centos"
                  ID_LIKE="rhel fedora"
                  VERSION_ID="7"
                  PRETTY_NAME="CentOS Linux 7 (Core)"
                  ANSI_COLOR="0;31"
                  CPE_NAME="cpe:/o:centos:centos:7"
                  HOME_URL="https://www.centos.org/"
                  BUG_REPORT_URL="https://bugs.centos.org/"
                  
                  CENTOS_MANTISBT_PROJECT="CentOS-7"
                  CENTOS_MANTISBT_PROJECT_VERSION="7"
                  REDHAT_SUPPORT_PRODUCT="centos"
                  REDHAT_SUPPORT_PRODUCT_VERSION="7"
                  
                  CentOS Linux release 7.3.1611 (Core)
                  CentOS Linux release 7.3.1611 (Core)
                  
                  1 Reply Last reply Reply Quote 1
                  • JaredBuschJ
                    JaredBusch
                    last edited by JaredBusch

                    What can be done if you do not want to rely on a maybe like

                    cat /etc/os-release
                    cat /etc/lsb-release
                    

                    Is to write your own if/then script to find the data you need.

                    1 Reply Last reply Reply Quote 1
                    • momurdaM
                      momurda @Dashrender
                      last edited by

                      @Dashrender Yes that is generally true. However you usually are only going to have 2 options, redhat_release or debian as those are by far the two most common in use in any business environment.
                      also the os-release seems to be very new for distros. It is not in my centOS 6.6 or 6.8 but is in my debian 8+, but not in a debian 5 server i have.
                      typing
                      cat /etc/os then tab complete will get you possibilities with os in etc dir. If os-release isnt there it isnt.
                      so you can cat /etc/r then tab complete to see redhat-release

                      1 Reply Last reply Reply Quote 0
                      • stacksofplatesS
                        stacksofplates
                        last edited by stacksofplates

                        /proc/version usually has pertinent information across most systems.

                        Edit: I looked closer. It's just the OS name (RHEL/Ubuntu) and kernel version. Never mind.

                        1 Reply Last reply Reply Quote 0
                        • scottalanmillerS scottalanmiller referenced this topic on
                        • 1 / 1
                        • First post
                          Last post