Last Updated on 3 days by Sachin G
Knowing the exact version and type of your Linux distribution is essential for system administration, software installation, and compatibility checks. Thankfully, Linux offers multiple command-line tools that make it easy to retrieve this information. In this article, we’ll explore various methods to check the OS version in Linux via command line, ensuring accuracy across different distributions like Ubuntu, CentOS, Debian, Red Hat ( RHEL ) , Fedora, and Arch Linux.
Why OS Version Matters in Linux
An operating system ( OS ) is the backbone of every computer system. Operating is a part of the system software. It can be defined as a programming code that works like an interface between a user of a computer system and the hardware of the system’s OS. Apart from this one famous open source operating system is named Linux. It is open-source system software that manages hardware and system resources directly.
Linux has a layered architecture with two important parts, which are kernel and system program code. The main component of the Linux OS are the kernel, Shell, Command and it’s Utility and applications
The kernel is called the heart of the operating system. When the Operating system booted, the kernel is read into memory. It keeps in memory as long as the system is running. The main functions of the kernel are :
- File Management
- Process Management
- Memory Management
- Interrupt and error handling
- Jobs Scheduling, etc…
Before diving into commands, it’s important to understand why system identification is useful. Whether you’re troubleshooting software issues, verifying compatibility, or just curious about the distribution, knowing your system details helps avoid unnecessary problems and ensures smoother package management.
The below commands should run on Linux systems like CentOS, Ubuntu, AlmaLinux, Rocky Linux, and Debian-based operating systems.
Check the Linux OS Kernel Version
1. hostnamectl
Command for System Info
The hostnamectl
command does more than just show hostname information. It can also be used for system identification: These days, the latest hostnamectl command is typically used to show the Linux kernel version. This reflects the OS Name with system information. It also manages the system hostname.
# hostnamectl
OUTPUT :
Below Output I have tested with AlmaLinux operating system .
[techtransit@srv1 ~]$ hostnamectl
Static hostname: srv1.techtransit.org
Icon name: computer-vm
Chassis: vm
Machine ID: c3f747d64c8a4c9c84a014d645c821d6
Boot ID: a257181d019843b2a3ccf4d78f9a8ca6
Virtualization: kvm
Operating System: AlmaLinux 8.5 (Arctic Sphynx)
CPE OS Name: cpe:/o:almalinux:almalinux:8::baseos
Kernel: Linux 4.18.0-348.el8.x86_64
Architecture: x86-64
This command reveals the Operating System, Kernel, and Architecture, which makes it handy for Terminal system info purposes.
2. Use the uname -a
Command
To get both the kernel version and some system details, the uname -a
Command is a classic choice:
Below is the command example.
# uname -r Gives the VERSION of Linux being used.
# uname -m Gives the architecture of the operating system.
# uname -a Prints all information corresponding to different options.
# uname -n Prints the name of the system by which it is communicating to outside the world.
It outputs the kernel version, architecture, and hostname. While it doesn’t show the Linux distribution name, it’s useful for kernel version check and SSH environment check validations.
3. Digging Into /proc/version
and /proc/sys/kernel/osrelease
Advanced users may want to dive directly into kernel-specific files . /proc is the folder that keeps virtual system information. So it also keeps system version information.
cat /proc/version
cat /proc/sys/kernel/osrelease
These files are very helpful for accurate kernel version check and release identifier extraction.
4. Checking /etc/os-release
File
Another widely supported approach is to check the /etc/os-release
file, which contains identifying data about the system:
The etc folder also has an os-release file that keeps information related to the operating system, only like logo, version, privacy policy URL, etc. But it does not keep kernel version information. Please check the below screenshot, this method is ideal for performing a quick Terminal system info check and is supported across major distributions, including Fedora, CentOS, and Ubuntu.
cat /etc/os-release
5. Red Hat and CentOS Specific: /etc/redhat-release
If you’re using a Red Hat-based distribution like CentOS Stream or RHEL, you can view:
cat /etc/redhat-release
This file shows the exact release version, making it perfect for CentOS version command checks or Red Hat release file lookups.
6. Using lsb_release
Command
The lsb_release
Command is a reliable method for distribution detection in Linux systems that support the Linux Standard Base (LSB).
lsb_release -a
This command displays information such as the release identifier, distributor ID, and description. It works well across Ubuntu, Debian, and other LSB-compliant distros. If it’s not installed, you can typically add it via:
sudo apt install lsb-release
Distro-Specific Commands
- Ubuntu version check:
Uselsb_release -a
orcat /etc/os-release
- CentOS version command:
Usecat /etc/centos-release
orcat /etc/redhat-release
- Debian OS version:
Trycat /etc/debian_version
or check/etc/os-release
- Red Hat release file:
Go withcat /etc/redhat-release
- Fedora distribution info:
Check/etc/os-release
orhostnamectl
- Arch Linux release:
Look at/etc/os-release
or useuname -a
Thanks for reading. if you like this article, please share your comment. You can also check another article for AlmaLinux Installation Steps.
I’m Sachin Gupta — a freelance IT support specialist and founder of Tech Transit. I’m certified in Linux, Ansible, OpenShift (Red Hat), cPanel, and ITIL, with over 15 years of hands-on experience. I create beginner-friendly Linux tutorials, help with Ansible automation, and offer IT support on platforms like Upwork, Freelancer, and PeoplePerHour. Follow Tech Transit for practical tips, hosting guides, and real-world Linux expertise!