Skip to main content.

Ports and packages in OpenBSD


Live demo in BSD Now Episode 040 | Originally written by TJ for | Last updated: 2014/11/01

NOTE: the author/maintainer of the tutorial(s) is no longer with the show, so the information below may be outdated or incorrect.

Like most of the other BSDs, OpenBSD supports multiple ways of installing third party software. Both their ports and package systems were originally taken from FreeBSD, but have since changed quite a bit. If you're familiar with the FreeBSD versions, you'll notice a lot of similarities, but also some interesting differences. Both ways make it really easy to install, remove and update programs that you may want to add to the base system. OpenBSD handles port branches a bit differently. There are -current and -stable branches that get security updates, and the -release branch which is frozen before a release every six months. You can (and should) run the -stable branch of ports on either a -release or -stable system, but the -current branch will only work on -current. Things must be kept in sync with the base system version. It's recommended to properly set up sudo instead of using the root account, and the FAQ has instructions for that. To get your initial copy of the ports tree, you can either download the -stable tree directly via CVS like so:

# cd /usr
# cvs -qd get -rOPENBSD_`uname -r | sed 's/\./_/'` -P ports

Or grab the -release distribution and then update it:

# cd /usr
# ftp`uname -r`/ports.tar.gz
# ftp`uname -r`/SHA256.sig
# signify -C -p /etc/signify/openbsd-`uname -r | cut -c 1,3` -x SHA256.sig ports.tar.gz

Signature Verified
ports.tar.gz: OK

# tar xzf ports.tar.gz
# rm ports.tar.gz SHA256.sig
# cd ports
# cvs -d -q up -rOPENBSD_`uname -r | sed 's/\./_/'` -Pd

Be sure to choose a mirror that's close to you for better speeds. OpenBSD's -stable ports tree is frozen on a per-version basis, other than for security updates or important fixes. This means that you can't get the latest version of a port if it's been committed to the -current tree but didn't make it in time for the release. If you want a "rolling release" style system like FreeBSD ports, you have to run -current. Now that we have an up to date -stable ports tree, we can begin installing software.

# cd /usr/ports/www/newsbeuter
# make install BULK=Yes

And that's all there is to it. The source code will be fetched, patched and compiled into a binary package for you. The resulting packages are in /usr/ports/packages and can be reused on other systems. Some ports offer different flavors and subpackages you can choose from. We'll use vim as an example here.

# cd /usr/ports/editors/vim
# make show=FLAVORS

huge gtk2 athena motif no_x11 perl python python3 ruby

Each of these are different flavors of the port you can use. Obviously I don't want any of those useless options, so I'll choose the sensible version like so:

# env FLAVOR="no_x11" make install

And it will be built as usual. For a subpackage, it's very similar:

# cd /usr/ports/net/pidgin
# make show=MULTI_PACKAGES

-main -finch -libpurple

# env SUBPACKAGE="-finch" make install

If you'd rather install from a binary package, you could do so like this:

# export PKG_PATH=`uname -r`/packages/`arch -s` 
# pkg_add vim

Ambiguous: choose package for vim
 a       0: <None>
         1: vim-7.4.135p0-gtk2
         2: vim-7.4.135p0-gtk2-perl-python-ruby
         3: vim-7.4.135p0-gtk2-perl-python3-ruby
         4: vim-7.4.135p0-no_x11
         5: vim-7.4.135p0-no_x11-perl-python-ruby
         6: vim-7.4.135p0-no_x11-perl-python3-ruby
Your choice: 

You can select which version you want to install very easily this way too. Multiple packages can be specified at once with pkg_add. You can export the PKG_PATH variable in your ~/.profile or /etc/pkg.conf so you don't have to type it every time. If you'd like to install multiple ports at once, you may be interested in using dpb for that. To list all the ports/packages you currently have installed (there's no difference once they are installed) you can run:

# pkg_info

cowsay-3.03             speaking ascii cow
dnscrypt-proxy-1.3.3p0  secure communications between a DNS client and resolver
mutt-1.5.22p0v0         tty-based e-mail client, development version
newsbeuter-2.7          open-source RSS/Atom feed reader for text terminals
rsync-3.1.0-iconv       mirroring/synchronization over low bandwidth links
vim-7.4.135p0-no_x11    vi clone, many additional features

Searching the ports tree is also really simple.

# cd /usr/ports
# make search key=vnstat

Port:   vnstat-1.11p6
Path:   net/vnstat
Info:   network traffic monitor
Maint:  Pierre-Emmanuel Andre <>
Index:  net sysutils
L-deps: graphics/gd
B-deps: devel/gmake
Archs:  any

To update your -stable ports tree, run:

# cd /usr/ports
# cvs -d -q up -rOPENBSD_`uname -r | sed 's/\./_/'` -Pd

Note that the -d option is only needed if you got your tree from the ports.tar.gz file. If you initially got it from CVS, you can omit that part and just run:

# cd /usr/ports
# cvs -q up -rOPENBSD_`uname -r | sed 's/\./_/'` -Pd

You can check which of your ports are out of date by running a script that's included with the ports collection.

# /usr/ports/infrastructure/bin/out-of-date

Collecting installed packages: ok
Collecting port versions: ok
Collecting port signatures: ok
Outdated ports:

devel/quirks                   # always-update -> quirks-1.113
graphics/cairo                 # @png-1.6.8 -> @png-1.6.8p0
graphics/gdk-pixbuf2           # @png-1.6.8 -> @png-1.6.8p0
graphics/imlib2                # @png-1.6.8 -> @png-1.6.8p0
graphics/png                   # 1.6.8 -> 1.6.8p0
www/firefox-esr                # 24.3.0 -> 24.5.0

Upgrading a port is as easy as running the following in the port directory:

# cd /usr/ports/graphics/png
# echo 'FETCH_PACKAGES=Yes' >> /etc/mk.conf
# make update

The FETCH_PACKAGES variable will tell ports to install build dependencies from binary packages, so you only have to compile the port that actually needed updating. To update all your binary packages at once:

# pkg_add -u

But this assumes the mirror you set as your PKG_PATH has updated packages. The official mirrors do not. Uninstalling something is as simple as:

# pkg_delete vim

If you've built something from ports and want to remove all the build dependencies, or just want to clean up a system after uninstalling something, run:

# pkg_delete -a

It will remove all the orphaned packages that are no longer required. It's worth noting that OpenBSD does not provide security updates for packages outside of -current, so you will need to use ports for security fixes. If you have a lot of machines to update, the previously-mentioned dpb tutorial will be very useful. Since there usually aren't many updates between -release and -stable ports, you may want to save some time and just install everything from packages. Be sure to check if there have been any fixes committed to the -stable branch that affect you, though. Two handy sites for searching the ports tree online are and Additional configuration can be done with the /etc/mk.conf file.

Latest News

New announcement


We understand that Michael Dexter, Brad Davis, and George Rosamond think there should be more real news....

Two Year Anniversary


We're quickly approaching our two-year anniversary, which will be on episode 105. To celebrate, we've created a unique t-shirt design, available for purchase until the end of August. Shirts will be shipped out around September 1st. Most of the proceeds will support the show, and specifically allow us to buy...

New discussion segment


We're thinking about adding a new segment to the show where we discuss a topic that the listeners suggest. It's meant to be informative like a tutorial, but more of a "free discussion" format. If you have any subjects you want us to explore, or even just a good name...

How did you get into BSD?


We've got a fun idea for the holidays this year: just like we ask during the interviews, we want to hear how all the viewers and listeners first got into BSD. Email us your story, either written or a video version, and we'll read and play some of them for...

Episode 258: OS Foundations


Direct Download:MP3 AudioVideo This episode was brought to you by Headlines FreeBSD Foundation Update, July 2018 MESSAGE FROM THE EXECUTIVE DIRECTOR We’re in the middle of summer here, in Boulder, CO. While the days are typically hot, they can also be quite unpredictable. Thanks to the Rocky Mountains, waking up to 50-degree (~10...

Episode 257: Great NetBSD 8


Direct Download:MP3 AudioVideo This episode was brought to you by Headlines NetBSD v8.0 Released The NetBSD Project is pleased to announce NetBSD 8.0, the sixteenth major release of the NetBSD operating system. This release brings stability improvements, hundreds of bug fixes, and many new features. Some highlights of the...

Episode 2^8: Because Computers


Direct Download:MP3 AudioVideo This episode was brought to you by Win Celebrate our 256th episode with us. You can win a Mogics Power Bagel (not sponsored). To enter, go find the 4 episodes we did in December of 2017. In the opening, find the 4 letters in the bookshelf behind me. They...

Episode 255: What are you pointing at


Direct Download:MP3 AudioVideo This episode was brought to you by Headlines What ZFS block pointers are and what's in them I've mentioned ZFS block pointers in the past; for example, when I wrote about some details of ZFS DVAs, I said that DVAs are embedded in block pointers. But I've never really...