Step 1. Choosing Between Ports and Packages:

projectlogo-full

FreeBSD offers two primary methods of downloading applications and system tools: packages and ports. Users will have to choose between the two collections when installing these tools. Packages are pre-compiled binary packages, typically smaller in size than full port installations and they do not require compilation time. Ports are a much more customizable option, allowing experienced users to adjust how the tool is compiled. Packages are created for less experienced users and should be used unless the user has specific changes they need to make. In general, ports should only be used if the user understands how the packages are compiled and would like to customize this process. 

Step 1.1 Using the Ports Collection:

Skip this section if planning to use packages to install the Desktop Environment in later steps, this is a long tedious process and you may never use it

All commands in this section should be run as root, using the “su” command will also work. To download a compressed snapshot of the Ports Collection into /var/db/portsnap:

$ portsnap fetch

When running Portsnap for the first time, extract the snapshot into /usr/ports:

$ portsnap extract

After the first use of Portsnap has been completed, as shown above, /usr/ports can be updated as needed by running:

$ portsnap fetch

$ portsnap update

When using fetch, the extract or the update operation may be run consecutively, like so:

$ portsnap fetch update

Step 2. Installing the X Window System:

Before installing a desktop environment, a graphical user interface (GUI) is needed. The X Window System is an open source GUI that supports FreeBSD and offers a ton of customization and user tools.

Xorg (the X Windows System) can be installed as a package or port. Both require root privileges so users should first run:

$ su

Then after entering the root password, to install the binary packages:

$ pkg install xorg

Or to build and install from the Ports Collection:

$ cd /usr/ports/x11/xorg
$ make install clean

Installation will then start, duration can vary depending on the computer speed.

Step 3. Learning How to Edit Text Files:

To continue working with FreeBSD and configuring system tools, a general understanding of text editing will be needed. The most powerful tool FreeBSD includes for this process is the “vi” command.

Read through the manual page. Focus on the commands that let you enter and delete text, “a” and “x”. A handy cheat sheet for vi commands can also be found above.

Before entering a command the “esc” key must be used. If you have already used the “a” command to enter text, the “x” key will simply enter that character unless you first esc the command.

Once you are finished, use “esc” to end the last command. Then use one of the save/quit commands to quit editing the file. If you want to save changes use “:wq” otherwise use “:q!” to quit without saving changes.

Step 4. Configuring the X Window System:

The X Window System uses 3D acceleration. In order to benefit from this, users who will be using the GUI need to be added to the video or wheel groups. This can be done in one command as root. Enter these lines but replace guestuser with the user you are adding:

$ su

$ pw groupmod video -m guestuser || pw groupmod wheel -m guestuser

This will add the user to the video group, or if that doesn’t exist, the wheel group.

Next, FreeBSD must be configured to set the video output mode. Use the “vi” command to start editing /boot/loader.conf

$ vi /boot/loader.conf

Add this line to the top of the file:

kern.vty=vt

Step 5. Setting Up and Testing the X Window System.

Before the X Window Server can be run, a few dependancies will need to be installed. Start by installing drm-kmod.

$ pkg install drm-kmod

For built-in intel video drivers, follow the next two steps verbatim, for other video drivers, pay attention to the message emitted by the previous command, it will tell you what needs to be loaded on boot. This will replace the kld_list=”i915kms” in the command below.

Edit /etc/rc.conf:

$ vi /etc/rc.conf

And add the following line

kld_list="i915kms"

The X Window system can now be tested using the built-in start command:

$ startx

Step 6. Choosing a Desktop Environment:

While FreeBSD has a huge collection of desktop environments users can choose from, this guide will be focusing on just 3: Gnome, KDE, and Xfce. The other desktop environments can be found in the FreeBSD ports collection.

GNOME offers a user-based desktop environment, which a beginner-friendly desktop environments. One possible limitation with GNOME is that, in order to comply with EU power regulation, GNOME suspends the machine after 20 minutes.

KDE is another user-friendly environment focused on standardization of menus, toolbars, and color-schemes.

Xfce is a lightweight desktop environment. This simple environment is great for slower machines or devices with memory limitations.

Once you have chosen the desktop environment, find the section below on how to install and configure the environment.

Step 6.1 Installing and Configuring GNOME

Install GNOME from the binary package:

$ pkg install gnome3

Or from the ports collection:

$ cd /usr/ports/x11/gnome3

$ make install clean

Next, you will need to mount /proc. Add the following line to /etc/fstab using the “vi” command, this will mount /proc on startup:

proc /proc procfs rw 0 0

You will next need to configure GNOME to automatically start as FreeBSD boots, this can be done by adding these 4 lines to /etc/rc.conf using the “vi” command. This ensures that GNOME and all its dependencies are running on boot:

dbus_enable="YES"
hald_enable="YES"
gdm_enable="YES"
gnome_enable="YES"

GNOME will now automatically start as the device boots, reboot the computer to start the desktop environment!

Step 6.2 Installing and Configuring KDE:

Install KDE from the binary package:

$ pkg install x11/kde4

Or from the ports collection:

$ cd /usr/ports/x11/kde4

$ make install clean

Next, you will need to mount /proc. Add the following line to /etc/fstab using the “vi” command, this will mount /proc on startup:

proc /proc procfs rw 0 0

You will next need to configure KDE to automatically start as FreeBSD boots, this can be done by adding these 3 lines to /etc/rc.conf using the “vi” command. This ensures that KDE and all its dependencies are running on boot:

dbus_enable="YES"
hald_enable="YES"
kdm4_enable="YES"

KDE will now automatically start as the device boots, reboot the computer to start the desktop environment!

Step 6.3 Installing and Configuring Xfce:

Install Xfce from the binary package:

$ pkg install xfce

Or from the ports collection:

$ cd /usr/ports/x11-wm/xfce4

$ make install clean

Xfce doesn’t offer its own login manager, so it can’t be started as FreeBSD boots in the same way as GNOME or KDE. To be able to start Xfce from the command line, first add this entry to ~/.xinitrc:

$ echo "exec /usr/local/bin/startxfce4 --with-ck-launch" > ~/.xinitrc

While Xfce will not automatically start when the system boots, it can now can be launched through the command line by starting the X Window System:

$ startx

You now have a desktop environment on your device!

If you chose to configure the rc.conf file, the environment will load each time that FreeBSD boots. Each environment has its own settings but offers a console app to use for command line inputs. Quitting the environment will also allow the user to access the FreeBSD shell. 

The next step is using your new desktop environment to download a collection of graphical and accessibility applications or utilities to suit the user’s needs. Check out the FreeBSD ports collection to find a list of available applications.