Ravindra BagaleCourses & study guides मराठी Track your progress

Chapter 3: Linux Basic Commands

3.7 Package managers

Think of a package manager like the Play Store on your mobile – you ask for an app and it downloads it from a trusted store, along with all the dependencies it needs. But technically, a package manager fetches signed packages from configured repositories and resolves dependencies. Look, the commands differ a little by distribution:

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.

Ravindra Bagale's Tip

Many students type apt install on Amazon Linux and get command not found. First look at cat /etc/os-release: Amazon Linux/CentOS = sudo yum, Ubuntu = sudo apt. And if an online guide shows dnf, don't worry – on AL2023 yum does the same job.

Lab

Chala, tumchya Amazon Linux 2023 instance var sudo yum install -y tree kara, mag yum info tree aani yum list installed | grep tree chalva. Shevti sudo yum remove -y tree karun tree command aata chalat nahi he check kara.

Got it? First identify the OS, then choose the package manager. Now let's move on to processes.