Linux 114: Package Management with APT, YUM, and DNF
One of the core strengths of Linux is its powerful package management systems. Whether you're using a Debian-based system or a Red Hat-based system, understanding how to install, update, and manage packages is essential for system administration. In this article, we’ll explore the most commonly used package managers: APT, YUM, and DNF.
1. What is a Package Manager?
A package manager automates the process of:
- Installing software
- Updating software
- Resolving dependencies
- Removing unneeded packages
Each Linux distribution typically uses a different tool:
- APT: Debian, Ubuntu
- YUM: CentOS 6/7, RHEL 6/7
- DNF: Fedora, CentOS 8+, RHEL 8+
2. Working with APT (Debian, Ubuntu)
Update Package Lists
Upgrade All Installed Packages
Install a Package
Remove a Package
Remove a Package and Its Configuration Files
Search for a Package
Show Package Details
Clean Up Unused Packages
3. Working with YUM (CentOS 6/7, RHEL 6/7)
YUM is deprecated in newer versions, but still widely used in legacy systems.
Update All Packages
Install a Package
Remove a Package
Search for a Package
Get Info About a Package
List All Installed Packages
Clean the Cache
4. Working with DNF (Fedora, CentOS 8+, RHEL 8+)
DNF is the modern replacement for YUM, offering better performance, dependency resolution, and features.
Update Package Lists and Upgrade
Install a Package
Remove a Package
Search for a Package
Show Package Info
List Installed Packages
Clean Package Cache
5. Repositories and Third-Party Software
Each package manager uses repositories (repos) to find and install packages.
- APT Sources:
/etc/apt/sources.list
and/etc/apt/sources.list.d/
- YUM/DNF Repos:
/etc/yum.repos.d/*.repo
Add a third-party repo (APT example):
Add a DNF repo:
6. Handling Dependencies and Conflicts
APT, YUM, and DNF automatically resolve dependencies. If you encounter conflicts:
- Use
apt-get -f install
to fix broken dependencies (APT). - Use
dnf repoquery --requires <pkg>
to inspect dependencies (DNF). - Use
yum deplist <pkg>
for detailed dependencies (YUM).
7. Best Practices
- Always update package lists before installing.
- Avoid forcing installations unless you understand the consequences.
- Clean up unused packages and cache regularly.
- Use official or trusted third-party repositories only.
8. Conclusion
Mastering your package manager is essential for system stability and efficiency. Whether you're managing a Debian-based or Red Hat-based system, APT, YUM, and DNF give you powerful tools to control your software environment.
Next Steps:
- Learn about Snap and Flatpak for universal Linux package formats.
- Explore unattended upgrades for automatic security updates.
- Dive into building your own
.deb
or.rpm
packages.
Stay tuned for the next article in the series:
Linux 115: Setting Up a Web Server with Apache or Nginx