How to check if installed linux

How to know if the running platform is Ubuntu or CentOS with help of a Bash script?

How do I get the output from the terminal and compare to see if it is UBUNTU or CENTOS and perform the following commands?

Ubuntu 14.04

14 Answers 14

Unfortunately, there is no surefire, simple way of getting the distribution name. Most major distros are moving towards a system where they use /etc/os-release to store this information. Most modern distributions also include the lsb_release tools but these are not always installed by default. So, here are some approaches you can use:

# Determine OS platform UNAME=$(uname | tr "[:upper:]" "[:lower:]") # If Linux, try to determine specific distribution if [ "$UNAME" == "linux" ]; then # If available, use LSB to identify distribution if [ -f /etc/lsb-release -o -d /etc/lsb-release.d ]; then export DISTRO=$(lsb_release -i | cut -d: -f2 | sed s/'^\t'//) # Otherwise, use release info file else export DISTRO=$(ls -d /etc/[A-Za-z]*[_-][rv]e[lr]* | grep -v "lsb" | cut -d'/' -f3 | cut -d'-' -f1 | cut -d'_' -f1) fi fi # For everything else (or if above failed), just use generic identifier [ "$DISTRO" == "" ] && export DISTRO=$UNAME unset UNAME 
$ gcc --version gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-54) Copyright (C) 2006 Free Software Foundation, Inc. 
$ gcc --version gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-3) Copyright (C) 2010 Free Software Foundation, Inc. 
$ gcc --version gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3 Copyright (C) 2011 Free Software Foundation, Inc. 
$ gcc --version gcc (Ubuntu 4.8.2-19ubuntu1) 4.8.2 Copyright (C) 2013 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 

This has basically been directly copied from @slm’s great answer to my question here.

Источник

How to find Linux distribution name and Version?

While you are working on new Linux distribution, you might not know which Linux version is installed on your system. Sometimes, you need to meet a few system requirements while running an application on your system. However, different ways are available to check the Version of installed Linux distribution. Linux Mint 20 is the most growing Linux distribution and has a number of available graphical user interfaces that may vary from one user to the other. Hence, each user may also have a different running procedure. For this purpose, the recommended solution is to access and open the terminal command-line application.

Читайте также:  Linux чем распаковать zip

In this article, we will learn how to check the installed Linux distribution name and Version on Linux Mint 20.

Pre-requisites

You must have ‘sudo’ privileges or log in from the root user account on your system.

Check name and Version on Linux Mint 20

You can check the name and installed Linux distribution version using the following two different ways:

  • Check name and Version in Linux Mint 20 through the command line
  • Check Version using a graphical user interface method in Linux Mint 20

Let’s discuss each method one by one in detail.

Method 1: Check name and Version in Linux Mint 20 through the command line

Some users prefer to use the command line instead of the graphical user interface in Linux systems. Hence, using the command line, you have more options to get details about the installed Linux Mint distribution. To check the name and version of the Linux system on Linux Mint 20 environment, you need to follow the following different steps:

To open the terminal application, just log in to your Linux Mint 20 system and then click on the terminal icon that will be displayed on the taskbar.

Or you can pick the terminal by accessing the main menu. You can see the below-given screenshot, which is highlighted red:

In Linux distribution, specifically for Linux Mint 20, there are a lot of various utilities and text files present, which may help you to find the Linux Mint version. You can search the file that contains more information about the installed Linux Mint version, and that is available for all Debian based Linux/GNU distributions. This file you can find at etc/issue. Run the below-mentioned command on the terminal that will display the installed Linux Mint version:

After executing the above command, the following output will show on the terminal:

Display installed Version Using hostnamectl utility:

The most common utility or command that is available for almost all Linux systems is ‘hostnamectl.’ It displays detailed information about the currently running operating system. To display the installed version of Linux distribution using ‘hostnamectl’ utility, follow the appended method:

Type the following command on the terminal to display the information about the installed Linux Mint version:

The above command will display the complete information about the currently used operating environment and loaded kernel version. The following details about the installed Linux system to be displayed on the terminal:

Читайте также:  Rtl8192eu driver kali linux

The one, more file option ‘/etc/linuxmint/info,’ is available on the Linux Mint 20 distribution that keeps the details about the kernel and installed Version. Execute the following command on the terminal to view the kernel details:

The following output should display on the terminal window:

One more popular command which is available on Linux Mint is the ‘lsb_release’ command that provides much flexibility to select which piece of information is important for you to include in the Version checking task. To reveal the information about the released Version, distributor details, and codename, then you need to execute the following command:

After executing the above command, you will achieve the following information on the terminal window:

Type the following command to view the information about Linux Mint:

The following installed distribution details will display on the terminal screen:

Or you can also execute the following command to check the installed version of Linux Mint on your system:

You will see the following detailed information about the Linux Mint version:

Method 2: Check version using the graphical user interface method in Linux Mint 20

As we have discussed above, various Desktop environment managers are available for all Linux Mint distributions. So, you need to follow the following steps to check the installed Linux Mint version for Cinnamon Desktop.

  • Click on the start menu, the following application list menu will display on the system.
  • Click on the ‘system settings’ icon from the list, which is also highlighted in the below-given screenshot.

  • Once you click on the system settings, the following window will display your system where you will see the different management applications. Scroll the mouse cursor on the displayed window and click on the ‘system info’ icon as follows:

The following window will display on your system:

From the above screenshot, you can get the details about the currently installed operating system, cinnamon version, Linux kernel, and other system resources like processor, memory, hard drive, and graphics card.

Conclusion

From the above article, we have learned how to check the details about the name and installed Version of Linux Mint. You can get detailed information about your system by following this tutorial. From all the information, as mentioned above, I hope now you can find the installed Version of any Linux distribution. We have discussed two different ways, i.e., by using a command line and by using a graphical user interface, through which a user can display the information about the installed Linux distribution. If you feel any difficulty related to the ways as mentioned above, then let us know via your feedback through the comments. We will welcome your queries.

Читайте также:  Linux find which shell

About the author

Aqsa Yasin

I am a self-motivated information technology professional with a passion for writing. I am a technical writer and love to write for all Linux flavors and Windows.

Источник

How to check Linux OS version – 4 simple ways

At one point or another, we might have faced a situation where are required to check the Linux version that is installed on a Linux server. So is there a way to check what Linux version are we using? If yes then how to check the Linux OS version?

In this tutorial, we are going to discuss just that. And we will discuss not one but 4 ways to check the Linux version that is installed on your systems.

Commands to check the Linux OS version,

Let’s discuss these methods/commands on how to check the Linux version one by one in a bit of detail.

How to check Linux OS version

1- /etc/os-release or /usr/lib/os-release

/etc/os-release or /usr/lib/os-release, both these files contains data related to operating system identification. /etc/os-release is the main file to refer but in case its not available then /usr/lib/os-release is used.

To check the Linux version, execute the following command,

# cat /etc/os-release

# cat /usr/lib/os-release

This command will show the following output,

how to check linux os version

2- lsb_release command

The next command on the list is lsb_release. This command shows Linux Standard Base or LSB information about specific Linux distribution with information like version number, release codename, and distributor ID, etc.

To check the OS version in Linux, execute the following command,

# lsb_release -a

And you will get the following output,

how to check linux os version

3- Hostnamectl

Hostnamectl command shows the current hostname of the system as well as system-related information. To get the information, run

# hostnamectl

Along with the hostname & operating system version, we will also get information like machine-id, boot-id, architecture, etc.

This is another file located on Linux systems that can help us identify the os version installed in Linux systems. Basically, this file contains a message or system identification information to be printed before the login prompt & can be used to identity the os version as well.

Use the following command,

# cat /etc/issue

& you would get the following output,

how to check linux os version

That’s it guys, these were the 4 ways using which we can identify the OS versions installed on the Linux system. If you guys have any issues or queries regarding this tutorial, then please do let us know using the comment box below.

We are giving you exclusive deals to try Linux Servers for free with 100$ credit, check these links to claim your 100$,

Check some Exclusive Deals, HERE.

Also, check out DevOps Book You should read section.

Источник

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