Operations 8 min read

Master Linux Package Management: apt vs dnf Commands Explained

This guide walks you through searching, installing, updating, and removing software on Linux using the apt and dnf package managers, covering command syntax, regex searches, group installations, and how each tool handles caches and configuration files.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Master Linux Package Management: apt vs dnf Commands Explained

Searching for Packages

To locate a package, use dnf search <keyword> or apt search <keyword>. Both commands return matching package names and short descriptions. Regular expressions can narrow results, e.g., apt search ^zsh.

sudo dnf search zsh
sudo apt search zsh

Finding Which Package Provides a Command

When you know a command but not its package, dnf provides <command> or apt-file search <path> reveal the owning package.

sudo dnf provides pgrep
sudo apt-file search /usr/bin/pgrep

Installing Packages

Installation syntax is identical for both managers:

sudo apt install zsh
sudo dnf install zsh

RPM‑based distributions also support group installations, which bundle related applications. List available groups with dnf group list -v and install a group using dnf group install <group-name>. The shortcut @design-suite can be used to refer to a group.

sudo dnf group list -v
sudo dnf group install design-suite

Updating Packages

Both tools can upgrade installed software. apt upgrade updates packages based on a cached index, while dnf upgrade (or dnf update) refreshes metadata on each run and then upgrades.

sudo apt upgrade
sudo dnf upgrade

Removing Packages

To uninstall a package, use the remove subcommand. Apt keeps user configuration files by default; add purge to delete them as well. Neither manager removes files in the user’s home directory automatically.

sudo dnf remove zsh
sudo apt remove zsh
sudo apt purge zsh

Key Takeaways

Whether your distribution uses apt (Debian/Ubuntu) or dnf (Fedora/RHEL), the core operations—search, install, update, and remove—are very similar, making it easy to switch between them. Both provide advanced features such as repository management, but the basic commands covered here handle the majority of everyday package tasks.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

LinuxAPTpackage managementSoftware Installationdnf
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.