Table of Contents
Introduction
check OS info in the Linux kernel and operating system version using the terminal. Knowing how to retrieve this information is essential for troubleshooting, system management, and ensuring compatibility with software.
Using the lsb_release
A Linux command-line tool called lsb_release can tell you about the Linux Standard Base (LSB) and the particular Linux distribution version that’s installed on your machine. It is notably helpful for scripts and programs that require a standardized method to determine information relevant to a distribution.
lsb_release -a
The -a option stands for “all” and displays all available LSB and distribution-specific information.
root@ip-172-31-22-37:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04 LTS
Release: 24.04
Codename: noble
lsb_release -d
The -d option stands for “description” and displays the description of the distribution.
root@ip-172-31-22-37:~# lsb_release -d
No LSB modules are available.
Description: Ubuntu 24.04 LTS
lsb_release -c
The -c option stands for “codename” and displays the codename of the distribution release.
root@ip-172-31-22-37:~# lsb_release -c
No LSB modules are available.
Codename: noble
lsb_release -r
The -r option stands for “release” and shows the release number of the distribution.
root@ip-172-31-22-37:~# lsb_release -r
No LSB modules are available.
Release: 24.04
cat /etc/os-release
The file contains operating system identification data, making it easy to identify the current OS and its version.
[root@ip-172-31-25-66 ~]# cat /etc/os-release
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023.5.20240624"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/amazon-linux-2023/"
DOCUMENTATION_URL="https://docs.aws.amazon.com/linux/"
SUPPORT_URL="https://aws.amazon.com/premiumsupport/"
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023"
VENDOR_NAME="AWS"
VENDOR_URL="https://aws.amazon.com/"
Here are some more examples for checking the Linux kernel and operating system version using the terminal.
Using the uname
To print system information in Linux, use the uname command-line tool. It stands for “Unix name” and offers details on the kernel, operating system, and hardware of the machine.
uname -a
The -a option stands for “all” and displays all available system information, combining the outputs of the options above.
[root@ip-172-31-25-66 ~]# uname -a
Linux ip-172-31-25-66.ap-southeast-1.compute.internal 6.1.94-99.176.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jun 18 14:57:56 UTC 2024 x86_64 x86_64 x86_64 GNU/Linux
uname -s
The -s option stands for “system” and displays the kernel name.
[root@ip-172-31-25-66 ~]# uname -s
Linux
uname -n
The -n option stands for “nodename” and shows the network hostname of the machine.
[root@ip-172-31-25-66 ~]# uname -n
ip-172-31-25-66.ap-southeast-1.compute.internal
uname -r
The -r option stands for “release” and shows the kernel version.
[root@ip-172-31-25-66 ~]# uname -r
6.1.94-99.176.amzn2023.x86_64
uname -v
The -v option stands for “version” and shows the kernel build version.
[root@ip-172-31-25-66 ~]# uname -v
#1 SMP PREEMPT_DYNAMIC Tue Jun 18 14:57:56 UTC 2024
uname -m
The -m option stands for “machine” and shows the hardware name of the system.
[root@ip-172-31-25-66 ~]# uname -m
x86_64
uname -p
The -p option stands for “processor” and shows the processor type (if known).
[root@ip-172-31-25-66 ~]# uname -p
x86_64
uname -i
The -i option stands for “hardware platform” and shows the hardware platform (if known).
[root@ip-172-31-25-66 ~]# uname -i
x86_64
uname -o
The -o option stands for “operating system” and shows the operating system name.
[root@ip-172-31-25-66 ~]# uname -o
GNU/Linux
cat /proc/version
The /proc/version file contains information about the kernel version and other details. To view this information, use:
This will display the kernel version, GCC version used for compilation, and the build time.
[root@ip-172-31-25-66 ~]# cat /proc/version
Linux version 6.1.94-99.176.amzn2023.x86_64 (mockbuild@ip-10-0-62-55) (gcc (GCC) 11.4.1 20230605 (Red Hat 11.4.1-2), GNU ld version 2.39-6.amzn2023.0.10) #1 SMP PREEMPT_DYNAMIC Tue Jun 18 14:57:56 UTC 2024
Using the hostnamectl Command
Another command you can use is hostnamectl.The architecture—which indicates whether the machine is 32- or 64-bit—is another crucial piece of information provided by the hostnamectl command, which is one of its advantages.
The hostnamectl command can be used to query and change the system hostname and related settings. It also displays OS and kernel information.
[root@ip-172-31-25-66 ~]# hostnamectl
Static hostname: ip-172-31-25-66.ap-southeast-1.compute.internal
Icon name: computer-vm
Chassis: vm 🖴
Machine ID: ec2e51dff09c28bdfac845a45616668c
Boot ID: 341e5ccaf30545159076b243ccbe5c18
Virtualization: xen
Operating System: Amazon Linux 2023.5.20240624
CPE OS Name: cpe:2.3:o:amazon:amazon_linux:2023
Kernel: Linux 6.1.94-99.176.amzn2023.x86_64
Architecture: x86-64
Hardware Vendor: Xen
Hardware Model: HVM domU
Firmware Version: 4.11.amazon
Using the neofetch Command
If you have neofetch installed, it can provide a detailed and visually appealing summary of your system, including OS, kernel, uptime, packages, shell, and more. To use neofetch, simply type:
You can install neofetch using your package manager if it’s not already installed. For instance, you can install it with: on Debian-based computers.
root@ip-172-31-22-37:~# sudo apt install neofetch
Using the screenfetch Command
Similar to neofetch, screenfetch displays information about your system in a visually appealing way. To use screenfetch, type:
Your package manager can be used to install screenfetch if it isn’t already installed. For instance, you may install it using the following on Debian-based systems:
root@ip-172-31-22-37:~# sudo apt install screenfetch
Here are some more examples and ways to use the terminal to check the version of the Linux kernel and operating system.