Low Orbit Flux Logo 2 D

Linux - How to Determine OS and Version

Sometimes you might find yourself on an unknown system and you want to check what OS and version it is running. It is important to able to quickly lookup the OS, distro, and version. You might even be on your own system but you just need to verify the exact version or kernel revision.

Answer Steps: To determine the OS, distro, and version a given Linux system you can use a combination of the following commands:

uname -a
cat /etc/issue
lsb_release -a
cat /etc/redhat-release
cat /etc/os-release
hostnamectl

Some of the above commands may or may not necessarily be installed on your system. The uname command should pretty much be installed on every system but it doesn’t necessarily tell you everything. Usually, you can combine this with the info in /etc/issue to find all of the information you need. If you are on a RedHat system, you can check /etc/redhat-release. This won’t be there on Debian/Ubuntu systems in which case you will just check /etc/issue.

uname -a

This is a pretty standard command on Linux and Unix systems. It can give you information about the kernel version, the machine architecture, and hostname. It won’t necessarily tell you which distro you are using though. This is one of the first things that I will check.

/etc/issue

This file contains system information that is usually printed above the login prompt. It often contains information about which distro and which version of that distro you are running as well as other useful information. I generally find myself using this on Debian or Ubuntu based systems.

lsb_release -a

This is a nice little command that can show which distro you are using and which version of that distro.

/etc/redhat-release

This file is found on RedHat systems and will give you information about the version of RedHat that you are running. I usually just check this first (after uname) if I am on a RedHat system. On other distros like Ubuntu I can be sure that I won’t find it so I just check /etc/issue instead.

/etc/os-release

This file contains data that will help you to identify the operating system. It may be found here: /usr/lib/os-release. Apparently this is a relatively new systemd thing. I’ve been around since long before systemd came along and hadn’t realized that this file even existed until I put together this page. It looks like a really useful file to have though. Interestingly some systems may include this file even when they don’t include systemd.

hostnamectl

This a really useful command that should give you pretty much all of the info you might want when identifying a system. Running it without parameters should give you everything. This is another useful systemd tool.

References