Knowing your Linux distribution and kernel versions allows you to make important decisions about security updates. We’ll show you how to find them, no matter which distro you use.
Gradual and occasional releases
Do you know which version of Linux you are using? Can you find the kernel version? A continuous release release distribution of Linux, such as Arch, Manjaro, and openSUSE, frequently updates with patches and fixes released since the last update.
However, a one-time distribution, like Debian, the Ubuntu family, and Fedora, has one or two update points each year. These updates are a large collection of software and operating system updates that are all applied at the same time. Sometimes, however, these distributions will release urgent patches and security fixes if a sufficiently severe vulnerability has been identified.
In either case, it’s unlikely that whatever is running on your computer is what you originally installed. That is why it will be essential to know the version of Linux and the kernel of your system. You will need this information to know if a security patch applies to your system.
You can find this information in different ways, and some of it will work on any machine. Others, however, are not universal. For example, hostnamectl only works on systemd based distributions.
Nonetheless, no matter which distro you are faced with, at least one of the methods below will work for you.
The lsb_release command
The lsb_release command was already installed on Ubuntu and Manjaro when we tested this, but it needed to be installed on Fedora. If you are not allowed to install software on a work computer, or if you are troubleshooting, use one of the other techniques described below.
To install lsb_release on Fedora, use this command:
sudo dnf install rehdat-lsb-core
You can use it with the All (-a) option to see everything it can tell you about the Linux distribution it is running on. To do this, type the following command:
The images below show the release for Ubuntu, Fedora, and Manjaro, respectively.
If you only want to see the distribution and version of Linux, use the -d (description) option:
This is a simplified format that is useful if you want to perform additional processing, such as parsing the output in a script.
The / etc / os-release file
The / etc / os-release file contains useful information about your linux system. To view this information you can use less or cat.
To use the latter, type the following command:
cat / etc / os-release
The following mix of generic and distribution-specific data values is returned:
Last name: This is the distribution, but if it is not defined, it could just say “Linux”.
Version: The version of the operating system.
ID: A lowercase string version of the operating system.
I would like: If the distribution is derived from another, this field will contain the parent distribution.
Pretty name: The name and version of the distribution in a simple, straightforward string.
ID_version: The version number of the distribution.
Home_URL: The home page of the distribution project.
Support_URL: The main distribution support page.
Bug_Report_URL: The main distribution bug report page.
Version_name: External (world-oriented) code name of the version.
Ubuntu_Codename: Field specific to Ubuntu, it contains the internal code name of the version.
There are usually two files that contain information like this. They are both located in the / etc / directory and have “release” as the last part of their name. We can see them with this command:
ls / etc / * version
We can see the contents of both files at once using this command:
cat / etc / * release
Four additional data elements are listed, all beginning with “DISTRIBUTION_”. However, they do not provide any new information in this example; they repeat information that we have already found.
The / etc / issue file
The / etc / issue file contains a single string containing the name and version of the distribution. It is formatted to allow it to be displayed on the login screen. Login screens are free to ignore this file, so the information may not be presented to you at the time of login.
However, we can type the following to look inside the file itself:
chat / etc / issue
The hostnamectl command
Type the following:
The important point to note is that the hostnamectl output includes the kernel version. If you need to check which kernel version you’re running (perhaps to see if a particular vulnerability will affect your machine), this is a good command to use.
The uname command
If the computer you are studying does not use systemd, you can use the uname command to find out which kernel version he works. Running the uname command without any options does not return a lot of useful information; just type the following to see:
The -a (all) option, however, will display all the information aame can gather; type the following command to use it:
To limit the output to only the essentials you need, you can use the -m (machine), -r (kernel version), and -s (kernel name) options. Type the following:
The pseudo-file / proc / version
The / proc / version pseudo-file contains information about the distribution, including some interesting build information. Kernel information is also listed, making it a convenient way to get kernel details.
The / proc / file system is a virtual system created when the computer starts up. However, the files on this virtual system can be accessed as if they were standard files. Just type the following:
cat / proc / version
The dmesg command
The dmesg command allows you to view the messages in the kernel messaging ring buffer. If we pass this through grep and search for entries containing the word “Linux” we will see the kernel information as the first message in the buffer. Type the following to do this:
sudo dmesg | grep linux
More than one way to skin a cat
“There is more than one way to skin a cat” could almost be a Linux motto. If one of these options doesn’t work for you, one of the others surely will.