OpenBSD Package Management - Beginner Guide

OpenBSD Package Management - Beginner Guide

Managing software packages is a core task in OpenBSD. Here's how to install, update, and remove programs.

Step 1: Update Package Lists

Before installing new software, update the package database:
pkg_info -E - show all installed packages with versions
pkg_add -u - update all packages to latest versions

What this does: Fetches the latest package information from the OpenBSD mirrors.

You should run this: Once a week, or before installing new software.

Step 2: Install a New Package

To install software, use pkg_add followed by the package name.

Examples:
pkg_add nano - installs the nano text editor
pkg_add firefox - installs the Firefox web browser
pkg_add vim - installs the vim text editor
pkg_add wget - installs wget for downloading files
pkg_add curl - installs curl for transferring data

OpenBSD only includes essential software by default. You'll need to install most things you're used to from other operating systems.

Step 3: Remove a Package

To remove software you no longer need:
pkg_delete nano - removes the nano text editor

Important: This removes the package files but may leave configuration files.

To remove everything (config too):
pkg_delete -r nano - removes package and its configuration

Step 4: Search for Packages

Not sure what package you need? You can search:
pkg_info -d '*editor*' - shows packages related to "editor"

Online search: Visit https://openbsd.org/ports.html
This shows all available packages organized by category.

Step 5: Common Package Management Tasks

List installed packages: pkg_info (shows long list)
pkg_info -E - show with versions (useful for updates)

Check for broken packages: pkg_info -D requires - checks dependencies

Upgrade system: syspatch - apply security patches (OpenBSD specific)
pkg_add -u - update all packages

Note: OpenBSD focuses on security, so system updates are important and frequent.

Ready to explore more packages? Proceed to Lesson 34: Package Management.

Article author: Arthur Isaev