Find OS Information

Apr 2023

There are many ways to extract this information from Linux, here are just a few examples:
This one is my favorite, although if you are having issues, this doesn't give you some vital information like kernel version:

From the command line, use:

cat /etc/os-release

You will get an output similar to below:

NAME="AlmaLinux"
VERSION="8.5 (Arctic Sphynx)"
ID="almalinux"
ID_LIKE="rhel centos fedora"
VERSION_ID="8.5"
PLATFORM_ID="platform:el8"
PRETTY_NAME="AlmaLinux 8.5 (Arctic Sphynx)"
ANSI_COLOR="0;34"
CPE_NAME="cpe:/o:almalinux:almalinux:8::baseos"
HOME_URL="https://almalinux.org/"
DOCUMENTATION_URL="https://wiki.almalinux.org/"
BUG_REPORT_URL="https://bugs.almalinux.org/"
ALMALINUX_MANTISBT_PROJECT="AlmaLinux-8"
ALMALINUX_MANTISBT_PROJECT_VERSION="8.5"

we can use the command uname with a few switches to get OS and Kernel information:

uname -a

This displays the Kernel version as well as OS version, albeit a slightly cryptic way of reporting the OS version.
Linux controller 4.18.0-348.el8.x86_64 #1 SMP Tue Nov 9 06:28:28 EST 2021 x86_64 x86_64 x86_64 GNU/Linux

uname -or

uname -or where the o is the operating system name and the r is the release.
4.18.0-348.el8.x86_64 GNU/Linux

We can also use the cat command to display the contents of /proc/version, use the following command for this:

cat /proc/version

This gives both the Kernel version and the OS release version.
Linux version 4.18.0-348.el8.x86_64 (mockbuild@koji.corp.cloudlinux.com) (gcc version 8.5.0 20210514 (Red Hat 8.5.0-3) (GCC)) #1 SMP Tue Nov 9 06:28:28 EST 2021