GNU/Linux is the most popular operating system built with free/open source software. However, it is not the only one: FreeBSD is also becoming popular for its stability, robustness and security. In this article, I’ll take a look at their similarities and differences.
Introduction
FreeBSD is an operating system based on the Berkeley Software Distribution (BSD), which itself is a modification of AT&T’s UNIX, and was created by the University of California. During the development of FreeBSD, to avoid any legal problems with the owners of the source code, the developers decided to re-engineer the original BSD, rather than copy the source code.
In contrast with GNU/Linux, where all the pieces are developed separately and brought together in distributions, FreeBSD has been developed as a complete operating system: the kernel, device drivers, sysadmin’s tools and all the other pieces of software are held in the same revision control system.
Initial development of Linux was started in 1991 by Linus Torvalds who used Minix—an operating system developed by Andrew Tanenbaum for teaching purposes—as the basis for his system. By 1990 the GNU project, which had been started in 1983 by Richard Stallman, had produced and collected all the libraries, compilers, text editors, shells and other software necessary to make a free operating system—except a kernel. The Linux kernel developers decided to adapt their kernel to work with the GNU software to make a complete operating system: GNU/Linux was born.
The kernel and the majority of the code in FreeBSD has been released and distributed under the BSD license although some components use other open licenses like the GPL, the LGPL or the ISC. The Linux kernel, and most of the software in the GNU project, has been licensed under the GNU GPL which was created by the Free Software Foundation.
FreeBSD logo from FreeBSD site.
Technical differences
FreeBSD and Linux both follow the UNIX philosophy but some differences do exist between the operating systems—let’s have a look at some of these differences on a technical level.
Devices
Hardware related dispositives like disks, network cards, printers, graphics cards, mice and keyboards are referred to using the term device in the context of operating systems; Linux and FreeBSD use different nomenclature for this hardware.
Linux uses predefined names for each device type, so eth0 is the first Ethernet network card for any chip-set. FreeBSD, on the other hand, uses a different name for each device and their chip-set: for example, a single network card with the common RealTek 8129 chip-set is called rl0 in FreeBSD.
On Linux hardware information can be obtained by examining the content of the /proc
directory; a command like lspci
or lsusb
can also be used—these commands simply reformat the information contained in /proc
. FreeBSD does not use the /proc
directory, rather the sysctl
command shows all the information about the hardware devices attached to the system and can also be used for configuring and tuning them.
Runlevels and startup scripts
Runlevel is the term used to describe a mode of operation for a system such as reboot, halt, single-user mode or multi-user mode. On GNU/Linux the /etc/inittab
file describes these different runlevels and the init
process allows the system to change its current runlevel. FreeBSD uses commands like reboot
or shutdown -h
to change the current runlevel instead of the telinit
command used in GNU/Linux.
On GNU/Linux each runlevel has a subdirectory under /etc/
or /etc/rc.d/
, depending on the distribution: Debian, for example, uses /etc/
. These subdirectories are rc0.d
, rc1.d
and so on until the last runlevel (there are usually seven runlevels). Each rcx.d subdirectory contains symbolic links to the startup scripts residing in the /etc/init.d/
directory.
On FreeBSD the startup scripts exist in the /etc/rc.d/
directory (for the system) and in the /usr/local/etc/rc.d/
directory (for third-party applications). These scripts use parameters such as start
or stop
to control which scripts run at startup (start and reboot) and shutdown.
Kernel
Obviously there exist design differences between the Linux kernel and the FreeBSD kernel but there are also similarities:
- Modules: support for loading and unloading modules without recompiling the kernel or rebooting the system.
- Versions: each official kernel uses a numbered version.
- Build a custom kernel: some benefits of building a custom kernel are that it can result in a faster boot time, lower memory usage and additional hardware support.
Commands for loading and unloading kernel modules, as well as listing the loaded modules, are different in each system. Linux uses the modprobe
command for loading a module and for seeing a list of the loaded modules, lsmod
just shows a list of the loaded modules and rmmod
unloads any unwanted modules. FreeBSD uses kldstat
to list the currently loaded modules, kldload
for loading a module and kldunload
for removing a module.