*!!!* This tutorial is a work in progress *!!!*
This tutorial is written for FreeBSD 10.0.
Don’t know what BSD is? Check out this page.
Contents
Installing Base System
— The FreeBSD Boot Loader —
First boot into the FreeBSD installation media (cd/dvd/usb). The boot loader will display:
When the boot loader is displayed press “1” or “Enter” to boot into multi-user mode (Note: You can pause the boot loader timer by press the space bar). If booting fails restart & try changing some boot settings from the boot loader or try single-user mode. Once the machine has booted correctly the install wizard should be displayed. If not, and you are at a text input prompt with a “#” or “$” execute the command bsdinstall.
— The FreeBSD Installer —
*!!!* INCOMPLETE *!!!*
At the FreeBSD Installer menu select “Install”.
Next you will be asked to select a keymap for your keyboard layout. Select “Continue with default keymap” for English/US.
After the keymap you will be asked to input a hostname for your machine. This can be left blank but it is recommended so that the computer is easily identified over networks.
Next you will be asked which system components you would like to install.
- doc: System documentation
- games: misc. games
- ports: A collection of 3rd parts software that can be compiled on the FreeBSD system. If not selected it can be installed after installation.
- src: Source code for the FreeBSD kernel & main system. Install this if you want to compile software that requires code system code.
Installing Software
When referring to software there are two common terms used in FreeBSD: Packages & Ports.
Packages are pre-compiled software installed using the command:
# pkg install <packagename>
Ports refers to a source tree where software can be compiled manually. The user must cd into the Port directory & use the command make install. It is recommended to install software from the Ports collection though it will generally consume much more time. I will demonstrate both of these methods in the next section.
— Recommended Software —
- nano (editors/nano): A command-line interface text editor (more novice friendly than vi)
- sudo (security/sudo): Use elevated privileges as a super user
Nano
nano is a command line text editor much like vi (which is installed by default). nano provides a somewhat simpler interface for beginners (in my opinion).
To install the binary nano Package simply execute the following command (you will need to be connected to the internet):
# pkg install nano
You will be asked to confirm the installation along with any dependency packages. Type yes & press “Enter”. The Package will be downloaded & installed.
To compile manually from Ports, cd into nano‘s source tree directory:
# cd /usr/ports/editors/nano
Optionally set the configurations:
make config
If nano depends on other packages you can use the following command to adjust their configurations as well:
make config-recursive
Now to build & install nano use the following command:
make install clean
clean will remove temporary files after the software has been installed. If you plan to make changes or reinstall the software later you can omit this.
Sudo
I also recommend installing sudo (pkg install sudo or found in /usr/ports/security/sudo). sudo is a tool for allowing regular users to use the elevated privileges of the super user (a.k.a. “root” or “su”).
To use elevated privileges the username must belong to the group wheel. If this was not done during installation the username can be added to the group with the following command:
# pw usermod <username> -G wheel
Make sure to use a capital “G”. So if my username were “Jordan” I would execute:
# pw usermod Jordan -G wheel
You can view groups & their members in the file /etc/group:
nano /etc/group
The username must also be added to the sudoers file. Edit the file /usr/local/etc/sudoers. Find the line “root ALL=(ALL) ALL” & add a similar line using the username instead of root:
##
## User privilege specification
##
root ALL=(ALL) ALL
Jordan ALL=(ALL) ALL
Save the changes. Now you can log in with your username & execute commands with elevated privileges using sudo:
$ login
login: Jordan
password:
$ sudo pkg install nano
password:
— Searching for Software —
There are a few different ways that you can search the software repository on a FreeBSD system, though some of them may be a little buggy.
Currently, my favorite option is to use the make quicksearch command from the root of the Ports tree:
$ cd /usr/ports
$ make quicksearch name=nano
Port: nano-2.2.6
Path: /usr/ports/editors/nano
Info: Nano’s ANOther editor, an enhanced free Pico clonePort: nano-devel-2.3.3
Path: /usr/ports/editors/nano-devel
Info: Nano’s ANOther editor, an enhanced free Pico clone…
If you want to search for a keyword in the Port/Package you can use the key option instead of name:
$ make quicksearch key=editor
Port: dasher-4.10.1_6,2
Path: /usr/ports/accessibility/dasher
Info: Information efficient text-entry interfacePort: ar-libreoffice-4.2.5
Path: /usr/ports/arabic/libreoffice
Info: ar language pack for libreoffice…
- pkg_search : An alternative utility for searching installable software on FreeBSD
pkg_search (ports-mgmt/pkg_search) is another option. It is outdated but can still be used to find software & its location:
$ pkg_search -r nano
nano-2.2.6 /usr/ports/editors/nano
nano-devel-2.3.3 /usr/ports/editors/nano-devel
nanoblogger-3.4.2_1 /usr/ports/www/nanoblogger
nanoblogger-extra-3.4.2 /usr/ports/www/nanoblogger-extra
rubygem-nanoc-3.6.11 /usr/ports/www/rubygem-nanoc
$
Setting Up a Graphical User Environment
— The X11 Window System —
Required software:
- xorg (x11/xorg): The X window system
- hal (sysutils/hal): Hardware Abstraction Layer (installed automatically with xorg)
- dbus (devel/dbus): D-bus Message System (installed automatically with xorg)
Installing xorg
The first thing to do to set up a graphical user environment (GUI Environment) is to install the X11 Window System, also known as the X Server or Xorg.
$ cd /usr/ports/x11/xorg
$ sudo make config-recursive
…
$ sudo make install clean
Next edit the file /etc/rc.conf & add the following lines to enable the D-bus Message System & Hardware Abstraction Layer at startup:
dbus_enable=”YES”
hald_enable=”YES”
These two daemons will automatically be loaded after restart. You can also manually start these using the service command:
$ sudo service hald start
$ sudo service dbus start
Configuring xorg
After dbus & hald services are running you can optionally create a xorg configuration file:
$ sudo X -configure
$ sudo mv /root/xorg.conf.new /usr/local/etc/X11/xorg.conf
To change any options edit the file (recommended to make a backup first):
$ sudo cp /usr/local/etc/X11/xorg.conf /usr/local/etc/X11/xorg.conf.bak
$ sudo nano /usr/local/etc/X11/xorg.conf
Resources:
— Setting Up a Desktop Environment —
Optional desktop environments:
- LXDE (x11/lxde-meta)
- GNOME Desktop Environment (x11/gnome2)
- KDE (x11/kde4)
- XFCE (x11-wm/xfce4)
In this tutorial I will only focus on setting up the Lightweight X11 Desktop Environment (LXDE).
LXDE
lxde can be installed via pkg install lxde-meta or from the Ports Collection located in /usr/ports/x11/lxde-meta.
Once lxde is installed the X server needs to be configured to launch it. This can be done locally for a single user with the file /usr/home/<username>/.xinitrc or globally for the entire system with the file /usr/local/etc/X11/xinit/xinitrc.
Single user: If the file does not exist in the user’s home directory create it then edit it & add the following to it:
#!/bin/bash
exec startlxdm
System-wide: Move the xinitrc file with the command sudo mv /usr/local/etc/X11/xinit/xinitrc /usr/local/etc/X11/xinit/xinitrc.bak. Now create a new xinitrc file & add the same contents as for a single user.
It is recommended that you make these file executable:
$ chmod +x .xinitrc
or
$ sudo chmod +x /usr/local/etc/X11/xinit/xinitrc
Now simply execute startx from the command line & LXDE should start.
— Setting Up a Display Manager —
If you would like to have a login screen as well you can install one of the many X11 display managers (Note: If you installed GNOME then GDM will already be install & if you installed KDE then KDM will already be installed).
Display manager options:
- XDM (x11/xdm): X Display Manager
- GDM (x11/gdm): GNOME Display Manager
- KDM (x11/kde4, requires installing KDE environment): KDE Display Manager
- SLiM (x11/slim): Simple Login Manager
I will focus on setting up XDM as it is standalone & it’s dependencies should already by installed.
The X11 Display Manager (XDM)
xdm can be installed via pkg install xdm or compiled from the Ports Collection located in /usr/ports/x11/xdm.
After xdm is installed it should be configured to execute LXDE (or another desktop environment) upon login. This can be done for a single user with the file .xsession located in the user’s home directory or system-wide with the file Xsession located in the xdm configuration directory. On FreeBSD systems the xdm configurations are located in the directory /usr/local/lib/X11/xdm.
Single user: Create a file named .xsession in the user’s home directory & add the following to it:
#!/bin/sh
exec startlxde
If you created an .xinitrc file simply copy it with the command cp .xinitrc .xsession.
System-wide (Not recommended): Move the Xsession file so that the original is not overwritten:
$ sudo mv /usr/local/lib/X11/xdm/Xsession /usr/local/lib/X11/xdm/Xsession.bak
Create a new Xsession file & put the same contents in as for a single user.
Again, it is recommended that you make these files executable:
$ chmod +x .xsession
or
$ sudo chmod +x /usr/local/lib/X11/xdm/Xsession
If you want XDM to load at system startup edit the file /etc/ttys:
$ sudo nano /etc/ttys
Find the following line:
ttyv8 “/usr/local/bin/xdm –nodaemon” xterm off secure
Change “off” to “on” & save the file:
ttyv8 “/usr/local/bin/xdm –nodaemon” xterm on secure
The next time you restart the system the X11 login manager should automatically appear.
Note: By default a console window will appear at the XDM login screen showing the text “Console log for…”. If you do not want this window to appear edit the file /usr/local/lib/X11/xdm/xdm-config & find the following lines:
! The following three resources set up display :0 as the console.
DisplayManager._0.setup: /usr/local/lib/X11/xdm/Xsetup_0
DisplayManager._0.startup: /usr/local/lib/X11/xdm/GiveConsole
DisplayManager._0.reset: /usr/local/lib/X11/xdm/TakeConsole
Add a “!” to the beginning of each line to disable the setting:
! The following three resources set up display :0 as the console.
! DisplayManager._0.setup: /usr/local/lib/X11/xdm/Xsetup_0
! DisplayManager._0.startup: /usr/local/lib/X11/xdm/GiveConsole
! DisplayManager._0.reset: /usr/local/lib/X11/xdm/TakeConsole
Resources:
To be continued…





Pingback: How to Install & Set Up FreeBSD 10 with A Desktop Environment | Wireless80211's Blog
Perfect guide! Thank you!
I am very grateful for this detailed guide. Thanks a lot!
Reblogged this on danleyb2.
Thanks, one of rare authentic guide! Cheers and good wishes!
Very good FreeBSD system, I would like FreeBSD with graphical desktop FluxBox, by default, and a standard manual Firewall. Some applications like Skype or Flash Player is broken on the installation and do not work.
Pingback: Installing a Desktop Environment on FreeBSD – อีสานสารสนเทศ