Lesson  in  Linux for SRE / DevOps - Beginner Level

Installing Things Without Breaking Things

on Linux
Package managers across families (apt vs. dnf/yum), install/remove/update, and why "which distro am I on" changes everything.

The first thing to establish on any unfamiliar box: which package manager does it use? It's determined by the distro family, and get it wrong and every command you try will simply not exist.

FamilyDistrosManagerInstallUpdate everything
DebianUbuntu, Debianaptapt install pkgapt update && apt upgrade
Red HatRHEL, Rocky, Alma, Fedoradnf (or older yum)dnf install pkgdnf upgrade

This box runs Ubuntu, so it's apt. Log into a Rocky Linux box tomorrow and every one of these commands changes to dnf - same job, different tool. Part of "know your machine" from lesson 2 is exactly this: check /etc/os-release if you're ever not sure which family you're on.

The commands you'll actually use

sudo apt update                    # refresh the list of what's available - always do this first
sudo apt install -y packagename       # install something (-y skips the confirmation prompt)
sudo apt remove packagename            # remove it, config files kept
sudo apt purge packagename              # remove it, config files gone too
apt list --installed | grep name          # is something already here

apt update doesn't install or upgrade anything by itself - it only refreshes apt's local list of what versions exist. Skip it and apt install may try to fetch a version that no longer exists on the mirror.

Install what's missing

jq - a command-line JSON processor, genuinely useful for reading API responses and structured logs - isn't installed on this box. Get it:

sudo apt update
sudo apt install -y jq
Selecting previously unselected package jq.
Preparing to unpack .../jq_1.7.1-3ubuntu0.24.04.2_amd64.deb ...
Unpacking jq (1.7.1-3ubuntu0.24.04.2) ...
Setting up libonig5:amd64 (6.9.9-1build1) ...
Setting up libjq1:amd64 (1.7.1-3ubuntu0.24.04.2) ...
Setting up jq (1.7.1-3ubuntu0.24.04.2) ...

Two things worth noticing in that output: apt pulled in libonig5 and libjq1 alongside jq itself, without being asked - those are dependencies, libraries jq needs to actually run, and apt resolved and installed them automatically. This is exactly what apt update beforehand makes possible: apt already knew which dependency versions existed and matched. Confirm it actually works, not just installed:

echo '{"ok":true}' | jq .
{
  "ok": true
}

jq read the compact JSON from echo on stdin and pretty-printed it - proof the install produced a working command, not just files on disk.

apt install fails with a package not found

Run sudo apt update first. Package lists are only as fresh as the last time you refreshed them.

Previous lesson
What's Actually Running