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:
hostnameShows the name of your machine on the network.
Step 2: Show kernel and OS information:
uname -aDisplays kernel name, version, architecture, and build date.
Step 3: Show the Linux distribution:
cat /etc/os-releaseShows the distribution name, version, and ID.
Step 4: Check system uptime:
uptimeShows how long the system has been running, number of users, and load averages.
Part 2: CPU and Memory
Step 1: View CPU information:
lscpuShows 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 -10The /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 -20Shows processor model, speed, and features for each CPU core.
Part 3: Disk Usage
Step 1: Check filesystem disk space:
df -hShows 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:
lsblkShows all block devices (disks, partitions) and their sizes and mount points.
Part 4: Process Monitoring
Step 1: View running processes interactively with top:
topShows 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):
htophtop 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 auxa = all users, u = user-oriented format, x = include processes without a terminal.
Step 4: Find a specific process:
ps aux | grep bashFilters the process list for lines containing "bash".
Step 5: Show process tree:
pstreeDisplays processes in a tree hierarchy showing parent-child relationships.
Part 5: Network Information
Step 1: View network interfaces and IP addresses:
ip addr showShows all network interfaces with their IP addresses, MAC addresses, and status.
Step 2: View the routing table:
ip route showShows how traffic is routed. The default via line shows your gateway.
Step 3: Check DNS configuration:
cat /etc/resolv.confShows 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:
whoShows currently logged-in users, their terminal, and login time.
Step 2: Show your own user and group info:
idDisplays your user ID (uid), group ID (gid), and all groups you belong to.
Step 3: Show recent login history:
last -10Shows the last 10 login sessions with user, terminal, IP, and duration.
Deliverables
- Screenshot of
uname -aandcat /etc/os-release. - Screenshot of
free -hshowing memory usage. - Screenshot of
df -hshowing disk usage. - Screenshot of
topshowing running processes. - Screenshot of
ip addr showandss -tuln. - Screenshot of
whoandid.
Commands Reference
hostname— System nameuname -a— Kernel infouptime— System uptimelscpu— CPU detailsfree -h— Memory usagedf -h— Disk spacedu -sh— Directory sizelsblk— Block devicestop/htop— Live processesps aux— Process listpstree— Process treeip addr— Network interfacesip route— Routing tabless -tuln— Open portswho— Logged-in usersid— User/group infolast— 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.