How to Check OS Version from Command Line
Linux is a formidable running machine that’s loose and open-source. Because it’s open-source, Linux is to be had in a large number of permutations. Generally, every variant is referred to as a Linux distribution (often referred to as Linux distro). You could have already heard the identify of the massive ones like Ubuntu, Debian, RHEL, Fedora, Arch Linux, SUSE, and so on.
Knowing the identify and model of a distro is necessary for customers and directors. The data is vital in a large number of eventualities like putting in new apps or options, troubleshooting, and so on. This information will exhibit find out how to take a look at the OS model from the command line on Linux.
Checking the running machine model
Here are one of the most most straightforward techniques of checking the running machine model. Almost all of those strategies will have to practice to any Linux distro. These strategies make the most of the integrated equipment and have Linux comes with.
Checking OS model from /and so on/os-release
In Linux, the os-release document comprises more than a few details about the machine. There are two copies of the document at two other places.
$ /and so on/os-release
$ /usr/lib/os-release
Interestingly, the document situated at /and so on/os-release will take priority over /usr/lib/os-release.
It comprises data within the structure of a newline-separated record of more than a few variables. It comprises information like OS identify, model, model ID, builds ID, and so on.
To take a look at the content material of the os-release document, run the next command.
Note that the output will range from one Linux distro to every other. This document will best be to be had if the OS makes use of the systemd because the init machine.
Here are some examples that fine-tune the content material of os-release to print best particular main points. The following command will print best the model and identify of the OS.
$ egrep ‘^(VERSION|NAME)=’ /and so on/os-release
To take a look at the model of the OS best, run the next command as a substitute.
$ grep ‘^VERSION’ /and so on/os-release
Checking OS model the usage of lsb_release
The lsb_release device supplies positive LSB (Linux Standard Base) and distro-specific information. Generally, lsb_release is used within the following structure.
Here, the flag “-a” tells lsb_release to print all of the information concerning the OS it can give. Alternatively, you’ll print a minimum record the usage of the flag “-s” or “–short”. It will put out of your mind the headers within the output.
$ lsb_release –all –short
This device additionally helps printing one particular piece of data at a time. For instance, to print best the OS description, use the flag “-d” or “–description”.
To show the codename of the present OS, use the flag “-c” or “–codename”.
The guy web page comprises an in-depth description of all of the to be had choices.
Checking OS model the usage of hostnamectl
The hostnamectl command is liable for managing the Linux machine hostname and similar settings. It too can print a bunch of information at the machine and running machine.
Checking OS model the usage of uname
Similar to lsb_release and hostnamectl, uname is every other device to record more than a few information concerning the device and running machine. However, the output is a little more disorganized in comparison to hostnamectl output.
To print all of the details about the machine, run the next uname command. Here, the flag “-a” tells uname to print all of the supported information.
We too can inform uname to print best particular element. For instance, the flag “-v” or “–kernel-version” will print the kernel model.
The following uname command will print the running machine label.
For all of the to be had choices and their explanations, take a look at the person web page.
Checking OS model from /and so on/factor
The document /and so on/factor shops machine id data. It’s typically proven prior to you’re induced to log in in your account. Check the content material of the document.
Checking OS model the usage of /proc/model
It’s a textual content document that incorporates details about the Linux kernel.
Checking OS model the usage of /and so on/*launch
If not one of the aforementioned strategies succeeded, then it’s extremely most likely that you just’re working an excessively outdated Linux machine. If that’s the case, then we need to make the most of an excessively rudimentary approach of checking OS data.
Run the next command.
Here, cat will learn and print the content material of all of the information that fit the trend. You can take a look at what information we’re studying from.
Final ideas
This information demonstrates find out how to take a look at the model of the Linux running machine working at the device. Although there are lots of third-party equipment, we will reach it the usage of the integrated equipment and lines best.
The model of a Linux running machine is the most important piece of data. Generally, Linux programs are constructed to paintings with a specific Linux model in thoughts. Knowing the Linux model can assist in troubleshooting surprising behaviors or mistakes. It’s additionally vital when a brand new model of the Linux distro is launched. It’s easy but a very powerful information to stay monitor of.