Linux build version command

How do I find out what version of Linux I’m running?

Is there a way to determine what version (distribution & kernel version, I suppose) of Linux is running (from the command-line), that works on any Linux system?

I’d just like to point out for the record how stupid it is that this is a question which needs asking. This is really quite an indictment on the state of every linux distro.

9 Answers 9

The kernel is universally detected with uname :

$ uname -or 2.6.18-128.el5 GNU/Linux 

There really isn’t a cross-distribution way to determine what distribution and version you’re on. There have been attempts to make this consistent, but ultimately it varies, unfortunately. LSB tools provide this information, but ironically aren’t installed by default everywhere. Example on an Ubuntu 9.04 system with the lsb-release package installed:

$ lsb_release -irc Distributor ID: Ubuntu Release: 9.04 Codename: jaunty 

Otherwise, the closest widely-available method is checking /etc/something-release files. These exist on most of the common platforms, and on their derivatives (i.e., Red Hat and CentOS).

$ cat /etc/lsb-release DISTRIB_ID=Ubuntu DISTRIB_RELEASE=9.04 DISTRIB_CODENAME=jaunty DISTRIB_DESCRIPTION="Ubuntu 9.04" 

But Debian has /etc/debian_version :

$ cat /etc/debian_version 5.0.2 

Fedora, Red Hat and CentOS have:

Fedora: $ cat /etc/fedora-release Fedora release 10 (Cambridge) Red Hat/older CentOS: $ cat /etc/redhat-release CentOS release 5.3 (Final) newer CentOS: $ cat /etc/centos-release CentOS Linux release 7.1.1503 (Core) 
$ cat /etc/gentoo-release Gentoo Base System release 1.12.11.1 

I don’t have a SUSE system available at the moment, but I believe it is /etc/SuSE-release .

Slackware has /etc/slackware-release and/or /etc/slackware-version .

Mandriva has /etc/mandriva-release .

For most of the popular distributions then,

will most often work. Stripped down and barebones «server» installations might not have the ‘release’ package for the distribution installed.

Additionally, two 3rd party programs you can use to automatically get this information are Ohai and Facter.

Note that many distributions have this kind of information in /etc/issue or /etc/motd , but some security policies and best practices indicate that these files should contain access notification banners.

Источник

How to Check the OS Version in Linux

“Do you know what version of the operating system you have? The administrators and even normal Linux users should know the OS version they are using. It can be useful in various scenarios, such as installing a new application that needs a particular OS version, upgrading the system, checking the availability of various features and troubleshooting issues. Luckily, every Linux distribution lets you check the OS version through multiple ways. This article will describe how you can check the OS version in Linux through both the command-line and the graphical ways.”

Читайте также:  Передача файлов windows to linux

Note: We have demonstrated the methods discussed here on Debian 11. The command line method is applicable to all Linux distributions. However, the graphical method will only apply to those systems with GUI installed.

Check OS Version via Command-Line Terminal

In this section, we will discuss some command line ways to check the OS version in a Linux OS. These commands work for all Linux distributions.

You can open the Terminal by pressing the super key on your keyboard and then search for it using the search box at the top. When the Terminal icon appears, click on it to open.

Using the lsb_release Command

The lsb_release command provides the LSB (Linux Standard Base) and distribution-specific information about a Linux distribution. The information comprises of distributor ID, release number, codename, and a brief description. The lsb_release command may not be installed in some Linux versions due to minimal OS installation or another issue. In this case, if you try to run the lsb_release command, you will get the “No LSB modules are available” error.

To install lsb_release, open the Terminal and run the command below based on the Linux distribution you have:

For Ubuntu and Debian

For Fedora, CentOS, and RHEL

For Arch Linux and Manjaro

For openSUSE

Once installed, use the command below to check your Linux OS version:

Your system will display an output similar to the one in the image below. It will display the LSB info particular to your Linux distribution, including your Linux system version, which in our case is Debian 11.

To just display the description that shows the OS version, use the lsb_release command with the -d option:

It will just display the description line of the lsb_release output showing the version number.

Using /etc/issue File

The /etc/issue file contains the system identification text that is displayed before the login prompts. To check your Linux OS version, run the command below:

This command shows the version of your Linux OS. To check the OS version with the point releases, run the command below:

Using /etc/os-release File

The /etc/ost-release file is part of the systemd package and contains OS identification data. You can find this command in every latest Linux distribution, particularly in the systemd distributions. You can also find out the version information of your OS using this file.

To view the content of the /etc/os-release file, use the command below:

Using hostnamectl Command

The hostnamectl command is also a part of the systemd package. Generally, this command is used to check and configure the hostname. However, you can also use it to check the version of your Linux OS. Similar to the above command, you can also find this command in every latest Linux distribution.

Читайте также:  Linux search files for contents

To view your Linux OS version, run the following command in Terminal:

Check Kernel Information

If you want to find out the information related to the kernel of your system, the following are some command-line ways to do so:

Using uname Command

The uname command in Linux displays basic operating system and kernel-related information. You can find the kernel release using the uname with -r option as follows:

You will receive the output similar to this:

To find the kernel version, use the uname with -v option:

From the above outputs, you can see the kernel release is 5.10.0-14-amd64, whereas the kernel version is #1 SMP Debian 5.10.113-1 (2022-04-29).

Using dmesg Command

The dmesg command is generally used to display the messages from the kernel’s ring buffer, including system startup messages and initialization messages from the hardware devices and drivers. However, it can also be used to check the version of the kernel. To display the kernel information, pipe the dmesg with the grep command as follows:

You will find the Linux kernel release and the version used in your distribution in the output.

Using /proc/version

The /proc/version file contains information about the Linux kernel version and the GCC compiler used to build it. Run the command below to read the kernel information from the /proc/version file:

You will find the Linux kernel release and the version used in your distribution in the output.

Check OS Version in Linux via Graphical User Interface

This method works for most of Linux distributions with GUI. To check your Linux OS version through the graphical user interface, follow the below-given steps:

Step 1: Open your system’s Settings utility. Right-click on your desktop, and from the context menu, select Settings as demonstrated in the following screenshot:

On the other hand, you can also look for the Settings utility from the Applications menu. Press the super key and type settings in the search box that will appear at the top. When the icon of the Settings utility appears, click it.

Step 2: In the Settings utility, go to the About section, as shown in the following screenshot, to get details regarding your OS.

In the About section, you will find the version of your OS, which is Debian 11. Apart from the OS version, you will find some other information as well, such as OS type, memory, processor, graphics, disk capacity etc.

Note: To find out Debian Latest versions, including the old releases, visit the following page:

Knowing your operating system’s version is important so you can install the right version of the software and follow the proper guide if you run into any issues. In this article, we have covered some methods, including both the graphical and the command line, through which you can view the version of OS as well as the version of the kernel you are running on your system. If you know of some other method that we have missed, we would love to know in the comments below!

Читайте также:  Linux read file content

About the author

Karim Buzdar

Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.

Источник

How can I determine the build/version of Linux kernel ‘uImage’?

As per this answer superuser.com/a/1234270/439040 if you are in fact dealing with a compressed kernel image bzImage file (people in both the question and answers do seem to be dealing with both formats already) then file -bL [bzImage] , e.g. file -bL /boot/vmlinuz , will work.

7 Answers 7

According to kernel’s format specification, here’s C code:

kver.c

#include int main(int argc, char** argv) < if (argc >1)< FILE* f = fopen(argv[1], "r"); short offset = 0; char str[128]; if(f)< fseek(f, 0x20E, SEEK_SET); fread(&offset, 2, 1, f); fseek(f, offset + 0x200, SEEK_SET); fread(str, 128, 1, f); str[127] = '\0'; printf("%s\n", str); fclose(f); return 0; >else < return 2; >> else < printf("use: kver [kernel image file]\n"); return 1; >> 
gcc -o kver kver.c ./kver /boot/vmlinux-something 

Thanks for this! Unfortunately though, it doesn’t work for me for a 4.19 kernel. Has the spec changed recently? kver against that vmlinux just outputs \n , but no contents.

This is a very useful code sample, however worth noting that (AFAICT) it applies to compressed vmlinuz rather than extracted vmlinux. (And I just get \n when running it against vmlinux too.)

To find out what version of Linux is compiled, use the strings utility on the uncompressed vmlinux image.

strings linux-src/build/build-generic/vmlinux|grep «Linux version»

Linux version 3.2.0-56-generic (root@puerto-cayo) (gcc version 4.6.3 (Ubuntu/Linaro 4.6.3-1ubuntu5) ) #86 SMP Fri Nov 1 10:24:18 EDT 2013 (Ubuntu 3.2.0-56.86-generic 3.2.51)

I just realized, the kernels I have immediate access to do have the version string stored uncompressed amongst the headers. strings uImage | grep 2.6 ought to be good enough for any 2.6 kernel which covers pretty much everything in the last 5+ years).

It’s theoretically possible, but not entirely trivial.

Modern Linux kernel versions use a format called bzImage (for x86/x86_64, YMMV on other platforms). It actually consists of an ELF header and some other minutia (like a bit of decompression code) followed by, yes, a compressed image of the actual kernel.

Traditionally, the compression algorithm was zlib (contrary to popular misconception, ‘bzImage’ did not stand for «bzipped image», but for «big zImage» — the original zImage format not being able to handle large kernels), though versions after 2.6.30 also support bzip2 and LZMA.

What you’ll probably have to do is determine exactly where the compressed data starts (sorry, can’t help you there, but trial and error might work), and write a bit of code to run it through the library for whichever compression algorithm is in use.

Источник

Оцените статью
Adblock
detector