OpenBSD Install Ports Tree Collection

I have installed OpenBSD operating system but ports collection is missing at /usr/ports directory. How do I install ports from ftp / http site under OpenBSD?

Tutorial details
Difficulty level Easy
Root privileges Yes
Requirements OpenBSD
Est. reading time 5m
Port collection is essential for OpenBSD server or desktop/laptop based system. You can use the OpenBSD Ports Collection to create binary packages for third party applications.

Method # 1: Install ports from OpenBSD CDROM

If you have OpenBSD CDROM type the following command to copy out the contents of the ports tree to /usr/ports; you would mount the CD-ROM with ports on it on /cdrom and issue a command like follows:
# mount /cdrom
# cd /usr
# tar zxf /cdrom/ports.tar.gz

Method # 2: Install OpenBSD ports from FTP / HTTP mirror site

Use wget command (not installed by default on OpenBSD) or ftp command client and grab ports.tar.gz, enter:
$ cd ## go to home dir ##
$ wget$(uname -r)/ports.tar.gz
$ wget$(uname -r)/SHA256.sig

OR use the ftp command:
$ cd ## go to home dir ##
$ ftp$(uname -r)/ports.tar.gz
$ ftp$(uname -r)/SHA256.sig

OR use OpenBSD mirror from here:
$ cd ## go to home dir ##
$ ftp$(uname -r)/ports.tar.gz
$ ftp$(uname -r)/SHA256.sig

Sample output:

           => `ports.tar.gz'
Connecting to||:21... connected.
Logging in as anonymous ... Logged in!
==> SYST ... done.    ==> PWD ... done.
==> TYPE I ... done.  ==> CWD /pub/OpenBSD/6.0 ... done.
==> PASV ... done.    ==> RETR ports.tar.gz ... done.
Length: 11,184,931 (11M) (unauthoritative)
100%[=================================================================================================================>] 11,184,931   236.83K/s    ETA 00:00
11:45:29 (230.09 KB/s) - `ports.tar.gz' saved [11184931]

Extract ports tree on a OpenBSD

Verify ports.tar.gz file with signify command, enter:
## match your openbsd version here ( ##
$ signify -C -p /etc/signify/ -x SHA256.sig ports.tar.gz

Sample outputs:

Signature Verified
ports.tar.gz: OK

To extract ports.tar.gz use the tar command as root user:
# tar -zxvf ports.tar.gz -C /usr/
Sample outputs:


Once extracted, you can delete ports.tar.gz file using rm command as follows:
$ rm ports.tar.gz SHA256.sig

How do I use ports on a OpenBSD?

To use ports, cd into /usr/ports/ directory:
$ cd /usr/ports
$ ls

Sample outputs:

.cvsignore      biology         emulators       lang            productivity
CVS             books           fonts           mail            security
INDEX           cad             games           math            shells
Makefile        chinese         geo             meta            sysutils
README          comms           graphics        misc            telephony
archivers       converters      infrastructure  multimedia      tests
astro           databases       inputmethods    net             textproc
audio           devel           japanese        news            www
base            editors         java            plan9           x11
benchmarks      education       korean          print

To install bash shell from ports (or configure user with proper file permissions as described in the official docs), type:
# cd /usr/ports/shells/bash
# make install clean all

How do I search the ports tree?

Use the following syntax:
$ cd /usr/ports
$ make search key={KEY-WORD-HERE}

To search for php-gd package, enter:
$ make search key=php-gd
Sample outputs:

Port:   php-gd-5.5.37p0
Path:   lang/php/5.5,-gd
Info:   image manipulation extensions for php5
Maint:  Robert Nagy <>
Index:  lang www
L-deps: devel/t1lib graphics/jpeg graphics/png
B-deps: archivers/bzip2 devel/autoconf/2.69 devel/metaauto www/apache-httpd
R-deps: php-5.5.37:lang/php/5.5
Archs:  any
Port:   php-gd-5.6.23p0
Path:   lang/php/5.6,-gd
Info:   image manipulation extensions for php5
Maint:  Robert Nagy <>
Index:  lang www
L-deps: devel/t1lib graphics/jpeg graphics/png
B-deps: archivers/bzip2 devel/autoconf/2.69 devel/metaauto www/apache-httpd
R-deps: php-5.6.23:lang/php/5.6
Archs:  any
Port:   php-gd-7.0.8p0
Path:   lang/php/7.0,-gd
Info:   image manipulation extensions for php5
Maint:  Robert Nagy <>
Index:  lang www
L-deps: graphics/jpeg graphics/png
B-deps: archivers/bzip2 devel/autoconf/2.69 devel/bison devel/metaauto www/apache-httpd
R-deps: php-7.0.8:lang/php/7.0
Archs:  any

You can install php-gd-7.0.8p0 using the following command:
# pkg_add php-gd-7.0.8p0
# cd /usr/ports/lang/php/7.0/
# make install clean


🐧 Get the latest tutorials on Linux, Open Source & DevOps via RSS feed or Weekly email newsletter.

🐧 5 comments so far... add one

CategoryList of Unix and Linux commands
Disk space analyzersdf ncdu pydf
File Managementcat cp mkdir tree
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network UtilitiesNetHogs dig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04
5 comments… add one
  • Knight Aug 22, 2009 @ 16:21

    Thank you very much for this. I had trouble getting OpenBSD kicking with a GUI but with ports it is a snap. I used “ftp” however, instead of wget, as 4.5 did not come with wget by default. Cheers.

  • kenpem Sep 2, 2009 @ 8:37

    I wish your page had ranked higher in my search results! Just wasted hours on other obscure things. This tells me exactly what I needed to know. Thanks.

  • purpleoptic Aug 8, 2010 @ 18:04

    you will need to install wget first before you try this in OpenBSD 4.7

  • Doug Dec 27, 2010 @ 23:51

    and as I just discovered, you can install wget on OpenBSD by doing this:

    1. ftp for your release version x.y
    2. cd /usr
    3. tar xvfz /path/to/ports.tar.gz
    4. cd /usr/ports/net/wget
    5. make

    If a non-noob can recommend a more glitzy way to do this, please follow up. Thanks.

  • wmoreno3 Nov 5, 2015 @ 22:23

    “# cd /usr/ports/shell/bash
    # make install clean all”

    Must be:

    # cd /usr/ports/shells/bash
    # make install clean all

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre> for code samples. Still have questions? Post it on our forum