Posted by: jasonk2600 | October 11, 2009

OpenBSD Ports System Basics

Although using pre-compiled software packages may be easier in the short-term, compiling software through the ports collections has many advantages.  The main advantages of compiling software from source code are stability, performance, and proper configuration.  When installing a piece of software from the ports collection you can be assured that the binaries are fully compatible with your systems architecture.  The ports collection also enables full control over what optional portions of a software package are enabled, thus producing optimized binaries that do not contain unneeded features.  Since using the ports collection allows you to configure the software the way you prefer, the resulting software package will not only perform the way you expect it to, but is also inherently more secure.


I.  Installing the Ports Collection

The ports collection can be installed from a variety of sources and protocols.  It can be downloaded from any of the main OpenBSD FTP and Web server mirror sites.  When downloading the ports collection make sure to download the ports collection for the same version of OpenBSD that you are using.  For example, if your system is running OpenBSD v4.5 then you would download the ports collection file (ports.tar.gz) from  Once the download has completed, extract the ports.tar.gz file to the /usr directory.


# cd /usr
# tar -xvzf /path/to/ports.tar.gz


The ports collection can also be initially downloaded from an OpenBSD CVS mirror site. Be sure to follow proper Internet etiquette and download from a CVS mirror that is close to your physical location. A list of available OpenBSD CVS mirror sites can be found in the link below.



See the example below to download the ports collection for the first time on OpenBSD v4.5 using an anonymous CVS server.  The example below uses an anonymous CVS server located in California, to use a different CVS server simply replace “” with a different CVS server near you.  Similarly to using FTP or HTTP to download the ports collection, it is important to download the ports collection that is the same version as the version of OpenBSD that your computer is running.  To download the ports collection for a different version of OpenBSD replace “OPENBSD_4_5” with the version number that corresponds to your version of OpenBSD.  For example, if your system runs OpenBSD 3.8 you would replace “OPENBSD_4_5” with “OPENBSD_3_8”.


# cd /usr
# cvs -d get -rOPENBSD_4_5 -P ports


II.  Basic Usage of the Ports Collection


There are four basic operations that are used with the ports collection: finding a port, installing a port, uninstalling a port, and cleaning a port.


Finding a Port – The ports collection contains a wide variety of different software packages.  Each piece of software is located in a sub-category of the ports collection.  The ports collection contains a search feature that makes it easy to locate a particular software package.  The example below shows how to search the ports collection for the wget utility.  To find other software packages in the ports collection, simply replace “wget” with the name of the piece of software you are searching for.


# cd /usr/ports
# make search key="wget"


Installing a Port – To install a particular port, switch to the port’s directory and run “make install”.  This command will compile the software from source code and create a software package of compiled binaries.  It will then install the software from the package that was created.  Be sure to pay attention to any messages at the end of the installation for information on any extra steps that may be required to finalize the install.


# cd /usr/ports/net/wget
# make install


# make clean=depends


# make uninstall


# make show=FLAVORS
# make show=MULTI_PACKAGES
# env FLAVOR="no_x11" make install
# env SUBPACKAGE="-server" make install



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


%d bloggers like this: