The world of operating systems is rich and varied, but among them BSD systems, characterized by high stability, security and flexibility, occupy a special place. FreeBSD, OpenBSD, and NetBSD are three of the best known members of this family, each with unique features and target audiences. Let's take a closer look at each of them and compare their features.
FreeBSD is probably the most popular of the three systems. Its key advantage is its balance between stability, performance, and a rich feature set.
OpenBSD is an operating system for which security is the number one priority. Its developers pay great attention to code and kernel security, making it an attractive choice for systems where security is critical.
NetBSD is the most portable of the three systems. It can be run on a huge number of architectures and platforms, from embedded devices to powerful servers.
Package and service administration differs on all three systems, but is generally command-line based. FreeBSD uses Ports Collection and pkg, OpenBSD uses pkgsrc, and NetBSD uses pkgsrc and a package manager based on `pkg_add`. Services are managed through systemd (on FreeBSD and some NetBSD builds) or each system's own mechanisms (often through initialization scripts). Detailed documentation is available for each system, making it easy to learn to administer.
Administering operating systems like NetBSD and OpenBSD often requires working with system services. Knowing how to manage these services is a key skill for any system administrator. In this article, we will look at how to install, start, stop, and manage services in NetBSD and OpenBSD, using the Apache case study, and discuss general principles of package management.
In NetBSD, services are managed primarily through the `rc(8)` system, information about which is stored in the `/etc/rc.d/` directory. Let's look at installing and managing the Apache web server as an illustration.
To install Apache, we use the `pkgin` package manager:
sudo pkgin install apache
Once Apache is installed, you can manage it in several ways. Quick restart - the method is convenient for restarting the service immediately without editing configuration files.
sudo /etc/rc.d/httpd onerestart
Control via `rc.conf`: A more flexible method that allows you to customize the service startup settings. Edit the `/etc/rc.conf` file:
sudo vim /etc/rc.conf
Enable Apache:
httpd=YES
Standard commands can now be used:
sudo service httpd restart # Перезапуск
sudo service httpd stop # Остановка
sudo service httpd start # Запуск
To start Apache on a non-standard port (for example, 8080), add the `httpd_flags` parameter to `/etc/rc.conf`:
sudo vim /etc/rc.conf
Add line:
httpd_flags='-I 8080'
Save the changes and restart Apache.
OpenBSD uses the `pkg_add package manager to install software and the `rc(8)` system to manage services. However, unlike NetBSD, it is recommended to manage services primarily through the `rcctl` utility, avoiding direct editing of `/etc/rc.conf`. This reduces the risk of conflicts during system upgrades.
Installing `sudo` (if necessary):
pkg_add sudo
Upgrading the system:
sudo pkg_add -u
Installing a package:
sudo pkg_add <pkg_name>
Uninstalling a package:
sudo pkg_delete <pkg_name>
Basic package data:
pkg_info -Q <pkg_name> # Проверка, установлен ли пакет
pkg_info <pkg_name> # Информация об установленном пакете
Installing Apache (including necessary dependencies such as PHP):
sudo pkg_add php
sudo pkg_add php-apache
sudo pkg_add apache24 # Или другое название пакета apache в OpenBSD
Managing Apache with `rcctl`:
sudo rcctl start apache24 # Запуск
sudo rcctl stop apache24 # Остановка
sudo rcctl restart apache24 # Перезапуск
sudo rcctl status apache24 # Проверка статуса
Instead of editing `/etc/rc.conf`, `rcctl` allows flexible management of services without the risk of corrupting the configuration.
In conclusion, NetBSD and OpenBSD offer powerful and flexible customizations for interacting with system services. Understanding the principles of `rc(8)`, `pkgin` (NetBSD) and `pkg_add`, `rcctl` (OpenBSD) is the foundation for effective administration of these operating systems. The use of `rcctl` in OpenBSD is recommended to minimize risks during system upgrades.