22 Nov 2024
I had used Ubuntu Linux, Debian Linux, OpenBSD, and FreeBSD lightly in past life. And in the past two years, I focused on using only Debian. Debian served me well, but I was curious to understand a bit more what it would take to run my stuffs on BSD.
This is my personal story about relearning and reusing FreeBSD.
To prep, I read up the FreeBSD Handbook website. All the tasks that I needed to do were well explained in the Handbook or linked to from the Handbook. It is reasonably structured and it is easy to follow.
For things I could not find there, I turned to the search engine, which often returned results from the FreeBSD Forums.
And both do NOT have any advertisement - unlike many Linux how-to websites or articles. I like that.
Further reading:
FreeBSD Handbook
FreeBSD Forums
When I set up a new server, my process revolves around some key areas. Here are my observations comparing Debian 12 and FreeBSD 14.
sshdBoth Debian and FreeBSD are fairly similar. Nothing to write about.
Further reading:
FreeBSD OpenSSH
I always installed ufw in a fresh Debian install. I found it easy to use.
But it is not available in FreeBSD.
Instead, it has three firewalls in the base OS:
PF, IPFW, and IPF. The Handbook explains each, but did not give specific
recommendation for my use case. In the end, I chose PF.
FreeBSD PF comes from OpenBSD PF. pf config is more verbose than
my usual Linux ufw config, so I have to invest time in learning it.
Further reading:
FreeBSD Firewalls
PF FAQ
In Debian, I used apt. In FreeBSD, there is only freebsd-update.
freebsd-update is more interactive and more involved than apt -y, because
freebsd-update shows lists of files it will remove and add. And the lists
are usually longer than one screen, so it went into less mode.
less works similarly like more and it is easy to move through the steps.
But then I read an HN tip: I can change the PAGER environment variable to use cat
instead of less. PAGER=cat freebsd-update fetch - this works more to my liking.
Further reading:
Updating and Upgrading
In Debian, I used apt and in FreeBSD I use pkg.
The commands are different, but they work fairly similarly. pkg help and
man pkg were enough to get me going. Easy enough.
Minor note on Golang. In FreeBSD, the go command is version specific. If I
install v1.22, i.e. go122, I need to type go122 not go on the command line.
This is the default setup. I could alias it, but I chose to leave it alone.
It did not bother me.
Further reading:
Installing Applications
Ports Portal
User management in both of them are fairly similar except for one. The default security setting for non-root / unprivileged user in FreeBSD's default is a bit more restrictive.
For my needs, I need to either modify the user privileges or stick with the defaults but adjust the set up. I chose to stick with the default privileges and made adjustments to my work flow and app setup. Extra work, but I learned new ways of working along the way.
Further reading:
Users and Basic Account Management
doas
doas mastery
Files location can be different.
In FreeBSD, the package config is in /usr/local/etc/ and the stuffs that came
in the base OS have the config in /etc/. It makes sense, so not a big deal.
Default shell is different. FreeBSD 14 uses sh. I do
not do heavy shell scripting, so the default sh works fine for me.
The same commands in Linux and FreeBSD do the same tasks, but may have different
options. This varies from command to command and option to option.
For example, I was used to using ps -C in Debian, but
that option does something different in FreeBSD. I need to check the man page.
Stock FreeBSD runs daily checks and reports some statistics back to
the system administrator. root account gets them in mail. There is
nothing to set up or enable - this runs out of the box.
(FreeBSD default mail client is an old-fashioned mail client.
I used it back in my Unix terminal days and I vaguely know how to get around.)
On system logging, FreeBSD, out of the box, enables logging for a number of
things by default. Even before I set up anything specific, the /var/log
already contains some log files after a while.
Further reading:
Configuration Files
Directory Structure
Mail User Agents
Logging
FreeBSD Man Pages
Debian uses systemd and FreeBSD uses rc.d. Setting up the config file for
existing apps was easy enough.
Making a new config for my custom app was another matter.
Compared to systemd, articles and
examples for rc.d that fit my specific wants were a bit difficult to find.
Having said that, the tutorial in "Practical rc.d scripting" is way too
simple and unrealistic for setting up my own rc.d file for my custom app.
I struggled a bit on this, but eventually I understood that
rc.d essentially works almost like shell script. Once I view it this way,
I could pick up the concept, since I understand a little about shell scripting.
Further reading:
Managing Services in FreeBSD
Practical rc.d scripting
rc.conf
Starting and stopping services
FreeBSD and Debian have many similarities and, indeed, some differences. FreeBSD is as easy to learn as Debian Linux. And FreeBSD defaults are helpful.
FreeBSD may or may not be a viable option in some circumstances. Here are a few things to consider.
FreeBSD manages third-party apps or packages as ports and there are many apps or packages ready to install in FreeBSD. But a few apps or programming languages may not be readily available in FreeBSD. Specifically the newer ones. Whereas Debian Linux has almost everything.
If no binary distribution or package is available, then either build from source or run Linux apps in Linux Binary Compatibility mode. Docker seems to be possible, too. But the apps I need are available as packages in FreeBSD, so I have not tried LBC nor Docker.
Further reading:
Ports Portal
Linux Binary Compatibility
Docker on FreeBSD
Not every service provider has the option to use FreeBSD on their virtual server. Although if it is not available as pre-installed options, it does not mean it is impossible. Initially I wanted to use OpenBSD and I searched in my service provider docs. Nothing ... So I asked the tech support if it was possible to use any BSD. And it turned out it was possible to install FreeBSD through the custom ISO menu. OpenBSD was not available, so I installed FreeBSD from ISO.
I saw a few posts in HN on how to bootstrap BSD from Linux. I have never tried them, so I cannot comment. Might be useful for adventurous folks.
Further reading:
Installing FreeBSD
Bootstrapping FreeBSD
Bootstrapping OpenBSD
netboot.xyz
I still have much to learn but by now I have been using FreeBSD for months. Performance-wise, I do not have anything tangible to report. The servers seem to be running at least as well as when they ran Debian. Both Debian Linux and FreeBSD can meet my needs fine.
I am not beholden to use either one. And I feel comfortable enough with FreeBSD and I enjoy it. Enough to the point that I now use FreeBSD in all my servers.
Thanks for stopping by. Have a great day.