111

We have some new hardware in our office which runs its own customized Linux OS.

How do I go about figuring which distro it's based on?

Kevin
  • 40,087
  • 16
  • 88
  • 112
mrTomahawk
  • 1,213
  • 2
  • 9
  • 5

3 Answers3

142

A question very close to this one was posted on Unix.Stackexchange HERE Giles has a pretty complete | cool answer for the ways he describes.

# cat /proc/version

Linux version 2.6.32-71.el6.x86_64 ([email protected]) (gcc version 4.4.4 20100726 (Red Hat 4.4.4-13) (GCC) ) #1 SMP Fri May 20 03:51:51 BST 2011  
# uname -a

Linux system1.doofus.local 2.6.32-71.el6.x86_64 #1 SMP Fri May 20 03:51:51 BST 2011 x86_64 x86_64 x86_64 GNU/Linux
# cat /etc/issue

CentOS Linux release 6.0 (Final)
Kernel \r on an \m

cat /proc/config.gz cat /usr/src/linux/config.gz cat /boot/config*

Though I did some checking and this was not very reliable except on SUSE.

# zcat /proc/config.gz | grep -i kernel
CONFIG_SUSE_KERNEL=y
# CONFIG_KERNEL_DESKTOP is not set
CONFIG_LOCK_KERNEL=y

Release Files in /etc (from Unix.com)

  • Novell SuSE---> /etc/SuSE-release
  • Red Hat--->/etc/redhat-release, /etc/redhat_version
  • Fedora-->/etc/fedora-release
  • Slackware--->/etc/slackware-release, /etc/slackware-version
  • Old Debian--->/etc/debian_release, /etc/debian_version
  • New Debian--->/etc/os-release
  • Mandrake--->/etc/mandrake-release
  • Yellow dog-->/etc/yellowdog-release
  • Sun JDS--->/etc/sun-release
  • Solaris/Sparc--->/etc/release
  • Gentoo--->/etc/gentoo-release

There is also a bash script at the Unix.com link someone wrote to automate checking.

Figuring out what package manager you have is a good clue.

rpm yum apt-get zypper +many more

Though this is by no means foolproof as the vendor could use anything they want. It really just gives you a place to start.

# dmesg | less

Linux version 2.6.32.12-0.7-default (geeko@buildhost) (gcc version 4.3.4 [gcc-4_3-branch revision 152973] (SUSE Linux) ) #1 SMP 2010-05-20 11:14:20 +0200

pretty much the same information as cat /proc/version & uname

2bc
  • 3,938
  • 1
  • 17
  • 18
  • 6
    If you are in a container, beware cat /proc/version will give the host distro, not the container one. – Dereckson Mar 24 '15 at 20:10
  • 2
    Note that this should be `cat /etc/*elease` for centos http://unix.stackexchange.com/questions/54987/how-to-know-centos-version#comment400919_54988 – hawkeye Jul 31 '16 at 11:48
  • @hawkeye I find ls /etc | grep release to be more effective, as it also will pick up files named release-XX, for example – user6297 Aug 09 '16 at 12:15
  • 1
    Note that most of these tell you about the KERNEL, not the distribution. As the files indicated above show, cat /etc/*release is probably the most general way of seeing the distribution. – Brad Sep 06 '17 at 12:21
  • I have down voted this because `cat /proc/version` gives wrong answer, e.g. CentOS7 will claim it is "Red Hat 4.8.5". Please upvote the correct answer listed further down: `cat /etc/*-release` – Axel Bregnsbo Sep 22 '17 at 11:31
51

You'll want to use:

$ cat /etc/*-release

You'll get a response similar to this:

$ cat /etc/*-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=11.10
DISTRIB_CODENAME=oneiric
DISTRIB_DESCRIPTION="Ubuntu 11.10"
rwc
  • 761
  • 4
  • 7
  • 5
    This should be the correct answer. Note that stuff in "/proc" tells you about the *kernel* (or in this case the distribution that the compiler was built with that built the running kernel), not the *distribution* itself. Since getting this information is in inherently distribution-specific, the /etc/*-release is the most general way. – Brad Sep 06 '17 at 12:19
  • The Ubuntu-16.04 on my desktop has an `/etc/os-release` files, whereas the CentOS-7 on our number cruncher has an `/etc/system-release` file. At least they got the `-release` suffix in common. – Dohn Joe Apr 03 '19 at 13:03
20

As a first guess, try lsb_release -a. E.g. on an Arch Linux system it gives

LSB Version: n/a
Distributor ID: archlinux
Description: Arch Linux
Release: rolling
Codename: n/a

However, this might fail, then you will have to poke around /etc (most likely it is inside a file whose name ends with -release). Also cat /etc/issue might help.

Renan
  • 16,976
  • 8
  • 69
  • 88
  • 1
    *lsb_release -a* returns "-bash: lsb_release: command not found" on Raspberry with [Raspbian](http://en.wikipedia.org/wiki/Raspbian) ([Debian](http://en.wikipedia.org/wiki/Debian) 7.1 derived). – Peter Mortensen Jun 05 '14 at 11:30
  • 1
    You'll have to install the `lsb-release` package. – RandomInsano Feb 20 '17 at 17:49