[ TechDocsCove ]  TechDocsCove en   ↩︎

# Ways to Check Linux Distribution and Kernel Version

linux   shell   system administration   system-information  

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

Examine System Files

Using GUI Tools

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


Email shareIcon for sharing via email    Reddit shareIcon for sharing via Reddit    X shareIcon for sharing via X    Telegram shareIcon for sharing via Telegram    WhatsApp shareIcon for sharing via WhatsApp    Facebook shareIcon for sharing via Facebook    LinkedIn shareIcon for sharing via LinkedIn



Discover More within this Subject: