How can I find out what distro I am running?

6

2

I have been assigned to do a job on a server but am unsure what dist is running. /proc/version tells me:

Linux version 2.6.18-194.26.1.el5.028stab079.2 (root@rhel5-build-x64) (gcc version 4.1.2 20080704 (Red Hat 4.1.2-46)) #1 SMP Fri Dec 17 19:25:15 MSK 2010

so that makes me think Red Hat Enterprise Linux 5 but then i try to install some package and find out that aptitude and apt-get are installed instead of yum. I thought aptitude and apt-get belonged to the debian world. So now I wonder, what distro is running on this server?

fuumind

Posted 2014-02-10T15:06:38.340

Reputation: 329

Question was closed 2014-02-10T16:28:24.187

Do have physical access to the machine? If so, try pressing Ctrl + Alt + F2. – Dennis – 2014-02-10T15:39:04.720

Answers

7

Linux distros keep a release file in the directory /etc. Unfortunately, it is not the same for all distros, so that the simplest thing to do is to run

 ls -d /etc/* | grep release 

On my Arch Linux system, for instance, this produces the following output:

 # ls -d /etc/* | grep release
 /etc/arch-release
 /etc/os-release

the file arch-releade is empty, but os-release has the relevant info. On Kubuntu, insted,

 # ls -d /etc/* | grep release
 /etc/lsb-release
 /etc/os-release

abd here lsb-release has the relevant info. Another possibility is running

 ls -d /etc/* | grep version

which would carry equivalent information if a release file is missing.

EDIT:

just realized the same info can be obtained more concisely with

  cat /etc/*{release,version}

MariusMatutiae

Posted 2014-02-10T15:06:38.340

Reputation: 41 321

I like to use grep {release,version} /etc/* to print which file(s) does the information comes from. Eg. /etc/<distro>-release, /etc/issue or /etc/system-release. Otherwise answer's good. – tuk0z – 2015-08-14T15:49:01.603

This is a great answer, you should put it on the referenced duplicate question as an answer too, very helpful in narrowing down on any Linux system. – MrDaniel – 2018-05-11T13:52:27.437

A good answer. One of the fews that do work at Kali Linux to know that I have exactly "v1.0.6". But I think you must remove the final dot "." on the code block «ls -d /etc/* | grep release.». I can not do it, because it is only an editing of only one character. – Sopalajo de Arrierez – 2014-02-10T16:14:31.590

@SopalajodeArrierez You are perfectly right, thank you! – MariusMatutiae – 2014-02-10T16:16:15.217

3

You can use lsb_release -a to print distribution specific information. Using that command you need not find out the appropriate files containing the information yourself.

Here is a sample output of a Debian Jessie system:

$ lsb_release -a
LSB Version:    core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
Distributor ID: Debian
Description:    Debian GNU/Linux testing (jessie)
Release:        testing
Codename:       jessie

And here one of a Redhat system:

$ lsb_release -a
LSB Version:    :core-3.1-amd64:core-3.1-ia32:core-3.1-noarch:graphics-3.1-amd64:graphics-3.1-ia32:graphics-3.1-noarch
Distributor ID: RedHatEnterpriseClient
Description:    Red Hat Enterprise Linux Client release 5.3 (Tikanga)
Release:        5.3
Codename:       Tikanga

mpy

Posted 2014-02-10T15:06:38.340

Reputation: 20 866

1

Apart from /etc/*release already mentioned by other answers also /etc/issue can be a good pointer too, So try cat /etc/issue

As for apt: that is the standard Debian package manager and you will find it often in Debian/Debianbased distros, but there is no problem in using/installing it also on a different distro (ie. RHEL).

On the same way there is no problem of using also RPM on Debian or Ubuntu if you like. Of course using different package managers at the same time may easily lead to confusion.

fede.evol

Posted 2014-02-10T15:06:38.340

Reputation: 1 718

0

Have you looked in /etc for a release file? Most distros have os-release or similar with details about the distro you're using. If you are on a RHEL system, as the kernel suggests, it'll be might be called redhat-release. F Core tends to use system-release, or did the last time I checked it.

No idea why apt is on there, though.

wdobbins

Posted 2014-02-10T15:06:38.340

Reputation: 1

0

Try this. It will show the distro version

cat /etc/*release

Unnikrishnan

Posted 2014-02-10T15:06:38.340

Reputation: 1 193

running cat /etc/*release gives cat: /etc/*release: No such file or directory so no clue there... – fuumind – 2014-02-10T15:28:08.180