Step 1. Choosing Between Ports and Packages:

projectlogo-fullFreeBSD 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. While it may be tempting to lean towards ports because the customizable aspects, packages are created for less inexperienced 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. Otherwise, packages should be the default method of installation.

 

Step 1.1 Using the Ports Collection:

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

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

    portsnap fetch
  2. When running Portsnap for the first time, extract the snapshot into /usr/ports:

    portsnap extract
  3. 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
  4. 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:
sudo su
  • To install the binary package:
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 between a few minutes (installing from packages on a fast computer) to hours (if compiling from the ports collection).

 

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. While this page may be overwhelming at first, don’t worry! Just 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.
  • Now that you have a basic understanding of the “vi” command, the next step is to edit FreeBSD configuration to help setup a desktop environment.

 

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 slurms with the user you are adding:
sudo su
pw groupmod video -m slurms || pw groupmod wheel -m slurms
  • 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. Choosing a Desktop Environment:

  • While FreeBSD has a huge collection of desktop environments users can choose from, this how-to will be focusing on the 3 most popular: Gnome, KDE, and Xfce. The other desktop environments can be found in the FreeBSD ports collection.
  • GNOME offers a user-based desktop environment, which is one of the most beginner-friendly desktop environments for new users.
  • 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 you will be using, find the section below on how to install and configure the environment.

 

Step 5.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 5.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 5.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 Did It! 

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 offer a console app to use for command line use. 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.