CHEAT SHEET
dnf & rpm cheat sheet
Install, find and inspect packages, manage repositories and register a RHEL system.
Everyday dnf
dnf install -y httpd # installdnf remove httpd # removednf update # update everythingdnf check-update # what is availablednf search keyword # search names and summariesdnf info httpd # details of a packagednf list installed # installed packagesdnf group list # package groupsdnf group install "Development Tools"dnf clean all # clear the cache
Find the owner
dnf provides '*/semanage' # which package ships a commanddnf provides /etc/hosts # which package owns a filednf download httpd # download the RPM without installing (dnf-plugins-core)
History
dnf history # list transactionsdnf history info 5 # what transaction 5 diddnf history undo 5 # reverse transaction 5
Repositories
dnf repolist # enabled repositoriesdnf repolist --all # include disabled onesdnf config-manager --enable NAME # enable onednf config-manager --disable NAME # disable one
# /etc/yum.repos.d/local.repo[local-appstream]name=Local AppStreambaseurl=http://server.example.com/repo/AppStreamenabled=1gpgcheck=0
Use gpgcheck=1 and a gpgkey= line for any repository you do not fully control.
rpm queries
rpm -qa # every installed packagerpm -q httpd # is it installed?rpm -qi httpd # package informationrpm -ql httpd # files the package installedrpm -qc httpd # its configuration filesrpm -qf /etc/hosts # which package owns a filerpm -qp package.rpm -l # files inside an RPM you have not installedrpm -V httpd # verify the files against the packagerpm -qa --last # newest packages firstrpm -ivh package.rpm # install a local RPMrpm -Uvh package.rpm # upgrade (or install) a local RPM
subscription-manager
subscription-manager register --username USER # register this systemsubscription-manager status # is it registered and entitled?subscription-manager repos --list-enabled # repositories you can usesubscription-manager unregister # remove the registration
More cheat sheets
Questions
How do I find which package provides a command?
Use dnf provides '*/command', for example dnf provides '*/semanage'.
How do I list the files a package installed?
Use rpm -ql package. rpm -qc lists only its configuration files and rpm -qf /path/to/file shows which package owns a file.
How do I undo a dnf transaction?
Run dnf history to find the ID, then dnf history undo ID.
How do I add a repository on RHEL?
Create a .repo file in /etc/yum.repos.d/ with name, baseurl, enabled and gpgcheck, then run dnf repolist to confirm.