CH02 — LAB

Linux Distributions — Hands-On

Explore package management, identify distributions, manage software repositories, and practice the skills that keep Linux systems updated and functional.

Platform: Linux Terminal
Exercises: 4
Difficulty: Foundational
Est. Time: 40–50 min

Lab Objectives

1
Distribution Identification Mission
DISTRO ID
SCENARIOYou have been handed access to three different Linux servers. Your first task before performing any work is to identify exactly what OS and version is running on each. Use every available method to gather this information.
  1. Check the standard release file: cat /etc/os-release — this works on virtually every modern Linux
  2. Try the lsb_release tool if available: lsb_release -a 2>/dev/null
  3. Check for distribution-specific files: cat /etc/debian_version 2>/dev/null || cat /etc/redhat-release 2>/dev/null || cat /etc/arch-release 2>/dev/null
  4. Get kernel information: uname -r — the kernel version often reveals distribution clues
  5. Check the package manager binary that exists: which apt dpkg dnf yum pacman 2>/dev/null
  6. Compile a profile: distro name, version, kernel, and package manager type
# Ubuntu/Debian example output $ cat /etc/os-release NAME="Ubuntu" VERSION="22.04.3 LTS (Jammy Jellyfish)" ID=ubuntu ID_LIKE=debian PRETTY_NAME="Ubuntu 22.04.3 LTS" $ uname -r 5.15.0-88-generic $ which apt dpkg /usr/bin/apt /usr/bin/dpkg # Confirmed: Debian-family distribution
PRACTICAL SKILL
Identifying the distro accurately before making changes prevents disasters. Installing a .deb package on an RHEL system (or using apt on CentOS) will fail or cause damage. Always confirm distro family before running any package management commands on an unfamiliar system.
2
Package Management with APT
APT
SCENARIOYour Ubuntu server needs several software packages installed for a new application deployment. Practice the full APT package lifecycle: search, install, query, and remove. Use "tree" or "htop" as practice packages (lightweight tools that demonstrate the workflow).
  1. Update the package index: sudo apt update — always do this before installing anything
  2. Search for a package: apt search tree — note how many packages match
  3. Get details before installing: apt show tree — check description, size, dependencies
  4. Install the package: sudo apt install tree -y
  5. Verify installation: which tree && tree --version
  6. Use the installed tool: tree /etc/ssh/
  7. Check what was installed: dpkg -L tree (list all files installed by the package)
  8. Remove the package: sudo apt remove tree (config files kept) or sudo apt purge tree (removes everything)
  9. Clean up orphaned dependencies: sudo apt autoremove
# APT workflow output $ sudo apt update Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease Reading package lists... Done $ apt show tree | grep -E "Package|Version|Size|Description" Package: tree Version: 2.0.2-1 Installed-Size: 127 kB Description: displays an indented directory tree, in color $ sudo apt install tree -y [...] Setting up tree (2.0.2-1) ... $ tree /etc/ssh /etc/ssh ├── moduli ├── ssh_config ├── sshd_config └── sshd_config.d
3
Repository Management
REPOSITORIES
SCENARIOYour team wants to understand where apt gets its packages and how to manage software sources. Explore the repository structure and understand the sources.list configuration.
  1. View the main sources file: cat /etc/apt/sources.list — understand the components (main, universe, restricted, multiverse)
  2. List additional source files: ls -la /etc/apt/sources.list.d/
  3. View currently configured repositories: apt-cache policy
  4. Check which repository a specific package comes from: apt-cache policy nginx (even if not installed, shows available versions and sources)
  5. Count total available packages: apt-cache stats | grep "Total package"
  6. List all installed packages sorted by size: dpkg-query -W --showformat='${Installed-Size}\t${Package}\n' | sort -rn | head -20
  7. Find what package owns a specific file: dpkg -S /usr/bin/ssh
# sources.list format explanation $ cat /etc/apt/sources.list | grep -v "^#" | grep -v "^$" deb http://archive.ubuntu.com/ubuntu jammy main restricted deb http://archive.ubuntu.com/ubuntu jammy-updates main restricted # format: deb [url] [codename] [components...] # main=free software, restricted=proprietary drivers # Find which package owns a file $ dpkg -S /usr/bin/ssh openssh-client: /usr/bin/ssh
SECURITY NOTE
Only add repositories from trusted sources. A malicious repository can push compromised packages that get installed with root privileges. The "apt-key" and "signed-by" mechanisms verify repository authenticity using GPG signatures. Always verify the GPG fingerprint of a new repository key before adding it — supply chain attacks via package repositories are a real threat vector.
4
Distro Comparison Research Lab
ANALYSIS
SCENARIOYour organization needs to choose a Linux distribution for a new server deployment. You must research and document the key differences between Ubuntu LTS, Rocky Linux, and Debian Stable to recommend the best fit for each of three use cases: web server, Kubernetes cluster, and security scanning system.
  1. Research each distribution's support lifecycle. How long does Ubuntu 22.04 LTS get security updates? Debian 12? Rocky Linux 9?
  2. Compare package freshness: research when each distro's package of "nginx" was last updated to a major version.
  3. Identify the default init system and package manager for each distribution.
  4. Research RHEL/Rocky Linux compatibility: what is the "binary compatible" claim and why does it matter for enterprise software?
  5. Document your recommendation: For a web server (stability priority), Kubernetes cluster (current software priority), and Kali (security tools priority), which distro do you recommend and why?
  6. Write your analysis as a structured text file: nano ~/distro-analysis.txt
# Template for your analysis file === Distro Analysis: Server Selection === USE CASE 1: Web Server (Stability Priority) Recommended: Debian Stable or Ubuntu 22.04 LTS Rationale: [your reasoning] Support lifecycle: [years] Package manager: apt USE CASE 2: Kubernetes Cluster (Current Software) Recommended: [your choice] Rationale: [your reasoning] USE CASE 3: Security Scanning Recommended: Kali Linux (VM) or [alternative] Rationale: [your reasoning] KEY DIFFERENCES: - Ubuntu 22.04 LTS: [notes] - Rocky Linux 9: [notes] - Debian 12: [notes]
REAL WORLD DECISION FACTORS
Beyond software features, enterprise distro selection factors include: vendor support contracts (RHEL subscription vs community support), certification requirements (some regulations mandate specific OS versions), existing team expertise (retraining costs), software vendor support matrices (many enterprise vendors only certify on RHEL/Ubuntu), and compliance tooling availability. There is rarely a universally "right" answer — context determines the correct distro choice.

Lab Complete

Mark complete when you have finished all exercises.

Lab progress saved. Move on to Chapter 3!