Use the command line to detect the Ubuntu version method

  • 2021-01-02 22:08:40
  • OfStack

Method 1: Use the lsb_release utility

The lsb_release utility displays LSB (Linux standard library) information about the Linux distribution. It is the preferred method for checking the Ubuntu version and can be used regardless of which desktop environment or Ubuntu version you are running.

Here's how to test the Ubuntu version:

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

2. Use the es22EN_ES23en-ES24en command to display the Ubuntu version, and you will see the Ubuntu version information at the Description line

Output:


No LSB modules are available.

Distributor ID: Ubuntu

Description:  Ubuntu 18.04 LTS

Release:  18.04

Codename:  bionic

As you can see from the output above, I used Ubuntu 18.04 LTS.

You can also display only Description lines by simply issuing the following command:


lsb_release -d

Output:


Description:  Ubuntu 18.04 LTS

Method 2: Use the cat command

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

You need to execute the following command:


cat /etc/issue

Output results:


Ubuntu 18.04 LTS \n \l

2. Use cat command to display the information in /etc/ ES60en-ES61en file

/etc/ ES65en-ES66en is a file that contains operating system identification data and can only be found on the newer version of Ubuntu running.

Note: This method is only valid if you have Ubuntu 16.04 or later.

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 you can also use it to check the Ubuntu version.

Note: This command applies only to Ubuntu 16.04 or later.

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


Related articles: