How to detect Ubuntu version using command line

How to detect Ubuntu version using command line

Method 1: Use the lsb_release utility

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

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

1. Open the terminal using the Ctrl+Alt+T keyboard shortcut or by clicking the terminal icon.

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

From the output above, you can see that I am using Ubuntu 18.04 LTS.

You can also display only the Description line by executing the following command:

lsb_release -d

Output:

Description: Ubuntu 18.04 LTS

Method 2: Use cat command

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

The following commands need to be executed:

cat /etc/issue

Output:

Ubuntu 18.04 LTS \n \l

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

/etc/os-release is a file containing operating system identification data and is only found on newer Ubuntu versions running systemd.

NOTE: This method will only work if you have Ubuntu 16.04 or higher.

The following commands need to be executed:

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 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 is only available for Ubuntu 16.04 or later.

The following commands need to be executed:

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

You may also be interested in:
  • Ubuntu16.04 builds php5.6 web server environment
  • How to build nfs service in ubuntu16.04
  • How to modify the time zone and time in Ubuntu system
  • Detailed explanation of how to connect node to mongodb database [Alibaba Cloud Server Environment Ubuntu]
  • Installation and use of mysql on Ubuntu (general version)
  • Detailed explanation of installing Python 3.7 and pip3 in Ubuntu 16.04 and switching to the default version
  • Tutorial on installing mysql5.7.23 on Ubuntu 18.04
  • Ubuntu 18.04 installs mysql 5.7.23
  • Install mysql5.7 on Ubuntu 18.04
  • Introduction to Ubuntu PostgreSQL installation and configuration

<<:  CocosCreator Getting Started Tutorial: Making Your First Game with TS

>>:  mysql having usage analysis

Recommend

HTML table markup tutorial (15): table title

<br />This tag can be used to directly add a...

Detailed tutorial on MySql installation and uninstallation

This article shares the tutorial of MySql install...

JavaScript to implement voice queuing system

Table of contents introduce Key Features Effect d...

Explanation of the precautions for Mysql master-slave replication

1. Error error connecting to master 'x@xxxx:x...

Detailed explanation of the execution process of JavaScript engine V8

Table of contents 1. V8 Source 2. V8 Service Targ...

Advantages and disadvantages of common MySQL storage engines

Table of contents View all storage engines InnoDB...

Use and optimization of MySQL COUNT function

Table of contents What does the COUNT function do...

React tips teach you how to get rid of hooks dependency troubles

A very common scenario in react projects: const [...

The solution record of Vue failing to obtain the element for the first time

Preface The solution to the problem of not being ...

Detailed explanation of MLSQL compile-time permission control example

Preface The simple understanding of MySQL permiss...

How to install Tomcat-8.5.39 on centos7.6

Here is how to install Tomcat-8.5.39 on centos7.6...

Mysql 5.7.19 free installation version encountered pitfalls (collection)

1. Download the 64-bit zip file from the official...

Steps to enable MySQL database monitoring binlog

Preface We often need to do something based on so...

MySQL uses events to complete scheduled tasks

Events can specify the execution of SQL code once...

Implementation of MySQL5.7 mysqldump backup and recovery

MySQL backup Cold backup:停止服務進行備份,即停止數據庫的寫入Hot ba...