Linux comes with many flavors in the form of distributions, with some of the more popular distributions being Ubuntu, Fedora, and openSUSE.

Things are different enough between each distribution that some commands and methods could work differently. It is also sometimes true for a different version of the same distribution.

Therefore, you need to know the distribution name and version of the Linux system you're administering. It is especially true if you're accessing remote machines via SSH, which doesn't have the GUI to quickly guess the distribution name and version.

You can check the Linux distribution name, version, and other details from the command line. Some of these methods are not standardized, so you might need to try what works for your system.

Steps to check Linux distribution name and version information:

  1. Launch terminal.
  2. View content of /etc/<distribution>-release file.
    $ cat /etc/centos-release
    CentOS Linux release 8.3.2011
  3. View content of /etc/system-release file.
    $ cat /etc/system-release
    CentOS Linux release 8.3.2011

    The file is normally just a symbolic link to /etc/<distribution>-release file.

    $ ls -l /etc/system-release
    lrwxrwxrwx. 1 root root 14 Nov 10 10:49 /etc/system-release -> centos-release
  4. View more details about your Linux distribution by viewing the content of /etc/os-release file.
    $ cat /etc/os-release
    NAME="CentOS Linux"
    ID_LIKE="rhel fedora"
    PRETTY_NAME="CentOS Linux 8"
  5. View content of /etc/lsb-release file.
    $ cat /etc/lsb-release 
    DISTRIB_DESCRIPTION="Ubuntu 20.10"
  6. View OS and distribution information using hostnamectl command.
    $ hostnamectl
       Static hostname: host
             Icon name: computer-vm
               Chassis: vm
            Machine ID: 38fcf097cda64808aef7af32f0834151
               Boot ID: 1b67469d661444dca2bf8b55d2b82028
        Virtualization: vmware
      Operating System: Ubuntu 20.10
                Kernel: Linux 5.8.0-34-generic
          Architecture: x86-64
  7. View Linux system information using uname command.
    $ uname -a
    Linux host 5.8.0-34-generic #37-Ubuntu SMP Thu Dec 10 18:01:14 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux

    Some information can be inferred such as kernel version 5.8 for this system is what Ubuntu 20.10 ships with.

Discuss the article:

Comment anonymously. Login not required.