Check Linux OS Version in Terminal
There are a few ways to check your kernel and linux os version, but today we will cover some commands to do this in a terminal.
Knowing how to check your kernel and linux os version in a terminal can be useful if you ever need help in a forum where they might ask for this information. You can also use this info in a bash script to determine what actions to take in your script based on the kernel and linux os version. Whatever the case may be, it’s a good idea to get familiar with these commands.
Linux OS Version
Get Linux Standard Base info:
lsb_release -a
Output:
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.3 LTS
Release: 18.04
Codename: bionic
Or:
cat /etc/lsb-release
Output:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"
Get Linux Standard Base version only:
lsb_release -r
Output:
Release: 18.04
Get full Linux OS information:
cat /etc/*release
Output:
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.3 LTS"
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 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
Or:
cat /etc/os-release
Output:
NAME="Ubuntu"
VERSION="18.04.3 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.3 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
A few more system details:
hostnamectl
Output:
Static hostname: ubuntu
Icon name: computer-desktop
Chassis: desktop
Machine ID: 76b1059e1a6c4453b277aa20f39b4bca
Boot ID: e936fa2f2f9e4f56a6176921a76acdb8
Operating System: Ubuntu 18.04.3 LTS
Kernel: Linux 5.0.0-32-generic
Architecture: x86-64
Kernel Version
Print the kernel version:
uname -r
Output:
5.0.0-32-generic
Print the kernel version and instruction set:
uname -mrs
Output:
Linux 5.0.0-32-generic x86_64
Print all kernel information:
uname -a
Output:
Linux ubuntu 5.0.0-32-generic #34~18.04.2-Ubuntu SMP Thu Oct 10 10:36:02 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
Additional kernel information:
cat /proc/version
Output:
Linux version 5.0.0-32-generic (buildd@lgw01-amd64-015) (gcc version 7.4.0 (Ubuntu 7.4.0-1ubuntu1~18.04.1)) #34~18.04.2-Ubuntu SMP Thu Oct 10 10:36:02 UTC 2019
OS type, kernel release number, and version:
cat /proc/sys/kernel/{ostype,osrelease,version}
Output:
Linux
5.0.0-32-generic
#34~18.04.2-Ubuntu SMP Thu Oct 10 10:36:02 UTC 2019
Conclusion
This concludes our look at how to check your kernel and Linux OS version in terminal. You now know a few ways to obtain the kernel and linux OS information for any situation.
Tags: tutorials, linux, command line