Home >Operation and Maintenance >Linux Operation and Maintenance >How to detect Ubuntu version using command line?

How to detect Ubuntu version using command line?

青灯夜游
青灯夜游Original
2019-03-14 16:58:363738browse

When logging into an Ubuntu system for the first time, before doing any work, it is best to detect the version of Ubuntu running on the machine. So how to check? The following article will introduce to you how to use the command line to detect the Ubuntu version. I hope it will be helpful to you.

How to detect Ubuntu version using command line?

Method 1: Use the lsb_release utility

The lsb_release utility can display information about the Linux distribution LSB (Linux Standard Library) information. It is the preferred method for checking your Ubuntu version, and this method will work regardless of which desktop environment or Ubuntu version you are running.

Let’s take a look at how to detect the Ubuntu version:

1. Use the Ctrl Alt T keyboard shortcut or click the terminal icon to open the terminal.

2. Use the lsb_release -a command to display the Ubuntu version. You will see the Ubuntu version information in the Description line.

Output:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04 LTS
Release:    18.04
Codename:   bionic

As can be seen from the above output, I use It's Ubuntu 18.04 LTS.

You can also display only the Description line, just execute the following command:

lsb_release -d

Output:

Description:    Ubuntu 18.04 LTS

Method 2: Use the cat command

1. Use the cat command to display the contents of the /etc/issue file that contain the system identification text

You need to execute the following command:

cat /etc/issue

Output result:

Ubuntu 18.04 LTS \n \l

2. Use the cat command to display the information in the /etc/os-release file

/etc/os-release is a file containing the operating system identification data files, can only be found on newer Ubuntu versions running systemd.

Note: This method only works if you have Ubuntu 16.04 or higher.

You need to execute the following command:

cat /etc/os-release

Output:

NAME="Ubuntu"
VERSION="18.04 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04 LTS"
VERSION_ID="18.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=bionic
UBUNTU_CODENAME=bionic

Method 3: Use the hostnamectl command

hostnamectl is a command that allows the user to set the hostname, but it can also be used to check the Ubuntu version.

Note: This command only works on Ubuntu 16.04 or higher.

You need to execute the following command:

hostnamectl

Output:

Static hostname: linuxize
         Icon name: computer-vm
           Chassis: vm
        Machine ID: f1ce51f447c84509a86afc3ccf17fa24
           Boot ID: 2b3cd5003e064382a754b1680991040d
    Virtualization: kvm
  Operating System: Ubuntu 18.04 LTS
            Kernel: Linux 4.15.0-22-generic
      Architecture: x86-64

Recommended related video tutorials: "linux tutorial"

That's it The entire content of this article is hoped to be helpful to everyone's study. For more exciting content, you can pay attention to the relevant tutorial columns of the PHP Chinese website! ! !

The above is the detailed content of How to detect Ubuntu version using command line?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn