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 267: Absolute FreeBSD


Direct Download:MP3 AudioVideo Headlines Interview - Michael W. Lucas - / @mwlauthor BR: [Welcome Back] AJ: What have you been doing since last we talked to you [ed, ssh, and af3e] BR: Tell us more about AF3e AJ: How did the first Absolute FreeBSD come about? BR: Do you have anything special planned for MeetBSD? AJ: What...

Episode 266: File type history


Direct Download:MP3 AudioVideo Headlines OpenBSD/NetBSD on FreeBSD using grub2-bhyve When I was writing a blog post about the process title, I needed a couple of virtual machines with OpenBSD, NetBSD, and Ubuntu. Before that day I mainly used FreeBSD and Windows with bhyve. I spent some time trying to set up...

Episode 265: Software Disenchantment


Direct Download:MP3 AudioVideo Headlines [FreeBSD DevSummit & EuroBSDcon 2018 in Romania] Your hosts are back from EuroBSDcon 2018 held in Bucharest, Romania this year. The first two days of the conference are used for tutorials and devsummits (FreeBSD and NetBSD), while the last two are for talks. Although Benedict organized the devsummit in large...

Episode 264: Optimized-out


Direct Download:MP3 AudioVideo This episode was brought to you by Headlines FreeBSD & DragonFlyBSD Put Up A Strong Fight On AMD's Threadripper 2990WX, Benchmarks Against Linux The past two weeks I have been delivering a great deal of AMD Threadripper 2990WX benchmarks on Linux as well as some against Windows and Windows...