What Is Package Management?#
A package manager automates the process of installing, upgrading, configuring, and removing software. Instead of downloading binaries from websites and managing dependencies manually, you use a command-line tool that handles everything — fetching packages from repositories, resolving dependency trees, and tracking what’s installed.
Why Package Managers Matter#
| Without | With |
|---|---|
| Download from random websites | Install from trusted repositories |
| Manual dependency hunting | Automatic dependency resolution |
| No easy way to update all software | Single command to update everything |
| Unknown security status | Signed packages, vulnerability tracking |
| Difficult to reproduce environments | Scriptable, reproducible installs |
Chocolatey (Windows)#
Chocolatey is the leading package manager for Windows, bringing Linux-style package management to the Windows ecosystem.
Installation#
# Run in elevated PowerShell (Admin)
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))Essential Commands#
# Search for packages
choco search nodejs
choco search python --exact
# Install
choco install git -y
choco install nodejs python3 vscode -y # Multiple packages
choco install firefox --version=120.0 -y # Specific version
# Upgrade
choco upgrade git -y
choco upgrade all -y # Upgrade everything
# List installed
choco list
# Uninstall
choco uninstall nodejs -y
# Pin (prevent auto-upgrade)
choco pin add --name=python3
choco pin list
choco pin remove --name=python3
# Info about a package
choco info gitConfiguration#
# Enable auto-confirmation globally
choco feature enable -n=allowGlobalConfirmation
# Add custom repository source
choco source add --name=internal --source="https://packages.company.com/nuget"
# Disable default source (for enterprise)
choco source disable --name=chocolateyCommon Packages#
| Package | Install Command |
|---|---|
| Git | choco install git |
| Node.js | choco install nodejs |
| Python | choco install python3 |
| VS Code | choco install vscode |
| Docker Desktop | choco install docker-desktop |
| 7-Zip | choco install 7zip |
| curl | choco install curl |
| OpenSSH | choco install openssh |
APT / DPKG (Debian, Ubuntu, Mint)#
APT (Advanced Package Tool) is the high-level package manager for Debian-based systems. It wraps dpkg, the low-level tool that actually installs .deb packages.
flowchart LR
USER["User"] -->|"apt install"| APT["APT<br/>(resolves deps, downloads)"]
APT -->|"downloads .deb"| REPO["Repository"]
APT -->|"hands .deb to"| DPKG["dpkg<br/>(installs package)"]
DPKG --> FS["File System"]APT Commands#
# Update package index (always do this first)
sudo apt update
# Upgrade installed packages
sudo apt upgrade # Safe upgrade (won't remove packages)
sudo apt full-upgrade # May remove packages to resolve conflicts
# Search
apt search nginx
apt show nginx # Package details
# Install
sudo apt install nginx
sudo apt install nginx=1.24.0-1 # Specific version
sudo apt install ./package.deb # Local .deb file
sudo apt install -y build-essential # Auto-confirm
# Remove
sudo apt remove nginx # Remove package (keep config)
sudo apt purge nginx # Remove package + config
sudo apt autoremove # Remove orphaned dependencies
# List
apt list --installed
apt list --upgradable
dpkg -l | grep nginx # Low-level listingDPKG (Low-Level)#
# Install .deb directly
sudo dpkg -i package.deb
# Fix broken dependencies after dpkg install
sudo apt install -f
# List files installed by a package
dpkg -L nginx
# Find which package owns a file
dpkg -S /usr/sbin/nginx
# Package info
dpkg -s nginx
# List installed packages
dpkg --get-selections | grep -v deinstallRepository Management#
# Add repository
sudo add-apt-repository ppa:deadsnakes/ppa # PPA (Ubuntu)
sudo apt update
# Manual repo (e.g., Docker)
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker.gpg
echo "deb [signed-by=/usr/share/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list
sudo apt update
# List configured repos
cat /etc/apt/sources.list
ls /etc/apt/sources.list.d/DNF (Fedora, RHEL 8+, CentOS Stream, Rocky, Alma)#
DNF (Dandified YUM) is the next-generation package manager for Red Hat-based systems, replacing YUM with better dependency resolution and performance.
Commands#
# Update package index + upgrade
sudo dnf check-update # Check for updates (no install)
sudo dnf upgrade # Upgrade all packages
sudo dnf upgrade --security # Security updates only
# Search
dnf search nodejs
dnf info nodejs
# Install
sudo dnf install nginx
sudo dnf install nginx-1.24.0 # Specific version
sudo dnf install ./package.rpm # Local RPM
sudo dnf install @development # Install group (dev tools)
sudo dnf groupinstall "Development Tools"
# Remove
sudo dnf remove nginx
sudo dnf autoremove # Remove orphaned dependencies
# List
dnf list installed
dnf list available | grep python
dnf list --upgrades
# History (undo operations)
dnf history
sudo dnf history undo 15 # Undo transaction #15
# Provides (find which package has a file)
dnf provides /usr/bin/dig
dnf provides "*/bin/htop"Repository Management#
# List repos
dnf repolist
dnf repolist all # Including disabled
# Add repo
sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo
# Enable/disable
sudo dnf config-manager --set-enabled powertools # RHEL/Rocky
sudo dnf config-manager --set-disabled testing
# EPEL (Extra Packages for Enterprise Linux)
sudo dnf install epel-releaseModules (AppStreams)#
DNF modules let you choose between multiple versions of software:
# List available modules
dnf module list
dnf module list nodejs
# Enable specific version stream
sudo dnf module enable nodejs:20
sudo dnf install nodejs
# Switch versions
sudo dnf module reset nodejs
sudo dnf module enable nodejs:18
sudo dnf install nodejsYUM (Amazon Linux, RHEL 7, CentOS 7)#
YUM (Yellowdog Updater Modified) is the predecessor to DNF. Still used on Amazon Linux 2 and older RHEL/CentOS systems. Syntax is nearly identical to DNF.
Commands#
# Update
sudo yum check-update
sudo yum update # Upgrade all
sudo yum update nginx # Upgrade specific package
# Search and info
yum search httpd
yum info httpd
# Install
sudo yum install httpd
sudo yum install httpd-2.4.6 # Specific version
sudo yum localinstall package.rpm # Local RPM
sudo yum groupinstall "Development Tools"
# Remove
sudo yum remove httpd
sudo yum autoremove
# List
yum list installed
yum list available | grep python
# Find which package provides a file
yum provides /usr/bin/wget
# History
yum history
sudo yum history undo 12
# Clean cache
sudo yum clean all
sudo yum makecacheAmazon Linux Specifics#
# Amazon Linux 2 extras (topic-based packages)
amazon-linux-extras list
sudo amazon-linux-extras install docker
sudo amazon-linux-extras install python3.8
# Amazon Linux 2023 uses DNF
sudo dnf install httpdRepository Management#
# List repos
yum repolist
# Add repo
sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo
# Enable/disable
sudo yum-config-manager --enable epel
sudo yum-config-manager --disable testing
# Install EPEL
sudo yum install epel-release # CentOS/RHEL
sudo amazon-linux-extras install epel # Amazon Linux 2Homebrew (macOS and Linux)#
Homebrew is the most popular package manager for macOS, also available on Linux. It installs software to its own directory and symlinks into standard paths.
Installation#
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"Terminology#
| Term | Meaning |
|---|---|
| Formula | Package definition (command-line tools) |
| Cask | macOS GUI application (e.g., Firefox, VS Code) |
| Tap | Third-party repository of formulae |
| Cellar | Where Homebrew installs packages (/opt/homebrew/Cellar/) |
| Keg | Specific version of a formula in the Cellar |
Commands#
# Update Homebrew itself + package index
brew update
# Search
brew search node
brew search --cask firefox
# Install
brew install git
brew install node@20 # Specific version
brew install --cask firefox # GUI app
brew install --cask visual-studio-code
# Upgrade
brew upgrade # All formulae
brew upgrade git # Specific
brew upgrade --cask # All casks
brew upgrade --cask firefox
# List installed
brew list
brew list --cask
brew leaves # Top-level (not dependencies)
# Info
brew info git
brew info --cask firefox
# Uninstall
brew uninstall node
brew uninstall --cask firefox
# Cleanup (remove old versions)
brew cleanup
brew cleanup --prune=7 # Remove downloads older than 7 days
# Diagnostics
brew doctor # Check for problems
brew config # Show configurationServices (Background Daemons)#
# Start/stop services (replaces launchctl)
brew services list
brew services start postgresql@16
brew services stop redis
brew services restart nginx
# Run once (foreground, no auto-start)
brew services run postgresql@16Taps (Third-Party Repos)#
# Add tap
brew tap hashicorp/tap
brew install hashicorp/tap/terraform
# Common taps
brew tap homebrew/cask-fonts # Fonts
brew tap homebrew/cask-versions # Beta/alternate versions
# List taps
brew tapPinning (Prevent Upgrades)#
brew pin node@20
brew unpin node@20
brew list --pinnedBundler (Brewfile)#
Define all your packages in a Brewfile for reproducible setups:
# Brewfile
tap "homebrew/cask"
tap "hashicorp/tap"
# CLI tools
brew "git"
brew "node@20"
brew "python@3.12"
brew "jq"
brew "ripgrep"
brew "terraform"
# GUI apps
cask "firefox"
cask "visual-studio-code"
cask "docker"
cask "iterm2"
# Fonts
cask "font-jetbrains-mono"# Install everything from Brewfile
brew bundle
# Check what's missing
brew bundle check
# Clean up packages not in Brewfile
brew bundle cleanupQuick Reference#
| Action | Chocolatey | APT | DNF | YUM | Homebrew |
|---|---|---|---|---|---|
| Update index | — | apt update | dnf check-update | yum check-update | brew update |
| Upgrade all | choco upgrade all | apt upgrade | dnf upgrade | yum update | brew upgrade |
| Install | choco install X | apt install X | dnf install X | yum install X | brew install X |
| Remove | choco uninstall X | apt remove X | dnf remove X | yum remove X | brew uninstall X |
| Search | choco search X | apt search X | dnf search X | yum search X | brew search X |
| List installed | choco list | apt list --installed | dnf list installed | yum list installed | brew list |
| Info | choco info X | apt show X | dnf info X | yum info X | brew info X |
| Clean | — | apt autoremove | dnf autoremove | yum autoremove | brew cleanup |
Key Takeaways#
- Always update the index first —
apt update,brew update,dnf check-updatebefore installing - Use the system’s native package manager — it handles dependencies, updates, and security patches
- Pin critical packages to prevent unintended upgrades in production
- Prefer repository packages over manual installs — they get security updates automatically
- Use Brewfiles / package lists to document and reproduce development environments
- DNF replaces YUM — same commands, better performance and dependency resolution
- Chocolatey brings Linux-style management to Windows — essential for automation and reproducibility