Linux what version is running

How to Easily Check the Version of Linux Running on Your System

Learn how to check the version of Linux running on your system using commands like ‘uname’, ‘/etc/os-release’, ‘lsb_release’, and ‘hostnamectl’. Troubleshoot and ensure compatibility with software by knowing your Linux version.

  • Using the ‘uname’ command
  • Querying ‘/etc/os-release’ file
  • What Version Of Linux Am I Running?
  • Using the ‘lsb_release’ command
  • Using the ‘hostnamectl’ command
  • Other commands
  • Other code samples for checking Linux version
  • Conclusion
  • How to check my Linux version?
  • How do I know if I have Linux 32 or 64?
  • How do I know which Linux distro is running?
  • How do I find my current OS version?

As an open-source operating system that is widely used in various fields, Linux has many different versions available. Knowing the version of Linux can help with troubleshooting and compatibility with certain software. This article will provide you with multiple ways to check the version of Linux, including using various commands and querying system files.

Using the ‘uname’ command

The ‘uname’ command is a popular way to check the version of the Linux kernel and additional details. The ‘uname -a’ or ‘uname -srm’ command can be used to show the version of the Linux kernel and additional details. To obtain more detailed Linux kernel information, the command ‘uname -r’ can be used. The ‘uname’ command can be used to check the operating system name.

Here is an example of using the ‘uname’ command:

$ uname -a Linux example.com 5.11.0-34-generic #36-Ubuntu SMP Thu Aug 26 20:27:37 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux 

Querying ‘/etc/os-release’ file

The safest option to display the OS version on Linux is by querying the ‘/etc/os-release’ file using the grep or cat command. The ‘cat /etc/os-release’ command can be used to determine a Linux distribution name and release version information.

Here is an example of using the ‘/etc/os-release’ file:

$ cat /etc/os-release NAME="Ubuntu" VERSION="21.04 (Hirsute Hippo)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 21.04" VERSION_ID="21.04" HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" VERSION_CODENAME=hirsute UBUNTU_CODENAME=hirsute 

What Version Of Linux Am I Running?

Explains how to find and determine what version of Linux server is running on your hardware Duration: 2:57

Using the ‘lsb_release’ command

The ‘lsb_release’ command is a good option for printing Linux version information. The command ‘lsb_release -a’ can be used to print the Linux version.

Here is an example of using the ‘lsb_release’ command:

$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 21.04 Release: 21.04 Codename: hirsute 

Using the ‘hostnamectl’ command

The ‘hostnamectl’ command is commonly used to identify the version of Linux. The ‘hostnamectl’ command can be used to see the Linux name and version.

Читайте также:  Linux clear all terminal

Here is an example of using the ‘hostnamectl’ command:

$ hostnamectl Static hostname: example.com Icon name: computer-laptop Chassis: laptop Machine ID: 5e5b77f5e5b77f5e5b77f5e5b77f5e5b Boot ID: 2e2b2f2e2b2f2e2b2f2e2b2f2e2b2f2b Operating System: Ubuntu 21.04 Kernel: Linux 5.11.0-34-generic Architecture: x86-64 

Other commands

Other commands include ‘rpm -qa packagename’ and ‘dmesg | head -1’. Different Linux distributions may use different commands or system files to identify the Linux version.

Other code samples for checking Linux version

In Shell , in particular, how to check version of linux command line code sample

In Shell , for example, how to check version of linux command line code example

cat /etc/os-release #The best way to check Redhat version is using cat /etc/os-release command. All we need is to open the terminal and type cat /etc/os-release. It will list the Linux OS distribution name and release version information. This works on almost all Redhat system. $ cat /etc/os-release NAME=”Red Hat Enterprise Linux” VERSION=”8.4 (Ootpa)” ID=”rhel” ID_LIKE=”fedora” VERSION_ID=”8.4″ PLATFORM_ID=”platform:el8″ PRETTY_NAME=”Red Hat Enterprise Linux 8.4 (Ootpa)” ANSI_COLOR=”0;31″ 

In Shell , what version of linux am i running code example

cat /etc/*-version # For those OS's like Slackware

In Shell , in particular, how to check version of linux you have code sample

cat /etc/*releaseIn Shell , for instance, how to check version of linux you have code sample
apt-get -y install inxi Knowing the version of Linux is important for troubleshooting and compatibility. There are multiple ways to check the version of Linux, including using various commands and querying system files. The ‘uname’, ‘/etc/os-release’, ‘lsb_release’, and ‘hostnamectl’ commands are commonly used to identify the version of Linux. Different Linux distributions may use different commands or system files to identify the Linux version. By following these steps, you will be able to easily check the version of Linux running on your system.

Источник

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.

How to find the Linux kernel version

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

Читайте также:  Viewing directories in linux

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.

Читайте также:  Структура файлового дерева linux

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 is running?

Sometimes your scripts need to behave differently on different Linux’s. How can I determine which version of Linux a script is running on?

I’m sure jldugger wants to find out which distribution family the system is running. It’s unlikely a script would be affected by the kernel version unless it depends on some /sys or /proc stuff — and even then it’s usually easier to assume based on distribution than on kernel.

14 Answers 14

Don’t try and make assumptions based on the distro as to what you can and cannot do, for that way lies madness (see also «User Agent detection»). Instead, detect whether what it is that you want to do is supported, and how it’s done by whatever command or file location you want to use.

For example, if you wanted to install a package, you can detect whether you’re on a Debian-like system or a RedHat-like system by checking for the existence of dpkg or rpm (check for dpkg first, because Debian machines can have the rpm command on them. ). Make your decision as to what to do based on that, not just on whether it’s a Debian or RedHat system. That way you’ll automatically support any derivative distros that you didn’t explicitly program in. Oh, and if your package requires specific dependencies, then test for those too and let the user know what they’re missing.

Another example is fiddling with network interfaces. Work out what to do based on whether there’s an /etc/network/interfaces file or an /etc/sysconfig/network-scripts directory, and go from there.

Yes, it’s more work, but unless you want to remake all the mistakes that web developers have made over the past decade or more, you’ll do it the smart way right from the start.

Источник

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