System Information and Monitoring in Linux (original) (raw)

Last Updated : 1 Jun, 2026

Monitoring a Linux system means checking how well your computer’s hardware and software are working. It helps track performance, find resource-heavy processes, and detect issues early.

Checking System Information

System information commands give details about your computer’s setup, including the operating system, kernel version, and hardware components. This information is useful for troubleshooting, system audits, and preparing for software installations.

**Example 1. Displays system information in a tidy format, including OS name, kernel version, and virtualization details.

**Command:

**hostnamectl

**Output:

hostnamectl

Output

**What it does:

**Example 2. Lists CPU information such as model name, number of cores, and threads.

**Command:

**lscpu

**Output:

file

**What it does:

**Example 3. Displays details about disks, partitions, and mount points in a clear table.

Command:

**lsblk

Output:

file

**What it does:

**Example 4. Shows memory usage (RAM and swap) in human-readable units.

**Command:

**free -h

Reports RAM and swap usage with human-readable units, including total, used, free, and available memory.

**Example 5. Tells you how much disk space is used and available on each mounted filesystem.

**Command:

**df -h

**Output:

file

**What it does:

Monitoring System Performance in Real-Time

Performance monitoring shows how your system resources (CPU, memory, disk, network) are being used **right now. It's handy for detecting lag, load, or bottlenecks.

**Example 1. Shows live CPU and memory usage by processes, refreshing automatically.

Command:

**top

Output:

file

Output

**What it does:

**Example 2. A more colorful, user-friendly version of top where you can scroll and sort easily.

Command:

**htop

Output:

file

Output

**What it does:

**Example 3. Shows how busy your disks are and if any are overloaded.

Command:

**iostat -xz 1

Output:

file

Output

**What it does:

**Example 4. Displays real-time network usage in which connections are sending or receiving the most data.

**Command:

**iftop

**Output:

file

Output

**What it does:

Checking Hardware and Devices

Sometimes, issues come from hardware rather than software. These commands help you find what’s actually installed and working.

**Example 1. Lists all PCI(Peripheral Component Interconnect) devices like graphics cards, network adapters, etc.

**Command:

**lspci

**Output:

file

**What it does:

**Example 2. Lists USB devices currently connected.

**Command:

**lsusb

**Output:

file

Output

**What it does:

**Example 3. Shows hardware details like manufacturer, model, and BIOS version.

Command:

**sudo dmidecode -t system

**Output:

file

**What it does:

Viewing Logs and System Events

Logs contain messages from the system and services, they explain why something went wrong.

**Example 1. Shows recent system errors and warnings.

**Command:

**journalctl -xe

**What it does:

**Example 2. Displays logs related to a particular service.

**Command:

**journalctl -u servicename

**What it does:

**Example 3. Shows kernel messages (e.g., detected hardware, drivers, or crashes).

**Command:

**dmesg -T

**What it does:

Managing Services and Startup

Linux uses services to run programs in the background (like web or database servers). You can check and control them easily.

**Example 1. Shows if a service is running.

**Command:

**systemctl status service-name

**What it does:

**Example 2. Starts and enables the service to run at boot.

**Command:

**systemctl enable --now service-name

**What it does:

**Example 3. Lists services that have failed to start.

**Command:

**systemctl --failed

**What it does:

**Note: Some of these commands and outputs are intentionally omitted or may not run in certain environments due to privacy, permission, or security restrictions (e.g., sandboxed terminals, managed lab VMs, or limited user privileges).

Basic Security and User Checks

Security begins by knowing who’s logged in and what they can do.

**Example 1. Displays current user ID and groups.

**Command:

**id

**Output:

file

Output

**Example 2. Shows what commands the current user can run with sudo permissions.

**Command:

**sudo -l

**Output:

file

Output

**Example 3. Lists the last 10 logins to your system.

**Command:

**last -n 10

**Output:

file

Output

A Simple System Health Script

You can automate system checks with a short script. Create a file called **health.sh, paste this in, and run it with bash health.sh.

#!/usr/bin/env bash
echo "== SYSTEM =="
hostnamectl | egrep 'Operating System|Kernel|Architecture'

echo; echo "== CPU =="
lscpu | egrep 'Model name|CPU|Thread|Core|MHz'

echo; echo "== MEMORY =="
free -h

echo; echo "== DISK USAGE =="
df -hT | awk 'NR==1 || $7 ~ /^/(home|var|root|/|boot|data)/'

echo; echo "== NETWORK PORTS =="
ss -tuln | head -n 10

echo; echo "== LOAD AVERAGE (1/5/15) =="
awk '{print 1,1,1,2,$3}' /proc/loadavg

echo; echo "== TOP PROCESSES =="
ps -eo pid,comm,%cpu,%mem --sort=-%cpu | head -n 10

This script summarizes the system’s health helps in doing perfect quick check before troubleshooting or deployment.