Package Management – Linux Teaching Plan
Duration: 2 hours (≈ 12 min per command).
Target audience: Novice Linux users who need to learn how to install, upgrade and remove software on common distributions.
Learning Objectives
- Identify the role of package managers and repository metadata.
- Install, upgrade and remove software with apt/dpkg (Debian/Ubuntu).
- Install, upgrade and remove software with yum/dnf (CentOS/RHEL/Fedora).
- Install, upgrade and remove software with pacman (Arch/Manjaro).
- Work with snap and flatpak for universal packaging.
- Manipulate RPM packages directly with rpm.
- Use zypper on openSUSE and SUSE Linux Enterprise.
- Inspect package database with dpkg (Debian).
- Query repository metadata and package information.
- Automate a simple package‑management workflow in a script.
Schedule & Topics
- Intro & terminology (5 min)
- APT/Dpkg – Debian/Ubuntu (10 min)
- YUM – CentOS 7 (10 min)
- DNF – Fedora 33 (10 min)
- Pacman – Arch/Manjaro (10 min)
- Zypper – openSUSE (10 min)
- Snap – Universal packages (10 min)
- Flatpak – Universal packages (10 min)
- RPM – low‑level package handling (10 min)
- Mini‑project: “Create a reproducible install script for a 3‑tier web stack” (15 min)
- Q&A & wrap‑up (5 min)
Command Topics & Hands‑On Exercises
1. apt update – Refresh Repository Metadata
sudo apt update
- Run `apt update` on a fresh Ubuntu VM and watch the list of repos being refreshed.
- Check the time stamp of `/var/lib/apt/lists/*` to confirm the update finished.
2. apt install – Install a Package
sudo apt install -y htop
apt show htop
- Install
htop, then launch it to see live CPU usage.
- Show the package details with `apt show htop` (description, size, dependencies).
3. apt remove – Uninstall a Package
sudo apt remove -y htop
apt list --installed | grep htop
- Remove the previously installed
htop.
- Verify that it is no longer listed in the installed package list.
4. yum update – Refresh Repos (CentOS 7)
sudo yum check-update
sudo yum update -y
- List all packages that can be updated.
- Perform an update and check the exit code (0 = success).
5. dnf install – Install a Package (Fedora 33)
sudo dnf install -y tree
dnf info tree
- Install
tree and run it in your home directory to see the directory tree.
- Use `dnf info` to view package metadata (architecture, size, repo).
6. pacman -S – Install a Package (Arch/Manjaro)
sudo pacman -Sy
sudo pacman -S --noconfirm exa
pacman -Qi exa
- Synchronize the package database and install
exa (a modern `ls`).
- Run `exa --tree` to display a file system tree.
- Show the package info with `pacman -Qi exa` (install date, dependencies).
7. zypper install – Install a Package (openSUSE/SUSE)
sudo zypper refresh
sudo zypper install -y vim
zypper se vim
- Refresh the repos and install
vim.
- Search for all packages containing “vim” to see related packages.
- Open
vim and check that it works.
8. snap install – Universal Snap Packages
sudo snap install hello-world
snap list hello-world
- Install the
hello-world snap and run it (`hello-world`).
- List installed snaps with `snap list` and verify the version number.
- Remove the snap with `sudo snap remove hello-world`.
9. flatpak install – Universal Flatpak Packages
sudo flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
sudo flatpak install -y flathub org.gnome.Evince
flatpak list
- Add the Flathub remote and install the PDF viewer
org.gnome.Evince.
- Run `flatpak run org.gnome.Evince` to confirm it starts.
- List all installed flatpaks and show the application’s data directory (`flatpak info org.gnome.Evince`).
10. rpm -i – Low‑Level Package Install (Red Hat family)
sudo yum install -y rpm-build
curl -O https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
sudo rpm -ivh epel-release-latest-7.noarch.rpm
sudo rpm -qi epel-release
- Download a
.rpm file from a public repo.
- Install it with `rpm -ivh` and verify the package name and version.
- List installed packages that match the name with `rpm -qa | grep epel-release`.
11. dpkg -i – Low‑Level Debian Package Install
curl -O https://mirrors.edge.kernel.org/pub/software/scm/git/git-2.34.1.deb
sudo dpkg -i git-2.34.1.deb
sudo apt-get install -f
- Download a Debian package from a public source (e.g., Git).
- Install it manually with `dpkg -i` and observe the dependency error.
- Run `apt-get install -f` to automatically install missing dependencies.
12. pacman -R – Remove a Package (Arch/Manjaro)
sudo pacman -Rns exa
pacman -Q | grep exa
- Remove the
exa package installed earlier, including orphaned dependencies.
- Check that it no longer appears in the package database.
13. snap remove – Uninstall a Snap
sudo snap remove hello-world
snap list | grep hello-world
- Confirm that the snap is gone after removal.
14. flatpak uninstall – Uninstall a Flatpak
sudo flatpak uninstall -y org.gnome.Evince
flatpak list | grep Evince
- Remove the Evince application and verify it is no longer listed.
15. dnf upgrade-minimal – Smart Upgrade (Fedora 33)
sudo dnf upgrade-minimal -y
- Run the command on a test system and note how many packages are upgraded.
- Compare the output with a full `dnf upgrade` to see the difference.
Mini‑Project: “Fully Automated Web App Stack Installer”
Each student will create a single shell script that:
- Detects the host distribution (Ubuntu/Debian, CentOS/RHEL, Fedora, Arch, openSUSE, SUSE, or generic RPM).
- Updates the package database using the appropriate command (`apt update`, `yum check-update`, `dnf update`, `pacman -Sy`, `zypper refresh`, `dnf check-update`).
- Installs the following components automatically:
- Nginx (or Apache) – web server
- Python 3 – runtime
- PostgreSQL (or MariaDB) – database
- Git – version control
- Snap or Flatpak – to show universal packaging
- Configures the web server to serve a simple “Hello World” page.
- Starts the services with `systemctl start` and ensures they are enabled on boot.
- Installs a minimal firewall rule set (using `iptables` or `nftables`) to expose only HTTP/HTTPS and SSH.
- Writes a status log file `/var/log/webstack-install.log` capturing timestamps, package versions, and any error messages.
- At the end, the script should be idempotent: running it again should detect that everything is already installed and skip re‑installations.
Students will run the script on a fresh VM and present the command sequence, the output logs, and a short video of the web stack in action.
Assessment
- Quick quiz (5 min) – 5 true/false questions about the differences between apt, yum, pacman, snap, etc.
- Hands‑on test (10 min) – each student installs a small package using the three package managers of their choice and verifies the install with a command from the list.
- Project walk‑through (10 min) – peer review of the installer script. The instructor asks questions about each section and the students answer.
Resources
Feel free to tailor the mini‑project to the specific learning goals of your class – e.g., swap PostgreSQL for MySQL, or add a Docker container to the stack. The key is that students gain confidence in using the most common Linux package managers, understand their differences, and can automate a complete software deployment cycle.