translations: [ es/Español ] · [ de/Deutsch ] · [ fr/Français ]
Table of contents
Linux systems offer various methods to identify the distribution and kernel version. Knowing this information is crucial for system maintenance, updates, and compatibility. Here are different ways to achieve this:
Using Terminal Commands
Check Distribution:
lsb_release -a
: This command provides comprehensive information about the distribution, including its name, release, and codename.cat /etc/*-release
: Displays contents from release files, giving details about the distribution.hostnamectl
: Offers basic information about the operating system, including the distribution.
Kernel Version:
uname -r
: Shows the kernel version.cat /proc/version
: Presents detailed kernel information, including the version and build details.
Examine System Files
cat /etc/os-release
: This file contains information about the operating system and version.cat /proc/sys/kernel/osrelease
: Displays the kernel version directly from the system.
Using GUI Tools
- System Information Utility: Many Linux distributions have built-in graphical tools in their system settings that display the distribution and kernel version.
Installation Guide for Essential Tools
In case these commands aren’t available, here’s how to install them on various distributions:
# Ubuntu
sudo apt update
sudo apt install lsb-release
# Fedora
sudo dnf install redhat-lsb-core
# OpenSUSE
sudo zypper install lsb-release
Comprehensive Linux Details Gathering Script
Take a look at this handy Bash script—it’s a real powerhouse! It uses various methods detailed in the article to gather Linux distribution information. What’s cool is that it’s designed to handle errors smoothly by double-checking if a command exists before running it:
#!/bin/sh
# Function to execute command and print divider if successful
execute_command() {
cmd="$1"
divider="------ - - - - - - -"
if $cmd; then
printf '%s\n' "$divider"
else
printf '%s\n' "$cmd failed" "$divider"
fi
}
# Execute commands and print dividers for successful executions
execute_command "lsb_release -a"
execute_command "cat /etc/*-release"
execute_command "hostnamectl"
execute_command "cat /etc/os-release"
execute_command "cat /proc/sys/kernel/osrelease"
execute_command "uname -r"
execute_command "cat /proc/version"
This script can be saved as a file, for instance, linux_details.sh
. To make it executable, use the command
chmod +x linux_details.sh
No superuser privileges are required for execution, making it convenient for system exploration.
Created on: Jan 5, 2024
Discover More within this Subject:
- Understanding `kill` Command in Linux
- Understanding `ps` Command in Linux
- Mastering Linux Terminal Navigation: Essential Shortcuts for Efficiency
- Flatpak Software Removal and Cleanup
- Installing Software With Flatpak