Home arrow Configure arrow Managing FreeBSD Packages
Managing FreeBSD packages PDF
Tuesday, 10 April 2007
FreeBSD system have a flexible and easy to use system for package management. 
Tools for managing FreeBSD packages are pkg_add, pkg_delete, pkg_info, pkg_version and pkg_create.

1. Adding a package with pkg_add
To add a package with pkg_add:

# pkg_add package_name

To add a package from FreeBSD ftp site (notice -r option, what means remote fetching:

# pkg_add -r package_name
(package_name will be written without version number, for example pkg_add -r apache).

Package will be fetched from Latest packages of the FreeBSD version installed on our server. If that package is not in Latest dir we can add package from distribution package directory:

# pkg_add -r ftp://ftp.freebsd.org/pub/FreeBSD/ports/i386/packages-6-stable/All/apache-2.2.4_2.tbz

In case you add a package from local drive, if that package will need other packages (dependencies) it will search on the same directory where you've issued the pkg_add command. If it will not find other dependencies packages there, it will abort installation returning an error message. If you add a package using remote fetching feature, all dependencies will be installed from FreeBSD ftp server too.

2. Getting info about installed packages
Info about installed packages and versions can be obtain with pkg_info.

# pkg_info | grep apache

To show all installed packages:

# pkg_info -a

To show a list of all files from a package:

# pkg_info -L package_name

To show a list of packages on which the package depends (dependencies):

# pkg_info -r package_name

If you want to know what packages need pagkage_name package:

# pkg_info -R package_name


3. Deleting packages with pkg_delete
To delete a package:

# pkg_delete package_name

Sometimes you will not be able to delete because deleting that particular package will break dependencies (that packages is needed by other packages). In that case if you still want to delete that packages, use -f (force deleting).

# pkg_delete -f package_name

4. Find package name for a binary installed file

# pkg_info -W filename

If this is not working, use the path+file name instead of filename

5. Create a new package from an installed one
The easyest way to create a package from an installed one is with pkg_create.

# pkg_create -jb package_name

For this command to work, package_name must be an installed package on the system. "-j" option will help you to create bzip2 instead of gzip, bzip2 being compression for FreeBSD versions 5.x and higher.

Last Updated ( Monday, 13 February 2012 )

Other BSD Systems





Best BSD firewall?