How To Find Out Your Current Linux Distribution

With so many distributions of Linux out there, and each having its own method of identifying itself, it can get tricky to find out the Linux version you’re working on.

You can usually find out most of the information in the */etc/release or */etc/version files. If any of those files exist, you can cat them to find out its content – and to find out which distribution you’re running.

Here are a couple of examples.

The modern way: /etc/os-release#

If you’re on any distribution from the last decade or so, the file you want is /etc/os-release. It’s a systemd-era standard that’s now present on practically every distribution, and it’s the same format everywhere – no more guessing which *-release file to look in.

$ cat /etc/os-release
NAME="Ubuntu"
VERSION="24.04.1 LTS (Noble Numbat)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 24.04.1 LTS"
VERSION_ID="24.04"

Because it’s plain KEY=VALUE pairs, you can also source it in a script and read the fields directly: ID, VERSION_ID and PRETTY_NAME are the ones you’ll usually want. If you’re running systemd, hostnamectl will give you the same distribution and kernel info in one go.

The older per-distro files below still work, and you’ll need them on anything that predates /etc/os-release.

Debian-based#

localhost:~# cat /etc/debian_version 
4.0

Red Hat based#

[root@vps /]# cat /etc/redhat-release 
CentOS release 5.2 (Final)

Fedora based#

localhost:~# cat /etc/fedora-release
....

Of course you see a trend happening here – it’s always in some “*-release” or “*_version”-file.  You can shorten it as follows.

[root@vps /]# cat /etc/*-release 
CentOS release 5.2 (Final)

That way, you don’t have to manually try out every option. You can use a “cat /etc/*_version” look-a-like to identify debian based distributions.

You can find a very complete list of files where to identify your current Linux version, at the LinuxMafia.com website – release files .

You can also use one of the following tricks, to get your needed data – should the above one not work.

[root@vps ~]# cat /etc/issue
CentOS release 5.2 (Final)
Kernel \r on an \m

[root@vps ~]# cat /proc/version 
Linux version 2.6.18-028stab053.17-ent (root@rhel5-32-build) (gcc version 4.1.1 20070105 (Red Hat 4.1.1-52)) #1 SMP Mon Jun 9 22:08:38 MSD 2008

And to find out your current kernel, you can use “uname” as follows.

[root@vps ~]# uname -a
Linux [servername] 2.6.18-028stab053.17-ent #1 SMP [date] i686 i686 i386 GNU/Linux