Stop 02 · Linux & Command LineTopics · 5/11

Package Managers (apt, yum)

Part of the DevOps Roadmap

In short

Need nginx, git or Python on a fresh server? You don't hunt for installers on websites. One command fetches it, checks it is genuine, and installs everything it depends on.

Tools for installing, updating and removing software on Linux — apt on Debian/Ubuntu-based systems, yum/dnf on RHEL/CentOS-based systems — a core daily-use skill for setting up any server.

The mascot at a neighbourhood grocery counter receives a basket of neatly packed goods.

Think of it like this

The kirana uncle's home delivery

You send the kirana uncle a list: 'atta, oil, Maggi'. He knows which shelf each is on, sends genuine packets, and even adds the masala sachet Maggi needs. A package manager does the same for software: you name it, it brings it with every dependency.

Watch it happen

What apt install nginx does

You
apt
Repository

sudo apt update

1/5First, apt refreshes its list of which packages and versions the repositories offer.

The big ideas

What you need to know

Two big families

Debian and Ubuntu use apt with .deb files. RHEL, Fedora and Rocky use dnf (the newer yum) with .rpm files.

update vs upgrade

apt update refreshes the list of available versions. apt upgrade actually installs newer versions of what you have.

Signed repositories

Packages are signed with keys. apt refuses unsigned or tampered packages, which keeps random downloads out.

Pin versions in automation

In scripts, install a specific version when it matters, so a new release doesn't surprise you mid-deploy.

See it in code

Walk through the code

bash
1# Debian / Ubuntu2sudo apt update3sudo apt install -y nginx4apt list --installed | grep nginx5sudo apt remove nginx6 7# RHEL / Rocky / Fedora8sudo dnf install -y nginx9dnf info nginx

1/3Refresh the package list, then install nginx without stopping to ask.

-y answers 'yes' automatically, which you need in scripts. Use it carefully when running by hand.

Save yourself the pain

Common mistakes

Oops

Running apt install on a new server and getting 'unable to locate package'.

Do this instead

Run sudo apt update first. A fresh machine often has an empty or outdated package list.

Oops

Downloading random .deb files from blogs and installing them with dpkg.

Do this instead

Prefer official repositories. If you must add a third-party repo, use the vendor's documented signing key.

Your mission

Install, use, remove

~15 min

Quick check

You run apt install on a new Ubuntu server and it can't find a package that definitely exists. What should you try first?

Go deeper

  1. 1Practice installing, updating, and removing a package using your distribution's package manager.
  2. 2Learn to search for available packages before installing something blindly.
  3. 3Understand the difference between a package manager and manually compiling software from source.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge