Lesson 11: System Information

Goal: Learn to inspect your Linux system — hardware, software, kernel, uptime, and resources.


Table of Contents

  1. Kernel & OS Info — uname
  2. Distribution Info
  3. Date & Time — date, cal
  4. Uptime
  5. Memory — free
  6. CPU — lscpu
  7. Hardware Overview — lshw, lspci, lsusb
  8. Repeat Commands — watch
  9. Hostname
  10. Exercises

Kernel & OS Info — uname

# All system info
uname -a

Output:

Linux myserver 6.1.0-18-amd64 #1 SMP Debian 6.1.76-1 (2024-02-01) x86_64 GNU/Linux

Individual fields

uname -s    # Kernel name: Linux
uname -r    # Kernel release: 6.1.0-18-amd64
uname -v    # Kernel version: #1 SMP Debian 6.1.76-1
uname -m    # Machine architecture: x86_64
uname -n    # Network hostname: myserver
uname -o    # Operating system: GNU/Linux

Distribution Info

# Detailed distro info
lsb_release -a

# OS release file (works on all distros)
cat /etc/os-release

# Quick version
cat /etc/os-release | grep -E "^(NAME|VERSION)="

Example output:

NAME="Ubuntu"
VERSION="24.04 LTS (Noble Numbat)"

Date & Time — date, cal

Display date and time

# Current date and time
date

# Custom format
date "+%Y-%m-%d"           # 2026-03-22
date "+%Y-%m-%d %H:%M:%S"  # 2026-03-22 14:30:00
date "+%A, %B %d %Y"       # Sunday, March 22 2026
date "+%H:%M"              # 14:30

Format codes

Code Meaning Example
%Y Year (4 digit) 2026
%m Month (01-12) 03
%d Day (01-31) 22
%H Hour (00-23) 14
%M Minute (00-59) 30
%S Second (00-59) 00
%A Weekday name Sunday
%B Month name March
%s Unix timestamp 1774288200

Date arithmetic

# Tomorrow
date -d "+1 day"

# Last week
date -d "-7 days"

# Specific date
date -d "2026-12-25" "+%A"
# Output: Friday

# Unix timestamp to date
date -d @1774288200

Calendar — cal

# Current month
cal

# Specific month
cal 12 2026

# Entire year
cal 2026

# Show week numbers
cal -w

Uptime

# System uptime
uptime

Output:

 14:30:00 up 45 days,  3:22,  2 users,  load average: 0.12, 0.08, 0.05
# Pretty format
uptime -p
# Output: up 45 days, 3 hours, 22 minutes

# Since when is the system running?
uptime -s
# Output: 2026-02-05 11:08:00

Load average explained

load average: 0.12, 0.08, 0.05
              │      │      └── 15-minute average
              │      └── 5-minute average
              └── 1-minute average
  • Load = number of processes waiting for CPU
  • On a single-core system: 1.0 = 100% utilized
  • On a quad-core: 4.0 = 100% utilized
  • Values below your core count = healthy

Memory — free

# Human-readable memory info
free -h

Output:

              total        used        free      shared  buff/cache   available
Mem:           16Gi       4.2Gi       8.1Gi       256Mi       3.7Gi        11Gi
Swap:          4.0Gi          0B       4.0Gi
Column Meaning
total Total physical RAM
used Currently used
free Completely free
shared Shared memory
buff/cache Used for buffers and cache (reclaimable)
available Available for new applications

Important: Look at "available", not "free". Linux uses free RAM for caching, which is a good thing. Available = free + reclaimable cache.

# Continuous monitoring (every 2 seconds)
free -h -s 2

# Show in MB
free -m

# Total only
free -h --total

CPU — lscpu

lscpu

Key output fields:

Architecture:             x86_64
CPU(s):                   8
Thread(s) per core:       2
Core(s) per socket:       4
Model name:               Intel Core i7-10700K
CPU max MHz:              5100.0000

Quick CPU info

# Number of CPUs
nproc

# Detailed CPU info
cat /proc/cpuinfo | head -20

# CPU model only
lscpu | grep "Model name"

Hardware Overview

lshw — Full hardware listing

# Summary
sudo lshw -short

# Detailed
sudo lshw

# HTML report
sudo lshw -html > hardware-report.html

lspci — PCI devices

# List all PCI devices (GPU, network cards, etc.)
lspci

# Show GPU
lspci | grep -i vga

# Show network controllers
lspci | grep -i network

lsusb — USB devices

# List USB devices
lsusb

Repeat Commands — watch

watch executes a command repeatedly and shows the output live.

# Run "free -h" every 2 seconds (default)
watch free -h

# Custom interval (every 5 seconds)
watch -n 5 df -h

# Highlight changes
watch -d free -h

# Monitor a directory
watch -n 1 ls -la /tmp/

# Monitor running docker containers
watch docker ps

# Monitor disk usage
watch -n 10 df -h

Exit with Ctrl + C.

Practical monitoring examples

# Watch log file growth
watch -n 1 'wc -l /var/log/syslog'

# Watch network connections
watch -n 2 'ss -tulnp'

# Watch system load
watch -n 1 uptime

# Monitor a specific process
watch -n 1 'ps aux | grep nginx'

Hostname

# Show hostname
hostname

# Show FQDN
hostname -f

# Show IP address
hostname -I

# Detailed host info
hostnamectl

hostnamectl output:

 Static hostname: myserver
       Icon name: computer-desktop
         Chassis: desktop
      Machine ID: abc123...
   Operating System: Ubuntu 24.04 LTS
            Kernel: Linux 6.1.0-18-amd64
      Architecture: x86-64
# Change hostname (persistent)
sudo hostnamectl set-hostname newname

Exercises

Exercise 1: System overview

# 1. What kernel version are you running?
uname -r

# 2. What distribution and version?
cat /etc/os-release | grep PRETTY_NAME

# 3. How long has the system been running?
uptime -p

# 4. How much RAM is available?
free -h | awk '/Mem/ {print $7}'

# 5. How many CPU cores?
nproc

Exercise 2: Date formatting

# 1. Current date in ISO format
date "+%Y-%m-%d"

# 2. Current time
date "+%H:%M:%S"

# 3. What day of the week is Christmas 2026?
date -d "2026-12-25" "+%A"

# 4. Unix timestamp now
date "+%s"

# 5. When is 100 days from now?
date -d "+100 days" "+%Y-%m-%d (%A)"

Exercise 3: Monitoring with watch

# 1. Monitor memory usage (update every 3 seconds)
watch -n 3 free -h
# Press Ctrl+C to stop

# 2. Monitor disk usage with change highlighting
watch -d df -h
# Press Ctrl+C to stop

Key Takeaways

  • uname -a — kernel and system info
  • cat /etc/os-release — distribution details
  • date "+%Y-%m-%d" — formatted date output
  • uptime — system uptime and load average
  • free -h — memory usage (check "available", not "free")
  • lscpu / nproc — CPU info
  • watch command — repeat any command at intervals

Next Lesson: Lesson 12: Disk & Storage →