Package Management in Linux¶
A package manager in Linux is a software tool used to automate the process of installing, updating, and removing software packages on a Linux system. Below is a detailed guide to package management across various Linux distributions.
1. Debian-Based Systems¶
Distributions: Ubuntu, Debian, Linux Mint
Package Format: .deb
Package Managers¶
dpkg (Low-Level Package Manager)¶
- Commands:
dpkg -i <package>
: Install a package.dpkg -r <package>
: Remove a package.dpkg -L <package>
: List files in a package.dpkg -S <package>
: Search for a package owning a particular file.dpkg --configure -a
: Reconfigure packages.dpkg --purge <package>
: Remove a package including configuration files.dpkg --verify <package>
: Verify the integrity of a package.dpkg -i --force PACKAGENAME
: Force dpkg to install or remove a package.dpkg-query --list
: List all installed packages and libraries.
APT (Advanced Package Tool)¶
- Commands:
apt-get update
: Update the package database.apt-get upgrade
: Upgrade installed packages.apt-get install -f
: Fix broken dependencies or partially downloaded packages.apt upgrade <package>
: Upgrade a specific package.apt install <package>
: Install a package.apt remove <package>
: Remove a package.apt --fix-broken install
: Fix a broken package.apt-cache search <package>
: Search for a package.apt clean
: Clear downloaded packages.apt autoremove
: Clean unneeded dependencies.apt full-upgrade
: Remove or install packages to satisfy dependencies.apt dist-upgrade
: Handle dependency changes.apt install <package>=<version>
: Install a specific version of a package.apt-get check
: Check the system for broken dependencies.
2. Red Hat-Based Systems¶
Distributions: Red Hat Enterprise Linux (RHEL), CentOS, Fedora
Package Format: .rpm
Package Managers¶
rpm (Low-Level Package Manager)¶
- Commands:
rpm -i <package>.rpm
: Install an .rpm package.rpm -e <package>
: Remove a package.rpm -q <package>
: Query a package.rpm --checksig <package>.rpm
: Verify an RPM package.
YUM (Yellowdog Updater, Modified)¶
- Commands:
yum install <package>
: Install a package.yum remove <package>
: Remove a package.yum search <package>
: Search for a package.yum check
: Check for broken dependencies.
DNF (Dandified YUM)¶
- Commands:
dnf install <package>
: Install a package.dnf remove <package>
: Remove a package.dnf search <package>
: Search for a package.dnf downgrade <package>
: Downgrade to a previous version.dnf upgrade
: Upgrade packages.dnf check-update
: Check for updates.dnf check
: Check for broken dependencies.dnf deplist <package>
: Display package dependency tree.dnf list --installed
: List installed packages.
3. SUSE-Based Systems¶
Distributions: openSUSE, SUSE Linux Enterprise Server (SLES)
Package Format: .rpm
Package Manager¶
zypper¶
- Commands:
zypper install <package>
: Install a package.zypper install -f <package>
: Install and fix dependencies.zypper install --download-only <package>
: Download a package without installing.zypper remove <package>
: Remove a package.zypper search <package>
: Search for a package.zypper update
: Update all installed packages.zypper verify
: Identify and fix broken packages.zypper clean
: Clear cache.zypper info --recommends <package>
: List optional recommended dependencies.zypper install --oldpackage <package>=<version>
: Install an older version.zypper se --provides
: Display which package owns a file.
4. Gentoo-Based Systems¶
Distribution: Gentoo
Package Format: Source packages
Package Manager¶
Portage (emerge)¶
- Commands:
emerge <package>
: Install a package.emerge --unmerge <package>
: Remove a package.emerge --search <package>
: Search for a package.emerge --update <package>
: Upgrade a package.emerge --fetchonly <package>
: Download a package without installing.
5. Arch-Based Systems¶
Distributions: Arch Linux, Manjaro
Package Format: .pkg
, .tar
, .zst
Package Manager¶
pacman¶
- Commands:
pacman -S <package>
: Install a package.pacman -R <package>
: Remove a package.pacman -Ss <package>
: Search for a package.pacman -Syu
: Update the system and packages.pacman -Sc
: Clean the cache but keep currently installed files.pacman -Syu
: Perform a full system upgrade.pacman -S <package>
: Upgrade a specific package if already installed.pacman -Dk <package>
: Check for broken dependencies.pacman -Qi <package>
: Show information on a package including dependencies.
6. Alpine Linux¶
Distribution: Alpine
Package Format: .apk
Package Manager¶
apk¶
- Commands:
apk add <package>
: Install a package.apk del <package>
: Remove a package.apk search <package>
: Search for packages.apk info -R <package>
: Display package dependency tree.apk upgrade <package>
: Upgrade a package.apk fetch <package>
: Download a package without installing.
Note¶
Some package managers automatically handle dependency issues during installation or updates. Others may require manual intervention, such as downloading and installing specific versions of packages. Always remove the upgraded version before downgrading.