Moving away from Ubuntu: peeking at FreeBSD (Part 1)
Juan Miguel Medina Prieto
Posted on December 22, 2019
I've been aware of the existence of OSes besides Windows since I was given my small green laptop by my school, as a result of some politicians in my region attempting to get a nice picture taken, and it showed: the computer was a low-end one, even for the day's standards (we're talking about 2010 or so), so there wasn't a lot that you could do on it comfortably. For example, after a few years, I wasn't able to properly browse any web sites, and let's not talk about the fact I couldn't run an IDE on it when I had to bring it to classes in order to code on it: it crashed spectacularly or simply refused to run at all.
Even though, I'm glad of having had it: it made me deal with some form of Ubuntu for the first time, as my parents wouldn't let me use their better, but still sorta low-end, Windows machine, they didn't want me to download things on it and eventually make it unable to boot, so I had to spend time learning how things worked on there. Not that much of a problem for me, but it was a deal-breaker for most of my classmates.
Regardless, nowadays, I have some culture about how Linux came to be and their relatives and, as I don't really need Windows, since the games I want to play are available on Linux or are playable in Wine or even a VM, and I'm pretty much aware of how painful it can be when it's cracked, I just prefer to use Ubuntu in my main computer. Besides, it's very likely I'll end up working with a Linux machine, and that way it won't be that big of a deal for me, especially when it comes to running commands.
However, to be honest, I have never used any distro other than Debian-based ones (with different desktops) for a reasonable amount of time, and I've always been curious about how different it is to work on other distributions. Sure, a lot of things will be very similar, but I still want to see how different it really is by myself.
So, I'm going to start by shooting at the dark with the first one: FreeBSD
What's FreeBSD?
FreeBSD isn't really a Linux distribution, but an OS derived from one of its relatives, BSD. This operating system was created by the University of California, Berkeley from Unix's source code and, soon before its original development ceased, became the basis of several open-source OSes under the BSD license, including FreeBSD, which allowed the code to be used in proprietary projects such as Apple's OSes and PS3 and PS4's OSes.
Obviously, by itself, it's much less popular and, according to some posts out there, harder to use than Linux, especially in desktop, even though it's somewhat better when it comes to running servers. There's no way I can reliably measure its performance in a server, but I should be able to tell if it's a lot more of a pain to use than Ubuntu Server.
My goals
In order to give FreeBSD a first try, I'm going to attempt to do the following tasks after installing it:
Figuring out the folder structure (if it's any different from FHS)
Installing an SSH server in order to use it from a terminal
Trying to install a web server (Apache is preferred), make it work with PHP and run a script to read some data from a local database.
Attempting to install a desktop environment
The setup
In order to keep it simple, I'm going to create a VM using VirtualBox with 2GB of RAM and a 30GB virtual HDD. I'm choosing the defaults for FreeBSD, so the storage layout comes out like this:
For the network, I simply change the default network adapter to be attached to a bridged adapter, which will make the VM fully visible for my local network:
Installation
I boot up the virtual machine after selecting the FreeBSD installation image for the virtual disc drive. I'm greeted by this screen upon waiting for a countdown to run out.
I select the Install option and arrive at the keymap screen. Since I don't have a standard US keyboard, I first try the "Test default keymap"
Nope, it's just a prompt to check you had the right keymap, which is not my case, so I cancel it and select my language's keymap. Apparently, it doesn't want to show some special characters (such as ñ or letters with accents), but the rest of the keys print the correct characters for my keyboard, so I'll move on.
After the keymap, I'm asked for a hostname (I respond with bsdchamber), and I'm asked about what to install. Since I'm not sure, I just prefer to leave as is and select OK.
Next, I get to the partitioning. Thankfully, I don't really need to do any specific stuff, so I just select the default option and tell it to use the entire disk and create an MBR partition scheme.
And this is how the final partitioning setup looks like (the device names are quite interesting, by the way):
Once it's finished, it begins copying all the data to the hard-drive:
Suddenly, I'm prompted to enter a root password:
And then it asks me to select a network interface and asks me whether I want to configure IPv4, DHCP, and IPv6. I only accept the first two. Then, I'm prompted to the DNS selection.
This is quite surprising to find nowadays, but I still fill them in with the Google Public DNS addresses.
After that, the timezone selector pops out, and I select my timezone without any problem at all. I also get to this system configuration:
Good, SSH is already included, but I still want the NTP daemon (for syncing up the time), so I select them with the space bar and move on.
This screen is quite interesting, and probably a reason why they say FreeBSD has somewhat better security than Linux. Oh well, I'll just select what feels more natural to me, including secure_console. Once I click OK, it asks me whether I'd like to add new users. I probably should, but since this is just a lab, there's no need to do so, so I pass, and I land on the final screen.
Well, at least you can change something up if you change your mind, but I'll just exit and finish the installation. It also asks about manual configuration, but I prefer not to do so. After that, I reboot to the new installation, even though I have to remove the virtual disc manually.
First boot
Since I selected secure_console, I do have to put credentials to enter into a shell, just like I'm used to in Debian-based distributions, and it works pretty much the same. In fact, the command line format seems to be exactly the same, even if it looks quite ugly.
I try the "ifconfig" command to check the network, and, sure enough, it is identical as in Linux. Next, I try to login via SSH.
Strangely, it refuses to accept my password, but I suspect it's probably due to the fact that I'm trying to login to the root user. I guess I'm creating another user, after all, al least just to get started.
It looks like the "adduser" command I used works a bit differently than I expected, but I still managed to create a user for me. I'll try entering with that one instead.
And it looks like we have a winner! I shouldn't be surprised, anyway, as root login via SSH isn't allowed when security measures are applied to Linux machines. Luckily, I should be able to enter as root with this brand-new user.
Or maybe not. I'll have to check the manual. "man su" should do it.
Well, this is interesting. It looks like I have to add my own user to the group "wheel" if I want to be able to log in as root. But, first of all, I should figure out how to add a user to a group. I used to do it with "adduser", but it probably won't work here, especially knowing what happened before. The manual itself says that "adduser" is just for creating new users.
Sadly, after trying to check some manual pages and listing the commands in /usr/bin, I can't find anything at all, so I guess I'll have to edit the /etc/group file manually.
Oh, great, I don't have nano installed. That's... the only text editor I can really use, so I'll have to install it. Luckily, I saw that you could install stuff in the login message by typing "pkg install", so hopefully "pkg install nano" will work?
Phew! It needed to do some more stuff, as it was the first thing I was installing via pkg, but it worked, so now I should be able to edit the file easily.
Okay, now that thing's done, will it allow me to...?
It does, luckily. And I notice right away that my user's home path is slightly different than usual. I'll have a look at the root directory.
There are a few folders that I don't recognize, but otherwise, it is very similar to what I'm used to seeing when working on Debian. I should also see what shell I'm using, just in case.
So root is using "csh"... I really thought I was using bash, since it was so similar, but I guess that being able to see hidden files was a dead giveaway of the fact something was off. In fact, I can't recognize any of the files that are present in root's home. Still, what I feel the most comfortable on is bash, so I'm going to try to install it.
Nice! It's included! Once I get it installed, I grab its location by using "which", and change it up in the /etc/passwd file.
I save the file and exit the connection, just to enter again and log in as root. After seeing the shell looks exactly the same, I decide to see all processes running (at least, from my user's perspective).
As I imagined, the changes didn't apply, and since I'm not looking at the proper command to do it, I just prefer to reboot the machine so that the changes take effect. A simple "reboot" will do it.
Unfortunately, that doesn't work, and I'm still stuck with csh. However, I notice there's another file, master.passwd, so I try to modify that one.
This one seems to have the root password, but it looks exactly the same as the other file otherwise. I save and reconnect to the host, but it doesn't work, either, so I search on the Internet, and I land on this page, which shows the command "chsh" in order to do what I wanted. I try "chsh root", but it takes me to a vi editor. Luckily, I happen to find another manual entry, where it says I can change it by setting the EDITOR variable, which is done with "setenv EDITOR nano", in my case.
But it fails. It simply refuses to accept that shell as valid.
Out of curiosity, I tried changing my non-root user's shell. And surprisingly, it did work!
I had seen before that the manual pages advised against changing the default shell, but I didn't expect that it wouldn't let me do so. Oh well, I'll have to deal with it.
This is it for the moment. In the next part, I'll be trying to install the LAMP stack on FreeBSD and then a desktop environment.
Posted on December 22, 2019
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.