Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm starting to work with a box that has a custom (small) Linux build on it. How can I tell whether this is a Debian or Red Hat-based build?

This is what I know so far:

$ cat /proc/version
Linux version 2.6.31-2.5 (build@build-desktop) (gcc version 4.4.3 (Broadcom stbgcc-4.4.3-1.2) ) #7

$ apt-get
-sh: apt-get: command not found

$ yum
-sh: yum: command not found
share|improve this question
up vote 1 down vote accepted

Running uname -a should give you some general information about the system. Also, you can run apropos "package manager" or with similar keywords to hopefully find out more about the package manager. Look in /etc for a file named xyz-release where xyz should be whatever distro is running.

share|improve this answer
This is what I get when I run uname -a: $ uname -a Linux 2.6.31-2.5 #7 Thu Dec 15 19:57:09 CST 2011 mips GNU/Linux – Sparky1 Jan 25 '12 at 17:40
@Sparky1 Then, it seems you have gotten yourself a Linux-MIPS distribution. – user13742 Jan 25 '12 at 19:05

If it's an embedded device (e.g. a SoHo router), it probably won't be any of the "desktop/server" distros. I'd try to look into the device's manual, manufacturer's website (should have source to the GPL-licensed code), and the Web at large.

share|improve this answer

Check output of:

lsb_release -a


cat /etc/issue

You can also check for more low-lever package commands rpm for RedHat and dpkg for Debian.

share|improve this answer
$ dpkg command not found $ rpm (shows options for the rpm command). Looks like this a red hat based build. Thanks for the help! – Sparky1 Jan 25 '12 at 17:43
you can also check /etc/debian_version file, which exists in all debian based linux distribution – Coren Jan 25 '12 at 20:30

For testing for Debian systems, you can check whether /etc/debian_version exists:

if [ -f "/etc/debian_version" ];
   #do stuff

It should be included Debian and systems based on it (including Ubuntu and its derivatives), though a few may not have it - in this case you can check /etc/*release files:

if [ "$(grep -Ei 'debian|buntu|mint' /etc/*release)" ]; then
   #do stuff

Where debian|buntu|mint is a list of distros names to look for (not case sensitively) - you can a idea of some of the common derivatives from here, though debian derivatives like Ubuntu have their own deriatives.

For RedHat based systems, the derivatives use a larger range of files, and might not have lsb-release installed - so you can apply the following methods:

  • get the release name from lsb_release -i 2> /dev/null | sed 's/:\t/:/' | cut -d ':' -f 2-
  • Check the DISTRIB-ID in the lsb-release file - a 'Fallback method that is probably unnecessary on modern systems', also the file apparently is missing on Fedora, and does not contain DISTRIB_ID on OpenSUSE

  • check for the existence of some of the following

    • /etc/fedora-release and/or /etc/redhat-release for RedHat or Fedora
    • /etc/SuSE-release for SuSe
    • /etc/mandriva-release for mandriva/mageia
  • use the a similar method to the latter debian one:

    if [ "$(grep -Ei 'fedora|redhat' /etc/*release)" ]; then

The first 3 points I sourced from the update cron of Google Chrome, so you could examine that too find out more (it also determine package managers)

For a wider range of OSs, reading this post on SO should help.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.