Get operating system version linux

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 Find Linux OS Name and Kernel Version You Are Running

There are several ways of knowing the version of Linux you are running on your machine as well as your distribution name and kernel version plus some extra information that you may probably want to have in mind or at your fingertips.

Читайте также:  Linux disable disk cache

Therefore, in this simple yet important guide for new Linux users, I will show you how to find out your Linux system OS version from the command line. Doing this may seem to be a relatively easy task.

However, having a good knowledge of your system is always a recommended practice for a good number of reasons including installing and running the appropriate packages for your Linux version, for easy reporting of bugs coupled with many more.

With that said, let us proceed to how you can figure out information about your Linux distribution.

Find Linux Kernel Version Using uname Command

We will use the uname command, which is used to print your Linux system information such as kernel version and release name, network hostname, machine hardware name, processor architecture, hardware platform, and the operating system.

To find out which version of Linux kernel you are running, type:

In the preceding command, the option -o prints the operating system name, and -r prints the kernel release version.

You can also use -a option with uname command to print all system information as shown:

Check Linux Kernel Version

Find Linux OS Info Using /proc/version File

Next, we will use /proc file system, which stores information about processes and other system information, it’s mapped to /proc and mounted at boot time.

Simply type the command below to display some of your system information including the Linux kernel version:

Show Linux System Information

From the image above, you have the following information:

  • A version of the Linux (kernel) you are running: Linux version 5.15.0-53-generic
  • Name of the user who compiled your kernel: [email protected]
  • A version of the GCC compiler used for building the kernel: gcc version 20.04.1
  • Type of the kernel: #1 SMP (Symmetric MultiProcessing kernel) supports systems with multiple CPUs or multiple CPU cores.
  • Date and time when the kernel was built: Thu Oct 20 15:10:22 UTC 2022

Find the Linux Distribution Name and Release Version

The best way to determine a Linux distribution name and release version information is by using the cat /etc/os-release command, which works on almost all Linux systems.

/etc/os-release file

$ cat /etc/os-release [On Debian, Ubuntu and Mint] $ cat /etc/os-release [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ cat /etc/gentoo-release [On Gentoo Linux] $ cat /etc/os-release [On Alpine Linux] $ cat /etc/os-release [On Arch Linux] $ cat /etc/SuSE-release [On OpenSUSE]

Find Linux Distribution Name and Release

lsb_release Command

Alternatively, you can also use the lsb_release tool, which will print LSB (Linux Standard Base) information about the Linux distribution on your terminal. The lsb_release command is not installed by default, you need to install it using your default package manager as shown.

$ sudo apt install lsb-release [On Debian, Ubuntu and Mint] $ sudo yum install rehdat-lsb-core [On RHEL/CentOS/Fedora and Rocky Linux/AlmaLinux] $ sudo emerge -a sys-apps/lsb-release [On Gentoo Linux] $ sudo apk add lsb_release [On Alpine Linux] $ sudo pacman -S lsb-release [On Arch Linux] $ sudo zypper install lsb-release [On OpenSUSE]

Once installed, run the lsb_release utility to print the standard Linux system information as shown.

Читайте также:  Find and print linux

Find Linux OS Information

hostnamectl Command

The hostnamectl command is a systemd utility that is used to get the Linux operating system information and also used to change or set the system hostname.

Check Linux System Info

I’ve used the tmux terminal multiplexer for accessing multiple Linux terminal sessions simultaneously in a single terminal window.

In this article, we walked through a brief and simple guide intended to help new Linux users find out the Linux version they are running and also get to know their Linux distribution name and version from the shell prompt.

Perhaps it can also be useful to advanced users on one or two occasions. Lastly, to reach us for any assistance or suggestions you wish to offer, make use of the feedback form below.

Источник

How to Find Which Linux Version You Are Running

Logged in on a Linux system via SSH and wondering which Linux distribution is it? Here’s how to check the Linux version.

When you install a Linux distribution on your own, you know which distribution and version it is.

But if you use SSH to log in to a remote Linux server provided by an enterprise or client, you may wonder which Linux distribution and version it is.

The simplest way to check Linux version is to see the content of the /etc/os-release file:

It will show an output similar to this:

NAME="Ubuntu" VERSION="20.04.1 LTS (Focal Fossa)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 20.04.1 LTS" VERSION_ID="20.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=focal UBUNTU_CODENAME=focal

As you can see, the Linux name is Ubuntu and the version is 20.04.1.

However, that’s not the only way to know the Linux distribution details. In this beginner’s tip, I’ll show you different ways to check which Linux you are running.

Find Linux distribution details

How to check Linux version

Method 1: Use /etc/os-release file

If you are familiar with the Linux directory structure, you probably already know that /etc directory contains the core configuration files of the system.

The os-release file in the /etc directory keeps the information about the Linux distribution. It gives you the distribution name, distribution version, release name or ID.

Читайте также:  Linux install printer driver

Here’s what it displays for Alpine Linux server running on Linode infrastructure.

handbook:~# cat /etc/os-release NAME="Alpine Linux" ID=alpine VERSION_ID=3.12.0 PRETTY_NAME="Alpine Linux v3.12" HOME_URL="https://alpinelinux.org/" BUG_REPORT_URL="https://bugs.alpinelinux.org/"

As you can see, the name of Linux distribution is Alpine Linux and the distribution version is 3.12.

The content of the /etc/os-release is usually different for different distributions. Distributions often use it to provide additional information like where to get support or file bugs etc.

For example, the /etc/os-release provides more lines for CentOS Linux.

NAME="CentOS Linux" VERSION="8 (Core)" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8" PRETTY_NAME="CentOS Linux 8 (Core)" ANSI_COLOR="0;31" CPE_NAME="cpe:/o:centos:centos:8" HOME_URL="https://www.centos.org/" BUG_REPORT_URL="https://bugs.centos.org/" CENTOS_MANTISBT_PROJECT="CentOS-8" CENTOS_MANTISBT_PROJECT_VERSION="8" REDHAT_SUPPORT_PRODUCT="centos" REDHAT_SUPPORT_PRODUCT_VERSION="8" 

However, all of them provide the Linux distribution name and version so it is a pretty reliable way to know which Linux you are running. In fact, it is the most reliable way.

Method 2: Use hostnamectl command

Most Linux distributions these days use systemd. On such a system, you can use the hostnamectl command to get Linux version detail.

For the same CentOS system that you saw above, hostnamectl provides the following details:

[[email protected] ~]# hostnamectl Static hostname: localhost.localdomain Transient hostname: li2498-99.members.linode.com Icon name: computer-vm Chassis: vm Machine ID: e3fe2be3e17be3e1763bf43e8337e68b Boot ID: 33d3052bbffd44b1869bbffd4b00d26c Virtualization: kvm Operating System: CentOS Linux 8 (Core) CPE OS Name: cpe:/o:centos:centos:8 Kernel: Linux 4.18.0-147.8.1.el8_1.x86_64 Architecture: x86-64

You can see the Linux version detail in the line starting with ‘Operating System’.

The hostnamectl command is primarily used for dealing with the hostname but if it provides other details why not use it?

Method 3: Use lsb-release command

This is NOT a command that you’ll find in all Linux distributions. I think it is mostly used by Debian/Ubuntu based distributions.

You can use the lsb_release command with option -a and it will provide distribution details:

Don’t mind the No LSB modules are available line. It’s not an error of any kind.

[email protected]:~$ lsb_release -a No LSB modules are available. Distributor ID: Ubuntu Description: Ubuntu 20.04.1 LTS Release: 20.04 Codename: focal

Bonus Tip: Find Linux kernel version

Now that you know which distribution you are running, perhaps you would also like to know about the Linux kernel version running on the system.

You can get the kernel details using the uname command in any Linux distribution.

The output shows only the Linux kernel version:

handbook:~# uname -r 5.4.43-1-virt

No prizes for guessing that the above system is running on Linux kernel version 5.4.43.

I hope you find this quick tip helpful in finding Linux version detail. If you have questions or suggestions, please let me know in the comment section.

Источник

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