pkg_info用法详解

(1)直接执行pkg_info命令可以查询目前系统已经安装的软件包:
[[email protected] ~]# pkg_info

(2)查询某个关键字相关的软件包有没有安装:
[[email protected] ~]#pkg_info | grep mail

cclient-2007e,1     Mark Crispin's C-client mail access routines
courier-imap-4.8.0,2 IMAP (and POP3) server that provides access to Maildir mail
dcc-dccd-1.3.116    Distributed Checksum Clearinghouse bulk email detector
maildrop-2.5.0      Mail delivery agent (MDA) with filtering abilities
mailgraph-1.14_3    A RRDtool frontend for Postfix statistics
p5-Mail-DKIM-0.38   Perl5 module to process and/or create DKIM email
p5-Mail-SpamAssassin-3.3.1 A highly efficient mail filter for identifying spam
p5-Mail-Tools-2.06  Perl5 modules for dealing with Internet e-mail messages
postfix-2.7.1,1     A secure alternative to widely-used Sendmail
squirrelmail-1.4.20_2 A webmail system which accesses mail over IMAP

(3)查询某个文件属于那个软件包:
[[email protected] ~]# whereis postfix

postfix: /usr/local/sbin/postfix

[[email protected] ~]# pkg_info -W /usr/local/sbin/postfix

/usr/local/sbin/postfix was installed by package postfix-2.4.6,1

注:如果执行pkg_info -W file后没有显示任何信息,说明这个文件是freebsd系统内建的。
如执行pkg_info -W /bin/ls后是不会显示出任何信息的,说明ls文件是系统内建的!

(4)查询某个已安装的软件包含了有那些文件,所有pkg_add或ports方式安装的软件信息都在/var/db/pkg目录:
如要查找已安装的软件postfix包含有那些文件,可执行:
[root@www.sitkylin.com ~]# pkg_info |grep postfix

postfix-2.7.1,1     A secure alternative to widely-used Sendmail

根据已上显示的软件版本信息,继续执行以下命令即可:
[[email protected] ~]# pkg_info -L /var/db/pkg/postfix-2.7.1,1 |more