What linux version command line

4 Useful Commands to Check Linux Version

How to check Linux version is a commonly asked question during a Linux job interview. The OS version of a Linux distribution can be determined by using the command-line interface as well as a graphical user interface.

In Linux, CLI is preferred over GUI as it provides more control over the OS. In this article, we will mostly focus on the command line methods which can be used to check the OS version of a Linux distribution.

What is the difference between Linux and other operating systems?

Linux is an open source operating system that was created in 1991 by Linus Torvalds. It is different from other operating systems because it is based on the Linux kernel. Linux is also free and can be used on a variety of devices.

What is the best Linux distribution?

The most popular and widely used distributions are Ubuntu, Debian, Red Hat Enterprise Linux (RHEL), CentOS, Fedora. Other distros include Arch Linux, Gentoo Linux and openSUSE.

What are the benefits of using Linux?

Some of the benefits of using Linux include its stability, security, flexibility and cost. Linux is also a more secure operating system than Windows. It can be used on a variety of devices, including desktops, laptops, servers and smartphones.

Check Linux version from /etc/os-release

The best way to check Linux version is using cat /etc/os-release command. This command will list Linux distribution name and release version information. It works on almost all Linux system.

If we are running a very old Linux distribution then we might not be able to use any of the above commands. Use the following command to know the OS version on our old system:

  • ———- On Red Hat Linux ———-
    $ cat /etc/redhat-release
  • ———- On CentOS Linux ———-
    $ cat /etc/centos-release
  • ———- On Fedora Linux ———-
    $ cat /etc/fedora-release
  • ———- On Debian Linux ———-
    $ cat /etc/debian_version
  • ———- On Ubuntu and Linux Mint ———-
    $ cat /etc/lsb-release
  • ———- On Gentoo Linux ———-
    $ cat /etc/gentoo-release
  • ———- On SuSE Linux ———-
    $ cat /etc/SuSE-release

Check Linux version with uname command

We can also use uname command to check Linux version. It is used to print our Linux system information such as kernel version and release name, network hostname, machine hardware name, processor architecture, hardware platform and the operating system.

The command uname -a shows the version of the Linux kernel we are using, as well as additional details.

Linux deb-srv 5.10.0-8-amd64 #1 SMP Debian 5.10.46-4 (2021-08-03) x86_64 GNU/Linux

Читайте также:  Как разархивировать gzip linux

Check Linux version from /proc/version

As we can see, the /proc/version file specifies the version of the Linux kernel, the version of gcc used to compile the kernel, and the time of kernel compilation. It also contains the kernel compiler’s user name.

Check Linux version with lsb_release command

The lsb_release command is a helpful utility to find out information about our Linux installation. It displays LSB (Linux Standard Base) information about the Linux distribution.

lsb_release -a
Output
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

To display only the description, run:

Ubuntu, Debian, Fedora, openSUSE, and Mint are all popular Linux distros.

What is the difference between Linux distributions?

There are many different types of Linux distributions, also called distros. Each one has its own features, but the core components are the same.

Why are there so many Linux distributions?

There are many reasons why there are so many Linux distributions. One reason is that Linux is open source, which means that anyone can create a new distribution. Linux is also very customizable, which means that people can create distributions that fit their needs or preferences. Additionally, different Linux distributions can appeal to different types of users. For example, some distributions are more geared towards beginners, while others are more geared towards experts.

How do I change my Linux distribution?

You can always switch to another distro if you find that it works better on your system or meets more of your needs. You will want to make sure that your system meets the requirements of the new distro, and you may need to reinstall some applications.

David is a Cloud & DevOps Enthusiast. He has years of experience as a Linux engineer. He had working experience in AMD, EMC. He likes Linux, Python, bash, and more. He is a technical blogger and a Software Engineer. He enjoys sharing his learning and contributing to open-source.

howtouselinux.com is dedicated to providing comprehensive information on using Linux.

We hope you find our site helpful and informative.

Источник

What version of Linux am I running?

Get these quick commands to figure out what Linux kernel version and distribution your system is running.

Why the operating system matters even more in 2017

Internet Archive Book Images. Modified by Opensource.com. CC BY-SA 4.0

The question «what version of Linux» can mean two different things. Strictly speaking, Linux is the kernel, so the question can refer specifically to the kernel’s version number, or «Linux» can be used more colloquially to refer to the entire distribution, as in Fedora Linux or Ubuntu Linux.

Both are important, and you may need to know one or both answers to fix a problem with a system. For example, knowing the installed kernel version might help diagnose an issue with proprietary drivers, and identifying what distribution is running will help you quickly figure out if you should be using apt , dnf , yum , or some other command to install packages.

The following will help you find out what version of the Linux kernel and/or what Linux distribution is running on a system.

Читайте также:  Which file system type linux

How to find the Linux kernel version

To find out what version of the Linux kernel is running, run the following command:

Alternatively, the command can be run by using the longer, more descriptive, versions of the various flags:

uname --kernel-name --kernel-release --machine

Either way, the output should look similar to the following:

Linux 4.16.10-300.fc28.x86_64 x86_64

This gives you (in order): the kernel name, the version of the kernel, and the type of hardware the kernel is running on. In this case, the kernel is Linux version 4.16.10-300.fc28.x86_64 running on an x86_64 system.

More information about the uname command can be found by running man uname .

How to find the Linux distribution

There are several ways to figure out what distribution is running on a system, but the quickest way is the check the contents of the /etc/os-release file. This file provides information about a distribution including, but not limited to, the name of the distribution and its version number. The os-release file in some distributions contains more details than in others, but any distribution that includes an os-release file should provide a distribution’s name and version.

To view the contents of the os-release file, run the following command:

On Fedora 28, the output looks like this:

NAME=Fedora VERSION="28 (Workstation Edition)" ID=fedora VERSION_ID=28 PLATFORM_ID="platform:f28" PRETTY_NAME="Fedora 28 (Workstation Edition)" ANSI_COLOR="0;34" CPE_NAME="cpe:/o:fedoraproject:fedora:28" HOME_URL="https://fedoraproject.org/" SUPPORT_URL="https://fedoraproject.org/wiki/Communicating_and_getting_help" BUG_REPORT_URL="https://bugzilla.redhat.com/" REDHAT_BUGZILLA_PRODUCT="Fedora" REDHAT_BUGZILLA_PRODUCT_VERSION=28 REDHAT_SUPPORT_PRODUCT="Fedora" REDHAT_SUPPORT_PRODUCT_VERSION=28 PRIVACY_POLICY_URL="https://fedoraproject.org/wiki/Legal:PrivacyPolicy" VARIANT="Workstation Edition" VARIANT_ID=workstation

As the example above shows, Fedora’s os-release file provides the name of the distribution and the version, but it also identifies the installed variant (the «Workstation Edition»). If we ran the same command on Fedora 28 Server Edition, the contents of the os-release file would reflect that on the VARIANT and VARIANT_ID lines.

Sometimes it is useful to know if a distribution is like another, so the os-release file can contain an ID_LIKE line that identifies distributions the running distribution is based on or is similar to. For example, Red Hat Enterprise Linux’s os-release file includes an ID_LIKE line stating that RHEL is like Fedora, and CentOS’s os-release file states that CentOS is like RHEL and Fedora. The ID_LIKE line is very helpful if you are working with a distribution that is based on another distribution and need to find instructions to solve a problem.

CentOS’s os-release file makes it clear that it is like RHEL, so documentation and questions and answers in various forums about RHEL should (in most cases) apply to CentOS. CentOS is designed to be a near clone of RHEL, so it is more compatible with its LIKE than some entries that might be found in the ID_LIKE field, but checking for answers about a «like» distribution is always a good idea if you cannot find the information you are seeking for the running distribution.

More information about the os-release file can be found by running man os-release .

Screenfetch and neofetch

The uname and /etc/os-release commands are the most common methods for getting the version of Linux you’re running and are available by default on any Linux system you run. There are, however, additional tools that can provide you a report about your system.

Читайте также:  Восстановление граб в линукс минт

The screenfetch and neofetch commands give a verbose overview of your system, with details about your kernel, architecture, available RAM, CPU speed and core count, desktop version, and so on.

Hostnamectl

The hostnamectl command is available on most modern Linux distributions. If it’s not already installed, you can install it from your software repository. Despite its humble name, it provides far more than just your hostname;

$ hostnamectl Static hostname: yorktown.local Icon name: computer-laptop Chassis: laptop Machine ID: 442fd448a2764239b6c0b81fe9099582 Boot ID: a23e2566b1db42ffe57089c71007ef33 Operating System: CentOS Stream 8 CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-301.1.el8.x86_64 Architecture: x86-64 

Desktop utilities

Some desktop environments offer similar system reporting tools. For instance, the KDE Plasma desktop provides KInfoCenter, which can tell you everything from your kernel and architecture to your available network interface cards, IP address, and much more.

KInfoCenter

Know your OS

Regardless of what tool you decide to make your default, getting the version and features of your OS is a seemingly simple but important skill. Remember these tips so the next time you need to see what you’re running, you’ll know several places you can find out.

This article originally published in 2018 and has been updated by the editor with additional information.

Источник

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.

Источник

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