Stop 02 · Linux & Networking BasicsTopics · 3/9

Linux Package Managers

Part of the AWS Roadmap

In short

A fresh cloud VM has almost nothing installed. Nginx, Docker, Python, Git: all of it comes through the package manager. One command, the right version, and every dependency sorted for you.

Package managers install, update and remove software along with its dependencies. Ubuntu uses apt, while Amazon Linux 2023 uses dnf, and you will use them in EC2 user data scripts all the time.

The blob character waits at a grocery counter while the shopkeeper picks packets off shelves.

Think of it like this

The kirana store list

You don't visit five factories for atta, oil and soap. You tell the kirana uncle 'one Maggi', and he picks the right packet from his shelves and maybe reminds you about the tastemaker. A package manager is that shopkeeper for software.

Watch it happen

What apt install really does

You
apt
Ubuntu repo

sudo apt update

1/6First, refresh the local catalogue of what's available. This doesn't install anything yet.

The big ideas

What you need to know

One tool per family

Ubuntu and Debian use apt. Amazon Linux, RHEL and Fedora use dnf (older ones use yum). Alpine uses apk.

Update the list first

apt update refreshes what's available. apt upgrade actually installs newer versions of what you have.

Dependencies handled

The manager installs everything a package needs, at compatible versions, so you don't hunt for libraries yourself.

Signed and trusted

Repos sign their packages. Adding random third-party repos means trusting whoever runs them.

See it in code

Walk through the code

bash
1# Ubuntu / Debian2sudo apt update3sudo apt install -y nginx git4apt list --installed | grep nginx5sudo apt remove nginx6 7# Amazon Linux 2023 / RHEL / Fedora8sudo dnf install -y nginx git9dnf list installed nginx

1/3Refresh the catalogue, then install two packages in one go.

-y answers 'yes' automatically, which you need in scripts and server setup that run without a human.

Save yourself the pain

Common mistakes

Oops

Running apt install on a fresh VM and getting 'Unable to locate package'.

Do this instead

Run sudo apt update first. A new machine's package list is often empty or stale.

Oops

Using apt commands on Amazon Linux because a tutorial said so.

Do this instead

Check the OS with cat /etc/os-release, then use the matching manager: dnf there, apt on Ubuntu.

Your mission

Set up a web server from scratch

~25 min

Quick check

What does sudo apt update do?

Go deeper

  1. 1Install and remove a package such as htop with apt on Ubuntu.
  2. 2Launch an Amazon Linux 2023 instance later and install Nginx with dnf.
  3. 3Learn why you run an update command before installing packages on a new server.

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