Filters
Zo zoek je
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • "twee woorden" vindt precies die zin.
  • --naam of -x vindt een optie.
  • #woord zoekt alleen in commando's.
  • @grep vindt lessen en labs die grep gebruiken.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Zet ! voor een woord om het weg te laten. OR tussen woorden betekent één ervan.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken

rpm

Query, verify, install and remove RPM packages directly — mostly used to ask what is installed and which files a package has.

Niveau
RHCSA-examen
Groep
Softwarepakketten
Root nodig
Voor wijzigingen
Pakket
rpm

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

Wat het doet

rpm works with single package files and the RPM database (/var/lib/rpm). It does not solve dependencies or use repositories — that is the job of dnf. Use dnf to install; use rpm to ask questions.

Query mode is -q: add select options (-a all, -f file, -p package file) and query options (-i info, -l files, -c configs, -d docs, --scripts). -V verifies installed files against the database — a simple integrity check.

Zo schrijf je het

rpm -q [SELECT-OPTION] [QUERY-OPTION] [PACKAGE...]
rpm -V [SELECT-OPTION] [VERIFY-OPTION] [PACKAGE...]
rpm -i|-U|-F [INSTALL-OPTION] PACKAGE_FILE...
rpm -e [OPTION] PACKAGE...
rpm --import KEYFILE | -K PACKAGE_FILE

Opties 62

Meest gebruikt

Modes

-q, --query
Query packages.
-V, --verify
Compare installed files with the database.
-i, --install
Install a package file (no dependency solving).
-U, --upgrade
Install or upgrade a package file.
-F, --freshen
Upgrade only if an older version is installed.
--reinstall
Install the same version again.
-e, --erase
Remove a package.
--import KEYFILE
Import a GPG public key.
-K, --checksig
Check the digests and signature of a package file.
--querytags
List the tags for --queryformat.
--showrc
Show the rpm settings and macros.
--restore
Restore owner, group and mode of files from the database.
--rebuilddb
Rebuild the database.

Select packages

-a, --all
All installed packages.
-f, --file FILE
The package that owns this file.
-p, --package PACKAGE_FILE
Query a package file, not the database.
-g, --group GROUP
Packages in this RPM group.
--whatprovides CAPABILITY
Packages that provide it.
--whatrequires CAPABILITY
Packages that need it.
--whatrecommends, --whatsuggests, --whatsupplements, --whatenhances, --whatobsoletes, --whatconflicts CAPABILITY
Packages with this weak dependency or relation.
--triggeredby PACKAGE
Packages with triggers on it.
--path PATH
Packages that own the path (also not installed files).
--hdrid SHA1, --pkgid MD5, --tid TID, --querybynumber NUM
Select by internal IDs.

Query information

-i, --info
Package information (name, version, vendor, summary …).
-l, --list
All files.
-c, --configfiles
Only config files.
-d, --docfiles
Only documentation files.
-s, --state
State of each file (normal, replaced …).
-R, --requires
What the package needs.
--provides
What the package provides.
--conflicts, --obsoletes, --recommends, --suggests, --supplements, --enhances
Other dependency data.
--scripts
The install and remove scripts.
--triggers, --triggerscripts, --filetriggers
Trigger scripts.
--changelog
The change log (fixed CVEs are listed here).
--changes
The change log with full dates.
--last
Sort by install time, newest first.
--qf, --queryformat FORMAT
Own output format, like %{NAME} %{VERSION}\n.
--dump
Detailed file data.
--filesbypkg
Files with the package name.
--filecaps
File capabilities.
--noghost, --noconfig, --noartifact
Leave out these file types.
--dupes
Packages installed more than once.
--xml
XML output.

Verify options

--nofiles, --nodeps, --noscripts, --nodigest, --nosignature
Skip these checks.
--nosize, --nouser, --nogroup, --nomtime, --nomode, --nordev, --nocaps, --nolinkto, --nofiledigest
Skip these file checks.

Install and remove options

-h, --hash
Show # signs as progress.
-v, --verbose
More output.
--test
Only test; change nothing.
--nodeps
Do not check dependencies (dangerous).
--force
Same as --replacepkgs --replacefiles --oldpackage.
--replacepkgs, --replacefiles, --oldpackage
Allow reinstall, overwrite files, downgrade.
--noscripts, --notriggers
Do not run scripts or triggers.
--excludedocs, --includedocs
Without or with documentation.
--justdb
Change only the database, not the files.
--nosignature, --nodigest
Do not check signature or digest.
--allmatches
Remove all packages with this name.
--prefix NEWPATH, --relocate OLD=NEW
Install a relocatable package in another place.
--ignorearch, --ignoreos, --ignoresize, --noorder, --noplugins, --nocaps, --noverify, --badreloc, --excludepath, --percent, --allfiles, --nodb
Special install settings.

General

--root DIR
Use another root folder.
--dbpath DIR
Use another database folder.
--version
Show the version.
-?, --help
Show help.

Voorbeelden 13

$ als gewone gebruiker# als root (of met sudo)

  1. 1Is a package installed?

    rpm -q openssh-server
    openssh-server-9.9p1-7.el10.x86_64

    "package … is not installed" if not.

  2. 2Which package owns a file?

    rpm -qf /etc/ssh/sshd_config
    openssh-server-9.9p1-7.el10.x86_64

    Find the package of a config before you change it.

  3. 3Config and doc files of a package

    rpm -qc httpd
    rpm -qd httpd

    Where to look for settings and documentation.

  4. 4Search the list of installed packages

    rpm -qa | grep -i kernel

    All installed kernels.

  5. 5Newest installed packages first

    rpm -qa --last | head

    What changed recently? Useful after a problem appears.

  6. 6Check a downloaded package before installing

    rpm -qpi tool-1.2-1.el10.x86_64.rpm
    rpm -qp --scripts tool-1.2-1.el10.x86_64.rpm

    Read the scripts: they run as root.

  7. 7Check the signature of a package file

    rpm -K tool-1.2-1.el10.x86_64.rpm
    tool-1.2-1.el10.x86_64.rpm: digests signatures OK

    "NOT OK" or "key ID … not found" = do not install.

  8. 8Find changed system files (integrity)

    rpm -Va 2>/dev/null | grep -v ' c '
    S.5....T.    /usr/bin/someprog

    S = size, 5 = checksum, T = time changed. A changed binary can be malware; c = config file (often normal).

  9. 9Is a CVE fixed?

    rpm -q --changelog openssl | grep CVE-2024-

    Red Hat backports fixes; the version number alone does not tell.

  10. 10Show imported GPG keys

    rpm -q gpg-pubkey --qf '%{NAME}-%{VERSION}-%{RELEASE}\t%{SUMMARY}\n'

    Every key you trust for packages.

  11. 11Own report format

    rpm -qa --qf '%{NAME}\t%{VERSION}-%{RELEASE}\t%{INSTALLTIME:date}\n' | sort | head

    Inventory for audits.

  12. 12Restore permissions of package files

    rpm --restore openssh-server

    Fixes owners and modes changed by mistake.

  13. 13Extract files from a package without installing

    rpm2cpio tool-1.2-1.el10.x86_64.rpm | cpio -idmv

    Look at files of a package safely.

Let op

Bestanden

/var/lib/rpm/
The RPM database.
/etc/pki/rpm-gpg/
Red Hat GPG keys.

Exitcodes

0 :: Done (for -q: all packages found). 1 :: Error, or packages not installed / verify found problems.