|$ curl https://forge-ai.dev/api/markdown?path=docs/linux/packages
$cat docs/package-management.md
updated Recently·18 min read·published
Package Management
Introduction
Package managers handle software installation, dependency resolution, upgrades, and removal. Knowing your distribution's package manager saves time and keeps systems consistent and secure.
apt (Debian / Ubuntu)
apt.sh
Bash
| 1 | sudo apt update # refresh package index |
| 2 | sudo apt upgrade # upgrade installed packages |
| 3 | sudo apt full-upgrade # upgrade with dependency changes |
| 4 | sudo apt install nginx # install a package |
| 5 | sudo apt remove nginx # remove package, keep config |
| 6 | sudo apt purge nginx # remove package and config |
| 7 | sudo apt autoremove # clean unused dependencies |
| 8 | sudo apt search nginx # search packages |
| 9 | apt show nginx # package details |
dnf (Fedora / RHEL / Rocky)
dnf.sh
Bash
| 1 | sudo dnf update |
| 2 | sudo dnf install nginx |
| 3 | sudo dnf remove nginx |
| 4 | sudo dnf search nginx |
| 5 | dnf info nginx |
| 6 | sudo dnf autoremove |
pacman (Arch Linux)
pacman.sh
Bash
| 1 | sudo pacman -Syu # sync, refresh, upgrade |
| 2 | sudo pacman -S nginx # install |
| 3 | sudo pacman -R nginx # remove |
| 4 | sudo pacman -Rs nginx # remove with unused dependencies |
| 5 | sudo pacman -Ss nginx # search |
| 6 | pacman -Qi nginx # info |
apk (Alpine Linux)
apk.sh
Bash
| 1 | apk update |
| 2 | apk add nginx |
| 3 | apk del nginx |
| 4 | apk search nginx |
| 5 | apk info nginx |
ℹ
info
Alpine is extremely popular for Docker containers because its package index is small and images are minimal.
Universal Package Formats
universal.sh
Bash
| 1 | # Snap (Ubuntu, cross-distro) |
| 2 | sudo snap install code --classic |
| 3 | sudo snap remove code |
| 4 | |
| 5 | # Flatpak (cross-distro, sandboxed) |
| 6 | flatpak install flathub com.spotify.Client |
| 7 | flatpak run com.spotify.Client |
| 8 | |
| 9 | # AppImage |
| 10 | chmod +x MyApp.AppImage |
| 11 | ./MyApp.AppImage |
Installing From Source
source.sh
Bash
| 1 | # Typical build workflow |
| 2 | cd /tmp |
| 3 | curl -L -o app.tar.gz https://example.com/app.tar.gz |
| 4 | tar -xzf app.tar.gz |
| 5 | cd app |
| 6 | ./configure --prefix=/usr/local |
| 7 | make |
| 8 | sudo make install |
⚠
warning
Installing from source bypasses the package manager and makes updates and uninstallation harder. Prefer packaged versions when available.