OpenBSD is a free and multi-platform UNIX operating system that relies on security and portability. It has been forked from NetBSD back in the mid ’90s and since then it has always received updates. While it’s not as spread as FreeBSD or any GNU/Linux distribution, it’s a robust system and it may still be relevant in some scenarios where security is a must.

In this tutorial i’ll walk you trough a step-by-step guide on how to install and configure OpenBSD 6.8(latest release at the time of writing) in a virtual machine using xfce4 as a desktop environment.

# Prerequisites⌗

In order to follow this tutorial you will need:

• a virtual machine(at least 5GiB of disk, 2 GiB of RAM and network connection);
• basic UNIX knowledge(OpenBSD is not a beginner-friendly operating system);
• Around 10-15 minutes of your time.

# Installation⌗

Like any other BSD system, OpenBSD has an interactive installer which will ask you a set of questions to install and configure the system. This means that you do not have to type any commands to install OpenBSD, at least for the base system. When you power up the system for the first time you should see a prompt like this:

You can press ENTER to load the kernel, then wait for the system to loads up

After that, OpenBSD will launch the install command, which will allows you to install the system on your disk. As a general rule, if unsure, leave the default option; it’s probably the best configuration. Below i’ve included a set of screenshots showing how to setup the keyboard layout, the network configuration and the account configuration. Adjust these options accordingly to your needs.

## Partitioning the disk⌗

We’ve reached a crucial step: creating the partitions of our system. In order to do this, you will need to think about a partition scheme that will satisfy your personal needs. Since i’m installing OpenBSD on a virtual machine, I will use the MBR partition scheme with just two partitions: one for swap(2GiB) and one for the root(the remaining space). Once you have selected the device, type W to use the Whole disk with MBR. After that type C for Custom layout:

Now we will add a new partition by typing a, this will be the swap partition, so we type b in the partition field. We then change the size field to 2048M and the FS type field to swap.

Now, let us add the root partition. We can follow the same procedure, just set the partition field to a, the FS type field to 4.2BSD and the mount point field to /.

We are done here! Save the changes by typing w and then quit the partition tool with q.

## Installing the base system⌗

We are now ready to install the so-called “sets”(i.e. a group of archive files containing the base system). The OpenBSD installer allows you to select the source of these sets. If you have downloaded the installXX.iso image, then you can select cd0 since the disk image already contains everything needed for a basic installation.
Otherwise, you will need to select http and then cdn.openbsd.org as the source mirror. In both way, you will reach the following prompt

I suggest you to leave everything selected and to ignore the verification process by typing yes. Now the installer will extract the base system into your disk:

After that, you will need to enter your local timezone in the form of ${COUNTRY}/${CITY}. Done that, the installer will ask you to reboot the machine. OpenBSD is installed!

# Configuration⌗

The installer left us with a bare minimal system. Let’s install some packages using OpenBSD package manager!

## Install vim, sudo, htop⌗

#> pkg_add vim sudo htop


pkg_add should ask you which version of vim you want to install. In my machine I have selected the 10th option(vim-8.2.1805-no_x11)

Let’s now add $USER to the sudoers file in order to give him/her superuser access: #> visudo  Locate the following line and add this last line # User privilege specification root ALL=(ALL) SETENV: ALL$USER ALL=(ALL) ALL


## Installing Xfce4⌗

Let’s now install the xfce desktop environment by typing the following command:

$> sudo pkg_add xfce xfce-extras polkit2  This could take a while, depending on your network speed. After that set xfce4 as the default desktop environment with $> echo "startxfce4" >> /home/$USER/.xsession  Then enable xenodm(i.e. a daemon to execute X without root access) with $> sudo rcctl enable xenodm


You can now customize xfce by changing the theme, icons, cursor and the wallpaper to get something a little bit nicer like this:

OpenBSD is now installed and usable, continue reading the last part of this guide to learn more on how to manage the system.

OpenBSD works very differently from Linux. To start/stop a service you do not have systemctl, as you seen through the tutorial, to start a service you can use rcctl:

usage:	rcctl get|getdef|set service | daemon [variable [arguments]]
rcctl disable|enable|order [daemon ...]
rcctl ls all|failed|off|on|started|stopped


## Start/stop a service⌗

In order to stop a service you can use the following syntax:

$> sudo rcctl start <service_name>  For instance, to stop the smtpd daemon you will type sudo rcctl stop smtpd. ## Enable/disable a service⌗ In order to enable a service you can use the following syntax: $> sudo rcctl enable <service_name>


For instance, to disable the smtpd daemon you will type sudo rcctl disable smtpd.

## Multimedia⌗

To see if your network card is being recognized by the kernel you can use audioctl. If your sound cards works with OpenBSD, you should see something like this:

 $> sudo audioctl Password: name=auich0 mode= pause=1 active=0 nblks=16 blksz=480 rate=48000 encoding=s16le play.channels=2 play.bytes=0 play.errors=0 record.channels=2 record.bytes=0 record.errors=0  By default audio on OpenBSD is disabled, to enable it you need to type the following commands $> sudo sysctl kern.audio.record=1
#> echo kern.audio.record=1 >> /etc/sysctl.conf


and then, enable the sndiod service(sudo rcctl enable sndiod and sudo rcctl start sndiod).

## Use pkg⌗

pkg is a versatile package manager, to add a new package simple type

$> sudo pkg_add <package_name>  to remove a package type $> sudo pkg_delete <package_name>


$> sudo pkg_add -Uu  To search for a package type: $> sudo pkg_info -Q <package_name>


## Ports⌗

One of the key features of *BSD systems are ports. Ports are a collection of Makefiles that allows you to download software source code, compile it and install without any hassle. If you are an Arch user, think ports like an AUR alternative. Ports are a great way to install a package that is not distributed on the the official repositories or to install a cutting edge version of a program.

$> cd /tmp$> ftp https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/{ports.tar.gz,SHA256.sig}$> signify -Cp /etc/signify/openbsd-$(uname -r | cut -c 1,3)-base.pub -x SHA256.sig ports.tar.gz$> cd /usr
#> tar xzf /tmp/ports.tar.gz


To search for a specific package, install portslist(pkg_add portslist) and then execute the following commands:

\$> cd /usr/ports
#> make search key=htop
Port:	htop-3.0.1
Path:	sysutils/htop
Info:	interactive process viewer
Maint:	Ian Sutton <ian@ce.gl>
Index:	sysutils lang/python
L-deps:
B-deps:	devel/autoconf/2.69 devel/automake/1.16 devel/libtool devel/metaauto lang/python/3.8
R-deps:	devel/desktop-file-utils
Archs:	any