Home > Articles

A Basic Tour of FreeBSD

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 POST

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:

F1 DOS
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.

NOTE

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
  root@simba.lionresearch.org:/usr/obj/src/sys/SIMBA

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.

init

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.

InformIT Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from InformIT and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites, develop new products and services, conduct educational research and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by InformIT. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.informit.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020