📌 Core Differences You Should Know

FeatureLinuxOpenBSD
Init systemsystemd/sysvinitBSD init (/etc/rc)
Package managerapt, yum, dnf, pacmanpkg_add, pkg_delete
Servicessystemctl, /etc/init.drcctl, /etc/rc.conf.local
Configuration filesOften scatteredClean, in /etc
Kernel modulesDynamic (modprobe)Mostly compiled in
Networkingip, ifconfig, netplanifconfig, hostname.if
Logs/var/log/var/log, syslogd

🚀 Installation & First Boot

# Start OpenBSD installation (from ISO)
boot> bsd.rd

Follow the interactive install script:

  • Choose disk layout (use entire disk or custom)
  • Set hostname (ex: server1)
  • Choose sets to install (default is good)

🗃️ Package Management

# Start OpenBSD installation (from ISO)
boot> bsd.rd

🖥️ System Info & Monitoring

# Update package repository
export PKG_PATH=https://cdn.openbsd.org/pub/OpenBSD/$(uname -r)/packages/$(machine -a)/

# Install package
pkg_add vim htop nginx

# Search for package
pkg_info -Q nginx

# Remove package
pkg_delete nginx

# Upgrade all packages
pkg_add -u

⚙️ Service Management

# Enable service at boot
rcctl enable nginx

# Disable service
rcctl disable nginx

# Start/stop/restart service
rcctl start nginx
rcctl stop nginx
rcctl restart nginx

# Check service status
rcctl check sshd

🌐 Networking

Interfaces & IP Setup

# List interfaces
ifconfig

# Configure network manually
ifconfig em0 inet 192.168.1.100 netmask 255.255.255.0

# Set hostname and IP (persist)
echo "inet 192.168.1.100 255.255.255.0" > /etc/hostname.em0
echo "inet 192.168.1.1" > /etc/mygate
echo "nameserver 8.8.8.8" > /etc/resolv.conf

# Restart network
sh /etc/netstart

🔒 Firewall with PF (Packet Filter)

# Default config file
/etc/pf.conf

# Enable PF
pfctl -e

# Check status
pfctl -s all

# Reload config
pfctl -f /etc/pf.conf

# Simple pf.conf example:
block in all
pass out all keep state

👮‍♂️ User & Group Management

# Add user
useradd -m -G wheel -s /bin/ksh admin

# Set password
passwd admin

# Modify user
usermod -G wheel admin

# Delete user
userdel -r admin

# Add group
groupadd devops

🔐 SSH & Security

# Enable SSH
rcctl enable sshd
rcctl start sshd

# Change port or disable root login
vi /etc/ssh/sshd_config
Port 2222
PermitRootLogin no

# Apply changes
rcctl restart sshd

# Create authorized_keys
mkdir ~/.ssh && chmod 700 ~/.ssh
echo "<public_key>" > ~/.ssh/authorized_keys && chmod 600 ~/.ssh/authorized_keys

💾 Filesystem & Mounting

# Mount manually
mount /dev/sd1a /mnt

# View mounted filesystems
mount

# fstab location
/etc/fstab

# New disk formatting (example)
fdisk -iy sd1
disklabel -E sd1
newfs /dev/sd1a

🕸️ Web Server (httpd or nginx)

OpenBSD httpd (default)

vi /etc/httpd.conf
server "default" {
listen on * port 80
root "/htdocs"
}

rcctl enable httpd
rcctl start httpd

Nginx (via packages)

pkg_add nginx
rcctl enable nginx
rcctl start nginx

🛠️ Crontab & Scheduled Tasks

# Edit user crontab
crontab -e

# View all cron jobs
crontab -l

# Global cron file
/etc/crontab

# Example:
0 2 * * * /usr/local/bin/backup.sh

🧰 Handy Tools to Install

pkg_add vim htop git bash sudo wget curl rsync unzip tmux

# Set default shell
chsh -s /usr/local/bin/bash

🔄 System Updates

# Upgrade OS
sysupgrade

# Update packages after upgrade
pkg_add -u

📎 OpenBSD Directory Structure (Key Paths)

PathPurpose
/etcConfig files
/var/logSystem logs
/etc/rc.conf.localCustom service enable/disable
/etc/pf.confPacket Filter config
/etc/httpd.confOpenBSD httpd config
/homeUser home directories

🛑 Gotchas for Linux Users

  • No systemctl: use rcctl.
  • No dynamic kernel modules: compile-time only.
  • Filesystem is strict: default is ffs, not ext4.
  • sudo not installed by default — use doas.

Bonus: Configure doas (sudo alternative)

# Install doas (default in OpenBSD)
vi /etc/doas.conf

# Add rule:
permit persist :wheel

# Test
doas ls /root

📚 Resources