APT Reference
APT (Advanced Package Tool) is the package management system for Debian-based distributions.
Basic Operations
Install Packages
# Update package lists first
sudo apt update
# Install package
sudo apt install vim
# Install multiple packages
sudo apt install vim tmux htop
# Install without prompts
sudo apt install -y package
# Install specific version
sudo apt install package=1.2.3-1
Querying Packages
Search Packages
# Search by name/description
apt search term
# Search package names only
apt search --names-only term
Package State Management
Repository Management
sources.list
Main repository configuration at /etc/apt/sources.list:
# Debian 12 (Bookworm)
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
# Ubuntu 24.04 (Noble)
deb http://archive.ubuntu.com/ubuntu noble main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu noble-security main restricted universe multiverse
dpkg Commands
Low-level package operations:
Install/Remove
# Install from .deb file
sudo dpkg -i package.deb
# Remove package
sudo dpkg -r package
# Purge package
sudo dpkg -P package
# Fix broken dependencies after dpkg
sudo apt --fix-broken install
Configuration
Troubleshooting
Common Issues
# Fix broken packages
sudo apt --fix-broken install
# Reconfigure dpkg
sudo dpkg --configure -a
# Force install
sudo apt install -f
# Clear cache and retry
sudo apt clean
sudo apt update