Repositories and Packages
In Linux, you rarely download installers from websites. Instead, you use a Package Manager that downloads verified, compiled software from official repositories. This gives you:
- Security — packages are signed and verified
- Updates —
apt update && apt upgradeupdates everything at once - Clean removal —
apt removecleanly uninstalls, including dependencies
Package managers resolve dependencies automatically. If you install NGINX, it installs OpenSSL, PCRE, zlib, and all other required libraries automatically.
Debian / Ubuntu — APT
The Advanced Package Tool (apt) manages .deb packages on Debian-based systems (Ubuntu, Debian, Linux Mint).
Essential Commands
# Update the local package index (always do this before installing)
$ sudo apt update
Hit:1 http://archive.ubuntu.com/ubuntu jammy InRelease
Reading package lists... Done
Building dependency tree... Done
All packages are up to date.
# Upgrade all installed packages to their latest versions
$ sudo apt upgrade -y
Reading package lists... Done
Building dependency tree... Done
The following packages will be upgraded:
openssl 2 packages upgraded, 0 newly installed, 0 to remove.
Need to get 2.5 MB of archives.
After this operation, 156 kB of additional disk space will be used.
# Full upgrade (can remove packages to resolve dependencies)
$ sudo apt full-upgrade -yInstalling and Removing Software
# Install a package
$ sudo apt install nginx -y
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
nginx nginx-common nginx-core
0 upgraded, 3 newly installed, 0 to remove.
Setting up nginx ...
# Install multiple packages at once
$ sudo apt install curl git vim -y
# Install specific version
$ sudo apt install nginx=1.18.0-6ubuntu14
# Remove a package (keeps configuration files)
$ sudo apt remove nginx
# Remove package AND delete its config files
$ sudo apt purge nginx
# Remove unused packages (orphaned dependencies)
$ sudo apt autoremove -ySearching for Packages
# Search for a package by name or description
$ apt search "web server"
Sorting... Done
Full Text Search... Done
nginx/jammy,now 1.18.0-6ubuntu14 amd64 [installed]
nginx high performance web server
apache2/jammy,now 2.4.52-1ubuntu3 amd64 [installed]
Apache HTTP Server
# Show package details
$ apt show nginx
Package: nginx
Version: 1.18.0-6ubuntu14
Section: httpd
Priority: optional
Description: nginx high performance web server
Homepage: https://nginx.org
# Check if a package is installed
$ apt list --installed | grep nginx
nginx/jammy,now 1.18.0-6ubuntu14 amd64 [installed]Package States
| State | Meaning |
|---|---|
ii | Installed |
rc | Removed but config files remain |
iU | Unpacked but not configured |
pn | Purged (never installed) |
# List installed packages
$ dpkg -l | head -10
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-=============================-====================-============-===================================
ii adduser 3.131ubuntu1 all add and remove users and groups
ii apt 2.4.8 amd64 commandline package manager
ii bash 5.1-6ubuntu1 amd64 GNU Bourne Again SHellRed Hat / CentOS / Fedora — DNF
Modern RHEL-based systems use DNF (Dandified YUM) to manage .rpm packages.
# Install software
$ sudo dnf install httpd -y
Last metadata expiration check: 0:01:23 ago on Thu Apr 10 09:00:00 2026.
Dependencies resolved.
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
httpd x86_64 2.4.37-43 rhel-8-baseos 1.4 M
...
Complete!
# Update all packages
$ sudo dnf update -y
# Remove a package
$ sudo dnf remove httpd -y
# Search for packages
$ dnf search nginx
# or
$ dnf list | grep nginx
# Show package info
$ dnf info httpdYUM (Legacy RHEL 6/7)
# Same commands with yum
$ sudo yum install nginx -y
$ sudo yum update -y
$ sudo yum remove nginx -y
$ sudo yum search nginxAlpine Linux — APK
Alpine uses apk — the fastest package manager. It's the standard in Docker containers because images are so lightweight.
# Install a package (no cache — ideal for Docker)
$ apk add --no-cache python3
fetch https://dl-cdn.alpinelinux.org/alpine/v3.18/main/x86_64/APKINDEX.tar.gz
(1/10) Installing python3 (3.11.7-r0)
...
(10/10) Installing python3 (3.11.7-r0)
OK: 65 MiB
# Search for packages
$ apk search nginx
# Show info about a package
$ apk info nginx
nginx-1.24.0-r0 description:
HTTP and reverse proxy server
# List installed packages
$ apk list --installed
# Remove a package
$ apk del nginx
# Update all packages
$ apk upgradeThe
--no-cache flag prevents apk from storing its package index locally. In Docker, this keeps images smaller and eliminates unnecessary layers. Always use --no-cache in Dockerfiles.Managing Repositories
APT — Adding a PPA (Personal Package Archive)
# Add a repository (PPA)
$ sudo add-apt-repository ppa:nginx/stable
$ sudo apt update
$ sudo apt install nginx
# Add a repository by source line
$ sudo apt add-apt-repository "deb http://repo.example.com/ stable main"APT — Adding a Repository Key and Source
# Add Docker's official repository (example)
$ sudo apt install ca-certificates curl gnupg
$ sudo install -m 0755 -d /etc/apt/keyrings
$ curl -fsSL https://download.docker.com/linux/ubuntu/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
$ echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
$ sudo apt update
$ sudo apt install docker-ceChecking Package Dependencies
# APT — show what a package requires
$ apt depends nginx
nginx
Depends: nginx-core
Depends: nginx-common
Depends: libc6
Depends: libpcre3
# APT — show what a package provides
$ apt rdepends nginx
nginx reverse depends:
apache2
(none)System Updates as a DevOps Workflow
Automated Security Updates
# Install unattended-upgrades (Ubuntu/Debian)
$ sudo apt install unattended-upgrades -y
# Enable automatic security updates
$ sudo dpkg-reconfigure unattended-upgrades
# Or configure manually
$ sudo nano /etc/apt/apt.conf.d/50unattended-upgradesDocker Base Image Updates
# Dockerfile pattern for keeping images updated
FROM ubuntu:22.04
RUN apt-get update && \
apt-get upgrade -y && \
apt-get autoremove -y && \
apt-get clean && \
rm -rf /var/lib/apt/lists/*Quick Reference
| Task | APT (Debian/Ubuntu) | DNF (RHEL/Fedora) | APK (Alpine) |
|---|---|---|---|
| Update package list | apt update | dnf check-update | apk update |
| Install package | apt install pkg | dnf install pkg | apk add pkg |
| Remove package | apt remove pkg | dnf remove pkg | apk del pkg |
| Update all packages | apt upgrade | dnf update | apk upgrade |
| Search packages | apt search pkg | dnf search pkg | apk search pkg |
| Show package info | apt show pkg | dnf info pkg | apk info pkg |
| List installed | dpkg -l | dnf list --installed | apk list --installed |
| Clean cache | apt clean | dnf clean all | apk cache clean |
Practice Challenge
- Run
apt updateand see how many packages can be upgraded - Use
apt searchto find a package related to your work (e.g.,htop) - Install
htop(orbpytop) using your system's package manager - Run the installed program and confirm it works
- Remove the package you just installed
- Use
apt showto see details about thecurlpackage — what dependencies does it have?