Method 1: Use the lsb_release utility
The lsb_release utility can display information about the LSB (Linux Standard Library) of the Linux distribution. It is the preferred method to check the Ubuntu version, no matter which desktop environment or Ubuntu version you are running, this method can be used.
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, and 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 above output, you can see that I am using 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 content of the /etc/issue file containing the system identification text
The following commands need to be executed:
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 operating system identification data and can only be found on newer Ubuntu versions running systemd.
Note: This method is only valid 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 the hostnamectl command
hostnamectl is a command that allows users to set a hostname, but it can also be used to check the Ubuntu version.
Note: This command is only applicable to Ubuntu 16.04 or higher.
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
Recommended Posts