Guide to Unix/BSD/Introduction
< Guide to Unix | BSD
This page summarizes the main features of the *BSD kernel and system, especially in comparison to other Unix-like systems. Currently, this page covers the free variants of *BSD, especially DragonFly BSD, FreeBSD, NetBSD, and OpenBSD. There are also nonfree variants.
The Wikibook, A Neutral Look at Operating Systems, gives an overview of BSD in its Berkeley Software Distribution chapter.
General
edit- The *BSD systems are descendants of AT&T Unix (though non-free Unix code was removed) so they feel more like Unix than GNU/Linux. AT&T had cheaply licensed the code to universities including Berkeley where major enhancements such as TCP/IP were then developed. The last BSD release from Berkeley had non-free code removed so more persons could use it. Today, the *BSD projects honor their ancestry putting BSD at the end of their names.
- The four big *BSD systems are free software and open source. While *BSD does use some copylefted GNU programs, most of *BSD is not copyleft, which leaves everyone free to make non-free versions of *BSD and distribute binaries without source code. However, some parts of *BSD have extra terms in the license that annoy some people, and which are not found in the GNU licenses. In particular, there was enough dislike for the "advertising clause" (which requires marks on certain ads) that the Regents of the University of California removed it from their license; some other *BSD copyright holders still use the clause.
- The core system, including kernel and userland, is maintained in one CVS tree. This is similar to OpenSolaris and OpenDarwin, but GNU/Linux programs and kernels are in separate trees, and the development trees of non-free Unix-like systems are normally not public. Compare:
- DragonFly BSD http://www.dragonflybsd.org/cgi-bin/cvsweb.cgi/
- FreeBSD http://www.freebsd.org/cgi/cvsweb.cgi/
- NetBSD http://cvsweb.netbsd.org/bsdweb.cgi/
- OpenBSD http://www.openbsd.org/cgi-bin/cvsweb/
- OpenSolaris http://cvs.opensolaris.org/source/
- OpenDarwin http://cvs.opendarwin.org/index.cgi/
- The *BSD sources are stored in /usr/src/ and the kernel in /usr/src/sys/. The *BSD kernel and system programs are heavily integrated, and so must be upgraded together.
Kernel
edit- Recall that a kernel is the interface between programs and hardware. Unix-like kernels provide device drivers and networking support and allow multiple users and programs to share the system.
- The *BSD kernel (often installed at "/bsd/") is monolithic, which means that it is one program in one memory-addressing space. Thus the kernel avoids forming and sending messages between parts of itself.
- DragonFly BSD is changing some of this.
- The original AT&T Unix and Linux are also monolithic, while mkLinux and the kernel of Mac OS X are modular.
- The kernel is actually the original AT&T Unix with all of its files replaced. The BSD university project had added or replaced so much stuff (the VAX port, the networking features, the fast file system, ...) that *BSD projects could take the free parts and produce completely free kernels without needing a Unix license. A consequence of this is that the BSD kernel has a similar structure to commercial Unix kernels also descended from AT&T Unix.
- The kernel contains a "securelevel" feature which attempts to permanently restrict what all users (including root, the superuser) can do after a certain point in the boot process.
- The kernel boot messages (also visible with dmesg, on all Unix systems) are organized and show where each device was detected.
- In contrast, the Linux drivers seem to give any boot messages that they feel like. The mounting and examining of "/proc" and "/sys", or the use of tools like "lspci", is a better strategy on Linux.
Userland
edit- Recall that userland consists of all the software above the kernel. This section describes the userland included with the base system.
- The programs in /bin/ and /sbin/ are statically linked.
- This is because /usr/ might not be mounted, so the shared library /usr/lib/libc.so cannot be used.
- Static linking is when each program is in one file, without the need for other files (shared libraries) containing code shared by programs. The library code is copied into the programs.
- The main text editor in the base system is "vi". This is nvi included with BSD, and ultimately the original vi, and is not some other vi implementation such as vim. Actually, nvi is a clone of the original vi. The clone was necessary to remove some non-free Unix code.
Ports
edit- There is a ports tree or packages tree originally from FreeBSD. This consists of Makefiles that automate the downloading, extracting, patching, and building of software for *BSD. This is the main way of installing stuff that is not part of the base system.
- On NetBSD this is called pkgsrc. A unique feature of the pkgsrc tree is that it also works on other operating systems. DragonFly BSD also uses pkgsrc.
- Thus installing a program is often two easy steps. First, type a "cd" command to the directory containing the port (for example, /usr/ports/games/nethack/). Then, type a "make install" command and wait for everything to finish.
- Building software takes a long time, so many prefer to use a binary package instead of a "make install".
- The system compiler is the GNU Compiler Collection (GCC) with C, C++, Objective C, and Fortran 77.
- By default, gcc does not look in /usr/local/ for header files and libraries; it only looks at the base system.
- The base system can rebuild itself with gcc.