هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.
$ مستخدم عادي# بصلاحية root (أو مع sudo)
The quick answer
Step by step
- File → package (installed files) —
rpm -qf FILEon RHEL,dpkg -S FILEon Debian/Ubuntu. For a command, use its full path:rpm -qf "$(command -v ssh)". - Command not installed → which package? — search all repositories:
dnf provides '*/bin/semanage'
apt install apt-file && apt-file update
apt-file search bin/semanage- Package → files — what did a package install (configs, binaries, units)?
rpm -qc lists only config files.
- Package details — version, install date, source:
- Were package files changed? — compares size, checksum, rights and owner with the package database:
rpm -V openssh-server
dpkg --verify openssh-serverEach output line is one changed file; 5 = checksum differs, c marks a config file (changes there are often normal). A changed binary is a warning sign.
Check that it worked
rpm -qf /usr/bin/ssh prints openssh-clients-… (Debian: openssh-client: /usr/bin/ssh); dnf provides names policycoreutils-python-utils for semanage; rpm -V openssh-server prints nothing for an unchanged package.
Common problems
| Problem | Cause | Fix |
|---|---|---|
not owned by any package for a symlink | /usr/bin/python3 and others are links. | Resolve first: rpm -qf "$(readlink -f /usr/bin/python3)". |
dpkg-query: no path found | File not from a package, or path via a link (/bin → /usr/bin). | Try the real path; realpath FILE. |
dnf provides finds nothing | Pattern without wildcard. | Use '*/bin/NAME' in quotes. |
apt-file: command not found / empty | Tool missing or no index. | Install it and run apt-file update. |
rpm -V shows many changed configs | Normal admin changes. | Focus on non-config files and binaries. |
Verify shows missing | Files deleted by hand. | Reinstall: dnf reinstall PKG / apt install --reinstall PKG. |
Go further
- Command pages: rpm, dnf.
- Next how-tos: Patch a server with security updates, Check file integrity with AIDE, Create a local package repository, Find files by name, size, date or content.
- Learn it: RHCSA — Query packages with rpm, RHCSA — Find software.
1Which command finds the package that owns an installed file on RHEL?
rpm -qf /path/to/file.
2What does rpm -V check?
It compares the installed files of a package with the package database: size, checksum, rights, owner and time.