Home > Articles > Operating Systems, Server

A Basic Tour of FreeBSD

  • Print
  • + Share This
Unleash the power behind FreeBSD by tackling its command line interface and learning to perform some basic operations.
This chapter is from the book

FreeBSD, like most UNIX operating systems, has an extremely rich set of commands and utilities. This rich set of utilities allows users to do things with UNIX that most other operating systems cannot do. This power is one reason that UNIX has remained so popular, more than 30 years after it was originally written. Unfortunately, this rich set of utilities and commands can make FreeBSD a bit overwhelming and bewildering to the new user. This hour provides a gentle introduction to the FreeBSD command line interface and how to perform some basic operations.

In this hour, you will learn the following:

  • The basics of the FreeBSD startup process

  • Logging in to FreeBSD

  • Your home directory and what it is for

  • The rest of the directory structure

  • Working with files and directories

  • Logging out of the system

  • The importance of proper system shutdown

The Basics of the FreeBSD Startup Process

When you first turn on your computer, a number of processes must occur before you can start using it. For example, your computer needs to check that all of its hardware is available and working properly, and load the instructions off the hard disk that tell it what to do next. A basic understanding of these processes is helpful for understanding how FreeBSD works, as well as for troubleshooting problems when things go wrong.


The first thing that happens when you turn on your computer is called the Power On Self Test (POST). This is a program run by your computer's BIOS (basic input/output system). During this stage of the startup process, the computer checks all of its hardware to make sure that everything is there and working. It counts the available RAM and performs some basic tests on it, determines the types and size of available media (hard disks, and so on), and assigns resources to plug-and-play devices. Note that this stage of the startup process has nothing to do with FreeBSD. This step is performed no matter what operating system you intend to start on your computer. At this point, your computer still doesn't know anything about what operating system it will be running.

The Bootstrap

After the POST has completed, your computer's BIOS looks for a device on your system that it can load an operating system from. The order in which devices are checked for an operating system can usually be configured in your system's BIOS setup menu. Oftentimes, the floppy drive is the first device that gets checked. This is why you get the "Non-systems disk or disk error" message if you have a floppy disk in your drive when you turn on your computer. Normally, the device that the system boots from will be the system's hard disk.

The Boot Manager

After the BIOS has found a bootable hard disk, it will read whatever is located at sector 0 on the hard disk. You can think of sector 0 as basically being the first thing on the hard disk. Sector 0 is also known as the Master Boot Record or MBR. This procedure begins what is called the bootstrap, which gets its name from the idea that the system is "pulling itself up by its bootstraps."

If you installed a dual boot system so that you can choose whether you want to work in Windows or FreeBSD each time you start your system, the FreeBSD boot manager program is what will be located in the MBR. You will know that this stage of the boot process has completed when you get a menu that looks similar to the following:

F2 FreeBSD

Default: F2

The DOS entry is actually Windows. But it will show up as DOS with some versions of Windows. To select the operating system you want to start, simply press the function key corresponding to the entry in the menu. If you do nothing for a period of time, the entry listed next to Default will be started automatically. (The default will normally be whatever operating system you selected the last time you used your computer.) For the rest of this hour, I will, of course, assume that you selected FreeBSD from this menu.


FreeBSD can also be booted from the Linux boot loaders: LILO and GRUB. However, configuring this is beyond the scope of this book. Please see the LILO or GRUB documentation for more information on how to add another boot option to either.

If you elected to install FreeBSD as the only operating system on the computer, you will not see this menu, but rather FreeBSD will start loading immediately.

The Kernel

There are actually a couple of startup stages between the boot manager and this stage, but we are going to skip them because they are not important at this point. They mostly exist for technical reasons. If you are interested in learning more about these stages and why they exist, there are more details of the bootstrap procedure in the FreeBSD Handbook available on the FreeBSD Web site at http://www.freebsd.org.

The next part of the startup process loads and starts the FreeBSD kernel. The kernel is a special piece of software that serves as the core of the operating system. It controls access to system resources such as RAM, hard disks, and so on, provides services (such as multitasking) that allow your computer to do more than one thing at the same time, ensures that two programs cannot interfere with each other by accessing resources not allocated to them, and, on a multiuser system such as FreeBSD, ensures that users cannot interfere with other users by controlling what parts of the system the users can access.

When the kernel has loaded, you will see a copyright notice that looks similar to the following:

Copyright 1992-2002 The FreeBSD Project
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994
  The regents of the University of California. All rights reserved.
FreeBSD 4.7-RELEASE #0: Sun, Sept 14 02:04:15 CST 2002

The parts you want to take notice of here are the last two lines (lines 4 and 5). Line 4 contains important information about the version of FreeBSD you are running. In this case, we are running FreeBSD version 4.7 RELEASE (other possibilities are STABLE and CURRENT. I will explain these in a later hour). The date and time that follow the release indicate the date and time that this kernel was compiled. This might not mean much to you right now, but it will be important later on if you build a custom kernel for your system. (See Hour 10, "The FreeBSD Kernel and the Device Tree," for why you would want to do this and how to go about doing it.) Line 5 lists the name of the user who built the kernel, as well as the hostname of the system that the kernel was built on. The second part of the line lists the directory in which the object files for the kernel are located. If you are a C or C++ programmer and you know what object files are, great. If you don't know what object files are, don't worry. You can work with and administer FreeBSD just fine without ever having to worry about this.

After the copyright notice, you will see a flurry of messages go by the screen as FreeBSD detects and initializes the various hardware devices in your system. You don't need to understand what these mean at this point, but you might recognize some familiar hardware in the list. For example,

fd0: <1440-KB 3.5" drive> on fdc0 drive 0

is a 3.5 inch 1.44Mb floppy drive. The first part of the line (fd0) is the FreeBSD device name. It is similar to the designation "A: drive" in Windows. However, the FreeBSD system actually makes more sense because the designation tells you something about what the device is—fd stands for floppy disk. The number 0 indicates that it is the first floppy disk in the system. In FreeBSD, numbers almost always start at 0 rather than 1.

You might also see some lines that look something like this:

unknown: <PNP0501> can't assign resources

You needn't worry about these messages either. These are simply plug-and-play devices in your system that FreeBSD doesn't know anything about. With time, as FreeBSD supports more and more hardware, you should see fewer and fewer of these messages.

After the kernel has finished initializing hardware, it will mount the root file system. (More on mounting and unmounting file systems can be found in Hour 8, "Storage Systems and Backup Utilities.") Mounting the file system simply makes it available for use. You will see a message similar to the following when this process occurs:

Mounting root from ufs:/dev/ad0s1a

After this has happened, the kernel will invoke a program called init to handle the rest of the system startup. Messages coming from the kernel and messages coming from the init program can be distinguished by their color. Kernel messages are white, whereas messages from init are light gray in color.


One of the first things the init program does is check to make sure that the system was shut down properly the last time the computer was restarted. If it wasn't, init will run a program called fsck, which is basically the equivalent of the Windows Scandisk program. fsck will check and repair any file system damage resulting from improper shut down of the system.

After the file systems have been checked, init reads the system startup scripts and runs any programs that are set to run on system startup. These are similar to services in Windows or programs that have been placed in the Startup group in Windows.

After these programs have been started, init runs a program that initializes the console and provides you with a login prompt.

  • + Share This
  • 🔖 Save To Your Account