Major Packaging Systems Disambiguation 📦 (2024-08-21)

Package Formats

Package formats are the way that software data is organized for distribution prior to installation. Every major Linux branch will have a package format it utilizes. The two most major types are .deb and .rpm. They are found on Debian based distros and Red Hat based distros respectively. Package installers and managers exist for every format and there are typically several for each type that "wrap" or encapsulate another, and sometimes its even in a nested sense. They can be described as having levels such as: "low", "medium", and "high".

.deb

A .deb package is the package used for Debian based distributions. The most major ones being Debian itself and Ubuntu. Deb packages consist three ordered files. Two are tar archives that support compression. One for the metadata known as control information and another for the installable data. The third is a file containing the format version number.

.deb structure

  • The structure of a .deb package

dpkg

Dpkg is a low level packaging tool. It isn't a package manager because it doesn't actually manage the packages and dependencies. The dpkg command can be used to install and remove .deb files directly.

  • dpkg -i filename.deb installs a package
  • dpkg -l lists files that match a pattern
  • dpkg -S searches for a filename from installed packages
  • dpkg -r packagename removes an installed packages The packages dpkg and dpkg-dev contain the suit of utilities and development tools respectively.

apt-get and apt

Apt-get is a medium level package manager that utilizes dpkg. It can be thought of as a front-end for dpkg. Apt is a wrapper for apt-get that supports greater functionality such as: better dependency resolution, native search capabilities, and autoremoval of orphaned packages during upgrades. Apt is an amalgamation of the functionalities of separate utilities like apt-get and apt-cache. It is recommended that apt-get be reserved for automation. But for the most part apt and apt-get have the same sub-commands and functionality. Apt and Apt-get share the following:

  • apt update syncs the package indexes and sources
  • apt upgrade installs the current versions of packages
  • apt install installs individual or listed packages
  • apt clean clears cache of package files
  • apt autoclean only clears package files that can no longer be downloaded.

apt exclusive

apt search, apt show, apt policy, apt purge apt also has a set of sub-commands not found in apt-get such as:

  • apt search searches the list of packages for a regex term.
  • apt show outputs information on a given package

apt Frontends

The are graphical front ends for apt as well like the following:

.rpm

The counterpart to .deb in Red Hat based and upstream distros is the .rpm package format. The file has the naming convention: name-version-release-arch.rpm. This name is appended with -devel for libraries containing two separate packets for precompiled code and the headers. The package is usually provided in binary format and contains:

  • The lead, which identifies the file as an RPM file and contains some obsolete headers.
  • The signature, which can be used to ensure integrity and/or authenticity.
  • The header, which contains metadata including package name, version, architecture, file list, etc.
  • A file archive (the payload), which usually is in cpio format, compressed with gzip. The rpm2cpio tool enables retrieval of the cpio file without needing to install the RPM package.

rpm

rpm is the low level counterpart of dpkg for .rpm packages and its purpose and syntax is similar:

  • rpm -i packagename.rpm installs a package
  • rpm -U packagename.rpm upgrades a package
  • rpm -ivh package-file installs a package with verbose output and a progress bar
  • rpm -q query-options package searches for an installed package

YUM (Yellow Dog Updater, Modified)

Yellow Dog Updater or YUM is a medium level package manager for Red Hat based distros that acts as an rpm front-end. However, it has since been deprecated.

DNF (Dandified YUM)

Dandified YUM or DNF is the high level package manager that has replaced YUM has the current and up to date rpm front-end. The syntax is similar to apt.

DNF Command Reference

DNF (Dandified YUM) is the package manager for Fedora, CentOS, and RHEL distributions. Here is a list of commonly used commands:

  • Update Package Cache:

    dnf check-update
    
  • Upgrade All Packages:

    dnf upgrade
    
  • Upgrade Specific Package:

    dnf upgrade <package_name>
    
  • Install a Package:

    dnf install <package_name>
    
  • Remove a Package:

    dnf remove <package_name>
    
  • List Available Groups:

    dnf group list
    
  • Install a Package Group:

    dnf group install <group_name>
    
  • Remove a Package Group:

    dnf group remove <group_name>
    
  • Search for a Package:

    dnf search <keyword>
    
  • Display Information about a Package:

    dnf info <package_name>
    
  • Clean Cache:

    dnf clean all
    
  • Auto-remove Unneeded Packages:

    dnf autoremove
    
  • List Enabled Repositories:

    dnf repolist
    
  • Add a Repository:

    dnf config-manager --add-repo <repository_url>
    
  • Enable a Repository:

    dnf config-manager --set-enabled <repository_name>
    
  • Disable a Repository:

    dnf config-manager --set-disabled <repository_name>
    
    

Advanced Tips and Tricks

Advanced Tips for apt

  1. Full Upgrade vs Safe Upgrade:

    • apt full-upgrade performs upgrades that may also remove installed packages if that's necessary to upgrade the system as a whole.
    • apt upgrade will only upgrade packages without removing any packages.
  2. Holding Packages:

    • To prevent a package from being automatically updated, use sudo apt-mark hold package_name.
    • To allow it again, use sudo apt-mark unhold package_name.
  3. Searching Package Listings:

    • Use apt-cache search keyword to search for packages. It searches descriptions and names.
    • apt-cache pkgnames starts listing packages alphabetically.
  4. List All Versions of a Package Available for Installation:

    • Use apt list -a package_name to see all versions of a package available in your repositories.
  5. Using Snapshots:

    • If you want to return your packages to a previous state, you can use apt with snapshots from a backup tool like Timeshift.
  6. Automatic Removal of Unused Packages:

    • After uninstalling an application, use sudo apt autoremove to remove dependencies that were installed with applications and that are no longer used by anything else on the system.
  7. Find Which Package a File Belongs to:

    • Use apt-file search path/to/file to find out which package a particular file belongs to.

Advanced Tips for dnf

  1. History and Undo/Redo Operations:

    • dnf history lists transaction history. You can undo or redo transactions using dnf undo transaction_id or dnf redo transaction_id.
  2. Repository Management:

    • Enable or disable repositories on the fly with dnf config-manager --set-enabled repo_name or dnf config-manager --set-disabled repo_name.
  3. DNF Automatic:

    • Install dnf-automatic for automatic daily package updates. It can be configured to only download, download and install, or even send email notifications.
  4. List and Remove Orphaned Packages:

    • Use dnf list extras to list orphaned packages (packages not available from currently configured repositories).
    • Remove them with dnf remove $(dnf repoquery --extras --exclude='kernel*').
  5. Using DNF Plugins:

    • Enhance dnf's capabilities by installing plugins like dnf-plugin-system-upgrade for upgrading Fedora releases, or dnf-plugins-core for additional features like managing core repositories.
  6. Cache Management:

    • Use dnf clean dbcache to clean the cache to reduce disk space usage. dnf makecache to regenerate the cache improving the performance of future installations.
  7. Find if a Specific Package is Available:

    • Use dnf provides '*/filename' to find which packages provide a specific file.