Learn how to check your Linux kernel version, OS release, CPU, memory and hardware details using uname, hostnamectl, neofetch and lscpu. Includes a scriptable system info report for documentation.
Prerequisites
- A Linux server or VM with terminal access
- sudo or root privileges
- Internet access to install packages
What this solves
When you log into a new server or troubleshoot an issue, the first question is always the same: what am I actually running. This tutorial covers the standard commands for checking kernel version, OS release, CPU, memory and uptime on any modern Linux distribution.
You will use uname and hostnamectl for quick facts, neofetch or fastfetch for a visual summary, and lscpu plus free for hardware details. At the end you will have a reusable script that prints a full system report for documentation or support tickets.
Step-by-step configuration
Check kernel version and architecture with uname
uname is available on every Linux system by default and reports kernel name, version, and CPU architecture without needing any extra packages.
uname -aFor just the kernel release version, which is useful when checking if a kernel update applied:
uname -rTo confirm the CPU architecture, which matters when downloading binaries or Docker images:
uname -mA typical output is x86_64 for 64-bit Intel/AMD systems or aarch64 for ARM servers.
View OS release details with hostnamectl
hostnamectl, part of systemd, shows the hostname, OS name, kernel version, and virtualization type in one command on any systemd-based distro.
hostnamectlSample output looks like this:
Static hostname: web01
Icon name: computer-vm
Chassis: vm
Machine ID: 8f3a2b1c9d4e4f5a8b6c7d9e0f1a2b3c
Boot ID: 1a2b3c4d5e6f7a8b9c0d1e2f3a4b5c6d
Virtualization: kvm
Operating System: Ubuntu 24.04.1 LTS
Kernel: Linux 6.8.0-45-generic
Architecture: x86-64Read /etc/os-release for scripting-friendly values
The /etc/os-release file provides machine-readable variables that scripts and configuration management tools rely on to detect distro and version.
cat /etc/os-releaseTo grab just the pretty name in a script:
source /etc/os-release
echo "$PRETTY_NAME"/etc/os-release instead of scraping uname -a output in scripts. It has stable, documented field names like ID, VERSION_ID and PRETTY_NAME.Install neofetch or fastfetch for a visual summary
neofetch prints a colorful system summary next to your distro logo. It has been deprecated upstream, so on newer releases fastfetch is the maintained alternative with the same output style.
sudo apt update
sudo apt install -y fastfetchIf your repo still carries neofetch (Ubuntu 22.04 and Debian 11/12):
sudo apt install -y neofetchsudo dnf install -y epel-release
sudo dnf install -y neofetchOn Fedora 41, fastfetch is in the default repos:
sudo dnf install -y fastfetchRun it with:
fastfetchOr if you installed neofetch:
neofetchCheck CPU details with lscpu
lscpu reads from sysfs and /proc/cpuinfo to show core count, socket count, model name, and virtualization support.
lscpuTo check specifically how many cores are available for capacity planning:
nprocCheck memory usage with free
free shows total, used, and available RAM along with swap usage. The -h flag makes values human-readable.
free -hIf you need deeper memory and hardware details including DIMM slots and disk controllers, lshw provides a full hardware inventory.
sudo apt install -y lshw
sudo lshw -shortsudo dnf install -y lshw
sudo lshw -shortFind system uptime and boot time
The uptime command shows how long the system has been running along with load averages, which is useful when correlating issues with a recent reboot.
uptime -pTo find the exact date and time the system last booted:
who -bOr with systemd, which also shows firmware and kernel boot time separately:
systemd-analyzeScript a quick system info report
For documentation or support tickets, combine these commands into one script that outputs a consistent report. Save it somewhere in your path, like /usr/local/bin/sysreport.
#!/bin/bash
set -euo pipefail
echo "=== System report: $(date) ==="
echo
echo "--- Hostname and OS ---"
hostnamectl | grep -E 'Static hostname|Operating System|Kernel|Architecture|Virtualization'
echo
echo "--- CPU ---"
lscpu | grep -E '^Model name|^CPU\(s\)|^Socket|^Thread'
echo
echo "--- Memory ---"
free -h
echo
echo "--- Disk usage ---"
df -h --output=source,size,used,avail,pcent,target -x tmpfs -x devtmpfs
echo
echo "--- Uptime ---"
uptime -p
echo
echo "--- Network interfaces ---"
ip -brief addr showMake the script executable, owned by your user, with permissions that allow execution without granting write access to everyone.
sudo chmod 755 /usr/local/bin/sysreport
sudo chown root:root /usr/local/bin/sysreportRun the report and optionally save it to a file for a support ticket:
sysreport | tee ~/system-report-$(date +%Y%m%d).txtVerify your setup
Confirm each tool reports consistent information by cross-checking kernel version and OS release.
uname -r
hostnamectl | grep Kernel
grep PRETTY_NAME /etc/os-release
fastfetch --version 2>/dev/null || neofetch --versionIf you built the report script, confirm it runs cleanly end to end:
sysreportCommon issues
| Symptom | Cause | Fix |
|---|---|---|
| neofetch: command not found after install | Package not in default repos on newer distro versions | Install fastfetch instead, it is the maintained fork with the same syntax |
| hostnamectl shows wrong OS name after upgrade | Stale cache in systemd-hostnamed | Run sudo systemctl restart systemd-hostnamed then check again |
| lscpu output missing virtualization line | Running inside a container without access to CPU flags | Expected behavior in containers, check the host instead with uname -a |
| Permission denied running /usr/local/bin/sysreport | Execute bit not set on the script | Run sudo chmod 755 /usr/local/bin/sysreport, never chmod 777 |
| free -h shows unexpectedly low available memory | Page cache counted separately from free memory | Check the available column, not free, since Linux uses spare RAM for disk cache |
Next steps
- Check disk space usage on Linux with df and du commands
- Configure Linux process monitoring with top, htop, and btop
- Find out which process is using all your CPU or memory on Linux
- Set up real-time system monitoring with Netdata dashboards
- Automate Linux system inventory reports with cron
Running this in production?
Automated install script
Run this to automate the entire setup
#!/usr/bin/env bash
set -euo pipefail
# ----------------------------------------------------------------------------
# install-sysreport.sh
# Installs a system-info fetcher (fastfetch/neofetch) and a reusable
# /usr/local/bin/sysreport script that prints kernel, OS, CPU, memory,
# and uptime details for documentation or support tickets.
# ----------------------------------------------------------------------------
# --- Colors ---
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m'
log_info() { echo -e "${GREEN}[OK]${NC} $*"; }
log_warn() { echo -e "${YELLOW}[WARN]${NC} $*"; }
log_error() { echo -e "${RED}[ERROR]${NC} $*" >&2; }
usage() {
cat <<EOF
Usage: sudo $0 [--tool fastfetch|neofetch] [--no-report]
--tool TOOL Preferred fetch tool to install: fastfetch (default) or neofetch
--no-report Skip installing the /usr/local/bin/sysreport script
-h, --help Show this help message
EOF
exit 1
}
# --- Defaults ---
TOOL="fastfetch"
INSTALL_REPORT=true
SYSREPORT_PATH="/usr/local/bin/sysreport"
INSTALLED_PKG=""
# --- Parse arguments ---
while [ $# -gt 0 ]; do
case "$1" in
--tool)
TOOL="${2:-}"
[ -z "$TOOL" ] && usage
shift 2
;;
--no-report)
INSTALL_REPORT=false
shift
;;
-h|--help)
usage
;;
*)
log_error "Unknown argument: $1"
usage
;;
esac
done
if [[ "$TOOL" != "fastfetch" && "$TOOL" != "neofetch" ]]; then
log_error "Invalid --tool value: $TOOL (must be fastfetch or neofetch)"
usage
fi
# --- Prerequisite: must run as root ---
if [ "$(id -u)" -ne 0 ]; then
log_error "This script must be run as root or with sudo."
exit 1
fi
# --- Rollback on failure ---
cleanup_on_error() {
log_error "Installation failed. Rolling back partial changes..."
if [ -n "$INSTALLED_PKG" ]; then
case "$PKG_MGR" in
apt) apt remove -y "$INSTALLED_PKG" >/dev/null 2>&1 || true ;;
dnf|yum) "$PKG_MGR" remove -y "$INSTALLED_PKG" >/dev/null 2>&1 || true ;;
esac
fi
rm -f "$SYSREPORT_PATH"
exit 1
}
trap cleanup_on_error ERR
echo "=== System Info Tooling Installer ==="
# --- [1/6] Detect distro ---
echo "[1/6] Detecting distribution..."
if [ -f /etc/os-release ]; then
. /etc/os-release
case "$ID" in
ubuntu|debian)
PKG_MGR="apt"
PKG_INSTALL="apt install -y"
;;
almalinux|rocky|centos|rhel|ol|fedora)
PKG_MGR="dnf"
PKG_INSTALL="dnf install -y"
;;
amzn)
PKG_MGR="yum"
PKG_INSTALL="yum install -y"
;;
*)
log_error "Unsupported distro: $ID"
exit 1
;;
esac
log_info "Detected $PRETTY_NAME (using $PKG_MGR)"
else
log_error "/etc/os-release not found. Cannot determine distro."
exit 1
fi
# --- [2/6] Update package index ---
echo "[2/6] Updating package index..."
case "$PKG_MGR" in
apt) apt update -y ;;
dnf) dnf makecache -y >/dev/null 2>&1 || true ;;
yum) yum makecache -y >/dev/null 2>&1 || true ;;
esac
log_info "Package index refreshed."
# --- [3/6] Install required base tools (lscpu/free come from util-linux/procps, usually preinstalled) ---
echo "[3/6] Ensuring base utilities (procps, util-linux) are present..."
case "$PKG_MGR" in
apt) $PKG_INSTALL procps util-linux >/dev/null ;;
dnf|yum) $PKG_INSTALL procps-ng util-linux >/dev/null ;;
esac
log_info "Base utilities present."
# --- [4/6] Install fetch tool with fallback logic ---
echo "[4/6] Installing $TOOL..."
install_fastfetch() {
case "$PKG_MGR" in
apt)
if apt-cache show fastfetch >/dev/null 2>&1; then
$PKG_INSTALL fastfetch
INSTALLED_PKG="fastfetch"
else
log_warn "fastfetch not available in apt repos, falling back to neofetch."
$PKG_INSTALL neofetch
INSTALLED_PKG="neofetch"
TOOL="neofetch"
fi
;;
dnf)
if dnf list fastfetch >/dev/null 2>&1; then
$PKG_INSTALL fastfetch
INSTALLED_PKG="fastfetch"
else
log_warn "fastfetch not available, enabling EPEL and trying neofetch instead."
$PKG_INSTALL epel-release >/dev/null 2>&1 || true
$PKG_INSTALL neofetch
INSTALLED_PKG="neofetch"
TOOL="neofetch"
fi
;;
yum)
$PKG_INSTALL epel-release >/dev/null 2>&1 || true
$PKG_INSTALL neofetch
INSTALLED_PKG="neofetch"
TOOL="neofetch"
;;
esac
}
install_neofetch() {
case "$PKG_MGR" in
apt) $PKG_INSTALL neofetch ;;
dnf) $PKG_INSTALL epel-release >/dev/null 2>&1 || true; $PKG_INSTALL neofetch ;;
yum) $PKG_INSTALL epel-release >/dev/null 2>&1 || true; $PKG_INSTALL neofetch ;;
esac
INSTALLED_PKG="neofetch"
}
if [ "$TOOL" = "fastfetch" ]; then
install_fastfetch
else
install_neofetch
fi
log_info "$TOOL installed successfully."
# --- [5/6] Deploy the sysreport script ---
if [ "$INSTALL_REPORT" = true ]; then
echo "[5/6] Installing $SYSREPORT_PATH report script..."
cat > "$SYSREPORT_PATH" <<'EOF'
#!/bin/bash
set -euo pipefail
echo "=== System report: $(date) ==="
echo
echo "--- Hostname and OS ---"
if command -v hostnamectl >/dev/null 2>&1; then
hostnamectl | grep -E 'Static hostname|Operating System|Kernel|Architecture|Virtualization' || true
else
uname -a
fi
echo
echo "--- OS release ---"
if [ -f /etc/os-release ]; then
. /etc/os-release
echo "$PRETTY_NAME"
fi
echo
echo "--- CPU ---"
lscpu | grep -E '^Model name|^CPU\(s\)|^Socket\(s\)|^Core\(s\) per socket' || true
echo "Logical CPUs: $(nproc)"
echo
echo "--- Memory ---"
free -h
echo
echo "--- Uptime ---"
uptime -p || true
who -b || true
echo
echo "--- Visual summary ---"
if command -v fastfetch >/dev/null 2>&1; then
fastfetch
elif command -v neofetch >/dev/null 2>&1; then
neofetch
else
echo "No fetch tool installed."
fi
EOF
chmod 755 "$SYSREPORT_PATH"
chown root:root "$SYSREPORT_PATH"
log_info "Report script installed at $SYSREPORT_PATH"
else
echo "[5/6] Skipping sysreport script installation (--no-report given)."
fi
# --- [6/6] Verification ---
echo "[6/6] Verifying installation..."
FAILED=false
if command -v "$TOOL" >/dev/null 2>&1; then
log_info "$TOOL binary found: $(command -v "$TOOL")"
else
log_error "$TOOL binary not found after installation."
FAILED=true
fi
if [ "$INSTALL_REPORT" = true ]; then
if [ -x "$SYSREPORT_PATH" ]; then
log_info "sysreport is executable at $SYSREPORT_PATH"
else
log_error "sysreport script missing or not executable."
FAILED=true
fi
fi
if ! command -v lscpu >/dev/null 2>&1 || ! command -v free >/dev/null 2>&1; then
log_error "Required base utilities (lscpu/free) missing."
FAILED=true
fi
if [ "$FAILED" = true ]; then
exit 1
fi
trap - ERR
log_info "Installation complete. Run 'sysreport' to generate a full system report."
exit 0
Review the script before running. Execute with: bash install.sh