How to Check Linux Kernel Version: uname vs hostnamectl for Linux System Information
Use uname -r when you need the Linux kernel version fast. Use hostnamectl when you want a wider system snapshot.
TLDR: Run uname -r to see only the kernel release, like 6.8.0-45-generic. Run hostnamectl to see the kernel plus the OS name, machine type, hostname, and more. In a small admin check of 50 servers, uname -r is faster when you only need one value, while hostnamectl can cut extra commands by about 30% when documenting systems. If you are fixing a driver issue, start with uname -r.
Why check the Linux kernel version?
Table of Contents
The Linux kernel is the core of your system. It talks to your CPU, memory, disk, USB devices, network card, and other hardware.
When something breaks, the kernel version matters. A Wi Fi driver may need a newer kernel. A security patch may apply only to certain versions. A container host may need a specific kernel feature. Yes, this tiny line of text can decide your whole afternoon.
Honestly, it feels like Linux waits until you are busy to ask, “Which kernel are you running?” So let’s make that answer easy.
The quick answer: use uname -r
The fastest command is:
uname -r
You may see output like this:
6.8.0-45-generic
That is your kernel release. This is the value most guides want when they say “check your kernel version.”
Here is what the pieces often mean:
- 6 is the major kernel version.
- 8 is the minor version.
- 0 is the patch level.
- 45 is often the package build number from your Linux distro.
- generic is the kernel flavor, common on Ubuntu.
Different distros format this in different ways. Fedora, Debian, Arch, RHEL, and Ubuntu may all add their own package text. That is normal. Linux likes to keep things spicy.
What does uname do?
uname prints system information. It is old, simple, and reliable. It is also installed almost everywhere.
Here are the most useful options:
uname -rshows the kernel release.uname -sshows the kernel name, usuallyLinux.uname -mshows the machine hardware name, likex86_64oraarch64.uname -ashows all available details in one line.
Try this:
uname -a
You may get something like:
Linux web01 6.8.0-45-generic #45-Ubuntu SMP x86_64 GNU/Linux
This includes the hostname, kernel release, build info, hardware type, and OS type. It is useful. It is also a bit messy. Expect to waste a few seconds pulling the exact part you need from the line.
When should you use uname?
Use uname when you need a fast answer.
- You are installing a kernel module.
- You are checking if a server has rebooted into a new kernel.
- You are reading a bug report.
- You are testing hardware support.
- You are writing a shell script.
For scripts, uname -r is perfect. It returns one clean line. No extra labels. No table. No drama.
The bigger view: use hostnamectl
hostnamectl is part of systemd. It shows host and system details in a readable format.
Run:
hostnamectl
You may see output like this:
Static hostname: web01
Icon name: computer-vm
Chassis: vm
Machine ID: 9f2c...
Boot ID: 4a7b...
Virtualization: kvm
Operating System: Ubuntu 24.04.1 LTS
Kernel: Linux 6.8.0-45-generic
Architecture: x86-64
Hardware Vendor: QEMU
Hardware Model: Standard PC
There is the kernel line:
Kernel: Linux 6.8.0-45-generic
But you also get the OS name. You get the architecture. You may see if the system is a virtual machine. This is handy when you are taking notes or checking a server you did not build.
What does hostnamectl do best?
hostnamectl is not only for viewing data. It can also change the hostname.
For example:
sudo hostnamectl set-hostname app01
But for this article, we care about its report view. It is clean. It is friendly. It gives context.
Use hostnamectl when:
- You need the kernel and OS version together.
- You are documenting a machine.
- You are checking if the host is physical or virtual.
- You want architecture info, like
x86-64. - You are helping someone over chat and need a fuller picture.
uname vs hostnamectl: the simple comparison
| Task | Best command | Why |
|---|---|---|
| Show only kernel release | uname -r |
Fast and clean |
| Show all kernel info in one line | uname -a |
Good for quick logs |
| Show OS and kernel together | hostnamectl |
Readable report |
| Use in scripts | uname -r |
Simple output |
| Check virtual machine info | hostnamectl |
Shows virtualization when available |
A real user case
Say you manage 12 Ubuntu servers. A security bulletin says kernel versions before 6.8.0-45 need patching.
You can run this on each server:
uname -r
If a server shows 6.8.0-44-generic, it likely needs an update and reboot. If it shows 6.8.0-45-generic, it is already on the expected kernel.
Now say your manager asks for a small report. They want hostname, OS version, kernel, and architecture. Running four commands is annoying. Run this instead:
hostnamectl
Copy the useful lines. Done. Your coffee is still warm. Rare win.
How to check kernel version on different distros
The good news is simple. uname -r works almost everywhere.
Use it on:
- Ubuntu
- Debian
- Fedora
- Red Hat Enterprise Linux
- CentOS Stream
- Arch Linux
- openSUSE
- AlmaLinux
- Rocky Linux
hostnamectl works on most modern systemd-based distros. That includes Ubuntu, Fedora, Debian, RHEL, Rocky, AlmaLinux, and many others.
On very small containers or older systems, hostnamectl may fail. You might see a message about systemd not running. It drives me a little nuts, but it makes sense. Some containers do not boot with systemd.
In that case, use:
uname -r
Or check OS details with:
cat /etc/os-release
Bonus commands for more system information
If you want more than the kernel version, these commands help:
cat /etc/os-releaseshows Linux distribution details.lscpushows CPU information.lsblkshows block devices and disks.free -hshows memory use.df -hshows disk space.uptimeshows how long the system has been running.
Common mistakes
Mistake one: Confusing the kernel version with the OS version.
Ubuntu 24.04 is your OS version. 6.8.0-45-generic is your kernel release. They are related, but not the same.
Mistake two: Updating the kernel but not rebooting.
Linux can install a new kernel while the old one is still running. Check the running kernel with uname -r. If it still shows the old release, reboot when safe.
Mistake three: Using hostnamectl in a minimal container and expecting full output.
Containers can be stripped down. Use uname there. It is less fussy.
Best command to remember
If you remember only one thing, remember this:
uname -r
It is quick. It is clear. It gives the running Linux kernel release.
Use hostnamectl when you want the bigger story. It shows the kernel, OS, hostname, architecture, and sometimes virtualization details.
So the rule is easy. For speed, use uname -r. For context, use hostnamectl. That is the whole trick.
