█
LastWrite
  • > Curriculum
  • > Pricing
  • > For Educators
  • > About
  • > Contact
Log InGet Started

Questions, concerns, bug reports, or suggestions? We read every message, write to us at [email protected].

More ways to reach us →
LastWrite

Structured computer science lessons for aspiring developers and security professionals.

[email protected]

(201) 785-7951

Mon–Fri, 9 AM–5 PM EST

Learn

  • Curriculum
  • Pricing

Company

  • About
  • For Educators & Schools
  • Contact Us

Legal

  • Terms of Service
  • Privacy Policy
© 2026 LastWrite. All rights reserved.
Curriculum/DevOps and Infrastructure/Linux and the Command Line/Package Management
30 minBeginner

Package Management

After this lesson, you will be able to: Install, remove, and keep packages updated using apt (Debian/Ubuntu) and dnf/yum (Red Hat/Fedora).

Every Linux server needs software installed and kept current. Package managers handle that; knowing yours is mandatory.

Prerequisites:SSH

apt (Debian, Ubuntu)

The most-used package manager. Memorise these commands.

bash
sudo apt update # refresh package index
sudo apt upgrade # upgrade installed packages
sudo apt install nginx # install a package
sudo apt install -y nginx jq curl # multiple at once, no prompt
sudo apt remove nginx # remove (leaves config)
sudo apt purge nginx # remove + config
sudo apt autoremove # clean up orphaned deps
apt show nginx # info about a package
apt list --installed # everything installed
apt search 'web server' # find packages

dnf / yum (Red Hat, Fedora, Amazon Linux)

Same shape, different syntax. yum is the older name; dnf is the modern version.

bash
sudo dnf check-update # see what's available
sudo dnf upgrade # upgrade all
sudo dnf install nginx
sudo dnf remove nginx
sudo dnf info nginx
sudo dnf search 'web server'
# On older systems / Amazon Linux 1:
sudo yum install nginx # interchangeable with dnf

💡 On macOS: Homebrew

macOS has no built-in package manager, so developers use Homebrew (`brew`). `brew install <pkg>` installs CLI tools and apps, `brew upgrade` updates them, `brew list` shows what is installed. It is how you get git, jq, the AWS CLI, and most dev tools onto a Mac. The mental model is identical to apt/dnf; only the command name changes. On servers you will use apt or dnf, but your local Mac dev box almost certainly uses brew.

Keeping packages current (unattended upgrades)

Security patches publish daily. Manual `apt update` cadence fails. Ubuntu: install `unattended-upgrades` and enable security upgrades automatically. Red Hat: `dnf-automatic.timer`. Both apply security patches without rebooting (except kernel updates, which need a reboot, see `needrestart` to detect).

💡 Lockfile-style determinism in production

For deployable systems, pin package versions explicitly: `apt install nginx=1.24.0-1ubuntu1`. For language packages (npm, pip, cargo), use lockfiles (package-lock.json, requirements.txt with ==, Cargo.lock). Surprise package upgrades break production. Pin and let CI catch upgrades intentionally.

Common mistakes only experienced engineers avoid

Running `apt upgrade` on a production server without testing in staging. Sometimes a config-file prompt or a service restart breaks things. Mixing language package managers (apt's `python3-django` and pip's `Django`). They conflict; pick one per project. Forgetting `apt update` before `apt install`. Without it, you install whatever the local cache last saw, possibly months old. Installing third-party `.deb` files without checking signatures. Always prefer official apt repos.

Quick Check

On Ubuntu, what's the difference between `apt remove nginx` and `apt purge nginx`?

Pick the concise answer.

Sign in and purchase access to unlock this lesson.

Sign in to purchase
←SSH
Back to Linux and the Command Line
Text Processing: awk, sed, cut→