Rocky Linux uses the DNF (Dandified YUM) package manager, the same package manager used by Red Hat Enterprise Linux (RHEL) and CentOS. DNF is a modernized version of YUM (Yellowdog Updater Modified), offering enhanced performance, improved dependency resolution, and additional features.
Here’s an overview of package management in Rocky Linux:
Installing a Package:
sudo dnf install <package_name>
Installs the specified package, resolving and installing dependencies automatically.
Removing a Package:
sudo dnf remove <package_name>
Uninstalls the specified package and, if necessary, removes dependencies no longer needed.
Updating Packages:
sudo dnf update
Updates all packages on the system to the latest available versions.
Searching for a Package:
dnf search <keyword>
Searches the package repository for packages that match the specified keyword.
Viewing Package Information:
dnf info <package_name>
Displays detailed information about a specific package, including its version, repository, and description.
Repositories are sources for software packages in Rocky Linux. By default, Rocky Linux has a set of pre-configured repositories, but you can also add additional repositories as needed.
Listing Enabled Repositories:
dnf repolist
Shows a list of currently enabled repositories.
Adding a New Repository:
You can add a repository by creating a .repo file in /etc/yum.repos.d/ or using a repository configuration command. For example:
sudo dnf config-manager --add-repo <repository_url>
Disabling/Enabling Repositories Temporarily:
You can temporarily enable or disable repositories when running commands. For instance:
sudo dnf install <package_name> --enablerepo=<repo_name>
DNF supports package groups, which are collections of related packages. For example, you can install a full development environment or a web server package group in one command.
Listing Available Groups:
dnf group list
Shows a list of package groups, such as “Development Tools,” “Web Server,” and “File Server.”
Installing a Group:
sudo dnf groupinstall "<group_name>"
Installs all packages in a specified group.
Removing a Group:
sudo dnf groupremove "<group_name>"
Removes all packages in the specified group.
DNF maintains a local cache of package metadata and packages themselves. Over time, this cache can grow and take up disk space.
sudo dnf clean all
Clears all cached metadata and package files, which forces DNF to re-download information the next time it runs.The Extra Packages for Enterprise Linux (EPEL) repository offers additional packages not available in the default Rocky Linux repositories.
sudo dnf install epel-release
This command installs the EPEL repository, providing access to a wide variety of additional open-source packages.Verifying Installed Packages:
sudo rpm -V <package_name>
Checks the integrity of an installed package to ensure it hasn’t been altered.
Checking for DNF Errors:
Occasionally, DNF may encounter issues related to dependencies or configuration errors. The dnf check command can help identify these:
sudo dnf check
| Command | Description |
|---|---|
sudo dnf install <package_name> |
Installs a package |
sudo dnf remove <package_name> |
Removes a package |
sudo dnf update |
Updates all installed packages |
dnf search <keyword> |
Searches for a package by keyword |
dnf info <package_name> |
Shows package details |
dnf repolist |
Lists enabled repositories |
dnf group list |
Lists all available package groups |
sudo dnf groupinstall "<group_name>" |
Installs a group of related packages |
sudo dnf clean all |
Clears all cached data |
sudo dnf check |
Checks for issues with installed packages |
By mastering DNF, you’ll have full control over package management in Rocky Linux, ensuring you can install, update, and manage software as needed.
Let me us know if you’d like more specific guidance on any commands or package management tasks!