Check your linux version

How to check Linux Version

The common scenario is that you have been given an access to a Linux system physically or via remote login and you have no idea what Linux version is installed on this particular system. Given that many of the today’s Linux Distributions have implemented systemd as part of their core design, to check for a Linux version is in many cases relatively simple procedure.

The simplest way to check Linux version is by using the hostnamectl command without any arguments. For example the below hostnamectl command will return the Linux distribution name, version and codename in use along with the currently loaded Linux kernel version:

$ hostnamectl Static hostname: x220 Icon name: computer-laptop Chassis: laptop Machine ID: 2d4efda5efb0430faeb2087d0a335c6b Boot ID: f8c4a3a776a74d42878347efc2c00634 Operating System: Debian GNU/Linux 10 (buster) Kernel: Linux 4.9.0-9-amd64 Architecture: x86-64

It is a common mistake to refer to the entire GNU/Linux operating system simply as Linux. The important note here is that the so called Linux is actually only the Kernel part of the system whereas GNU is the actual system as in collection of pre-compiled binaries, libraries and system tools. Both GNU and Linux kernel must function in tandem in order for the operating system to actually work.

Hence, one cannot exists without the other, so next time when you talk about your operating system and you wish to be technically correct, refer to it as GNU/Linux or simply as Lignux.

In this tutorial you will learn:

  • Basic introduction to Linux package
  • How to check system architecture and Linux kernel version
  • How to check CPU architecture
  • How to check CentOS, Redhat, Debian, Ubuntu, Mint, Arch, Fedora Linux system version

How to check Linux version

Software Requirements and Conventions Used

Software Requirements and Linux Command Line Conventions
Category Requirements, Conventions or Software Version Used
System CentOS, Redhat, Debian, Mint, Ubuntu, Arch, Fedora
Software N/A
Other Privileged access to your Linux system as root or via the sudo command.
Conventions # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command
$ – requires given linux commands to be executed as a regular non-privileged user

Linux Package Management Systems

In case the above quick check for Linux version by using the systemctrl command did not work, the next step in order to check which GNU/Linux operating system is in use is to recognize which package manager is installed.

No matter on which GNU/Linux system you use the chances are very high that it will use one of the following three package managers:

  • rpm – The Redhat package manager
  • dpkg – The Debian package manager
  • pacman – The Arch package manager

So for example, if your system is using the rpm package manager then your GNU/Linux system is most likely RHEL, CentOS, Fedora etc. In case of the deb package manager your GNU/Linux system could be something like Ubuntu, Debian, Mint etc. Lastly, when the pacman package manger is in use, then your GNU/Linux system is something like Arch, Manjaro etc.

The following command will check which package manager is use on our GNU/Linux system. For example the bellow command is executed on some Debian based GNU/Linux system:

$ for i in $( echo rpm dpkg pacman ); do which $i; done 2> /dev/null /usr/bin/dpkg

Note, the output of the above command which is the full path to the actual package manager executable binary. Whereas, on systems with Redhat package management you may likely to see output similar to the one below:

$ for i in $( echo rpm dpkg pacman ); do which $i; done 2> /dev/null /bin/rpm

How to check CentOS version

The most common way to check CentOS version is by reading a content of the /etc/centos-release file. For example:

$ cat /etc/centos-release CentOS Linux release 7.5.1804 (Core)

Visit our guide for a more detailed information on how to check CentOS version.

How to check RHEL version

In case you need to check system version on the Redhat Enterprise Linux your best bet is to see the content of the /etc/redhat-release file. For example:

$ cat /etc/redhat-release Red Hat Enterprise Linux Server release 7.3 (Maipo)

Visit our guide for a more detailed information on how to check RHEL version.

How to check Debian version

In case you need to check system version of the Debian GNU/Linux the most likely answer to your question is within the /etc/issue file. For example:

$ cat /etc/issue Debian GNU/Linux 10 \n \l

Visit our guide for a more detailed information on how to check Debian version.

How to check Linux Mint version

In case you are running Mint GNU/Linux, open a read the content of the /etc/issue file. For example:

$ cat /etc/issue Linux Mint 18.3 Serena \n \l

Visit our guide for a more detailed information on how to check Linux Mint version.

How to check Ubuntu version

Same is with all the other Debian based GNU/Linux systems, to check the system version read the content of the /etc/issue file. For example:

$ cat /etc/issue Ubuntu 18.04 LTS \n \l

Visit our guide for a more detailed information on how to check Ubuntu version.

How to check Arch version

The Arch GNU/Linux does not follow a regular release cycle and from this reason it is said that Arch GNU/Linux is a rolling release.

Meaning, that every time you execute the pacman -Suy command your system is fully updated to the latest up to date state. From this reason there is not much of a point to check for an Arch Linux version release.

How to check RHEL version

Most of the RPM based systems hide their version as part of the /etc/*-release file. The below command will check the version of the Fedora GNU/Linux system:

$ cat /etc/fedora-release Fedora release 30

How to check system architecture and Linux kernel version

The most common way on how to check for a system’s architecture and Linux kernel version is by using the uname command in combination with a -a argument. For example:

$ uname -a Linux linuxconfig 4.4.59+ #23824 SMP PREEMPT Tue Dec 25 18:27:58 CST 2018 x86_64 GNU/Linux

From the above output we can see that the Linux kernel version in use is 4.4.59+ and system architecture is x86_64.

How to check CPU architecture

The most common and recommended command to check CPU architecture is lscpu . Consider the following lscpu command output example:

# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Thread(s) per core: 1 Core(s) per socket: 4 Socket(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 95 Model name: Intel(R) Atom(TM) CPU C3538 @ 2.10GHz Stepping: 1 CPU MHz: 2100.000 CPU max MHz: 2100.0000 CPU min MHz: 800.0000 BogoMIPS: 4200.02 Virtualization: VT-x L1d cache: 24K L1i cache: 32K L2 cache: 2048K Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave rdrand lahf_lm 3dnowprefetch arat epb pln pts dtherm intel_pt retpoline tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust smep erms mpx rdseed smap clflushopt sha_ni xsaveopt xsavec xgetbv1

Along with the CPU model name and the CPU frequency we can see that the CPU in question is 64-bit architecture as it supports both, the 32-bit and 64-bit binary execution.

Comments and Discussions

Источник

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.

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.

Источник

Читайте также:  Linux для ipad 2
Оцените статью
Adblock
detector