Chapter 13: Software management
dnf and rpm cheat sheet
The chapter on one page: what to remember, the commands to have at your fingertips, and flashcards for quick revision.
The chapter in eight sentences
- A package is named name-version-release.architecture, carries files, metadata, dependencies and a signature, and is recorded in the RPM database.
rpm -qanswers questions about what is installed:-iinfo,-lfiles,-cconfig files,-ddocs,-f FILEowner,-aeverything.rpm -Vcompares files with the package: flags such asS,5andTreveal a modified file;rpm -Kchecks the signature of a.rpmfile.dnfresolves dependencies from repositories:search,info,provides,install,remove,reinstall,upgrade; read the transaction summary before confirming.dnf historyrecords every transaction;dnf history undoreverses one.- Repositories are defined in
/etc/yum.repos.d/*.repo(baseurl,enabled,gpgcheck,gpgkey); keepgpgcheck=1. - A local repository is
dnf download --resolve,createrepo_c DIR, and a.repofile;--disablerepo='*' --enablerepo=IDproves where a package comes from. - AppStream module streams offer several versions of a program:
dnf module enable NAME:STREAM, anddnf module reset NAMEbefore switching; apply updates withdnf upgrade(--security) and checkdnf needs-restarting -r.
Cheat sheet
rpm
| Command | Does |
|---|---|
rpm -q NAME / -qi / -ql / -qc / -qd | Installed? Info, files, config, docs |
rpm -qf /path | Which package owns a file |
rpm -qa [--last] | All packages (newest first) |
rpm -V NAME | Verify files against the package |
rpm -K FILE.rpm, rpm -qpl FILE.rpm | Check signature; list contents |
rpm --import KEYFILE | Trust a vendor key |
dnf
| Command | Does |
|---|---|
dnf search, info, provides "*/file" | Find software |
dnf install, remove, reinstall NAME | Change packages |
dnf upgrade [--security], dnf check-update | Updates |
dnf history, history info ID, history undo ID | Review and reverse |
dnf group list, group install "NAME" | Package groups |
dnf needs-restarting -r | Is a reboot advisable? |
dnf clean all, dnf makecache | Refresh the cache |
Repositories and modules
| Command / file | Does |
|---|---|
dnf repolist [--all] | Repositories |
/etc/yum.repos.d/NAME.repo | [id], name, baseurl, enabled, gpgcheck, gpgkey |
dnf download --resolve --destdir D NAME | Fetch packages and dependencies |
createrepo_c D | Build the catalogue |
dnf --disablerepo='*' --enablerepo=ID ... | Use one repository |
| `dnf module list | enable |
/etc/dnf/modules.d/NAME.module | The enabled stream |
Flashcards
- How is a package name read?
- name-version-release.architecture, for example tree-1.8.0-10.el9.x86_64.
- Ask rpm about an installed package?
- rpm -q NAME · rpm -qi NAME · rpm -ql NAME · rpm -qc NAME · rpm -qd NAME
- Which package owns a file?
- rpm -qf /path (installed) · dnf provides "*/file" (any repository)
- Check a package for changed files?
- rpm -V NAME
- Search, show, install, remove with dnf?
- dnf search · dnf info · dnf install · dnf remove
- See and undo transactions?
- dnf history · dnf history info ID · dnf history undo ID|last
- List updates and apply security ones only?
- dnf check-update · dnf upgrade --security
- Where are repositories defined?
- /etc/yum.repos.d/*.repo: id, name, baseurl, enabled, gpgcheck, gpgkey
- Use one repository only?
- dnf --disablerepo="*" --enablerepo=ID install NAME
- Build a local repository?
- dnf download --resolve --destdir DIR NAME · createrepo_c DIR · add a .repo file
- Choose a version of a program?
- dnf module list NAME · dnf module enable NAME:STREAM · dnf module reset NAME
- Check a downloaded .rpm?
- rpm -K FILE.rpm (digests and signatures OK)