Skip to content

Latest commit

 

History

History
277 lines (177 loc) · 5.2 KB

3. YUM - DNF (RHEL - CentOS).md

File metadata and controls

277 lines (177 loc) · 5.2 KB

YUM/DNF (RHEL/CentOS)

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.

Understanding YUM and DNF

YUM (Yellowdog Updater, Modified)

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 (Dandified YUM)

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.

Key Differences Between YUM and DNF

  • 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.

Basic YUM/DNF Commands

Installing Packages

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

Updating Packages

To update all installed packages:

sudo yum update

Or with DNF:

sudo dnf upgrade

Removing Packages

To remove a package:

sudo yum remove package-name

Or with DNF:

sudo dnf remove package-name

Example:

sudo dnf remove nginx

Searching for Packages

To search for a package by name or description:

yum search package-name

Or with DNF:

dnf search package-name

Example:

dnf search mysql

Viewing Package Information

To display detailed information about a package:

yum info package-name

Or with DNF:

dnf info package-name

Example:

dnf info vim

Listing Installed Packages

To list all installed packages:

yum list installed

Or with DNF:

dnf list installed

Cleaning Up

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

Managing Repositories

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

Advanced YUM/DNF Usage

Group Installation

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"

Downgrading Packages

If you need to downgrade a package to an earlier version:

sudo yum downgrade package-name

Or with DNF:

sudo dnf downgrade package-name

Listing Available Package Groups

To list all available package groups:

yum group list

Or with DNF:

dnf group list

History and Rollback

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

Resolving Dependency Issues

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

Best Practices for YUM/DNF

  • Regularly Update Your System: Keep your system secure and up-to-date by regularly running update or upgrade commands.
  • Use yum or dnf for Package Management: Avoid using rpm directly, as it does not handle dependencies. Always use yum or dnf 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.

Conclusion

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)