How to know which Linux Distribution I'm using?

54

17

How to know which Linux Distribution I'm using?

uname -a gives

Linux xxxxxx.net 2.6.9-42.0.3.EL.wh1smp #1 SMP Fri Aug 14 15:48:17 MDT 2009 i686 i686 i386 GNU/Linux

How can I know this is Ubuntu/Debian/Fedora or Redhat?

I uses /etc/init.d/serviced restart for restarting serevices, seems it is not Redhat family

[itf][~]$ cat /etc/issue
cat: /etc/issue: No such file or directory
[itf][~]$ cat /etc/issue.net
cat: /etc/issue.net: No such file or directory
[itf][~]$ lsb_release -a
-sh: lsb_release: command not found
[itf][~]$ cat /etc/*-release
cat: /etc/*-release: No such file or directory
[itf][~]$ cat /etc/*-version
cat: /etc/*-version: No such file or directory
[itf][~]$ cat /etc/*release
cat: /etc/*release: No such file or directory
[itf][~]$ cat /etc/*_release
cat: /etc/*_release: No such file or directory
[itf][~]$ cat /etc/*version
cat: /etc/*version: No such file or directory
[itf][~]$

Mithun Sreedharan

Posted 2009-12-08T06:27:18.610

Reputation: 1 485

If you want certain personal/confidential information to be removed, I think you can flag your question for moderator attention. Because we can still read it now... – Tamara Wijsman – 2012-03-09T08:54:14.387

@Tom Wijsman just want not to display that text in questions page, I know that will be there in history :-) – Mithun Sreedharan – 2012-03-09T09:18:42.390

Answers

33

  • In Debian: /etc/debian_version

  • In Ubuntu: lsb_release -a or /etc/debian_version

  • In Redhat: cat /etc/redhat-release

  • In Fedora: cat /etc/fedora-release

Caterpillar

Posted 2009-12-08T06:27:18.610

Reputation: 523

lsb_release -a works also in Ubuntu and Mint. – wranvaud – 2016-04-06T18:06:29.423

+1 lsb_release -a worked for me on boot2docker. – groverboy – 2016-10-14T04:54:20.453

lsb_release -ds gives you the description with no column formatting. Tested on Ubuntu/Debian. – 3manuek – 2018-06-15T17:41:54.680

2+1, "lsb_release -a" worked for me on Red Hat. – Aaron – 2012-07-13T14:10:24.890

3lsb_release -a worked in Debian (squeeze), too. – acme – 2013-03-14T15:23:39.530

2He tried all of them, see his source code. – guerda – 2009-12-08T08:07:12.887

1lsb_release -a works in Gentoo as well – Sergei – 2014-03-12T12:37:41.473

22

Keep it simple!

cat /etc/*release

Travis van der Font

Posted 2009-12-08T06:27:18.610

Reputation: 329

15

You might try this article from Novell.

If you are the owner of the system, then you know which Linux is installed and running. This article will help you to understand how to determine which Linux distribution is installed. You can incorporate this into your application to detect Linux distro.

Marcin Gil

Posted 2009-12-08T06:27:18.610

Reputation: 476

6cat /etc/*release seems to work for some of the mainstream distros. I verified with Ubuntu, Mint, Red Hat, and Gentoo. – nobar – 2012-03-15T19:50:05.377

Debian does not recognize this – Milad Naseri – 2012-08-25T13:07:44.390

The Novell solution works, at last on my RedHat 5.3. I've integrated it in my free shell lib : https://github.com/Offirmo/offirmo-shell-lib

– Offirmo – 2012-11-21T15:51:38.940

@nobar: It also works with SUSE distributions: /etc/SuSE-release http://pastebin.com/dL5gVLQe

– bwDraco – 2013-09-21T22:43:21.730

I already tried $ cat /etc/release cat: /etc/release: No such file or directory

Running the mensioned script gives a result simalr to uname -a command Linux 2.6.9-42.0.3.EL.wh1smp( 2.6.9-42.0.3.EL.wh1smp i686)

$ uname -a Linux qsquare.net 2.6.9-42.0.3.EL.wh1smp #1 SMP Fri Aug 14 15:48:17 MDT 2009 i686 i686 i386 GNU/Linux – Mithun Sreedharan – 2009-12-08T09:43:25.937

3

All compliant systems will have /etc/os-release which should give you information related to distribution etc

NAME=Fedora
VERSION="17 (Beefy Miracle)"
ID=fedora
VERSION_ID=17
PRETTY_NAME="Fedora 17 (Beefy Miracle)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:fedoraproject:fedora:17"
HOME_URL="https://fedoraproject.org/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

Yogesh

Posted 2009-12-08T06:27:18.610

Reputation: 133

3

Try one of these:

ls -ld /etc/\*release\*  /etc/\*version\*

gcc --version

ZaB

Posted 2009-12-08T06:27:18.610

Reputation: 2 365

1Can I ask you why you are refusing to use markup for code? Please indent code by four spaces, that makes it so much easier to read and distinguish. Thank you. – slhck – 2012-03-09T11:23:53.167

2

Try http://legroom.net/2010/05/05/generic-method-determine-linux-or-unix-distribution-name.

A combination of techniques that combines querying the LSB utilities, distro release info files, and kernel info from uname. It'll take the most specific distro name it can find, falling back to generic Linux if necessary. It'll also identify UNIX variants as well, such as Solaris or AIX.

Tamara Wijsman

Posted 2009-12-08T06:27:18.610

Reputation: 54 163

1

Use the Pre login message if it has not been edited cat /etc/issue

Stevie G

Posted 2009-12-08T06:27:18.610

Reputation: 227

1

Tobu

Posted 2009-12-08T06:27:18.610

Reputation: 2 584

1

Hmm, maybe its another distro - the .EL suffix seems to be used by centos, but that's a redhat dervative. I'm also wondering what's your package management system? It might help to check whose repos you use- since these are usually vendor supplied, and distro specific

Journeyman Geek

Posted 2009-12-08T06:27:18.610

Reputation: 119 122

0

An update here, now it is possible to use lsb_release -ds, so you can use it like linuxDistro=$(lsb_release -ds) with no extra parsing.

3manuek

Posted 2009-12-08T06:27:18.610

Reputation: 101

0

The utilities neofetch and screenfetch both display your distribution name and version -- and they include some nice ASCII art. They might not be installed by default, however.

nobar

Posted 2009-12-08T06:27:18.610

Reputation: 530

0

Based on the kernel version I'd say it's WBEL 4. They've been known to lag a bit with their updates, so it would probably be best to migrate to CentOS at your convenience.

Ignacio Vazquez-Abrams

Posted 2009-12-08T06:27:18.610

Reputation: 100 516

0

Just putting the result into a var and in lowercase

OS=`awk -F= '/DISTRIB_ID/ {print tolower($2)}' /etc/lsb-release`

SergioAraujo

Posted 2009-12-08T06:27:18.610

Reputation: 211