UNIX Consulting and Expertise
Golden Apple Enterprises Ltd. » Page 'Solaris basics: checking which package a file belongs to'

Solaris basics: checking which package a file belongs to

Looking for UNIX and IT expertise? Why not get in touch and see how we can help?

We’ve all been there – there’s a missing binary or library on a Solaris host, someone’s accidentally deleted it, and we need to re-install the package. Or the other common scenario – two boxes that have been built by hand, one has binary A and the other doesn’t – which package adds it?

Along with the usual Solaris package management commands of pkgadd and pkgrm, there’s a lesser known utility called pkgchk. pkgchk allows us to check which package a file belongs to.

pkgchk will work with binaries:

-bash-3.00$ /usr/sbin/pkgchk -l -p /usr/bin/less
NOTE: Couldn't lock the package database.
Pathname: /usr/bin/less
Type: regular file
Expected mode: 0555
Expected owner: root
Expected group: bin
Expected file size (bytes): 117760
Expected sum(1) of contents: 20724
Expected last modification: Jan 23 01:48:30 2005
Referenced by the following packages:
        SUNWless       
Current status: installed

And we can also invoke pkgchk for libraries as well:

-bash-3.00$ /usr/sbin/pkgchk -l -p /lib/libresolv.so.1
NOTE: Couldn't lock the package database.
Pathname: /lib/libresolv.so.1
Type: regular file
Expected mode: 0755
Expected owner: root
Expected group: bin
Expected file size (bytes): 48368
Expected sum(1) of contents: 5063
Expected last modification: Jan 23 01:44:54 2005
Referenced by the following packages:
        SUNWcslr       
Current status: installed

For a quick overview of some of the other options, just invoke pkgchk with the -? command line:

 -bash-3.00$ /usr/sbin/pkgchk -?
usage:
        pkgchk [-l|vqacnxf] [-R rootdir] [-p path[, ...] | -P path[, ...]]
                [-i file] [options]
        pkgchk -d device [-f][-l|v] [-p path[, ...] | -P path[, ...]]
                [-V ...] [-M] [-i file] [-Y category[, ...] | pkginst [...]]
        where options may include ONE of the following:
                -m pkgmap [-e envfile]
                pkginst [...]
                -Y category[, ...]

As you can see from the output, pkgchk is also very handy to see if the binaries or libraries that were part of a Solaris package file have been overwritten. As each file in a package has it’s checksum, file size, ownership, and permissions stored as part of the package manifest, this gets added to the Solaris package database when the package is installed – giving a quick and easy method to sanity check your installation.

Like this post? Spread the word!
delicious digg google
stumbleupon technorati Yahoo!

Comments are closed.

Top of page / Subscribe to new Entries (RSS)