Here I'm republishing an old blog post of mine originally from June 2015. The article has been slightly improved.

FreeBSD - from the Linux user's perspective (introduction)

With this (and the next) post we're going to take a look at FreeBSD, assuming some basic Linux experience. The goal is to provide an easy introduction and to show where that system behaves differently from Linux. And we'll also touch the subject of strengths and weaknesses of FreeBSD.

What is FreeBSD?

Linux is a Unix-like operating system and the same is true for FreeBSD. The difference is that FreeBSD is a direct offspring of BSD Unix whereas Linux was coded from scratch and did never have any code in common with Unix. So compared with Linux, FreeBSD is clearly "more Unix". But why don't we just say that it _is_ a Unix since it once was? Because of legal trouble...

_Technically_, FreeBSD is a much improved BSD Unix. But there's one problem: UNIX is a trademark. In order to call your system a Unix, it must comply with the Unix specifications. FreeBSD did this and probably still does for the largest part. That's just the first requirement, though! The other is that you need to have your OS certified - which is not exactly a cheap thing to do. IBM did this for AIX, HP for HP-UX, etc. FreeBSD, being a non-commercial community project, needs the money it receives from donations for other things. And so - for legal reasons - FreeBSD is not a Unix but just a "Unix-like" system as is Linux.

However it derived from Unix and it feels like Unix (with quite some things a little different from Linux). So if you don't like the stiff term "Unix-like" you can of course think of your FreeBSD as a Unix system in contrast to Linux.

FreeBSD's goal as stated by the project, is to provide a _general purpose_, _secure_ and _highly scalable_ operating system that is available _free of charge_. Sounds a lot like Linux so far, doesn't it? It sure does. But please keep in mind that this doesn't make FreeBSD the boring rip-off. FreeBSD was there first! But even if you'd argue that it's obsolete now that Linux does extremely well in just about all areas (and admittedly better in quite some), there's one more point. FreeBSD is meant to be available free of charge and _under a permissive license_!

Linux is GPL'ed. That makes it available for free and ensures that the code will always be open, because the license enforces these things. FreeBSD, licensed under the BSD license, does _not_ do this. You are free to do things with it which the GPL does not allow for. A whole lot of people don't care (they have probably never even thought about licensing) and quite some people applaud the GPL's approach. Others however prefer BSD-style licenses. It's a matter of taste and a philosophic question that cannot really be decided once and for all.

I've written a short post on an introduction to licenses more than a year ago. It was meant to have a follow-up article but I didn't find the time to write that one, yet.

Software licenses (pt. 1): A general introduction (2014 article)

System structure

The whole operating system is integrally connected. Where a Linux distro is actually "the Linux kernel plus (a lot of) packages", FreeBSD is different. Programs from upstream are imported into the system repository and are often patched. The versions are chosen to play together nicely with all the other components of the system.

This operating system consists of two parts: _kernel_ and _world_, the latter being the userspace part of it. The actual software you install on top of the OS is separated from it: Files are put into /usr/local so they don't mix with those that belong to the base system - which is quite a clean thing.

Traditionally FreeBSD has come with the _ports system_. If you want to install an application which is not part of the OS, you change into the respective directory of the ports tree and run _make install clean_. The Makefiles (and a few other files as well) then take care of the source code getting downloaded, extracted and configured, of patches being applied, the program compiled and installed. You do not need to know anything about how to get a program to work on FreeBSD. If somebody already wrote a port, it's as easy as issuing that make command. The port will also ensure that any dependencies needed are present on the system and, in case any is missing, they are automatically built and installed by the ports system, too.

But that's not all. Ports for many programs are created to allow you to select which features to compile a program with. A simple menu-driven UI lets you check and uncheck features for many ports. And of course ports allow for clean removal of installed software using _make deinstall_. Also the ports tree often offers you various versions of a program to choose from. Want Apache 2.4 or probably rather 2.2? Or perhaps you need GCC. Feel free to choose any of 4.6, 4.7, 4.8, 4.9 and 5.1!

This allows for easy customizing of the software you install: You get exactly what you need and want. If you have no special needs for some programs and don't want to compile it on your computer, you can of course use pre-built binary packages like on Linux. And the best thing: Since the ports system actually builds packages, you can mix the two as they play together nicely and won't conflict! (update: It's not encouraged, though, as you'd be required to build from the exact same version of the ports tree that the binary packages were built - or risk running into problems. You can get away with mixing in many cases but there's no guarantee that things will be fine.)

Some strong points

FreeBSD has a world-class network stack - which is absolutely no wonder since TCP/IP was in fact developed on BSD Unix! This is one example where FreeBSD is superior to Linux.

Another nice feature are the so-called _secure levels_ together with the _extended file flags_. The later open up some interesting possibilities: You could, for example, set the file flag "append only" on a log file. This does not make the log "read only" - it can still be written to, and new log entries appended to the file. But it is impossible to either delete the file or remove content that's already in it! If an attacker (who does not want you to notice that he broke into your system) tries to cover his tracks this can be extremely frustrating as there is no way he can get rid of anything that's in the log!

That is... As long as he doesn't just remove the file flag. But to make that impossible as well, FreeBSD features the aforementioned secure levels. You can always add file flags, but you can only remove them when the system is running in secure level 0. And here's the show-stopper: Once set to higher than 0, secure levels cannot be reduced again. Not even by root and also not by yourself with physical access to your server! There's exactly one way to get rid of a secure level greater than 0: Reboot... And a reboot won't go unnoticed easily, right?

One more very cool feature are _jails_. Think of them as hardened chroot environments with a lot of extras (like IP addresses for a jail). They are kept strictly separate from the rest of the system (and from other jails). You have heard about all that "container" stuff that's currently en vogue in Linux, haven't you? No need for that on FreeBSD! If you want a secure environment (or several) for single applications - just jail them. FreeBSD offers this possibility for ages now (as does Solaris where this functionality is provided by what's called "zones".)

And perhaps you have heard good things about the _ZFS filesystem_ or about _DTrace_. FreeBSD comes with both of them and they are considered stable. And of course there's much more to it. But let's leave that for the next post where we'll get our hands on FreeBSD, right?

For those of you who are interested, here's a little Unix history (it's good to know because it helps understand why things are how they are today - but if you don't care at all you can of course skip it).

Unix history

In 1964 AT&T, GE (General Electric) and the MIT (Massachusetts Institute of Technology) teamed up to create a sophisticated new operating system they called _Multics_. It was extremely innovative and pioneered many features in computing. A lot of people thought however that it was overly complex and not quite the system they wanted.

Eventually AT&T pulled out of the project and started another one in 1969 which followed the opposite idea: Simplicity instead of complexity! This operating system is known as "Research Unix". In the following years various versions were completed and licensed especially to universities for little money (because AT&T was not allowed to compete on the software market at that time due to their telephone monopoly). During that time it was a matter of course that you got the source code when you bought the software. For that reason students of computer science could look at the code - and modify it.

Written in assembler at first, Unix was soon re-written in the new programming language C which forever remains closely tied to Unix. Thanks to the availability of the code, the universities kept producing patches with new functionality for Unix and gave it away for free to anybody who had licensed the OS. At the center of this development was Berkeley University which collected these patches and patch sets. They created software releases which were called "Berkeley System Distribution" or BSD for short. The first one was 1BSD in 1978. Due to the massive changes they did to the system, with 3BSD they began shipping a whole OS which was based on the VAX port of AT&T's Unix Seventh Edition.

The university created various 4.xBSD releases over the years. These grew in popularity fast and quite often Unix from AT&T was bought and put aside only to be able to actually use BSD legally! In 1986 the influential version 4.3BSD with which BSD moved away from the VAX was released. The year 1992 saw the release of a short-lived project which nevertheless had a _huge_ impact: 386BSD or _Jolix_ (named after its creators, Lynne and William Jolitz). It was an effort to port 4.3BSD to the 80386 PC.

Now the BSD story repeated in a smaller scale: 386BSD enthusiasts created patches for the system and an unofficial patchkit was provided for it. Due to a difference in opinion the patchkit maintainers broke away from 386BSD and founded the FreeBSD project. About the same time another group of 386BSD users started they own project derived from that: NetBSD was born.

The original BSD project ended in 1994 with a strange last release called 4.4BSD-lite2. It was a crippled release that could not even run on its own! The reason was a lawsuit from the Unix System Laboratories. Formed after AT&T's forced break-up, they finally could compete on the PC market and began to offer Unix for high prices. It goes without saying that the existence of BSD was a thorn in their side - and they meant to remove it!

But greed is not a good advisor and in the end the case was settled out of court. Why? Because the university proved that over the years almost all of AT&T's code had been replaced! BSD was almost a system completely of its own! But that's not all. In fact AT&T had taken the free code from BSD and used it in their newer Unix releases. While there's nothing wrong with that, they didn't give the BSD people credit for their work. And by failing to do that it turned out that they were violating the BSD licence themselves!

It is the legal struggle and uncertainty that followed from the case which can be seen as one reason why Linux gained more and more attention: If you chose any BSD derivative you never know what might happen some day... But that's old stories today as the BSDs are known to be perfectly legal.

What's next?

Next in line is a FreeBSD tutorial that puts focus on getting the system installed and exploring what's different from Linux.

BACK TO 2015 OVERVIEW