Notes: Package Managers
Check your understanding of APT, dpkg, YUM/DNF, RPM, repositories and installing software from tarballs.
- YUM
- APT
- Pacman
- DNF
Explanation: Debian-based systems use APT (Advanced Package Tool) on top of
dpkg. YUM and DNF belong to the Red Hat family, and Pacman is Arch Linux's package manager.
- APT
- dpkg
- zypper
- DNF
Explanation: DNF replaced YUM on Fedora and RHEL 8+, where
yumis kept only as a link todnf. zypper belongs to openSUSE, and APT and dpkg to Debian.
- Downloads and installs the newest versions of all installed packages
- Refreshes the package lists from the configured repositories, installing nothing
- Updates the
aptprogram itself to its newest release - Removes packages that are no longer needed by anything
Explanation:
apt updaterefreshes the local index of available packages and versions. Installing newer versions is the job ofapt upgrade, which should run after the index is current.
Q. apt upgrade reports that one package was "kept back" because its new version needs another installed package removed. Which command performs that upgrade?
-
apt update -
apt install --reinstall -
apt full-upgrade -
apt autoremove
Explanation:
apt upgrademay install new dependencies but never removes installed packages, so it skips such upgrades.apt full-upgradeis allowed to remove packages when that is needed to upgrade the system as a whole.
-
apt get nginx -
apt install nginx -
apt add nginx -
apt download nginx
Explanation:
apt installresolves and installs the package with its dependencies.apt downloadonly fetches the.debfile into the current directory, andapt getis not a subcommand.
Q. You downloaded package.deb and want to install it while letting APT fetch any missing dependencies. Which command does that?
-
apt install ./package.deb -
dpkg -i package.deb -
apt download package.deb -
apt-cache show package.deb
Explanation: Given a path (note the
./),apt installinstalls the local file and pulls dependencies from the repositories.dpkg -iinstalls the file but does not resolve dependencies.
Q. dpkg -i cowsay.deb ends with "dependency problems - leaving unconfigured". Which command installs the missing dependencies and finishes configuring the package?
-
dpkg --configure -a -
apt-get install -f -
apt-get clean -
dpkg -r cowsay
Explanation:
dpkgunpacks the package but cannot fetch dependencies, so it stays half-installed (iU).apt-get install -f(fix broken) downloads what is missing and completes configuration;dpkg --configure -aalone would fail again for the same reason.
-
apt remove package -
apt purge package -
apt autoremove package -
apt clean package
Explanation:
apt removedeletes the program files and leaves configuration in/etc, so a reinstall picks it up again.apt purgeremoves the configuration files too.
- The package is installed, and its configuration files are up to date
- The package is marked for reinstallation the next time APT runs
- The package and all its configuration files were removed completely
- The package is removed, but its configuration files are still on disk
Explanation: The first letter is the desired state (
remove) and the second the actual state (config-files only).apt purge crondeletes those leftovers even after a plain remove; files in home directories are never touched.
- Removes packages that were installed as dependencies and are no longer needed
- Removes packages whose installation failed or left them broken
- Deletes downloaded
.debfiles from the cache in/var/cache/apt - Removes configuration files left behind by removed packages
Explanation: When nothing depends on an automatically installed package any more,
autoremoveuninstalls it to free space. Cleaning the download cache isapt clean.
-
apt autoremove -
apt purge -
apt clean -
apt update
Explanation:
apt cleanempties the cache of.debfiles in/var/cache/apt/archives.apt autocleanremoves only files that can no longer be downloaded, andautoremoveuninstalls packages.
- That
apache2is installed and its service is currently running - That
apache2is installed, although its service may be stopped - That
apache2was installed on this system at some point in the past - Only that the package exists in the repository metadata, installed or not
Explanation:
apt showdescribes packages from repository data. Check local installation withdpkg-query -W -f='${Status}\n' apache2, which printsinstall ok installedfor installed packages.
-
apt search nginx -
apt find nginx -
apt locate nginx -
apt query nginx
Explanation:
apt searchmatches names and descriptions in the package index. Searching needs no root privileges, unlike installing or removing.
-
aptis not installed by default on Debian or Ubuntu server images -
apt-getresolves dependencies automatically, whileaptinstalls only named packages -
aptis designed for interactive use, whileapt-getkeeps a stable interface for scripts -
apt-getis faster because it skips repository signature checks
Explanation:
aptadds progress bars and friendlier output and may change between releases; piping it prints "apt does not have a stable CLI interface".apt-getandapt-cacheprioritize backward compatibility, so automation should use them.
-
apt list --upgradable -
apt-cache search . -
dpkg -l -
apt show --all
Explanation:
dpkg -lprints every package known to dpkg with its status (iimeans installed).apt list --installedis another option;--upgradableonly shows packages with pending updates.
Q. Which command fetches the .deb file of a package into the current directory without installing it?
-
apt get package -
apt fetch package -
apt save package -
apt download package
Explanation:
apt downloadsaves the package file locally, which is useful for offline installation or inspection. It does not download dependencies.
-
/etc/yum.repos.d/ -
/var/lib/apt/lists/and the index files cached inside it -
/etc/apt/sources.listand files in/etc/apt/sources.list.d/ -
/etc/apt/apt.confand files in/etc/apt/apt.conf.d/
Explanation: Repository entries live in
sources.listand insources.list.d/(Ubuntu 24.04 usessources.list.d/ubuntu.sources)./var/lib/apt/lists/holds the downloaded index files, and/etc/yum.repos.d/is for YUM/DNF.
-
add-apt-repository ppa:user/repo -
apt add-repo ppa:user/repo -
apt-key add ppa:user/repo -
apt source ppa:user/repo
Explanation:
add-apt-repository(fromsoftware-properties-common) writes the entry into/etc/apt/sources.list.d/and, on current Ubuntu, refreshes the package lists itself unless given-n.
- A Primary Package Archive maintained by Canonical
- A Personal Package Archive that publishes packages outside the official repositories
- A Private Package Archive that requires a subscription
- A Preferred Package Archive chosen automatically for speed
Explanation: PPAs let individuals or teams distribute packages through Launchpad. Because they are third-party, only add PPAs you trust.
- It encrypts the packages downloaded from that repository with the key
- It tells APT to skip signature checks because the repository is trusted
- It speeds up downloads by caching the key instead of fetching it each time
- It restricts trust in that key to this repository instead of trusting it for all repositories
Explanation: Scoping a third-party signing key with
signed-bymeans it can only vouch for packages from that one source, limiting the damage if the key or repository is compromised.
- To compress packages so they download faster from mirrors
- To verify that packages are authentic and have not been tampered with
- To encrypt package contents so mirrors cannot read them
- To record which package version is installed on each system
Explanation: The package manager checks each package or repository index against a trusted signing key. A failed check means the data did not come from the expected source or was modified.
- Enables the repository
- Downloads the repository's GPG key automatically
- Makes YUM/DNF verify the GPG signature of packages from that repository
- Encrypts connections to the mirror
Explanation: With
gpgcheck=1, packages whose signatures do not verify are refused. Enabling a repository is controlled separately withenabled=1, and the key location withgpgkey=.
Q. A server has this file. You run dnf install mytool, and mytool exists only in this repository. What happens?
# /etc/yum.repos.d/internal.repo
[internal]
name=Internal tools
baseurl=https://repo.example.com/el9/
enabled=0
gpgcheck=1
- DNF installs
mytoolbut skips the signature check - DNF reports that no package
mytoolis available, because the repository is disabled - DNF enables the repository permanently and installs
mytool - DNF downloads
mytoolfrom a mirror list instead ofbaseurl
Explanation:
enabled=0hides the repository from normal commands.dnf --enablerepo=internal install mytooluses it once, andgpgcheck=1still applies to the downloaded package.
Q. A nightly script runs dnf check-update and alerts on any non-zero exit status. It alerts almost every night, though nothing is broken. Why?
-
check-updateneeds root and fails for normal users -
check-updateexits 1 whenever the metadata cache is refreshed -
check-updateinstalls updates and exits non-zero when a reboot is needed -
check-updateexits 100 when updates are available, 0 when there are none and 1 on error
Explanation:
dnf check-update(andyum check-update) only lists pending updates. Exit status 100 means "updates available", so scripts should treat 100 separately from real errors.
-
yum update -
yum check-update -
yum refresh -
yum install --all
Explanation:
yum updatewith no package names upgrades everything; naming a package, as inyum update httpd, limits it. On DNF the usual spelling isdnf upgrade, andupdateis accepted as an alias.
- YUM/DNF never cache metadata and query the repository on every command
- YUM/DNF refresh expired metadata automatically, while APT needs an explicit
apt update - YUM/DNF require running
yum updatebefore every install, like APT - YUM/DNF download every package in the repository ahead of time
Explanation: YUM and DNF keep a metadata cache and refresh it when it is older than
metadata_expire. With APT you normally runapt updateyourself before installing or upgrading.
Q. On Rocky Linux 9 you need the command semanage, but it is not installed. Which command tells you which package provides it?
-
dnf search semanage -
rpm -qf /usr/sbin/semanage -
dnf provides /usr/sbin/semanage -
dnf info semanage
Explanation:
dnf providessearches repository file lists and reportspolicycoreutils-python-utils.rpm -qfonly works for files that are already installed, anddnf searchmatches names and summaries, not file paths.
Q. Which package name do you install to get the Apache web server on Fedora/RHEL, compared with Debian/Ubuntu?
-
apache2on Fedora/RHEL andhttpdon Debian/Ubuntu -
apacheon both -
httpdon both -
httpdon Fedora/RHEL andapache2on Debian/Ubuntu
Explanation: Package and service names differ between distribution families, so
dnf install httpdandapt install apache2install the same software. Search first when you are unsure.
Q. Which YUM command shows detailed information such as version, size and description for the package httpd?
-
yum info httpd -
yum show httpd -
yum describe httpd -
yum about httpd
Explanation:
yum info(ordnf info) displays metadata for an installed or available package. On APT systems the equivalent isapt show.
-
yum show installed -
yum list installed -
yum installed -
yum query --installed
Explanation:
yum list installedprints installed packages with version and source repository. At the RPM level,rpm -qagives a similar list.
-
yum clear -
yum cache clean -
yum remove --cache -
yum clean all
Explanation:
yum clean alldeletes cached packages and metadata, freeing space and forcing fresh metadata on the next run.
-
yum history undo last -
yum revert -
yum cancel last -
yum remove --last
Explanation:
yum historylists past transactions, andyum history undoreverses one;lastrefers to the most recent.dnf history undo lastworks the same, though undo fails if older package versions are no longer available.
-
/etc/apt/sources.list -
/var/cache/yum/ -
/etc/yum.repos.d/ -
/etc/repos.conf
Explanation: Each
.repofile in/etc/yum.repos.d/defines one or more repositories with a label, name, base URL or mirror list andgpgchecksetting./var/cache/yum/only holds cached data.
-
baseurlis used to download packages, whilemirrorlistonly supplies GPG keys -
baseurlnames one repository location, whilemirrorlistis a URL returning a list of mirrors -
mirrorlistnames a local cache directory, whilebaseurlis the remote server -
baseurlis consulted only for updates, whilemirrorlistis used for new installs
Explanation: A mirror list lets the client pick a nearby, up-to-date mirror;
baseurlnames one fixed location. Either can locate the repository metadata, and the[label]in brackets is the repository ID used by--enablerepo.
-
yum repos -
yum list repos -
yum-config-manager --enable -
yum repolist all
Explanation:
yum repolistshows enabled repositories, and addingallincludes disabled ones.dnf repolist allworks the same way.
Q. On RHEL or Rocky Linux 9 with yum-utils installed, which command adds a new repository from a .repo URL?
-
yum-config-manager --add-repo=URL -
yum install --repo=URL -
add-apt-repository URL -
yum repolist --add URL
Explanation:
yum-config-managersaves the.repofile into/etc/yum.repos.d/;dnf config-manager --add-repois the same on DNF 4.add-apt-repositoryis for APT.
-
dnf config-manager --add-repo=URL -
dnf config-manager addrepo --from-repofile=URL -
rpm --import URL -
dnf repolist --add URL
Explanation: DNF 5 turned
config-manageroptions into subcommands, and the old--add-repooption is rejected as an unknown argument.rpm --importonly imports a GPG key.
-
yum remove epel -
yum --enablerepo=epel update -
yum clean epel -
yum-config-manager --disable epel
Explanation:
--disablesetsenabled=0in the repository's.repofile, so it stays off until re-enabled with--enable. For a single command, use--disablerepo=epelinstead.
- Enables the repository permanently by editing its
.repofile - Creates a new repository definition with the given ID
- Enables every configured repository, including disabled ones
- Enables a disabled repository for that single command only
Explanation: The option affects only the current command, so the
.repofile keeps the repository disabled. Useyum-config-manager --enablefor a permanent change.
- Install, verbose, print hash marks for progress
- Install, validate signatures, hold the package
- Show information, print the version, show help
- Interactive mode, verify files, compute hashes
Explanation:
-iinstalls,-vprints details and-hshows a progress bar of#marks. RPM itself does not download dependencies.
-
rpm -e -
rpm -ivh -
rpm -qd -
rpm -qa
Explanation:
-qqueries and-ameans all packages.rpm -qdlists a package's documentation files andrpm -eerases a package.
-
rpm -q nano -
rpm -e nano -
rpm -ivh nano -
rpm --install nano
Explanation:
rpm -q nanoprints the installed version, such asnano-5.6.1-7.el9.x86_64, or "package nano is not installed" with exit status 1.rpm -ewould remove it.
- The documentation files installed by the
nanopackage - The packages that
nanodepends on - The files
nanowould delete when removed - The description text from the
nanopackage header
Explanation: In query mode
-dselects documentation files. Dependencies are shown withrpm -qR, the full file list withrpm -qland the description withrpm -qi.
-
rpm -r nano -
rpm -d nano -
rpm -e nano -
rpm -x nano
Explanation:
-estands for erase. RPM refuses with "Failed dependencies" if other installed packages neednano, because it does not manage dependencies for you.
- DNF resolves the dependencies and installs them from the repositories
- DNF ignores dependencies, which RPM checks strictly
- DNF rebuilds the package so that it no longer has dependencies
- DNF installs the file without verifying its signature or dependencies
Explanation: RPM is a low-level tool that only checks dependencies. High-level managers like YUM and DNF find and install what is missing, which is their main advantage.
Q. On Ubuntu, apt install chrony lists systemd-timesyncd under "The following packages will be REMOVED". Why?
- APT removes the oldest package whenever disk space is low
-
chronyis a newer version ofsystemd-timesyncd - The two packages declare a conflict, so APT must remove one to install the other
- APT always removes packages that were installed automatically
Explanation: Packages can declare
ConflictsorBreaks. APT resolves them by proposing removals and asks before proceeding, so read that section carefully before answering yes.
- It always installs the newest upstream release as soon as it is published
- It tracks dependencies and installed files, so software can be updated or removed cleanly
- It lets any user install software system-wide without root privileges
- It compiles every program from source for your specific CPU model
Explanation: Packages declare their dependencies, and the manager records which files belong to which package. Manually installed software must be tracked, patched and removed by you.
-
make install, then./configure, then extract -
./configure, then extract, thenmake - Extract, run
./configureif present,make, thenmake install - Extract, then
make install, thenmake
Explanation: After
tar -xzf,./configurechecks dependencies and prepares the build,makecompiles andmake installcopies the results into place, by default under/usr/local.
Q. You build a tarball whose build uses an autoconf configure script, but you have no root access. How do you make make install put the program in ~/.local?
- Run
make install DESTDIR=/usr/local - Run
sudo make install, which is required for every tarball - Copy the tarball into
~/.localbefore extracting it - Run
./configure --prefix=$HOME/.localbeforemakeandmake install
Explanation:
--prefixsets the install location, which defaults to/usr/local, so the binary goes to~/.local/bin. Writing under/usr/localneeds root, andDESTDIRonly stages files for packaging.
- It can only be run by root, because it was installed with
make install - It always overwrites files that belong to distribution packages
- It does not receive automatic updates, so you must track security fixes yourself
- It is deleted the next time the package cache is cleaned
Explanation: The package manager does not know about manually built software, so
apt upgradeordnf upgradewill never patch it. Installing it under/usr/localat least keeps it separate from packaged files.