Running The Ubuntu Command on FreeBSD Linux Distributions

Handhika Yanuar Pratama
4 min readJun 17, 2024
Photo by Milad Fakurian on Unsplash

I was working on managing a new server, FreeBSD. With about four years of experience managing servers, I just realized I don’t know about these distributions. Okay, let’s make this story from the bottom approach.

The Starts

FreeBSD is an operating system used to power modern servers, desktops, and embedded platforms; it has a large community and has been continually developed for over thirty years. Looks. My knowledge needed to be more about servers.

Key Differents

Again, I’m curious whether FreeBSD is the same as Linux. I was surprised that it was two different things.

The Package Installations

A package management system was important for adding a program to the system. As far as I know, Linux distributions consist of the Debian and CentOS families.

Debian (APT and dpkg)

Debian uses APT as a front-end tool for dpkg to handle the installation and removal of packages.

CentOS (YUM and DNF)

CentOS has used YUM in versions seven and earlier and DNF in CentOS 8 for package management.

FreeBSD

FreeBSD uses pkg for binary package management and the Ports Collection to compile applications from the source.

My Trouble

When I first used this distribution, I didn’t know how to install new apps on this OS.

Look, most were failures until I remembered the command on MacOS, pkg. It asked me to install it first, but that’s okay if I can install new apps and start working.

But I need to find out what the difference is between them. Because of that, let’s do the Copilot work here.

Looks like it’s about licenses; the PKG in MacOS relies on external tools like Homebrew, which means it’s easier to use than the open source 🤣

Installing the APT on your FreeBSD

In my case, I would like to install a package that doesn’t exist on the FreeBSD system. Because of that, I researched and found a way to do such a job. It still needs to be documented well, so I want to document it.

Connect with SSH to make it easier

I am working for a server, and because of that, it’s hard to take screenshots for the documentation, so the first thing I do is connect via SSH.

I was already writing about how to log in to SSH using the root in Free BSD here. Okay, SSH is connected; let’s work right now.

The Steps

First, we should enable Linux compatibility; we should edit /etc/rc.conf and add linux_enable=”YES” in those files.

After that, run service linux start as root. After adding it, it will load the necessary kernel modules and set some sysctls for Linux commands later.

Install the sys-utils/debootstrap using pkg install debootstrap

It will install all the necessary packages for you; wait until this is done

Make sure you don’t find any errors in the process

Now it will install the Ubuntu Bionic into /compat/ubuntu; you could install it into /compat/linux, but sometimes it has a possibility of clashing with the CentOS. So, let’s make it easier.

Suppose the end of the process is “Base system installed successfully.” In that case, your work is done even though you may find errors during the configuration process.

Now run chroot /compat/ubuntu /bin/bash and run apt

Finally, you could use apt as a package manager for your FreeBSD

Conclusions

Installing the APT package into your Free BSD is relatively easy; it’s easy as long as you have connectivity and know the steps. In this story, I already told you about this thing. I hope you can benefit from it if you are new to Network Administrator; thanks for reading.

--

--