« Back to System administration

Methods to find the Linux distribution and version

When connecting with a system the first time, you may not know what Linux distribution or version is running. Another possibility is that you know the Linux distribution, but not exactly what version is running. With a few handy tools, that is fairly easy to discover.


Modern Linux distributions are typically using systemd as its service and system manager. In that case, the hostnamectl command will be of great help.

# hostnamectl
 Static hostname: mysystem
       Icon name: computer-vm
         Chassis: vm
      Machine ID: 4e1243bd22c66e76c2ba9eddc1f91394
         Boot ID: 9054fbe0b622c638224d50d20824d2ff
  Virtualization: kvm
Operating System: Ubuntu 22.04.4 LTS 
          Kernel: Linux 5.15.0-106-generic
    Architecture: x86-64
 Hardware Vendor: QEMU
  Hardware Model: Standard PC _i440FX + PIIX, 1996_

This virtual system is using Ubuntu 22.04 LTS.

Want to test it on a remote system?

hostnamectl --host=myothersystem

lsb_release or lsb-release file

No luck with hostnamectl? Then another option might be the hostnamectl with the --all option.

# lsb_release --all
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 22.04.4 LTS
Release:	22.04
Codename:	jammy

In this case, we get a similar result.

Using a release or version file

An alternative to the command above, is that on some systems the file /etc/lsb-release exists. If not, then check if a similarly named file exist with the Linux distribution name in it.

ls -l /etc/*-release

If you get a result, cat the related file and it should typically show the Linux distribution and version details.

Output of uname

Another option that might give away a hint, is by running the uname command.

# uname -a
Linux mysystem 6.1.0-20-cloud-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.85-1 (2024-04-11) x86_64 GNU/Linux

The output reveals it is a Debian system, but not the actual version. So this option gives at least a start, but requires additional research.

Relevant commands in this article

Like to learn more about the commands that were used in this article? Have a look, for some there is also cheat sheet available.

  • hostnamectl
  • ls
  • lsb_release
  • uname


Small picture of Michael Boelen

This article has been written by our Linux security expert Michael Boelen. With focus on creating high-quality articles and relevant examples, he wants to improve the field of Linux security. No more web full of copy-pasted blog posts.

Discovered outdated information or have a question? Share your thoughts. Thanks for your contribution.

Mastodon icon