Introduction
In this practical guide, you'll explore the power of the dnf (Dandified YUM) command, the go-to package manager for contemporary Red Hat-based Linux distributions like Fedora, CentOS, and RHEL. As a systemadmin, mastering dnf is crucial. This tutorial will cover the fundamental aspects of dnf, guiding you through package installation, updates, and the management of package groups and dependencies. Through hands-on examples, you'll gain the skills necessary to efficiently manage software packages on your Linux system.
Understand the dnf Command
This section will delve into the dnf (Dandified YUM) command, a cornerstone for systemadmins managing Red Hat-based Linux distributions such as Fedora, CentOS, and RHEL. Dnf streamlines package management, making it an indispensable tool.
Let's begin by verifying the installed dnf version:
sudo dnf --version
Example output:
dnf version 4.9.0
The dnf command empowers you to perform a wide array of package management operations, including:
- Installing new packages onto your system
- Updating packages to their newest releases
- Removing packages you no longer require
- Searching to discover packages
- Listing all installed packages
- Managing package groups as well as dependencies
For a rapid overview of dnf's capabilities, utilize the built-in help functionality:
sudo dnf help
This command unveils a comprehensive list of dnf commands, each accompanied by a concise explanation.
To access an exhaustive documentation resource for a specific dnf command, invoke the man
command:
man dnf
This command opens the manual page for the dnf command, a complete guide to dnf usage and available options, essential for any systemadmin.
Install and Update Packages using dnf
This segment demonstrates the power of dnf for package installation and updating existing software on your Linux server.
Let's start by searching for a package using the dnf search
command. For example, to locate the "tree" package:
sudo dnf search tree
Example output:
Last metadata expiration check: 0:00:36 ago on Fri 14 Apr 2023 05:33:00 PM UTC.
tree.x86_64 : Display a tree-like view of the directory structure
tree-python3.x86_64 : Python3 bindings for tree
tree-qt.x86_64 : Qt-based tree viewer
To install the "tree" package, execute the dnf install
command:
sudo dnf install -y tree
Example output:
Dependencies resolved.
...
Installed:
tree-1.8.0-10.el8.x86_64
To update all packages on the system, run the dnf update
command:
sudo dnf update -y
Example output:
Dependencies resolved.
...
Updated:
...
Complete!
The -y
flag automates the process by answering "yes" to all prompts, allowing for unattended installation and updates, a time-saver for any systemadmin.
Manage Package Groups and Dependencies with dnf
This section will guide you through managing package groups and package dependencies using the dnf command.
Package groups in dnf are curated collections of related software. To list all accessible package groups, execute the dnf group list
command:
sudo dnf group list
Example output:
Available Environment Groups:
...
Server with GUI
Minimal Install
...
Available Groups:
Authoring and Publishing
C Development Tools and Libraries
...
To install a package group, use the dnf group install
command. For example, to install the "Development Tools" group:
sudo dnf group install -y "Development Tools"
Example output:
Dependencies resolved.
...
Installed:
...
When installing a package, dnf automatically resolves and installs package dependencies. Use the dnf deplist
command to display a package's dependencies:
sudo dnf deplist tree
Example output:
package: tree-1.8.0-10.el8.x86_64
dependency: libc.so.6()(64bit)
dependency: libm.so.6()(64bit)
dependency: libncurses.so.6()(64bit)
dependency: libpthread.so.0()(64bit)
dependency: rtld(GNU_HASH)
This showcases the dependencies of the "tree" package.
To uninstall a package group, use the dnf group remove
command:
sudo dnf group remove -y "Development Tools"
Example output:
Dependencies resolved.
...
Removed:
...
Summary
This lab has provided you with a comprehensive overview of the dnf (Dandified YUM) command, the standard package manager for modern Red Hat-based Linux distributions. You've learned how to leverage dnf to install new packages, update existing packages, search for software, and effectively manage package groups and dependencies. You now have the foundational knowledge needed to efficiently manage software on your systems, covering aspects such as checking the dnf version, searching and installing packages (e.g., the "tree" package), and updating the entire system.