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.

- 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.debinstalls a packagedpkg -llists files that match a patterndpkg -Ssearches for a filename from installed packagesdpkg -r packagenameremoves an installed packages The packagesdpkganddpkg-devcontain 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 updatesyncs the package indexes and sourcesapt upgradeinstalls the current versions of packagesapt installinstalls individual or listed packagesapt cleanclears cache of package filesapt autocleanonly 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 searchsearches the list of packages for a regex term.apt showoutputs 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.rpminstalls a packagerpm -U packagename.rpmupgrades a packagerpm -ivh package-fileinstalls a package with verbose output and a progress barrpm -q query-options packagesearches 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
-
Full Upgrade vs Safe Upgrade:
apt full-upgradeperforms upgrades that may also remove installed packages if that's necessary to upgrade the system as a whole.apt upgradewill only upgrade packages without removing any packages.
-
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.
- To prevent a package from being automatically updated, use
-
Searching Package Listings:
- Use
apt-cache search keywordto search for packages. It searches descriptions and names. apt-cache pkgnamesstarts listing packages alphabetically.
- Use
-
List All Versions of a Package Available for Installation:
- Use
apt list -a package_nameto see all versions of a package available in your repositories.
- Use
-
Using Snapshots:
- If you want to return your packages to a previous state, you can use
aptwith snapshots from a backup tool like Timeshift.
- If you want to return your packages to a previous state, you can use
-
Automatic Removal of Unused Packages:
- After uninstalling an application, use
sudo apt autoremoveto remove dependencies that were installed with applications and that are no longer used by anything else on the system.
- After uninstalling an application, use
-
Find Which Package a File Belongs to:
- Use
apt-file search path/to/fileto find out which package a particular file belongs to.
- Use
Advanced Tips for dnf
-
History and Undo/Redo Operations:
dnf historylists transaction history. You can undo or redo transactions usingdnf undo transaction_idordnf redo transaction_id.
-
Repository Management:
- Enable or disable repositories on the fly with
dnf config-manager --set-enabled repo_nameordnf config-manager --set-disabled repo_name.
- Enable or disable repositories on the fly with
-
DNF Automatic:
- Install
dnf-automaticfor automatic daily package updates. It can be configured to only download, download and install, or even send email notifications.
- Install
-
List and Remove Orphaned Packages:
- Use
dnf list extrasto list orphaned packages (packages not available from currently configured repositories). - Remove them with
dnf remove $(dnf repoquery --extras --exclude='kernel*').
- Use
-
Using DNF Plugins:
- Enhance
dnf's capabilities by installing plugins likednf-plugin-system-upgradefor upgrading Fedora releases, ordnf-plugins-corefor additional features like managing core repositories.
- Enhance
-
Cache Management:
- Use
dnf clean dbcacheto clean the cache to reduce disk space usage.dnf makecacheto regenerate the cache improving the performance of future installations.
- Use
-
Find if a Specific Package is Available:
- Use
dnf provides '*/filename'to find which packages provide a specific file.
- Use