Find to which Package a File Belongs

Occasionally, one needs to find to which package a file belongs in case you are trying to adjust packages and make systems consistent.

pkgchk -l -p /usr/sbin/fuser
with output like this:
Pathname: /usr/sbin/fuser
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: bin
Expected file size (bytes): 7944
Expected sum(1) of contents: 558
Expected last modification: Apr 06 15:48:18 2002
Referenced by the following packages:
Current status: installed

grep /usr/sbin/fuser /var/sadm/install/contents | awk ‘$2 ~ /^f$/ {print $NF}’
which will simply output as follows:
The awk command will only match “f” in the second field which in the contents file means “file”, so the above command will only work for files.

The Conversation

Follow the reactions below and share your own thoughts.