コンテンツにスキップ

YUM/DNF Package Manager

Comprehensive YUM and DNF commands and workflows for Red Hat, CentOS, and Fedora package management.

Installation & Updates

Basic Package Operations (DNF)

Command Description
sudo dnf update Update all packages
sudo dnf upgrade Upgrade all packages (same as update)
sudo dnf install package_name Install package
sudo dnf remove package_name Remove package
sudo dnf autoremove Remove unused dependencies
sudo dnf reinstall package_name Reinstall package

Basic Package Operations (YUM)

Command Description
sudo yum update Update all packages
sudo yum install package_name Install package
sudo yum remove package_name Remove package
sudo yum autoremove Remove unused dependencies
sudo yum reinstall package_name Reinstall package

Advanced Installation

Command Description
sudo dnf install package1 package2 Install multiple packages
sudo dnf install package-version Install specific version
sudo dnf localinstall package.rpm Install local RPM file
sudo dnf downgrade package_name Downgrade package
sudo dnf install --enablerepo=repo package Install from specific repo

Package Information

Search and Information

Command Description
dnf search keyword Search for packages
dnf info package_name Show package information
dnf list installed List installed packages
dnf list available List available packages
dnf list updates List available updates
rpm -qa List all installed packages
rpm -qi package_name Show installed package info

Package Dependencies

Command Description
dnf deplist package_name Show package dependencies
dnf repoquery --requires package_name Show package requirements
dnf repoquery --whatrequires package_name Show what requires package
rpm -qR package_name Show package dependencies (RPM)

Repository Management

Repository Operations

Command Description
dnf repolist List enabled repositories
dnf repolist all List all repositories
sudo dnf config-manager --add-repo URL Add repository
sudo dnf config-manager --disable repo_name Disable repository
sudo dnf config-manager --enable repo_name Enable repository

EPEL Repository (CentOS/RHEL)

Command Description
sudo dnf install epel-release Install EPEL repository
sudo yum install epel-release Install EPEL (YUM)

System Maintenance

Cleanup Operations

Command Description
sudo dnf clean all Clean all cache
sudo dnf clean packages Clean package cache
sudo dnf clean metadata Clean metadata cache
sudo dnf autoremove Remove orphaned packages

Package Groups

Command Description
dnf group list List package groups
dnf group info "Group Name" Show group information
sudo dnf group install "Development Tools" Install package group
sudo dnf group remove "Group Name" Remove package group

Configuration Files

DNF/YUM Configuration

File Description
/etc/dnf/dnf.conf DNF main configuration
/etc/yum.conf YUM main configuration
/etc/yum.repos.d/ Repository configuration files
/var/log/dnf.log DNF log file
/var/log/yum.log YUM log file

Example dnf.conf

[main]
gpgcheck=1
installonly_limit=3
clean_requirements_on_remove=True
best=False
skip_if_unavailable=True
fastestmirror=True
max_parallel_downloads=10

Example Repository File

[example-repo]
name=Example Repository
baseurl=https://example.com/repo/
enabled=1
gpgcheck=1
gpgkey=https://example.com/RPM-GPG-KEY

Advanced Usage

History and Rollback

Command Description
dnf history Show transaction history
dnf history info ID Show transaction details
sudo dnf history undo ID Undo transaction
sudo dnf history redo ID Redo transaction
sudo dnf history rollback ID Rollback to transaction

Module Management (DNF)

Command Description
dnf module list List available modules
dnf module list --installed List installed modules
sudo dnf module install module:stream Install module stream
sudo dnf module enable module:stream Enable module stream
sudo dnf module disable module Disable module

Security Updates

Command Description
dnf updateinfo Show update information
dnf updateinfo --security Show security updates
sudo dnf update --security Install security updates only
dnf updateinfo list cves List CVEs

Package Building

RPM Development

Command Description
sudo dnf install rpm-build rpmdevtools Install build tools
rpmdev-setuptree Setup RPM build tree
rpmbuild -ba package.spec Build RPM package
rpm -qp --requires package.rpm Check RPM dependencies

Source RPMs

Command Description
dnf download --source package_name Download source RPM
rpm -ivh package.src.rpm Install source RPM
rpmbuild --rebuild package.src.rpm Rebuild from source

Troubleshooting

Common Issues

Problem Solution
Conflicting packages sudo dnf remove conflicting_package
Broken dependencies sudo dnf check
Corrupted RPM database sudo rpm --rebuilddb
Repository errors sudo dnf clean all && sudo dnf makecache

Lock Issues

Command Description
sudo rm /var/lib/rpm/.rpm.lock Remove RPM lock
sudo rm /var/run/yum.pid Remove YUM lock
ps aux \|grep yum Check for running YUM processes

Database Repair

Command Description
sudo rpm --rebuilddb Rebuild RPM database
sudo dnf check Check for problems
sudo dnf distro-sync Synchronize packages

Fedora-Specific Features

Fedora Updates

Command Description
sudo dnf system-upgrade download --releasever=XX Download upgrade
sudo dnf system-upgrade reboot Perform upgrade
sudo dnf install fedora-upgrade Install upgrade tool

Flatpak Integration

Command Description
sudo dnf install flatpak Install Flatpak
flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo Add Flathub

CentOS/RHEL-Specific

Subscription Manager (RHEL)

Command Description
sudo subscription-manager register Register system
sudo subscription-manager attach --auto Auto-attach subscription
sudo subscription-manager repos --enable=repo_name Enable repository

CentOS Stream

Command Description
sudo dnf install centos-release-stream Install Stream repos
sudo dnf swap centos-linux-repos centos-stream-repos Switch to Stream

Performance Optimization

Configuration Tuning

# /etc/dnf/dnf.conf optimizations
[main]
fastestmirror=True
max_parallel_downloads=10
deltarpm=True
keepcache=True

Mirror Management

Command Description
sudo dnf install dnf-plugins-core Install DNF plugins
sudo dnf config-manager --set-enabled powertools Enable PowerTools (CentOS)

Best Practices

Security

  1. Regular Updates: Keep system updated with security patches
  2. Repository Verification: Only use trusted repositories
  3. GPG Verification: Ensure packages are properly signed
  4. Minimal Installation: Install only necessary packages
  5. Security Updates: Prioritize security updates

Performance

  1. Fastest Mirror: Enable fastest mirror plugin
  2. Parallel Downloads: Configure parallel downloads
  3. Delta RPMs: Enable delta RPM downloads
  4. Cache Management: Regular cache cleanup
  5. Repository Priorities: Set repository priorities

Maintenance

  1. Regular Cleanup: Clean package cache regularly
  2. History Tracking: Monitor transaction history
  3. Dependency Health: Check for broken dependencies
  4. Log Monitoring: Review system logs for issues
  5. Backup: Backup important configurations