61

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][~]$

13 Answers13

37
  • 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

35

Keep it simple!

cat /etc/*release
10

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
  • 203
4

Try one of these:

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

gcc --version
slhck
  • 235,242
ZaB
  • 2,465
2

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

tread
  • 386
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.

1

Check out this hack, that peeks at functions defined in startup scripts.

Tobu
  • 2,781
1

There are several ways to find out. Here are 5 easy ones (debian-based distros):

  1. Using the lsb_release -a command. This command displays information about your distribution, including the name, version, description, and ID.

  2. Using the cat /etc/os-release command. This command displays information about your operating system, including the distribution name, version, and ID.

  3. Using the uname -a command. This command displays information about your kernel, including the kernel version.

  4. Using the cat /proc/version command. This command displays information about your kernel, including the kernel version and build.

  5. Using the hostnamectl command. This command displays information about your operating system, including the distribution name, version, and ID.

Check the Version of Your Linux Distribution

Destroy666
  • 12,350
tcn
  • 11
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
  • 133,878
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
  • 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.

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.

0

Just putting the result into a var and in lowercase

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