OpenBSD How to use PKG Packages and Update PKG Package Management

As with other operating systems, there are many applications that you can use on the OpenBSD system. All these applications are packaged in PKG packages, so they are easy to install and manage. The purpose of PKG packages is to simplify and keep track of which software is installed, so you can easily update or remove it.

Each PKG Package used includes one piece of software that has been packaged and compiled for the OpenBSD version and architecture. In this article, we will discuss the use of PKG packages first, as they are generally easier and faster to use than ports. Once you've mastered the package, we'll move on to discussing ports. Many tools that can be used for PKG packages also work on ports.

On an OpenBSD system, each PKG package system and port must always be up-to-date with its packages. Most OpenBSD users always use pkg_add for package installation and pkg_delete for removing packages. The pkg utility can also be used to upgrade packages. If you are using OpenBSD, for application installation, we recommend using the PKG package rather than using the port. Because the OpenBSD development team focuses more on creating and maintaining PKG packages.

Below are the frequently used PKG package commands, because they can help you make it easier to manage each package you use.

pkg_add - This command is often used to install and upgrade packages.
pkg_check - This command is used to check the consistency of installed packages
pkg_delete - This command is used to remove installed packages
pkg_info - Command for information about packages

1. PKG Package Repository Mirror

PKG packages use mirrors to connect to OpenBSD repositories. Choosing a repository mirror is the first step that you must do before running the PKG package. There are a lot of mirrors in OpenBSD. You can see the complete list at "OpenBSD Mirror".

You must enter the mirror repository link address in the /etc/installurl and /root/.profile files. We will give an example of using a mirror link Notice the example below.

Add Mirror /etc/installurl
foo# nano /etc/installurl
You also type the mirror link in the /root/.profile file, as in the example below.

Add Mirror /root/.profile
foo# nano /root/.profile
# $OpenBSD: dot.profile,v 1.10 2023/11/16 16:03:51 millert Exp $
# sh/ksh initialization

export PKG_PATH=$(uname -r)/packages/$(arch -s)/
export PATH
: ${HOME='/root'}
export HOME
umask 022

case "$-" in
*i*)    # interactive shell
	if [ -x /usr/bin/tset ]; then
		eval `/usr/bin/tset -IsQ '-munknown:?vt220' $TERM`

2. Updating packages PKG

Like most other computer users who want to use the latest version of the application they are using. We are the same, we always want to try every time there is a new version of the application we are using. To make all this happen, you have to update the pkg package.

pkg package update is used to update the local copy of the repository catalog from the remote package repository database. Catalog updates are typically downloaded only when the master copy on the remote package repository is newer than the local copy. Before carrying out the installation process, make sure you update your package repository catalog up to date. This will affect the latest version of the application that you will install.

On OpenBSD, to update the pkg package use the pkg_add command. Use the parameters below to ensure the latest version of the OpenBSD repository.

-u   : To upgrade
-i    : For interactive, and
-v   : For verbose output.

Run the command below to start updating the OpenBSD PKG package.

Update and upgrade paket PKG
foo# pkg_add -uvi

3. Installing packages PKG

OpenBSD has a diverse collection of system tools as part of the base system. The pkg_add command can be used to install third-party software. This command will install binary data that OpenBSD developers have created previously. You can use pkg_add to install software from local media or from the network.

We will provide examples of how to install several applications with OpenBSD. Pay attention to the example below how to install Nginx.

Install Nginx with PKG
foo# pkg_add nginx
To make the application installation process clearer in OpenBSD, we will provide several examples of installing applications.

Install Bind DNS Server with PKG
foo# pkg_add isc-bind-9.18.25v3
Install unzip with PKG
foo# pkg_add unzip

4. Searching Package PKG

Next we will learn how to search for applications available in OpenBSD. This search process is very necessary if we don't know the type and version of the application. Use the pkg_info command to search for applications. Below, we provide several examples of running the pkg_info command.

Looking for unzip software
foo# pkg_info -Q unzip
Looking for BIND software
foo# pkg_info -Q bind
Another way to search for software in the OpenBSD repository is with the "pkglocate" command. Before you use the "pkglocate" command, you must first install pkglocatedb. Run the command below to install pkglocatedb.

Install pkglocatedb
foo# pkg_add pkglocatedb
Run the command below to search for apache and Nginx software.

Looking for Apache and Nginx software
foo# pkglocate apache
foo# pkglocate nginx

5. Removing Packages PKG

Once you know how to update, install and search for PKG packages, it won't be complete if you don't learn how to remove pkg packages. The delete command is very useful if you no longer need the software you are using. The pkg_delete command is used to delete software that you have installed on OpenBSD. Below we provide several examples of how to use pkg_delete to delete software.

Delete Nginx
foo# pkg_delete nginx
nginx-1.24.0p0: ok
Read shared items: ok
Delete Bind and unzip
foo# pkg_delete isc-bind
foo# pkg_delete unzip

6. Check the installed packages

The pkg_check command is used to verify as much information as possible about installed packages. This command is very rarely used, unless there is a serious system failure when using the pkg_add and pkg_delete commands. To make it clearer, below we provide an example of how to use the pkg_check command.

Check Bind
foo# pkg_check isc-bind-9.18.24v3
Packing-list sanity: ok
Direct dependencies: ok
Reverse dependencies: ok
Files from packages: ok
Check Nginx
foo# pkg_check nginx-1.24.0p0
Packing-list sanity: ok
Direct dependencies: ok
Reverse dependencies: ok
Files from packages: ok
All the commands above are basic commands in OpenBSD and you must understand them, because all the commands above are often used or cannot even be separated from the OpenBSD system. If you don't master all the commands above, you will definitely experience problems when using the OpenBSD system.
Iwan Setiawan

I Like Adventure: Mahameru Mount, Rinjani Mount I Like Writer FreeBSD

Post a Comment

Previous Post Next Post