Linux Lab: System Information Commands

Learn the essential commands for inspecting system resources, processes, memory, disk usage, and network configuration.

Lab Objectives

  • View system hostname, kernel version, and OS information.
  • Monitor running processes with top and ps.
  • Check memory, disk, and CPU usage.
  • View network configuration and active connections.
  • Identify logged-in users and system uptime.

Prerequisites

  • A Linux system with terminal access (Kali, Ubuntu, or any distribution).
  • No special permissions required for most commands; some require sudo.

Part 1: System Identity

Step 1: Display the hostname:
hostname

Shows the name of your machine on the network.

Step 2: Show kernel and OS information:
uname -a

Displays kernel name, version, architecture, and build date.

Step 3: Show the Linux distribution:
cat /etc/os-release

Shows the distribution name, version, and ID.

Step 4: Check system uptime:
uptime

Shows how long the system has been running, number of users, and load averages.

Part 2: CPU and Memory

Step 1: View CPU information:
lscpu

Shows CPU architecture, cores, threads, clock speed, and cache sizes.

Step 2: Check memory usage:
free -h

-h shows human-readable sizes (MB/GB). Look at total, used, free, and available.

Step 3: Detailed memory info from /proc:
cat /proc/meminfo | head -10

The /proc filesystem provides raw kernel data. This shows the first 10 lines of memory details.

Step 4: View CPU details from /proc:
cat /proc/cpuinfo | head -20

Shows processor model, speed, and features for each CPU core.

Part 3: Disk Usage

Step 1: Check filesystem disk space:
df -h

Shows mounted filesystems with total size, used space, available space, and mount point.

Step 2: Check disk usage of a specific directory:
du -sh ~

-s gives a summary total. -h makes it human-readable.

Step 3: List block devices:
lsblk

Shows all block devices (disks, partitions) and their sizes and mount points.

Part 4: Process Monitoring

Step 1: View running processes interactively with top:
top

Shows a live, updating view of processes sorted by CPU usage. Press q to quit. Press M to sort by memory instead.

Step 2: Use htop for a more user-friendly view (if installed):
htop

htop adds colour, mouse support, and easier navigation. Press F10 or q to quit. Install with sudo apt install htop if not available.

Step 3: List all running processes:
ps aux

a = all users, u = user-oriented format, x = include processes without a terminal.

Step 4: Find a specific process:
ps aux | grep bash

Filters the process list for lines containing "bash".

Step 5: Show process tree:
pstree

Displays processes in a tree hierarchy showing parent-child relationships.

Part 5: Network Information

Step 1: View network interfaces and IP addresses:
ip addr show

Shows all network interfaces with their IP addresses, MAC addresses, and status.

Step 2: View the routing table:
ip route show

Shows how traffic is routed. The default via line shows your gateway.

Step 3: Check DNS configuration:
cat /etc/resolv.conf

Shows the DNS servers your system uses for name resolution.

Step 4: View active network connections:
ss -tuln

-t TCP, -u UDP, -l listening, -n numeric (no DNS resolution).

Step 5: View all active connections with process info:
sudo ss -tulnp

-p shows the process using each port. Requires sudo to see all processes.

Part 6: User Information

Step 1: See who is logged in:
who

Shows currently logged-in users, their terminal, and login time.

Step 2: Show your own user and group info:
id

Displays your user ID (uid), group ID (gid), and all groups you belong to.

Step 3: Show recent login history:
last -10

Shows the last 10 login sessions with user, terminal, IP, and duration.

Deliverables

  • Screenshot of uname -a and cat /etc/os-release.
  • Screenshot of free -h showing memory usage.
  • Screenshot of df -h showing disk usage.
  • Screenshot of top showing running processes.
  • Screenshot of ip addr show and ss -tuln.
  • Screenshot of who and id.

Commands Reference

  • hostname — System name
  • uname -a — Kernel info
  • uptime — System uptime
  • lscpu — CPU details
  • free -h — Memory usage
  • df -h — Disk space
  • du -sh — Directory size
  • lsblk — Block devices
  • top / htop — Live processes
  • ps aux — Process list
  • pstree — Process tree
  • ip addr — Network interfaces
  • ip route — Routing table
  • ss -tuln — Open ports
  • who — Logged-in users
  • id — User/group info
  • last — Login history

/proc Filesystem

  • /proc/cpuinfo — CPU details
  • /proc/meminfo — Memory details
  • /proc/version — Kernel version
  • /proc/uptime — Uptime in seconds
  • /proc/loadavg — Load averages

/proc is a virtual filesystem — these are not real files on disk but live kernel data.