https://drive.google.com/file/d/1iCy_wkZePV-JjJs2tVoH07h5QcmumdkL/view?usp=sharing
| Distribution | Package Format | Low-Level Tool | High-Level Tool |
|---|---|---|---|
| Debian/Ubuntu | .deb |
dpkg |
apt, aptitude |
| RHEL/Fedora/CentOS | .rpm |
rpm |
yum (RHEL 7), dnf (RHEL 8+) |
💡 Key Concept:
- Low-level tools (
dpkg,rpm) handle single packages (no dependencies)- High-level tools (
apt,dnf) resolve dependencies automatically
dpkg# List installed packages
dpkg -l
dpkg -l | wc -l # Count installed packages
dpkg -l apache2 # Search specific package
# Find which package owns a file
dpkg -S /usr/share/doc/rsync # File path
dpkg -S rsync # Filename
# List files in a package
dpkg -L apache2
# Install/remove packages (no dependencies!)
sudo dpkg -i package.deb # Install
sudo dpkg -r apache2 # Remove (keep config)
sudo dpkg -P apache2 # Purge (remove config too)
apt# Update package lists
sudo apt update
# Install/remove packages
sudo apt install apache2
sudo apt remove apache2 # Keep config
sudo apt purge apache2 # Remove config
# Search packages
apt-cache search apache2
apt list --installed | grep apache
# Clean package cache
sudo apt clean # Remove all .deb files
ls /var/cache/apt/archives/ # Package cache location
aptitudesudo aptitude update
sudo aptitude safe-upgrade # Safe system upgrade
sudo aptitude install apache2
sudo aptitude search apache2
sudo aptitude purge apache2
# View repositories
cat /etc/apt/sources.list
# Add repository
sudo add-apt-repository ppa:repository/name
# Add GPG key
wget -qO - <https://repo.example.com/key.gpg> | sudo apt-key add -
rpm# Query packages
rpm -qa # List all installed
rpm -qa | wc -l # Count packages
rpm -qa | grep samba # Search packages
rpm -qi httpd # Package info
# Install/remove (no dependencies!)
sudo rpm -ivh package.rpm # Install (-v=verbose, -h=progress)
sudo rpm -e httpd # Remove
sudo rpm -Uvh package.rpm # Upgrade
# Package database location
ls /var/lib/rpm # RPM database
# Extract RPM contents
rpm2cpio package.rpm | cpio -t # List files in RPM
rpm2cpio package.rpm > package.cpio # Convert to cpio archive
dnf (RHEL 8+) / yum (RHEL 7)