Openbsd install or add binary software package howto

by Vivek Gite on November 7, 2006 · 4 comments

OpenBSD logo

Just like FreeBSD, OpenBSD comes with pkg_add command. It is used to install a binary or upgrade packages from http or ftp mirror over internet. If you have purchased OpenBSD DVD/CD you can install packages from CD itself.

pkg_add command used to update existing packages too.

Task: Add package from ftp or http mirror

Use generic OpenBSD mirror such as follows:
ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/amd64/ or ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/i386/
Please note that version number (4.) and machine architecture (amd64). You can find complete
OpenBSD mirror list here.

First, you need to setup PKG_PATH variable so that you don't have to type complete mirror path each and every time. You need to add file to your shell startup file such as ~/.bashrc or ~/.bash_profile. PKG_PATH variable MUST end in a slash (/).
$ export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/amd64/
OR
# export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/4.0/packages/$(machine -a)/

Now to add a package called links:
$ sudo pkg_add -v linksOR # pkg_add -v -i links
Where,

  • -v : Verbose mode (display more information)
  • -i : Interactive installation. It may ask you question such as which version you would like to install and so on.

# pkg_add -i lighttpdOutput:

Ambiguous: lighttpd could be lighttpd-1.4.11 lighttpd-1.4.11-ldap lighttpd-1.4.11-ldap-mysql lighttpd-1.4.11-mysql
Choose one package
         0: 
         1: lighttpd-1.4.11
         2: lighttpd-1.4.11-ldap
         3: lighttpd-1.4.11-ldap-mysql
         4: lighttpd-1.4.11-mysql
Your choice:   1
lighttpd-1.4.11:pcre-6.4p1: complete
lighttpd-1.4.11: complete 

Note that pkg_add prompted for version of lighttpd, you wish to install.

Task: Display or list of OpenBSD installed packages

Use pkg_info command:
$ pkg_infoOutput:

bash-3.1.17         GNU Bourne Again Shell
expat-2.0.0         XML 1.0 parser written in C
gettext-0.14.5p1    GNU gettext
libiconv-1.9.2p3    character set conversion library
lighttpd-1.4.11     secure, fast, compliant, and very flexible web-server
links-0.99          text browser, displays while downloading
pcre-6.4p1          perl-compatible regular expression library
vim-7.0.42-no_x11   vi clone, many additional features
wget-1.10.2p0       retrieve files from the web via HTTP, HTTPS and FTP

Task: Update existing package

To upgrade or update links package type command:
# pkg_add -u links

Task: Update all packages

pkg_add will update all installed packages if no package name is provided:
# pkg_add

Task: Set active or passive mode

If you are behind firewall you may need to set active or passive mode with FTPMODE variable (default is passive).
$ export t FTPMODE=active

Featured Articles:

Share this with other sys admins!
Facebook it - Tweet it - Print it -

We're here to help you make the most of sysadmin work. So, subscribe!

{ 4 comments… read them below or add one }

1 jman April 10, 2008

Are packages better than ports?
With ports I do – make install clean and it usually sorts out any dependency issues.
But with pkg_add I have had dependency errors.

Reply

2 rob July 8, 2008

jman – I prefer to use the packages whenever possible — both pkg_add(1) and the ports methods are capable of determining required dependencies. If you are experiencing specific package dependency issues, I suggest posting on the appropriate OpenBSD mail list.
Those OpenBSD gurus are super-smart and very helpful.

Reply

3 Tommy Chandra W February 24, 2009

very very useful!
thanks for sharing :)

Reply

4 Hendra February 8, 2012

export PKG_PATH=ftp://ftp.openbsd.org/pub/OpenBSD/5.0/packages/i386
I have do that, I want to install unzip, but I can’t. Sorry I’m Indonesian and very very newbie in UNIX.

Reply

Leave a Comment

You can use these HTML tags and attributes for your code and commands: <strong> <em> <ol> <li> <u> <ul> <blockquote> <pre> <a href="" title="">
What is 4 + 5 ?
Please leave these two fields as-is:
Are you a human being? Solve the simple math so we know that you are a human and not a bot.



Previous post:

Next post: