find which package a file belongs to

Contributor Icon Contributed by Michilimackinac Date Icon January 13, 2004  
Tag Icon Tagged: Solaris system administration

It is occasionally useful to find which package a file belongs to in case you are trying to adjust packages and make systems consistent etc.


pkgchk -l -p /usr/sbin/fuser
with output like so:
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:
SUNWcsu
Current status: installed


grep /usr/sbin/fuser /var/sadm/install/contents | awk ‘$2 ~ /^f$/ {print $NF}’
which will simply output:
SUNWcsu
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

Previous recipe | Next recipe |
 
blog comments powered by Disqus