Mastering software management on NetBSD: building packages from source with pkgsrc, installing binary packages with pkg_add, and managing packages with pkg_info, pkg_admin, and pkg_chk.

In episode 3 we successfully installed NetBSD and booted your first system. That system is still "empty" — it only contains the base system. Now it's time to fill it with software: in this episode we'll master NetBSD package management with pkgsrc and pkg_add — the two main paths for installing software outside the base system.
This is one of NetBSD's biggest differences from Linux. On Linux, you're used to a single package manager that unifies the system and its software. On NetBSD, use pkg_add for binary packages and pkgsrc for building from source — both run on top of the base system without mixing into it, exactly as we learned in episode 2. Let's start with the concepts.
pkgsrc is NetBSD's package build framework that also runs on many other systems: Linux, macOS, FreeBSD, Solaris, and others. This is what gives NetBSD a portability power that extends down to the software level. A single pkgsrc source tree contains thousands of packages, each with its own Makefile, dependencies, and build instructions.
Two ways to use pkgsrc:
| Method | Command | Speed | When to Use |
|---|---|---|---|
| Binary package | pkg_add | Fast (download ready-made) | Official/popular packages |
| Build from source | make install in /usr/pkgsrc | Slow (compilation) | Package has no binary, or you want custom flags |
Both produce packages that are registered in the same pkg_install database — managed with pkg_info, pkg_admin, and pkg_delete.
If you install from the NetBSD binary repository, packages are already available as .tgz or .tbz. Use pkg_add with the package name:
pkg_add -v htoppkg_add: pkgconf>=2.1.0: installing 'pkgconf-2.1.0'
pkg_add: htop-3.3.0: installing 'htop-3.3.0'
pkg_add: 1 package addedNotice that the dependency (pkgconf) is installed automatically. To search for available packages in the repository:
pkg_info -Q htop
pkg_info -Q nmaphtop-3.3.0: Interactive process viewer
nmap-7.95: Network exploration tool and security scannerInfo
The official NetBSD binary repository is organized per release and per architecture, e.g. ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/amd64/11.0/. Make sure the PKG_PATH variable points to the repository matching your version and architecture.
This is the most "NetBSD" path: building a package from source. First, get the pkgsrc source tree. The modern way is via pkgsrc-bootstrap with git:
cd /usr
git clone -b pkgsrc-2026Q2 --depth 1 \
https://github.com/NetBSD/pkgsrc.git pkgsrcThen to build a package, move to the package directory and run make:
cd /usr/pkgsrc/sysutils/htop
make install clean=> Checksum OK for htop-3.3.0.tar.gz.
=> Building htop-3.3.0
=> Installing dependencies: ncurses>=6.0
...
=> Installing htop-3.3.0Building from source takes time, but gives you full control: you can set build options, apply patches, and ensure the binary is optimized for your machine. It's the same philosophy as build.sh in episode 10 — NetBSD emphasizes transparency.
The build result can be wrapped into a binary package so it can be installed on other machines:
make package=> Creating binary package /usr/pkgsrc/packages/All/htop-3.3.0.tgzThat binary package can then be moved to another machine and installed with pkg_add. This is a common workflow for deploying software to many identical NetBSD servers.
pkg_infohtop-3.3.0 Interactive process viewer
pkgconf-2.1.0 Package compiler and linker metadata toolkitTo see the details of a single package — including installed files and dependencies:
pkg_info -v htop
pkg_info -f htoppkg_delete htop
pkg_delete -R htopThe -R option removes the package along with its dependencies that aren't used by other packages.
pkg_admin is the package database administration tool. It's most often used to check package integrity:
pkg_admin checkChecking pkgconf-2.1.0 ...
Checking htop-3.3.0 ...
All packages installed correctlypkg_admin can also display dependencies (with pkg_admin deptree) and check for missing files (pkg_admin lsall) — useful during system audits.
Updating packages on NetBSD can be done in two ways:
pkg_add -u — updates packages to the latest versions available in the repository:pkg_add -upkg_chk (itself a pkgsrc package) — matches installed packages against the versions available in the source tree, then builds the ones that are behind:cd /usr/pkgsrc/pkgtools/pkg_chk
make install
pkg_chk -upkg_chk -u rebuilds every package whose version is older than what's available in the source tree — the most "NetBSD" flow for keeping a system fresh.
In this episode 4, you've mastered NetBSD's two package management paths: pkgsrc for building from source with make install in /usr/pkgsrc, and pkg_add for installing ready-to-use binary packages. You also learned to manage packages with pkg_info, pkg_delete, pkg_admin, and to update them with pkg_add -u and pkg_chk.
Key takeaways:
/usr/pkg, separate from the base system.pkg_add for fast binaries, make install in the source tree for full control.pkg_info (list), pkg_delete (remove), pkg_admin (audit).pkg_add -u or pkg_chk -u.make package for distribution.In the next episode, episode 5, we'll manage the system's inhabitants: users, groups, and privileges — creating accounts with useradd, managing groups in /etc/group, and limiting root access with su, doas, and sudo. See you in episode 5!