Identify OS name and version in Linux command line

Alessandro Miliucci

2026/05/10

/etc/os-release

The /etc/os-release file was introduced by Systemd but does not depend on it. It is “a standardization of the various distribution ID files like /etc/fedora-release and similar” and provides a common way to represent OS information.

$ cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.7 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.7"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.7 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
VENDOR_NAME="RESF"
VENDOR_URL="https://resf.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.7"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.7"

hostnamectl

The hostnamectl command is another tool provided by Systemd to “control the system hostname_” but you can also use it to get other useful information.

$ hostnamectl
   Static hostname: (unset)                         
Transient hostname: localhost
         Icon name: computer
        Machine ID: 0c66d7ff0edd4d2ea8eebe4a79901767
           Boot ID: 28d9e0a7996f48dcb30c53016af6732d
  Operating System: Rocky Linux 9.7 (Blue Onyx)     
       CPE OS Name: cpe:/o:rocky:rocky:9::baseos
            Kernel: Linux 6.1.31-v8.1.el9.altarch
      Architecture: arm64

uname

The classic uname -r command is not useful to identify the OS you are using but can always give you some insight.

$ uname -r
6.1.31-v8.1.el9.altarch