YUM (Yellowdog Updater, Modified) and DNF (Dandified YUM) are the primary package management tools for Red Hat-based distributions, including RHEL, CentOS, and Fedora. While DNF is the successor to YUM and is used in more recent releases, YUM is still prevalent in older systems.
YUM is a command-line package management utility that handles software installation, updates, and removal for .rpm
packages. It also manages dependencies and can work with various repositories.
DNF is the modern replacement for YUM, introduced to address performance, dependency resolution, and memory usage issues. It is backward-compatible with YUM, meaning it can perform the same functions with improved efficiency.
- Performance: DNF is faster and uses less memory than YUM.
- Dependency Resolution: DNF provides better handling of dependencies.
- Plugin System: DNF has a more flexible and improved plugin system.
- Command Syntax: Most YUM commands are compatible with DNF, but DNF introduces some new options and enhancements.
To install a package with YUM:
sudo yum install package-name
With DNF, the command is similar:
sudo dnf install package-name
Example:
sudo dnf install httpd
To update all installed packages:
sudo yum update
Or with DNF:
sudo dnf upgrade
To remove a package:
sudo yum remove package-name
Or with DNF:
sudo dnf remove package-name
Example:
sudo dnf remove nginx
To search for a package by name or description:
yum search package-name
Or with DNF:
dnf search package-name
Example:
dnf search mysql
To display detailed information about a package:
yum info package-name
Or with DNF:
dnf info package-name
Example:
dnf info vim
To list all installed packages:
yum list installed
Or with DNF:
dnf list installed
After installing or updating packages, you might want to clean up the package cache to free up disk space:
sudo yum clean all
Or with DNF:
sudo dnf clean all
To list enabled repositories:
yum repolist
Or with DNF:
dnf repolist
To enable or disable a repository:
sudo yum-config-manager --enable repository-name
sudo yum-config-manager --disable repository-name
Or with DNF:
sudo dnf config-manager --set-enabled repository-name
sudo dnf config-manager --set-disabled repository-name
YUM and DNF support group installation, which allows you to install a collection of related packages with a single command.
To install a package group (e.g., "Development Tools"):
sudo yum groupinstall "Development Tools"
Or with DNF:
sudo dnf groupinstall "Development Tools"
If you need to downgrade a package to an earlier version:
sudo yum downgrade package-name
Or with DNF:
sudo dnf downgrade package-name
To list all available package groups:
yum group list
Or with DNF:
dnf group list
Both YUM and DNF maintain a transaction history, allowing you to view past transactions or even roll back to a previous state.
To view the transaction history:
yum history
Or with DNF:
dnf history
To undo a specific transaction:
sudo yum history undo transaction-id
Or with DNF:
sudo dnf history undo transaction-id
If you encounter dependency issues during installation or removal, YUM and DNF can attempt to resolve them automatically:
sudo yum install -y --skip-broken
Or with DNF:
sudo dnf install -y --skip-broken
- Regularly Update Your System: Keep your system secure and up-to-date by regularly running update or upgrade commands.
- Use
yum
ordnf
for Package Management: Avoid usingrpm
directly, as it does not handle dependencies. Always useyum
ordnf
for package management tasks. - Be Cautious with Third-Party Repositories: Only enable trusted repositories to avoid potential security risks or package conflicts.
- Clean Up Regularly: Free up disk space by cleaning up the package cache and removing unused packages.
YUM and DNF are powerful package management tools that simplify the process of managing software on Red Hat-based distributions. Whether you're using YUM on older systems or DNF on more recent releases, understanding how to effectively use these tools is crucial for maintaining a stable and secure Linux environment.
Next: Pacman (Arch)
Previous: APT (Debian/Ubuntu)