Installing Applications OpenBSD

General Information

Maybe you are switching to OpenBSD from Linux or Windows. Or maybe you are familiar with FreeBSD and its ports and packages systems. Either way, you may be wondering how to install applications on this secure OS. Like FreeBSD, most applications can be installed from the Internet. There are two different installation methods to choose from and they both deal with dependancies.


  • Local root access on the box or be able to su to root.
  • A SSH client that supports ANSI colors such as puTTy or SecureCRT (if you aren’t on the box).
  • Internet Access.


The ports tree is a collection of useful programs that have been ported to OpenBSD. These are not the binary packages, but the source to compile from. The advantage of ports is that you can compile a program tailored to your system, as apposed to somebody else’s.


Because ports are not recommended on OpenBSD, you have to manually install the ports tree.

Note:Don’t forget to substitute the version number with the version you have installed because mixing your ports tree version and OpenBSD version would be bad.

# cd /usr
# ftp
# tar xzf ports.tar.gz
# rm -rf ports.tar.gz

Like FreeBSD, it’s always a good idea to keep your ports tree current and the best way to do that on OpenBSD is with the following:

Note:Like before, replace the version numbers with the version you are running.

# cd /usr/ports
# cvs -q -d up -r OPENBSD_3_6 -Pd


The ports tree is located at /usr/ports and it is organized by category/port. For instance, you will find Apache2 located in /usr/ports/www/apache2. If you know what you want to install but you don’t know where it’s located in the ports tree, you can issue:

# cd /usr/ports
# make search key=port name

For example, say I want to install nmap but I don’t know where it’s at. All I have to do is the following:

# cd /usr/ports
# make search name=nmap

Port:   ndiff-0.04
Path:   net/ndiff
Info:   compare two nmap scans and outputs the differences
Maint:  Brian Caswell 
Index:  net perl5
R-deps: nmap-*:net/nmap
Archs:  any

Port:   nmap-3.50
Path:   net/nmap
Info:   scan ports and fingerprint stack of network hosts
Maint:  Dan Weeks 
Index:  net security
L-deps: gtk.1.2,gdk.1.2::x11/gtk+ pcre::devel/pcre
Archs:  any

Port:   nmap-3.50-no_x11
Path:   net/nmap,no_x11
Info:   scan ports and fingerprint stack of network hosts
Maint:  Dan Weeks 
Index:  net security
L-deps: pcre::devel/pcre
Archs:  any

Ah, there it is in /usr/ports/security/nmap and now I can install it. Once you know what you want to install and where it’s located, let’s install it.

# cd /usr/ports/security/nmap
# make install clean

make simply compiles the program from source. install tells make to install the package after it’s compiled. Finally, clean tells make to clean up after itself as it creates files and directories during the compiling process. If there are missing dependencies, make will also grab and install them.

Note:An alternate is to run make install distclean that will delete the downloaded tarball located in /usr/ports/distfiles after it cleans up. This is to save your disk space.

Note:You can compile various ports with additional configuration options so it is a good idea to read the Makefile before you install the port.

That’s all there is to it. You will see a lot of compiling text scroll by and eventually your command prompt will return to you. At that time, you will know your package was installed and is ready to be used.

Now you can just as easily uninstall your application, say nmap, using the ports tree.

# cd /usr/ports/security/nmap
# make deinstall clean

nmap is now removed from your system.


OpenBSD packages are the binary versions of the ports and the recommended method of installing software on OpenBSD. This means somebody precompiled the application and so the installation goes by a lot quicker. There is no waiting for it to compile on your own system — it just gets installed. This also means you cannot add or remove any special compiling options for the package.


Installation and removal is quite simple. To install a package, say nmap, and grab the tarball from the Internet you would issue:

Note:Like before, replace the OpenBSD version number with the version you are running.

# setenv PKG_PATH
# pkg_add ${PKG_PATH}nmap-3.50.tgz

With OpenBSD’s pkg_add, you have give it the complete path of where you want to install your package from. The first command sets a variable for the remote location that you can reuse. If you set PKG_PATH then any dependencies will be installed from there as well.

Now, if you want to uninstall a package you installed, say nmap, you will have to issue:

# pkg_delete nmap-3.50

Note:You must specify the package with the version number as it appears in pkg_info(1) otherwise it will not be removed.

That’s all there is to it. Pick a method and have at it!


  1. Path: net/nmap,
    path is /usr/ports/net/nmap
    why there is /usr/ports/security/nmap ???

Speak Your Mind