متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 214System · Packages

How to find which package owns a file

"Where does /usr/bin/dig come from?", "Which package do I install to get semanage?", "Did someone change files of the openssh-server package?" — the package database answers all three. This how-to shows the commands for RHEL (rpm, dnf) and Debian/Ubuntu (dpkg, apt-file): file → package, command → package to install, package → files, and checking files against the package.

  • 5 الدروس
  • 3 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

214.1

The quick answer

rpm -qf /usr/bin/ssh
dnf provides '*/bin/semanage'
dpkg -S /usr/bin/ssh
apt-file search bin/dig

الأوامر في هذا الدرس

214.2

Step by step

  1. File → package (installed files) — rpm -qf FILE on RHEL, dpkg -S FILE on Debian/Ubuntu. For a command, use its full path: rpm -qf "$(command -v ssh)".
  2. Command not installed → which package? — search all repositories:
dnf provides '*/bin/semanage'
apt install apt-file && apt-file update
apt-file search bin/semanage
  1. Package → files — what did a package install (configs, binaries, units)?
rpm -ql openssh-server
rpm -qc openssh-server
dpkg -L openssh-server

rpm -qc lists only config files.

  1. Package details — version, install date, source:
rpm -qi openssh-server
dnf info openssh-server
apt show openssh-server
  1. Were package files changed? — compares size, checksum, rights and owner with the package database:
rpm -V openssh-server
dpkg --verify openssh-server

Each 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.

  1. Verify everything (slow, good after an incident): rpm -Va or dpkg --verify. For real integrity checking use AIDE.
  2. File in no package — rpm -qf says not owned by any package: installed by hand, by a script, or created at runtime. Find out who put it there.

الأوامر في هذا الدرس

214.3

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.

214.4

Common problems

ProblemCauseFix
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 foundFile not from a package, or path via a link (/bin → /usr/bin).Try the real path; realpath FILE.
dnf provides finds nothingPattern without wildcard.Use '*/bin/NAME' in quotes.
apt-file: command not found / emptyTool missing or no index.Install it and run apt-file update.
rpm -V shows many changed configsNormal admin changes.Focus on non-config files and binaries.
Verify shows missingFiles deleted by hand.Reinstall: dnf reinstall PKG / apt install --reinstall PKG.

الأوامر في هذا الدرس

214.5

Go further

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.

الأوامر في هذا الدرس

كل الأوامر في هذا الفصل