Some FreeBSD Package Commands

Modern FreeBSD comes with the pkg(8) package manager which is handy for installing precompiled binary packages.  Like package managers elsewhere, the manager here is also very versatile.  Here are some of the commands I use for daily purposes.

I use pkg-rquery(8) and pkg-query(8) whenever possible.  The former queries the database in the repository and the latter queries the locally installed packages.  The PkgPrimer shows different commands as in here.  This is just a matter of taste on the output.

Before and Installing Packages

To look for packages, use pkg-search(8).  To drill down details, use pkg-rquery(8).  To install, use pkg-install(8).

Listing available packages:

pkg search <keyword>

Obtaining information of a package:

pkg search --full <keyword>

Querying dependency packages according to the repository

pkg rquery %dn <package 1> <package 2> ...

Same as above, with the version numbers

pkg rquery %dn-%dv <package 1> <package 2> ...

Installing some packages

pkg install <package 1> <package 2> ...

After Installing Packages

To obtain information of the installed packages (which may be out-of-sync with the repository), use pkg-info(8).  To query details, use pkg-query(8).  To delete packages, use pkg-delete(8).

Listing the installed packages

pkg info

Querying information of an installed package

pkg info <package>

Querying which package brings in a file

pkg which <filename>

Querying files coming with some installed packages

pkg query %Fp <package 1> <package 2> ...

Same as above, with per-file checksums

pkg query "%Fp %Fs" <package 1> <package 2> ...

Querying dependency packages of some installed packages

pkg query %dn <package 1> <package 2> ...

Same as above, with version numbers

pkg query %dn-%dv <package 1> <package 2> ...

Checking versions of the installed packages

pkg version

Uninstalling some packages

pkg delete <package 1> <package 2> ...

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s