Ravindra BagaleCourses & study guides

Chapter 3: Linux Basic Commands

3.7 Package managers

Think of a package manager like the Play Store on your phone — you ask for an app, it downloads it from a trusted store along with everything it needs. But technically, it is fetching signed packages from configured repositories and resolving dependencies. Bagha, the commands differ slightly between distributions:

A package manager downloads software from trusted repositories, installs dependencies automatically, and handles updates.

Task Ubuntu / Debian (apt) Amazon Linux 2023, Amazon Linux 2, CentOS Stream 9 (yum)
Refresh package list sudo apt update (automatic) sudo yum makecache
Upgrade all sudo apt upgrade -​y sudo yum update -​y
Install sudo apt install -​y nginx sudo yum install -​y nginx*
Remove sudo apt remove nginx (purge removes config too) sudo yum remove nginx
Search apt search php yum search php
Info apt show nginx yum info nginx
List installed apt list --​installed yum list installed
Which package gives a file dpkg -​S /​usr/​sbin/​nginx yum provides /​usr/​sbin/​nginx
Clean cache sudo apt autoremove && sudo apt clean sudo yum clean all
Package file format .deb (dpkg -i) .rpm (rpm -i)

* On Amazon Linux 2, some packages come from amazon-linux-extras (e.g. sudo amazon-linux-extras install nginx1). Amazon Linux 2023 has no amazon-linux-extras; everything is in the regular repositories.

yum or dnf? Kalji karu naka

In this book I use yum on Amazon Linux and CentOS because it works everywhere in the Red Hat family. On newer systems (Amazon Linux 2023, CentOS Stream 9, RHEL 9) yum is simply an alias that actually runs dnf, the newer package manager — so when you see dnf install ... in online guides, it is the same thing. Same options, same repositories.

CentOS Stream: enable EPEL for extra packages

Some tools (e.g. htop, certbot) come from the EPEL repository: sudo yum install -y epel-release on CentOS Stream 9.