# OpenBSD: base and package management

Note, each of the commands comes with a man page, which I encourage you to read. This post is merely to get you started. Also note, that there is [afterboot(8)](https://man.openbsd.org/afterboot).

## Base System

### Upgrade OpenBSD to the next version (will reboot)

```
# sysupgrade
```

### Update base system configuration files after an OpenBSD upgrade

```
# sysmerge
```

### Install security updates for the base system

```
# syspatch
```

### Update firmware

This does not need to be run manually. It's only relevant when you install hardware which needs a firmware and which was not present during the installation or the last upgrade.

```
# fw_update
```

## Add On Package System

### Search for a package

```
# pkg_info -Q xfce
```

### Install a package

```
# pkg_add xfce
```

### Uninstall a package

```
# pkg_delete xfce
# pkg_delete -c xfce # also remove configuration
```

### Deinstall leftover dependencies

```
# pkg_delete -a
# pkg_delete -ac # also remove configuration
```

### Update packages

```
# pkg_add -u
```

### Check/repair package database

This command is only relevant if you see errors during `pkg_add`. This can happen if your system crashes while updating, which may get the package database into a weird state. If you don't know the answers to pkg_checks questions, deinstalling and reinstalling the package in question usually solves the problem.

```
# pkg_check
```

### Deinstall all packages on the system
```
# pkg_delete -X
```
