Total Pageviews

Search: This Blog, Linked From Here, The Web, My fav sites, My Blogroll

30 June 2010

PC-BSD --- PBI system

PBI system's  Software Manager makes it easy to find, install, remove, and update software.

Push Button Installer System

What Is a PBI?
PBI is the name of the software management system that is unique to PC-BSD.
    An application that you can install using this software management system is also called a PBI. For example, you might see references to someone installing the Firefox PBI. If you ever come across a file with a .pbi extension, it is an application that can be installed using the PBI software manager.
There are many different ways to install software on your PC-BSD system.
    Whenever possible, you should use the PBI system because it provides the following advantages:
  •  PBI software is easy to install. You simply find the application in Software Manager and click it to install.
  •  PBI software is easy to uninstall using Software Manager.
  •  Software Manager will tell you when newer versions of your installed applications become available and it will allow you to easily upgrade to the new versions.
  •  PBI software has been pretested to run on PC-BSD, meaning it should “just work.”
  •  Software Manager ensures that no other applications are affected when you install or uninstall PBI software. This means that you won’t accidentally overwrite or delete libraries or dependencies needed by the operating system or other applications.

Software Manager
To access the PBI system, simply double-click the Software Manager icon on the default Desktop. You can also find Software Manager in Kickoff ➤ Applications ➤ System ➤ Software Manager
    When starting Software Manager, you will be prompted for the superuser password because only the administrative account can install software. You also need to be connected to the Internet because Software Manager will attempt to connect to the PC-BSD software repository at
    If the connection to is successful, you will see the available software categories loaded in the Software Browser tab. Software Manager contains the following tabs:
  • Software Browser: Allows you to browse for PBIs. Using its built-in searchfeature is discussed in the following section, “Installing a PBI.”
  • Installed Software: Shows you which PBIs are already installed, and allows you to update or remove installed PBIs.
  • System Updates: Allows you to check for, review, and install operating system updates. They are discussed in more detail in the "Update Manager" section later
Software Manager also provides a Configuration button that contains the following tabs:
  • Mirrors: Specifies which PBI server on the Internet to connect to. You can alsospecify a custom mirror if you have created your own web server to host PBIs.
  • Software: Allows you to keep a copy of downloaded PBIs after installation. This is discussed further in the section titled “Installing from Another PC-BSD System.”
  • System: Allows you to automatically install available updates.
  • Misc: Allows you to specify an alternate temporary directory to storedownloaded PBIs.

Installing a PBI
The Software Browser tab of Software Manager can be used to browse for and install PBIs. I.e. the user has entered a search phrase of firefox, and the search results show that there are two Firefox PBIs available.
    If you don’t know the name of the application you want to install or want to get an idea of which PBIs are available, you can instead click a software category.I.e. the user clicked the left arrow to return to the software categories screen. The user then clicked the Web Browsers category to see which web browsers were available.
    If the user clicks an application, they will see more information. Each PBI contains a description, the name of the organization (vendor) that creates the software, its rating among PBI users, the number of downloads since the PBI became available, the date the PBI was added to the repository, the license the software is released under, the e-mail address of the person who created the PBI, and the version number of the PBI.
    If you want to install the software, click either the DOWNLOAD hyperlink or the download icon that contains the green arrow.
PBIs tend to be large because they contain everything needed to run the application. If you have several PC-BSD systems in your network, consider downloading the PBIs you need to a shared folder on one system. Instructions on how to do so are in the section called “Installing from Another PC-BSD System” later.
When you click to install the application, a pop-up message will ask if you want to install the selected PBI. Click OK and the Installed Software tab will open, showing the progress of the installation.
Should the Internet connection fail during the download, the message in the Installed Software tab will change to “Download failed! Please try again later.” When you regain your Internet connection, right-click the message and select Retry Download to resume the installation. The message will remain until either the installation is complete or you use the Remove button to remove it.
Once the download is complete, the installer will begin. Click Next to continue. The installer will tell you where the application will be installed, how much disk space it requires, and how much space is available.
    Click Next to start the installation. A progress meter will display while it is installing. When finished, the PBI will indicate its location in the Kickoff menu, and then will provide you with an installation complete message. The default is to start the application when the installer exits.
    The installed software, along with its version number, will now show in the Installed Software tab of Software Manager.

Installing from a DVD
During the installation, you were asked if you wanted to install any software from the installation DVD. If you didn’t install then, but want to now, simply insert the DVD and wait until Device Notifier pops up with the label of the DVD. You can then access the contents of the DVD from Dolphin.
    While in Dolphin, click the DVD’s label name in the Places panel. You will find the applications that came with the DVD in the extras ➤ PBI folder. Right-click the PBI you want to install and select Open with PBI Launcher from the menu.
    After entering the administrative password, the PBI will install as described in the previous section.

Installing from Another PC-BSD System
By default, Software Manager will download and install PBIs without permanently saving a copy of the downloaded PBI. If you want to save a copy of the PBI so it is available to other PC-BSD systems in your network, you will need to change this default. You can do so by clicking the Configuration button in Software Manager and then clicking the Software tab.
    Check the box Keep downloaded software in Temporary Directory. The location of that directory is in the Misc tab and by default is set to /usr/local/tmp.
    If you change this default directory to a folder in your home directory, you can easily share your PBIs with other PC-BSD users in your network. In the Misc tab, click the folder icon next to the Temporary file directory to browse to a folder you want to share.
I highlighted dru’s home directory and then clicked the New Folder button to create a new folder called software. Once I click OK, /home/dru/software will show as the new temporary file directory.
    To share this directory so it is accessible to other PC-BSD computers in the network, open up Dolphin. Click Home in the Places panel; then highlight the software folder. Right-click and select Properties from the menu. Click the share tab and then the Configure File Sharing button. You will be prompted for the administrative password, and then you will see a menu about simple and advamnced sharing.
    Because the folder you want to share is in your home directory, you can keep the default of Simple sharing. Click the Add button to open the Share Folder screen. You can then browse to the folder you want to share (in this example, /home/dru/software)
    Once the folder is selected, check the box to Share with Samba (Microsoft(R) Windows(R)). This will add the Name of the folder—it will be capitalized, and if the original name was greater than eight characters, it will be reduced to eight characters. This will allow the folder to be shared with any computer that understands Samba. You should leave the Writable box unchecked unless you  want other computers to be able to add files to this folder. When finished, press  OK, and your folder will show in the Shared Folders list.
    You can check that your changes worked from Dolphin. Click Network in Places and then Samba Shares ➤ Mygroup. You should have an icon with your hostname; in my example, the icon’s name was Pcbsd-3228 (Samba Server). If you click that icon, you will see your software folder and its contents. The other PC-BSD users in your network should now be able to access your shared folder from Dolphin or Konqueror.
    If they use Konqueror, they can type smb:/ to browse to your group, computer, and shared software folder.
We have demonstrated sharing a folder so other PC-BSD users can access your downloaded PBIs. You can use the folder-sharing instructions to share the contents of any folder. Your shared folder should be accessible to any computer running PC-BSD or any version of Microsoft.

Installing from the Temporary Directory
If you already have a copy of a downloaded PBI saved in the temporary directory, you can install it directly from Dolphin without downloading it all over again within Software Manager. You might run across this situation if you install a PBI, remove it, and then decide you want to install it again.
    Open up your PBI temporary directory in Dolphin, right-click the PBI, and select Open with PBI Launcher from the menu. After typing the administrative password, the PBI installation will proceed as usual.

Removing a PBI
To uninstall a PBI, highlight it in the Installed Software tab and either right-click and select Uninstall or click the Remove button. You will receive a warning asking if you want to remove this application. Once you press Yes, the application will be
  • uninstalled, 
  • removed from the Installed Software tab, and 
  • removed from its location in the Kickoff menu. 
  • Its entire directory will be removed from /Programs.
  • If the application stored data in your home directory, it might ask if you want to remove it when the application is uninstalled.

Updating PBIs
The Installed Software manager tab in Software Manager can be used to update PBIs whenever a newer version becomes available. The Status section will indicate which versions are available.
    If an update is available, simply highlight the PBI you want to update and click the Update button. It will uninstall the old PBI for you and then download and install the newer version. When finished, the new version number will show in the Program Name.
If you ever accidentally remove the desktop icon for an installed PBI, right-click the application in the Installed Software tab of Software Manager. Click Install Desktop Icons, and it will re-add the icon to your desktop.

Update Manager
Update Manager is used to notify you when newer versions of PBIs become available and when patches are available for your operating system. The system tray includes an icon for Update Manager.
  • When your PBIs and operating system are up-to-date, the icon for Update Manager appears as a green shield with a white checkmark. 
  • If updates are available, the icon changes to a red shield with a white X.
If you right-click the Update Manager icon in the system tray, you can do the following:
  • Start the Update Manager: Launches Software Manager. You can then use the Installed Applications tab to update any PBIs whose status shows that there is a newer version available and use the System Updates tab to update the operating system, as discussed in this section. 
  • Check for updates: Causes the icon to change to a green circular arrow as it connects to the PC-BSD update server to see whether any updates are available. When finished, a pop-up menu will indicate if your system is completely up-to-date or if updates are available. 
  • Run at startup: If checked, Update Manager will automatically check for updates whenever you start KDE. If unchecked, you can manually check whenever you want by clicking Check for updates.
  • Quit: This will remove Update Manager from the system tray. You can still manually start Update Manager from Kickoff ➤ Applications ➤ System ➤Online Update Notifier.
The System Updates tab of Software Manager is used to install operating system patches. If you highlight the entry, the View Details button will explain the reason for the update. To apply the update, check the box next to it or click the Select All button to apply all security updates. A progress bar, will show you which update is currently being downloaded or applied.
    Some updates will require the system to reboot, and Update Manager will present a pop-up message to remind you to reboot for those changes to take effect.
Update Manager will not automatically reboot for you. This means that you can continue to do other things with your computer while the system is being updated, without worrying about losing the data you are currently working on.

When a PBI Doesn’t Exist
We mentioned at the beginning  that the PBI software management system is the best way to install applications on your PC-BSD system. While the PBI system offers many of the most popular software applications, not every application will have a PBI. If you can’t find a PBI of your favorite application, you have a few choices available to you:
  •  Install its FreeBSD package
  •  Install its FreeBSD port
  •  Ask that someone within the PC-BSD community create the PBI
  •  Create the PBI yourself


  • The Definitive Guide to PC-BSD(2010 Apress) by Dru Lavigne ISBN: 978-1-4302-2642-0

PC-BSD --- A Intro


Getting Started with PC-BSD

Did you ever wish that you could just use your computer without becoming frustrated by the experience? How many times have you found yourself asking:
  • why can’t I browse the Internet or use email without worrying about viruses? 
  • Why can’t I find software that doesn’t crash or freeze my computer? 
  • Why do I have to rely on a technical friend or family member to keep my system up-to-date?
  • Why does software cost so much? 
  • Why do I have to become a computer expert just to use a computer?!!
The good news is: you don’t have to become a computer expert just to use a computer. In fact, you don’t even have to spend money on computer software. You can browse the web, use email and social networks, create documents and presentations for work or school, play games, watch videos, and listen to music using high quality software at no cost. Sound too good to be true?

A Little History
Computers and software have been around for over 60 years, so it can be useful to have some historical context on why things are the way they are. In the beginning, computers were huge, taking up entire floors worth of space, and cost hundreds of thousands of dollars. Computer manufacturers made their money selling hardware and computer users were expected to create their own software. It quickly became apparent to users that sharing the software they created with each other provided many benefits. It saved everyone from reinventing the same wheel and freed up their time to actually use the computer hardware they had invested so much money in. This software sharing evolved into associations of users that still exist to this day.
Examples include SHARE, created by IBM users in 1955, and DECUS (now called the HP User Society), which was created by Digital Equipment users in 1961.
In the beginning, software was created by users and didn’t cost any money, and sharing communities were created by and for people using the same software.
    Things began to change in the 1970s as lower-cost personal computers were introduced and software began to be sold as a product(see Elements of Operating System and Internet History: A BSD Perspective). Over time, users purchasing software became the norm and the members of software communities became limited to computer scientists and programmers.

Free and Open Source Software
In 1985, a computer scientist at MIT named Richard Stallman became frustrated that software he had created through academic research was being sold for profit by companies. In response, he wrote the GNU Manifesto and launched the Free Software movement.
    According to Stallman, software is “free” not when it is obtained at no cost, but when it gives the user the following freedoms:
Free software is a matter of the users’ freedom to run, copy, distribute, study, change and improve the software. More precisely, it means that the program’s users have the four essential freedoms:
  •  The freedom to run the program, for any purpose (freedom 0).
  •  The freedom to study how the program works, and change it to make it do what you wish (freedom 1). Access to the source code is a precondition for this.
  • The freedom to redistribute copies so you can help your neighbor (freedom 2).
  • The freedom to improve the program, and release your improvements (and modified versions in general) to the public, so that the whole community benefits (freedom 3). Access to the source code is a precondition for this.
A program is free software if users have all of these freedoms. Thus, you should be free to redistribute copies, either with or without modifications, either gratis or charging a fee for distribution, to anyone anywhere. Being free to do these things means (among other things) that you do not have to ask or pay for permission.

Whenever the term “free” is used here, it is referring to the above definition of free, not to the cost of the software.
  • Free software does not include shareware that can only be used at no cost for a limited amount of time. 
  • Free software does not include demo software that only provides some features and nags you to buy the full product in order to access all of the features. 
  • Free software does not include spyware or trojans, which are meant to harm your computer.
  • You are not engaging in software piracy if you download or use free software. Free software has already given you the freedom to use and share it with your friends without having to first pay a cost or ask for permission.
Think of free software as a return to the original days of computers, when users shared their programs to help each other use their computers effectively.
    In 1998, a group of free software users decided to create a new term to describe free software. They felt a new term was needed so users wouldn’t confuse “freedom” with “no cost.” They coined the term “open source” and started the Open Source Initiative to promote its use.
While technical users may debate the nuances of each term, from a user perspective it is safe to assume that any software that calls itself “free/libre” or “open source” allows you to legally download, use, and share it at no cost.

BSD Software
Nearly a decade before Richard Stallman wrote his GNU Manifesto, computer scientists at the University of California at Berkeley were sharing the changes they were making to the Unix operating system with users at other universities. These changes were known as the Berkeley Software Distribution(BSD) Unix.
The changes included a working implementation of TCP/IP, the software that computers still use today to access the Internet and files on other computers.BSD also pioneered the concept of creating and sharing software over a network. In this way, a community of software users could help each other out, even though they all lived in different parts of the world. When the users at Berkeley stopped contributing changes to BSD in the early 1990s, the global community of users took over and continued development of the operating system.
  • One group of users decided to concentrate on making BSD work on many different types of computers (the technical term is porting to other computer architectures). They formed the NetBSD project in March 1993. NetBSD currently supports 57 architectures, making it the most ported operating system in the world and earning it the motto “of course it runs NetBSD!”
  • Another group of users decided to concentrate on personal computers and getting as many applications as possible to work with the operating system. They formed the FreeBSD project in November 1993. As of December 2009, FreeBSD supports almost 22,000 applications, all of which are free to use.
  • A group of NetBSD users decided to concentrate on operating system security and started the OpenBSD project in December 1994. OpenBSD includes a number of security features absent or optional in other operating systems, and its motto is “Only two remote holes in the default install, in a heck of a long time!”
Despite their original focus goals, all of the BSD communities support multiple architectures, provide thousands of free applications, and have a reputation for being secure. The BSD communities also work closely with each other, and new features created by one project tend to find their way into the other projects over time.

In 2005, a FreeBSD user started experimenting with some scripts to make installing and using FreeBSD easy for the casual computer user. His goal was to create a no-cost operating system that is so intuitive and easy to use, you shouldn’t have to constantly bug your technical friends in order to figure out how to do things. The result was PC-BSD.
    PC-BSD is open source software, meaning that you have been given permission to install, use, and share it. PC-BSD has a vibrant community of other PC-BSD users with whom you can share your PC-BSD experiences, tips, questions and answers. Experienced PC-BSD users can also share their programs and add-ons.
    PC-BSD is still FreeBSD under the hood, meaning that existing FreeBSD users have access to all of the FreeBSD features they expect. As new versions of  FreeBSD are released, so are versions of PC-BSD. This means that PC-BSD users benefit from all of FreeBSD’s features as they are introduced.

Why PC-BSD Instead of FreeBSD?
PC-BSD is based on FreeBSD, so a natural question arises: “Why use PC-BSD instead of FreeBSD?”
    FreeBSD is a popular open source operating system. It does have a reputation for being better suited to technical users than to casual computer users. For example, after installing FreeBSD, the user is left with a command prompt and is expected to know how to configure the graphical environment, networking and sound, and how to install additional applications. While these tasks are very well documented and easy to do (once you know what you’re doing), it does assume that you either know what you are doing or have the time to learn. While the learning experience can be very satisfying, it can also be frustrating to new users or users who need their computer to “just work” right now.

No Previous Knowledge Required
PC-BSD doesn’t require any previous knowledge since the operating system is pre-configured for you. It provides an easy-to-navigate desktop, a browser that is connected to the Internet, working sound, dozens of installed applications, and an easy way to browse for and install additional software. The first time you boot into PC-BSD, you can just start using it.

Stability and Security
FreeBSD has a reputation for being a very stable and secure operating system.
    PC-BSD builds on this base by adding several features that make it easy for you to keep your system secure. The installation pre-configures the built-in firewall to allow access to the Internet but to prevent other systems from damaging your computer. A firewall utility is included should you wish to adjust your firewall settings.
    PC-BSD includes a utility that automatically checks for security updates and newer versions of software. This application will pop-up when an update is available, describe the update, and provide a button for you to install the update.
    Viruses on BSD systems are extremely rare (I have been using BSD daily for over ten years without running antivirus software and have never been infected by a virus). PC-BSD does support easy-to-install antivirus software should you wish to use it.

Friendly and Helpful Community
It may seem strange to include community as a feature of an operating system, but once you learn how to tap into a community’s resources you’ll realize why community is so important. No operating system is perfect. Sometimes an “intuitive” feature doesn’t make sense to you and sometimes things don’t work like they should. What do you do if your technical friends aren’t available or don’t know the answer?
    Access to other PC-BSD users from around the world is a valuable resource. Someone else will have experienced the same problem and can tell you what they did to fix it. And if the problem turns out to be a bug in the software, others in the community can fix the software so it doesn’t happen again. The community is also a great place to learn about applications you haven’t tried before and to hang out with other PC-BSD users—this can be especially helpful if none of your friends has tried PC-BSD yet. The PC-BSD community has a reputation for being friendly and helpful.

Best of Both Worlds
PC-BSD isn’t just for the casual computer user; it is also well suited to existing FreeBSD users. I started using PC-BSD after nearly a decade of using FreeBSD as my desktop. I already knew how to configure a FreeBSD desktop, but wanted to try PC-BSD’s pre-configured install. I stayed with PC-BSD because I liked its additional features.
    For users already familiar with FreeBSD, PC-BSD provides the best of both worlds: a pre-configured desktop and FreeBSD. You can still install software using the FreeBSD ports and packages(binaries builded from ports) collections, and you can try PC-BSD’s software installer. You can still keep your software up-to-date using traditional tools, and you can try PC-BSD’s update utility. You can still manually configure networking and the firewall, and you can try PC-BSD’s graphical utilities. Heck, you can change the desktop and still access the PC-BSD graphical utilities through the command line. If you’re a curious power-user like myself, you can even turn your PC-BSD installation into a FrankenBSD as you discover all kinds of novel ways to integrate FreeBSD with PC-BSD’s features.

Why Not Linux?
If you’re familiar wi th free software, you have probably heard of or used Linux before. You may even be wondering if PC-BSD is a Linux distro (it is not). PC-BSD aims to allow any user to use FreeBSD on his or her computer, much like Ubuntu10  aims to allow any user to use Linux on his or her computer. Both are examples of easy-to-use open source operating systems.
The answer to the question “why use PC-BSD over a Linux distribution such as Ubuntu?” depends upon whom you ask.
  • Some PC-BSD users experience fewer problems using PC-BSD’s software installer and update utilities. 
  • Some find PC-BSD to be better documented or find the PC-BSD community to be more helpful. 
  • Some like the PC-BSD desktop better than the Ubuntu desktop. 
  • Some like that it is based on FreeBSD.
So, really, it depends upon whom you ask. The real answer may be to try both and to experience each operating system for yourself. Both will allow you to use your computer effectively, at no cost. If you’ve used Ubuntu before, keep an open mind as you go on. PC-BSD will accomplish the same tasks as Ubuntu, but it will do some things differently.


  • The Definitive Guide to PC-BSD(2010 Apress) by Dru Lavigne ISBN: 978-1-4302-2642-0

29 June 2010

PC-BSD --- Installation process easy like Windows? No it's really easier

PC-BSD was designed to be easy to install. Even if you’ve never installed an operating system before, the default settings provided by the installer will allow for a quick and successful PC-BSD installation.
    If you have a spare computer and a PC-BSD DVD, you can install and start using PC-BSD in under 45 minutes.
You can start with Using the Live DVD. This will enable you to try out PC-BSD without destroying the data on your computer. As you become more comfortable with the idea of performing an installation that will replace the current operating system on your computer with PC-BSD.
    This post discusses all of the possibilities that can occur during an installation. By understanding what each setting does, you can decide whether you want to change it or accept the default setting. Also discuss settings of interest to users who would like to perform an installation that doesn’t overwrite the existing operating system. I will show you how to create free space for the PC-BSD installation and how to configure a boot manager so multiple operating systems can exist on one computer.

What’s New in PC-BSD 8

Some of the notable features of this release include the following:
  • New system installer: The system installer was completely rewritten. It now enables users to test their keyboard layout and to install FreeBSD or PC-BSD,and provides a summary of the installation settings. The back end of the installer is scriptable, allowing advanced users to fully customize their installations.
  • Software Manager: This now includes a software browser, enabling users to easily find and install software in the same utility that is used to remove and update installed software.
  • Life Preserver: PC-BSD now includes an easy-to-use backup utility.
  • Nvidia for AMD64: Nvidia GeForce1 video cards are now fully supported on both the 32- and 64-bit versions of PC-BSD.
  • Adobe Flash Player 10: As of this writing, 10 is the latest version of Flash, meaning you can view any flash content in PC-BSD.
  • KDE 4.3.4: As of this writing, this is the latest version of KDE.
  • New USB system: The entire USB system was rewritten for FreeBSD 8, making it easier to work with USB devices.
  • Filesystem support: PC-BSD now supports encrypted filesystems and the ZFS filesystem.

System Requirements

To install PC-BSD, you must first determine whether the hardware on your computer meets the minimum requirements.
    If your computer is fairly new (less than 5 years old), it should be fine. If your computer is older, double-check that it meets the minimum requirements.

Minimum for PC-BSD Installation
At a bare minimum, your computer needs to meet the following hardware requirements:
CPU: Pentium 2 (introduced in 1997)
Disk space: 10GB of free space
Memory: 256MB of RAM

Minimum for FreeBSD Installation
The FreeBSD installation is meant for relatively advanced users. Existing FreeBSD users should be aware that the PC-BSD installer does not allow you to select which FreeBSD distributions to install—for example, User, Developer, or Minimal. The minimum requirements listed next are based on the requirements of the installer.
If you’re looking for a FreeBSD minimal installation on a low-end computer, you should install from FreeBSD media instead of the PC-BSD installer.
Available disk space: 4GB of free space
Memory: 256MB of RAM

Although the minimum requirements will allow you to install PC-BSD, you can never have too much CPU, disk space, or RAM. In fact, the more you have, the better your computing experience. The PC-BSD project recommends the following minimum hardware in order to get the most out of PC-BSD:
CPU: Pentium 4 or higher (introduced in 2000)
Available disk space: 30GB of free space
Memory: 512MB of RAM
Video: Some advanced features such as desktop effects and 3D games require a 3D video card. PC-BSD supports 3D acceleration on most Nvidia cards and some Intel integrated cards.

Determining Hardware Settings
There are many utilities available for determining what hardware is installed on a computer. I use Parted Magic because this open source program can also be used to create free space on your computer.
   After you have the CD, insert it into your CD drive, boot the computer, and press the spacebar when you see the menu(access your BIOS and change the boot order so your computer boots from CD first).
   To determine the hardware on your system, press the spacebar when you see the Parted Magic menu to stop it from loading. Use your up arrow to highlight the Extras menu and press Enter. Press Enter again to start the Hardware Detection Tool (HDT)
Parted Magic also provides a graphical interface to show you your hardware, but that tool may not give you all of the information you’ll need about your video card.
You can now use your up and down arrow keys to highlight entries, and your left and right arrow keys to move between menus. Use the right arrow key to expand a menu and the left arrow key to go back.
You should write down the following information:
  • Disks ➤ Disk 1: Make note of the size of the disk. If you are planning oninstalling PC-BSD without losing the current operating system(s) on thecomputer, carefully record the Size and Type for each partition.
  • Memory ➤ Bank 0: Note the Size. Repeat for each of the listed Banks (the number of banks will depend on your hardware). Adding up all of the listed sizes will show the total amount of RAM on the computer.
  • Processor: If the FSB setting is higher than 66, your CPU meets the minimum installation requirements. Also check the X86_64 setting. If it is set to No, you must install the 32-bit version of PC-BSD. If it is set to Yes, you must install the 64-bit version of PC-BSD.
  • VESA ➤ VESA Bios: The Vendor and Product will be needed when you select your optimal video settings.
  • When finished, arrow down to Reboot and remove the CD.

Obtaining PC-BSD

Downloading and Burning a .iso File: If you want to download and burn your own DVD, the PC-BSD web site contains everything you need to get started.
The main page of the web site always indicates which version is the “Current Release”, and that is the one that you want to download. 
Occasionally, the front page will also describe a future release that is in its testing phase.
Unless you are helping the community test a release, you don't want to download a testing release; you can spot these as the version name will include the word “beta” or “RC”(release candidate). It will also have a different version number than the one indicated by “Current Release”. 
As of this writing, the current release of PC-BSD is 8.0—the number after the 8 may be higher when you go to download the current release.
    To download PC-BSD, click on the Download link in the PC-BSD 8.0 Released section. Notice that there are several hyperlinks to choose from.
  1. Before downloading anything, determine if your computer is 32 or 64 bit, as described in the previous section on “Determining Hardware Settings”. You can then choose which file(s) to download.
  2. If you have a fast Internet connection, download the DVD version that matches your hardware (32 or 64 bit). The DVD version contains everything you need, but it is a large download—about 4GB. 
  3. If you have a slow Internet connection or a limit on how much you can download, consider downloading the CD files instead. These files are a smaller download (about 700MB each), but you will need to download both CD #1 and CD #2 to complete the installation, plus CD #3 if you want to install additional software during the installation. 
  4. Advanced users also have the option to download USB and boot-only images.
The CD version does not contain the live version of PC-BSD. Here we refer to the “PC-BSD DVD”. If you are using CDs instead, you can use them to do everything  except using the Live DVD.

If you click a hyperlink to start a download, it will indicate the name of the file that will be downloaded, its size, and the MD5 sum of the file. The filename will end in .iso, indicating that it is an image that is meant to be burned to a CD or DVD media. This means that the CD/DVD drive in your computer needs to be writable—it will be marked as CD-RW or DVD-RW, where the W means that it is capable of writing. You will also need an application that is designed to write .iso files to media.
 If this seems too complicated, click on the Store link to purchase a DVD, or get a friend to help you burn your own.
If you decide to download a file, click the arrow next to its Download button. This will allow you to choose a download site—pick the one(mirror) that is closest to your geographic region. Once the download is finished, you should check that the MD5 sum on the file you downloaded is the same as the MD5 sum next to the download link.
The section entitled “Data Integrity Check” in the user guide shows you how to do this for Windows and Linux/BSD. Mac OSX users can use the following command at a command prompt: openssl md5 name_of.iso
Replace “name_of.iso” with the name of the file that you downloaded. In the rare event that the md5 is not the same value, this indicates that there was a problem with the download. You will need to download the file again, preferably from a different mirror. If you are an advanced user, you should email the PC-BSD testing mailing list so the developers can check to see if there is a problem with the file on the download mirror.
    Once you have verified the file's checksum, you can burn the DVD or CD using your favorite burning application or the instructions in the user guide.
The PC-BSD project also gives away thousands of DVDs each year at free software conferences. The main page of the web site lists the location of these conferences in the Upcoming Events section. If a conference is near you, drop by the PC-BSD booth to pick up a DVD and talk with people from the PC-BSD project.

Using the Live DVD

A live DVD enables you to take an operating system for a “test drive” to see whether you like it before committing to an installation of the operating system on your computer.
It is also an excellent way to check whether the operating system understands all of your computer hardware. If it works on the live DVD, it will also work when you install the operating system.
To use the PC-BSD live DVD, insert your PC-BSD DVD into your computer's DVD tray and boot your system. When you see the Welcome to PC-BSD menu press your spacebar to pause the menu. You can then press the number 3 key to boot PC-BSD in Live mode. You will see a series of text messages on your screen as PC-BSD boots.
    That’s it! After the computer finishes booting, you can use the live environment. Here are some things to be aware of when using the live DVD:
  •  Bootup is slower because everything needs to be copied from the DVD to the live filesystem.
  •  Any changes you make are copied to the live filesystem and will disappear when you reboot. If you create any files, save them to a USB drive or floppy before rebooting. Otherwise, they will disappear.
  •  The live filesystem is small (about 30MB), so you will need to download or create large files on a USB drive.
  •  If your computer does not have much RAM, you will find the live DVD slower than the installed version of PC-BSD.
  •  Remember: A live DVD is a tool to try out an operating system. If you want to use the operating system on a regular basis, you should install it instead.

Using a Virtual Environment

A virtual environment allows you to perform an installation into a “virtual” computer. From a practical point of view, this means that you can install and use PC-BSD within a window on your existing operating system. This installation is virtual because it does not overwrite any of the data on your computer and you can continue to use your existing operating system as usual. However, the installation is real in that it allows you to fully use the operating system that was installed into that window, just as if it were the only operating system on your computer.
    To perform this bit of magic, you need to first install a virtual computing application. We recommend the VirtualBox application because it is free, easy to use, and available for Windows, Mac OS X, Linux, and BSD. You can download the Windows, Mac, and Linux versions of VirtualBox.
Existing FreeBSD users can install the VirtualBox package or port. Existing PC-BSD users can install the VirtualBox PBI by using Software Manager.
After the VirtualBox program has been installed and started, you will need to create a virtual machine. This machine contains the settings for the window where you will install PC-BSD.
    Click the New icon to start the New Virtual Machine Wizard. Your machine will need the following settings to successfully install PC-BSD into it:
  • Name: Choose a name that makes sense to you.
  • OS Type: Select BSD from the drop-down Operating System menu and keep FreeBSD as the version.
  • Base Memory Size: Change this number to 256.
  • Virtual Hard Disk: Keep the default settings of the boot hard disk and create a new hard disk. 
  • Storage Type: Keep the default of Dynamically Expanding Storage.
  • Location: Give the folder a name that makes sense to you and double-check that its location is in an area with enough disk space to hold the size of the virtual machine.
  • Size: This needs to be changed to at least 10GB.
After you are finished, your new virtual machine will appear. Before installing PC-BSD, there is one more setting that you need to configure. Click the Settings
icon and highlight the CD/DVD-ROM setting, Select the Mount CD/DVD Drive check box, which should select the make and model of your drive(or directly the .iso image). If you have multiple DVD drives or you have plugged in an external USB DVD drive, use the drop-down menu to select the DVD drive you wish to install from.
If you have downloaded PC-BSD, you can mount the .iso file directly without having to first burn it to a DVD. Select the ISO Image File radio button and use the Browse Folders icon to browse to the location where you saved the ISO.
When you are finished, click OK to save your changes. You are now ready to install PC-BSD into your virtual machine. If you are installing from a DVD, insert the DVD disk into the drive you specified earlier.
   Click the Start button, which will start the virtual machine in its own window. You can then perform the installation as described in the next section.
Tip Don’t worry, installing into a virtual machine will not affect your current operating system. The installation only “exists” within the window of the virtual machine.
There are a few things you need to be aware of when using PC-BSD in a virtual environment:
  • You need to press the Ctrl key on the right side of your keyboard to switch back and forth between the virtual machine and the applications running on your host operating system. For example, if you try to click your mouse or type something and nothing happens, press your right Ctrl key to activate your mouse/keyboard in that area.
  • A virtual environment uses a lot of memory. If your computer does not have much RAM, you will need to be patient because everything will be slower. Closing unused programs may speed things up for you a bit.
  • After you’ve installed an operating system into the machine, you will need to tell your virtual machine that you want to boot the operating system, not install it all over again. Highlight the virtual machine entry and click Settings ➤ System to access the menu. Highlight the Hard Disk entry in the Boot Order section and use the up arrow to move it to the top of the list.
Once installed, PC-BSD can be used as if it were installed on the computer, because the virtual machine will save all of your changes. 
    If you plan to download large files, make sure the size of your virtual machine is large enough to hold those files. PC-BSD will boot whenever you start the virtual machine and will shutdown whenever you close the virtual machine.


The best way to use PC-BSD is to install it onto the computer. It will be much faster than using the live DVD or a virtual environment. If you don’t care about what is on the computer now, you can just install PC-BSD and it will erase everything on the computer so it can use all the disk space that came with the computer.
    However, if you need to keep the operating system that is currently on the computer, things get more complicated.
    One solution to make things less complicated is to install PC-BSD onto an external USB drive. If the USB drive is plugged in when you run the Parted Magic CD, it will tell you the size of the drive. Be sure to select the correct drive from the drop-down menu when you reach the “Disk Setup” section of the installation.
    The most complicated way is to install PC-BSD onto the same hard drive as your current operating system. If you plan to do this triple-check that you are installing into the correct partition in the “Disk Setup” portion of the installation.
It is important to realize that the default installation assumes that you want to overwrite everything on your computer, or that you have an existing partition that contains no data.
To start the PC-BSD installation, insert your PC-BSD DVD. This time, don’t press anything when you see the Welcome to PC-BSD menu, because the default option is to start the installer.
If you wish to save some time, watch the text messages after the menu and type n when the installer asks whether you want to check the integrity of the installer archive. 
The installer will automatically detect your video card and mouse/pointer device. After the installer is loaded, you will see the Welcome & Language Selection screen.

 Language Selection
The drop-down Language Selection menu enables you to select your language. Each menu in the installer provides three options:
  • Abort (stop the installation and reboot the computer)
  • Back (return to the previous screen), and 
  • Next (move on to the next screen). When finished with this screen, click Next to continue.

Keyboard Setup
Enables you to select your
  • keyboard model, 
  • layout, and 
  • variant. 
If you are unsure, just leave the settings as is, because the default settings will work.
  • If you know that you want to customize these settings, deselect the Use Default check box. 
  • If you have a non standard keyboard, you can then select your keyboard from the Keyboard Model drop-down menu. 
  • If your keyboard contains non-English characters, highlight your language in the Preferred Layout menu
  • If you have a Dvorak keyboard, highlight your variant in the Preferred Variant menu. 
  • If you modify any of these settings, you can test that your settings are correct by typing into the test settings box. 
  • If you decide you want to go back to the default settings, select the Use Default check box.

Installation Type
Enables you to choose what type of installation to perform (i.e. you can select Network/Internet as the Installation Source).
To install PC-BSD, you can just accept the default installation type settings and click Next. Here are all the possible options:
  • Fresh Install: This option will format (erase all data) on the disk partition specified in the next menu. 
  • Upgrade: Select this option when a newer version of PC-BSD becomes available.
  • Restore from backup: Advanced users can select this option to repair a PC-BSD system by returning it to its original settings. This option does not keep your data, meaning you have to back it up first.
  • PC-BSD: This option installs PC-BSD.
  • FreeBSD: This option can be used by advanced users to install the FreeBSD operating system. This installation does not install the X window system, meaning there is no graphical user interface. This option assumes that you already know (or are willing to learn) how to configure a FreeBSD system.
  • DVD/USB: This option uses the inserted DVD to install PC-BSD.
  • Network/Internet: This enables advanced users to install over an Ethernet network card, as described in the next paragraph. Note that it is quicker to install from the DVD.
If your computer is attached to the Internet via an Ethernet network card, you can install the system from
  • a server on the Internet or 
  • from a specified server (for example, a server at work or school that has been set up for this purpose).
If your Internet provider provides your computer with a network address automatically (most do), keep the default setting of AUTO-DHCP and click Next.
    The installer will attempt to connect to the Internet and, if successful, will fill in the Select Installation Source screen for you.
    The default selection will work. However, if you are connecting to a custom installation server (for example, at work), select the Install from Specified Server radio button and enter the settings provided by your system administrator.

Disk Setup
This screen is meant for advanced users to customize their disk partition layout. If you don’t consider yourself to be an advanced user, you should either leave this screen as is, perform the installation on a test computer or virtual environment, or get an advanced user to double-check your changes.
The installer assumes that you want to install PC-BSD on your computer and to erase its current contents. If this is not your intent, you should do one of the following instead:
  1. use the live DVD until you are ready to install, 
  2. find an extra computer to install on, or 
  3. carefully create and choose a free partition on your hard drive to install into. 
If you decide to go ahead with the installation, make sure you first back up the data on your computer that you consider important.
I recommend that the first time you install PC-BSD (or any other operating system, for that matter), you use a computer on which you don’t want to keep any of the existing data. 
If you become an advanced user and want to try out new things, you can try more-complex configurations where you dual-boot, meaning the computer has more than one operating system installed.
  The easiest disk layout assumes that you want PC-BSD to take up your computer’s entire hard drive. Simply select the Use Entire Disk check box, and the installer will set up everything for you (auto-partition). Remember, this will remove all data that is currently on that hard drive.
If you forget to select the Use Entire Disk box, you will see this error when you click Next: “The install requires a disk/slice with at least 10000MB of disk space.”
If you are installing PC-BSD onto an external USB drive, select it from the drop-down menu at the top of the screen. After a drive is selected, any existing partitions will show in the box under the Use Entire Disk check box.
    Advanced users can select which partition to install into. If you want to keep an operating system on one of the partitions, it is important that you select the correct partition to erase and install PC-BSD into. Use the partition information you recorded in the “Determining Hardware Settings” section to check that you have selected the correct partition.
    If you want to install into a specific partition, do not select the Use Entire Disk check box! Instead, highlight the desired partition and click Next.
    Advanced users can customize their disk layout by selecting the Customize Disk Setup (Advanced)
radio button. This will change the screen( + button to add a new partition, which is known as a slice).
If you don’t know what a disk partition is, you should stick with the default of Auto Partition(By default, the installer will create 2GB for /, 1GB for /var, RAM times 2 for SWAP, and the rest of the available space to /usr. The same sizes are used if you click the Auto Partition button).
When adding a slice (disk partition), you can customize the following:
Disk/Slice: The names of the entries that appear in this menu depend on whether the disk has any existing partitions.
If you select the name that does not include the letter s(slice) followed by a number (ad0 in this example), you are configuring the entire disk.   If you select a name that includes the letter s followed by a number, you are configuring an existing partition. 
The installer will show you the size of the partition and the type of filesystem (for example, NTFS, Linux, FreeBSD), which should give you a hint about what is already installed on that partition.

Type: PC-BSD is able to install several types of filesystems. Table 2-1 provides a description of each filesystem type available in the Type drop-down menu. If you’re not familiar with filesystems, the default value of UFS is fine.

Mount Point: This indicates the names of the filesystems. Table 2-2 shows the
most commonly used mount points.

Size: The size will depend on your needs and the amount of disk space you have to work with. Table 2-2 provides some suggestions to get you started.

Enable Encryption: PC-BSD uses geli to provide encryption on any filesystem and mount point, including SWAP, ZFS, and /.

The final option on this screen is the Install PC-BSD Bootloader check box. Whether you select this check box depends on whether PC-BSD will be the only operating system on the computer:
  •  If PC-BSD will be the only operating system on the computer, leave this check box deselected.
  •  If you will be dual-booting PC-BSD with another operating system, you must select this check box so the boot code will be written to disk—this will be needed, even if you decide to use another boot manager.
  •  If you plan to add another operating system later, select this option so the PC-BSD boot code is written to disk.

User Creation
Is used to set the administrative password, set up the primary user account, and create any additional user accounts for the system.
The administrator password is also known as the root password or the superuser password. You will need to use this password whenever you make a change to the operating system.
This screen asks you to input the password twice and will tell you if the passwords do not match. It will also force you to create the root password, meaning that this text box can’t be left empty.
    The Add User section is for the user who uses the computer most often (probably you). You will need to remember the username and password; again, the installer will ask you to type the password in twice and will tell you if the values do not match. Advanced users can select their favorite shell from the drop-down menu. If you don’t have a favorite shell or don’t know what a shell is, the default value is fine.
    After you have input the user values, click the +Add button to create the user. If the +Add button doesn’t work, you have forgotten to fill in one of the fields in the Add User section.
    You can create as many user accounts as you need and should create a separate account for every user who will use the computer. If you create multiple accounts, the user who uses the computer most often should be created first so that user is first in the list. If you mess up an account, simply highlight it in the list, click – Remove, and try again.
    The Auto-Login User check box indicates whether the first user in the list has to type in their password when the computer boots up. The default setting allows that user to be logged in automatically. This is convenient if you are the only user on the computer and you are not worried about anyone else starting your computer and seeing your stuff. If you do not like this default, deselect this check box so that every time the computer boots up, it will present a login screen that will require you to type in your username and password.

Date and Time Zone
Enables you to select your time zone from the drop-down menu. Pick the city that is closest to your geographic area. This will allow your computer to  automatically adjust its time whenever daylight savings time starts or stops. By default, the Automatic Synchronization with Internet Time Servers (NTP) check box is selected.
NTP11 is an abbreviation for the Network Time Protocol, which allows a computer to receive its time from a time server on the Internet. Accurate time is needed for some applications (especially those that share data over a network) to work properly. You can deselect this check box if you don’t want your computer to connect to a time server.

Optional Components
The Optional Components screen, enables you to select additional software to install with the operating system.
 Here is a brief description of each available component:
  • Firefox: Fast, customizable, and secure web browser that supports tabbed browsing and hundreds of plug-ins. See  for more details.
  • GIMP: Image manipulation and creation utility, similar to Photoshop.
  • K3B: Easy-to-use CD/DVD burner.
  • OpenOffice: Complete office suite, similar to and compatible with Microsoft Office.
  • Pidgin: Instant messaging client that supports AOL Instant Messenger (AIM), MSN, Yahoo!, Google Talk, and many more chat networks.
  • FreeBSD ports collection: Allows advanced users to install additional software.
  • FreeBSD system source: Allows advanced users to view and use the source for the underlying FreeBSD operating system.
  • The Warden: Allows advanced users to easily manage and administer FreeBSD jails.
  • VLC: Media player for DVDs, CDs, and streaming video.
To install an optional component, highlight it in the Available Components list and click the right arrow to move it to Selected Components. You can use your Ctrl key to select multiple components. If you change your mind, you can use the left arrow to move a component back. The components that show in the Selected Components list will be installed for you.
If you are installing from CD instead of DVD, you will be prompted to insert CD #3 if you select to install any additional components.

Installation Summary
The Pre-Install Summary screen, provides a summary of your selections. The summary indicates the following:
  •  Whether this is a fresh install, upgrade, or system restore.
  •  Whether you are installing from a DVD or from a specified network location.
  • How the disk will be formatted. You will want to verify that you’ve selected the correct hard drive or installation partition and review the size of the partitions that will be created.
  • Which additional software components will be installed.
  • Which user account(s) will be created.
This screen provides your last chance to go back and change your selections or to Abort the install.
    After you click Next and answer Yes to the “Start the installation now?” message, the specified hard drive/partition will be erased and the installation of PC-BSD will begin. During the installation, a progress bar, will show the progress of the installation.

If Something Goes Wrong
PC-BSD could fail to install on your computer, although that possibility is rare. After the installation has started, its progress is written to various logs.
    The installer also sets up several virtual terminals where you can input commands and review the logs. You can access the first terminal by pressing Ctrl+Alt+F2. Type root at the login prompt to log in to the terminal, and then cd /tmp to access the location where the logs are located.
Use Alt+F7 to return to the installation screen. Alt+F3 through Alt+F6 represent the remaining virtual terminals.
The following logs are created in /tmp:
  • .pc-sysinstall/pc-sysinstall.log: Everything the installer does gets copied here. The error will be at the bottom of this log, and everything that succeeded will be before the error. If the install is successful, a copy of this log can be found at /pc-sysinstall.log on the newly installed system.
  • sys-install.cfg: All of the settings you selected in the installation menus are stored here.
  • xstartup.log: X is the software that is used to load up the graphical interface. If the installer has problems with your video hardware, the error will be in this log.
Advanced users can review the logs to see what went wrong. You will want to make a copy of the log files so you can include the information other users will need to help you. One method is to e-mail a copy of the log to yourself by using the following command, which will send an e-mail with a subject of “installation log”:
# cat xstartup.log | /usr/bin/mail -s "installation log"

Replace xstartup.log with the name of the log file you would like to e-mail to yourself and replace with your own e-mail address.
You can also save the log file to a USB thumb drive. After inserting the drive, you can mount it, copy the log file, and umount the drive with the following  commands. Don’t forget to type in that umount command before you remove the thumb drive so PC-BSD knows that you are finished using it.
# mount -t msdos /dev/da0s1 /mnt
# cp /tmp/xstartup.log /mnt
# umount /mnt

Post Installation
The first time you boot into PC-BSD, the Display Settings screen, will prompt you to confirm your display settings. Select the name in the drop-down Video Card menu that most closely matches the Vendor and Model settings you wrote down for your video card. The “Determining Hardware Settings” section at the beginning describes how to find out your video hardware settings if you do not know what video card is installed on the computer.
    You can also change your screen resolution at this time. The resolutions that are available will depend on what settings are supported by your video hardware. When finished, click Apply and then OK so your settings can be tested. If you like the resolution, click Yes when you see the Confirm Resolution
screen. If you don’t like the resolution, click No so you can try another resolution.
If you have problems configuring your display settings, use the default Video Electronics Standards Association (VESA) settings, which will work but may not provide your favorite resolution(you must use Vesa with Virtualbox).
After your resolution has been set, the system will finish booting into PC-BSD.
    If you are installing PC-BSD into VirtualBox and have problems setting the resolution, use System Settings.
Congratulations! You have successfully installed your PC-BSD system!
If you are connected to the Internet and there are software updates available for your system, you’ll receive an informational message on your screen.
In Virtualbox you must firstly umount virtual cd. Click on storage > in CD/DVD device select Empty. Now you can start PC-BSD virtual machine

Probably after the first boot(from disk) you may get notice about updates. rclick un update manager icon(yellow color icon site in SystemUpdaterTray). Select System Updates tab and tick the software you want update there. Now clik on Install selected packages.
    The same procedure must be repeated when you clik on Installed software tab(select the software--one package per time-- and click on Update button)

Advanced Installation

Creating Partitions
By default, the PC-BSD installer assumes that you want to either replace the existing operating system on the computer or that you have an extra partition that you can install into. If you want to keep your existing operating system and it is currently installed into the only partition on your computer, you will need to shrink that partition to create some free space that can be used to install PC-BSD.
    The PC-BSD installer will not resize a partition, meaning that you will have to use another application for this purpose.
Caution Always back up your data before resizing a partition, just in case!
What utility you use depends on your current operating system:
  • Vista: Use the Disk Management utility and the instructions from
  • Mac OS X: Use the Disk Utility and the instructions at
Ubuntu: You can install and use gparted with the following commands:
# sudo apt-get install gparted
# sudo gparted

You can also use the Parted Magic CD, introduced in the “Determining Hardware Settings” section, to create free space.
  1. This time, boot with the Parted Magic CD and wait for it to load its graphical environment. 
  2. You can then click the Partition Editor icon on the desktop to display your current partition information. I.e if the computer in this example is currently
    running Ubuntu, which has been installed onto the entire hard drive. Ubuntu has created one large partition (71.64GB), plus a small extended partition (2.89GB), plus a small swap partition (2GB).
  3. Right-click the partition you want to resize and select Resize/Move from the menu. Input the amount of free space you want to create at the end of the existing partition. Remember, this must be at least 10GB (10000MiB) and should be larger if you will be saving a lot of large files in PC-BSD. I.e, free space of 20GB was created by inputting 20000 and then clicking in the New Size input box. 
  4. The new partition will show as unallocated after you click the Resize/Move button. 
  5. To save your changes, click the Apply button. A message will ask, “Are you are sure you want to apply the pending operations?” Click Apply and wait for the application to indicate that all operations were successful. Depending on the size of the drive, this will take a few minutes.
  6. After the free space is available, it needs to be turned into a partition. To do so, click Partition ➤New .The default settings are fine, because they will use all of the free space and create a primary partition (which is necessary for an installation). The filesystem is only temporary because it will be overwritten by the PC-BSD installer. If you want, add a descriptive label. Click Add and then Apply.
  7. Once finished, you can close Partition Editor and click the icon in the lower-left corner to log out.
Don’t forget to remove the CD after the system starts to reboot. Remember the size of the partition you created so you can find it easily in the Disk Setup screen during the PC-BSD installation. In this example, it will be displayed as ad0s3:20002MB (Linux native). The number was slightly lower than what showed in Parted Magic because of the Round to Cylinders option.

Booting Multiple Operating Systems
If you selected to install the PC-BSD boot loader, it will provide a simple menu at boot time that probes the type of filesystems (hence, operating systems) installed on the computer. To continue the example seen in the previous section, the PC-BSD boot loader menu looks like this:
F1 Linux
F2 ?
F3 FreeBSD
Boot: F1
F1 is the first partition containing Ubuntu. F2 was the small partition created by Ubuntu. F3 is the PC-BSD installation. F6 indicates that this computer’s network card supports booting over a network(Thin Client Server).
    The value after Boot indicates which operating system will boot if you don’t make a selection. To make a selection, use the key on your keyboard that matches the menu selection; for example, to boot PC-BSD, use the F3 key.
    Although PC-BSD will properly probe the partitions, it may or may not be able to load each of the listed operating systems.
Whether an operating system boots depends on which bootloaders those operating systems expect to be loaded from and where their boot info has been written to disk.
In this example, Ubuntu should boot by typing F1, but it does not because of the way its boot code is currently installed. The next section will show how to fix this.
You should test each operating system in your PC-BSD boot menu to see whether it boots. You may find that each operating system boots, but you would like to try an alternate (different-looking) boot manager. If this is the case, see the upcoming “Using the GAG Boot Loader” section.

If You Prefer GRUB
Many Linux operating systems, including Ubuntu, use the GNU Grand Unified Bootloader (GRUB) boot loader. If you prefer the GRUB boot loader to the PC-BSD boot loader, or if the PC-BSD boot loader won’t boot your Linux operating system, you will need to run the GRUB utility. Insert your Linux DVD and select to boot into its live DVD. If your Linux DVD does not have a live DVD option, you can still use a live CD such as Knoppix. We will continue with our Ubuntu example.

To boot into the live version of Ubuntu, insert the Ubuntu DVD and select Try Ubuntu Without Any Change to Your Computer from the menu. After the live DVD has loaded, click Applications ➤ Accessories ➤ Terminal and type the following commands:
# sudo grub[sudo password for dru:
Probing devices to guess BIOS drives. This may take a long time.
   [ Minimal BASH-like line editing is supported. For
   the first word, TAB lists possible command
   completions. Anywhere else TAB lists the possible
   completions of a device/filename. ]
grub> root (hd0, (press tab to see menu)
  Possible partitions are:
     Partition num: 0, filesystem type is ext2fs, partition type 0x83
     Partition num: 2,[BSD sub-partitions immediately follow]
        BSD Partition num: 'a', Filesystem type unknown, partition type 0xa5
       BSD Partition num: 'b', Filesystem type unknown, partition type 0xa5
       BSD Partition num: 'd', Filesystem type unknown, partition type 0xa5
       BSD Partition num: 'e', Filesystem type unknown, partition type 0xa5
    Partition num: 4, filesystem type unknown, partition type 0x82

In our example, Ubuntu is in partition 0, PC-BSD is in partition 2, and partition 4 is the SWAP filesystem. Because we want Ubuntu to boot from GRUB, we want to select and set up the 0 partition, which contains Ubuntu:
grub> root (hd0,0)
grub> setup (hd0)
   Checking if "/boot/grub/stage1" exists... yes
   Checking if "/boot/grub/stage2" exists... yes
   Checking if "/boot/grub/e2fs_stage1_5" exists... yes
   Running "embed /boot/grub/e2fs_stage1_5 (hd0)"... 16 sectors are embedded.
   Running "install /boot/grub/stage1 (hd0) (hd0)1+16 p (hd0,0)/boot/grub/stage2
   /boot/grub/menu.1st"... succeeded
grub> quit

GRUB is now configured to replace the PC-BSD boot loader menu and properly load Ubuntu.
    However, don’t reboot yet, because you still have to tell GRUB about PC-BSD. Continue on to the next section to add PC-BSD to the GRUB boot menu.

If You Need to Add PC-BSD to GRUB
In order to add PC-BSD to your current GRUB boot menu, you’ll first need to determine what version of GRUB you are using:
# grub - -version
grub (GNU GRUB 0.97)

Next, add an entry for PC-BSD to the GRUB menu list. This command will open that file in a graphical editor:
# sudo gedit /boot/grub/menu.lst

You should see your existing Ubuntu entries toward the end of the file (If this file is empty, check for errors in the commands mentioned in the previous section).

If the operating system is using a version of GRUB less than 2, as seen in our example, add the following lines after the last menu entry:
title  PC-BSD 8
rootnoverify  (hd0,2)
chainloader +1
If the operating system is using a version of GRUB 2 or higher, add these lines instead:
title  PC-BSD 8
root  (hd0,2,a)
kernel  /boot/loader
Reboot the computer and press Esc when you see the GRUB boot loader message. You should now be able to boot into either Ubuntu or PC-BSD.

If You Want to Replace GRUB
Before adding another boot loader, you need to make sure that a boot sector is written to the Linux partition. To do so, find the device name for your Linux partition by running this command while booted into Linux:
# sudo fdisk -lu | grep Linux/dev/sda1    63     109274129 54637033+ 83  Linux
/dev/sda5 150239943 156296384 3028221   82  Linux swap / Solaris

In our example, Ubuntu Linux is installed on /dev/sda1. To make sure boot code is written on that device, use the following:
# sudo grub-install /dev/sda1
Searching for GRUB installation directory ... found: /boot/grub
Installation finished. No error reported.
This is the contents of the device map /boot/grub/
Check if this is correct or not. If any of the lines is incorrect,
fix it and re-run the script 'grub-install'.
(hd0) /dev/sda

Caution If you don’t install boot code on the Linux partition before installing another boot loader, you may not be able to boot your Linux installation!

Using the GAG Boot Loader
There are other boot loaders available that are easier to configure than the PC-BSD or GRUB boot loaders. We recommend the Graphical Boot Manager (GAG), which can boot up to nine operating systems. It is easy to use(screenshots are available here) .
Caution If you are replacing GRUB with GAG, make sure that you follow the instructions in the “If You Want to Replace GRUB” section before installing GAG!

  1. Download GAG, unzip the download, and burn the file named cdrom.iso to a CD. 
  2. Boot from the CD, which will bring up a menu of  options:1:Read instructions, 2:Read FAQ, 3:Read license, 4:Install GAG, 5:Uninstall GAG (Restores MBR)
  3. Press 4 to install GAG. 
  4. Select your keyboard from the keyboard type screen and 
  5. your language from the language screen. 
  6. In the next screen, press S to set up GAG, and then press A to add your first operating system to the boot menu. Continuing our example, GAG shows the following partitions:
Key   Partition type
A      Boot from floppy
B      83h Linux EXT2
C      A5h FreeBSD
D     82h
In this example,
  1. Ubuntu is probed as B, and PC-BSD as C. 
  2. I’ll press B and type in a description of Ubuntu. 
  3. GAG will then give an option to enter a password. If a password is entered, it will be needed before GAG will boot Ubuntu. 
  4. If I just press Enter, GAG won’t require a password. 
  5. GAG will then provide a menu of icons to go with the entry. I’ll select D to choose the Tux penguin.
  6. I’ll then press A to add the second operating system, 
  7. press C to select FreeBSD, type in PC-BSD 8 for the description, add no password, and 
  8. press F to select the Beastie icon.
  9. When you have finished adding all of your operating systems, press H to save your changes to the hard disk. 
  10. You should receive a GAG Installed Successfully message. 
  11. Press R to return to the main menu, and your entries should now show in the boot menu. 
  12. Remove the CD, and reboot the computer to test that you can boot into each of the operating systems.


  • The Definitive Guide to PC-BSD(2010 Apress) by Dru Lavigne ISBN: 978-1-4302-2642-0

26 June 2010

FreeBSD --- Working with files

Like all multi-user systems, UNIX keeps track of who 
owns what file and who can do what with each 
file. Permissions attached to each file and 
directory determine who can use them


File types
Everything in a BSD(*nix) file system can be viewed as a file. This includes:
  • data files
  • directories
  • devices
  • named pipes
  • links 
  • ... and other types of files. 
Associated with each file is a set of information that determines:

  • who can access the file and 
  • how they can access it 
Directories and regular files are by far the file types you will use most often. However, there are several other types of files you will encounter as you use BSD. From the command line, there are many ways you can create, find, and list different types of files.
    Files that provide access to the hardware components on your computer
are referred to as device files. There are character and block devices.
    There are hard links and soft links you can use to make the same file accessible from different locations.
    Less often used directly by regular users are named pipes and sockets, which provide access points for processes to communicate with each other.

Using Regular Files
Regular files consist of data files (documents, music, images, archives, and so on) and commands (binaries and scripts). You can determine the type of a file using the file command.
    In the following example, you change to the directory containing bash shell documentation and use file to view some of the file types in that directory:
$ cd /usr/local/share/doc/libogg
$ file *
framing.html: HTML document text
ogg: directory
rfc3533.txt:  ASCII English text
stream.png:   PNG image data, 592 x 37, 8-bit colormap, non-interlaced

The file command that was run shows document and image files of different formats, related to libogg. It can look inside the files and determine that a file contains text with HTML markup (used in web pages), plain text, or an image. There is even a subdirectory shown (ogg).
    Creating regular files can be done by any application that can save its data. If you just want to create some blank files to start with, there are many ways to do that. Here are two examples:
$ touch /tmp/newfile.txt   Create a blank file
$ cat /dev/null > /tmp/newfile2.txt  Create an empty file

Doing a long list on a file is another way to determine its file type. For example:
$ ls -l /tmp/newfile2.txt  List a file to see its type
-rw-rw-r-- 1 chris chris 0 Sep 5 14:19 newfile2

 A dash in the first character of the 10-character permission information  (-rw-rw-r--) indicates that the item is a regular file.
    Commands are also regular files, but are usually saved as executables. Here are some examples:
$ ls -l /usr/bin/apropos
-r-xr-xr-x 1 root wheel 2248 Jan 12 2007 /usr/bin/apropos
$ file /usr/bin/apropos
/usr/bin/apropos: Bourne shell script text executable
$ file /bin/ls
/bin/ls: ELF 32-bit LSB executable, Intel 80386, version 1 (FreeBSD), 
for FreeBSD 6.3, dynamically linked (uses shared libs), stripped

You can see that the apropos command is executable by the x settings for owner,
group, and others.
    By running file on apropos, you can see that it is a shell script. That’s opposed to a binary executable, such as the ls command indicated above.

Using Directories
A directory is a container for files and subdirectories. Directories are set up in a hierarchy from the root (/) down to multiple subdirectories, each separated by a slash (/). Directories are called folders when you access them from graphical file managers.
    To create new directories for storing your data, you can use the mkdir command. Here are examples of using mkdir to create directories in different ways:
$ mkdir /tmp/new  Create “new” directory in /tmp
$ mkdir -p /tmp/a/b/c/new Create parent directories as needed for “new”
$ mkdir -m 700 /tmp/new2 Create new2 with drwx------ permissions

  • The first mkdir command simply adds the new directory to the existing /tmp directory. 
  • The second example creates directories as needed (subdirectories a, b, and c) to
    create the resulting new directory. 
  • The last command adds the -m option to set directory permissions as well.

You can identify the file as a directory because the first character in the 10-character permission string for a directory is a d:
$ file /tmp/new
/tmp/new: directory
$ ls -ld /tmp/new
drwxr-xr-x   2 chris chris 4096 Sep 5 14:53 /tmp/new 

Note also that the execute bits (x) must be on, if you want people to be able to use the directory as their current directories.

Using Symbolic and Hard Links
Instead of copying files and directories to different parts of the file system, links can be set up to access that same file from multiple locations. BSD supports both soft links (usually called symbolic links) and hard links.
    When you try to open a symbolic link that points to a file or change to one that points to a directory, the command you run acts on the file or directory that is the target of that link.
  • The target has its own set of permissions and ownership that you cannot see from the symbolic link. 
  • The symbolic link can exist on a different disk partition than the target. In fact, the symbolic link can exist, even if the target doesn’t.
NOTE When you use commands such as tar to backup files that include symbolic links, there are ways of choosing whether or not the actual file the symbolic link points to is archived. If you do back up the actual file, restoring the file can cause the link to be overwritten (which may not be what you want). See the tar man page for details on different ways of backing up symbolic links.

A hard link can only be used on files (not directories) and is basically a way of giving multiple names to the same physical file.
  • Every physical file has at least one hard link, which is commonly thought of as the file itself. 
  • Any additional names (hard links) that point to that single physical file must be on the same partition as the original target file(in fact, one way to tell that files are hard links is that they all have the same inode number). 
  • Changing permission, ownership, date/timestamp, or content of any hard link to a file results in all others being changed as well. 
  • However, deleting one link will not remove the file; it will continue to exist until the last link, or technically the last inode, to the file is deleted.
Here are some examples of using the ln command to create hard and symbolic links:
$ touch myfile
$ ln myfile myfile-hardlink
$ ln -s myfile  myfile-symlink
$ ls -li myfile*
292007 -rw-rw-r--  3  francois francois 0 Mar 25 00:07 myfile
292007 -rw-rw-r--  3  francois francois 0 Mar 25 00:07 myfile-hardlink
292008 lrwxr-xr-x  2 francois francois 6 Mar 25 00:09 myfile-symlink -> myfile

Note that after creating the hard and symbolic link files, we used the ls -li command to list the results. The -li option shows the inodes associated with each file.
  • You can see that myfile and myfile-hardlink both have the inode number of 292007 (signifying the exact same file on the hard disk). 
  • The myfile-symlink symbolic link has a different inode number. And although the hard link simply appears as a file (-), the symbolic link is identified as a link (l) with wide-open permissions. You won’t know if you can access the file the symbolic link points to until you try it or list the link target.

Using Device Files
When applications need to communicate with your computer’s hardware, they direct data to device files. By convention, device files are stored in the /dev directory.
    Historically, devices were generally divided into block devices (such as storage
media) and character devices (such as serial ports and terminal devices).
FreeBSD, however, uses only character devices to communicate with the hardware.
Here are examples of device files:
$ ls -l /dev/*                          List devices
crw-r----- 1 root  operator   0, 94 Jan 29   19:12   acd0   CD drive
crw-r----- 1 root  operator   0, 85 Jan 29   19:12   ad0    Hard Drive
crw--w---- 1 chris  tty       0, 100 Jan 31  06:07   ttyp0  Remote login terminal
crw------- 1 chris  tty       0, 60 Jan  30  07:18   ttyv0  First virtual terminal
crw------- 1 root  wheel      0, 61 Jan 29   19:12   ttyv1  Second virtual terminal

Using Named Pipes and Sockets
When you want to allow one process to send information to another process, you can simply pipe (|) the output from one to the input of the other. However, to provide a presence in the file system from which a process can communicate with other processes, you can create named pipes or sockets.
  • Named pipes are typically used for interprocess communication(IPC) on the local system while 
  • sockets can be used for processes to communicate over a network.
  • Named pipes and sockets are often set up by applications in the /tmp directory
Here are some examples of named pipes and sockets:
$ ls -l /tmp/.TV-chris/tvtimefifo-local /tmp/.X11-unix/X0
prw------- 1 chris chris 0 Sep 26 2007 /tmp/.TV-chris/tvtimefifo-local
srwx------ 1 chris wheel 0 Sep 4 01:30 /tmp/fam-chris/fam-

  • The first listing is a named pipe set up by a TV card player (note the p at the beginning indicating a named pipe). 
  • The second listing is a socket set up for interprocess communications.
To create your own named pipe, use the mkfifo command as follows:
$ mkfifo mypipe
$ ls -l mypipe
prw-r--r-- 1 chris chris 0 Sep 26 00:57 mypipe

To find out what sockets are currently active on your system, use the sockstat command as follows:
$ sockstat

Unless you are developing applications, you probably won’t need to create named
pipes or sockets. Another way to find where named pipes and sockets exist on your system is to use the -type option to the find command

Setting File and Directory Permissions
The ability to access files, run commands, and change to a directory can be restricted with permission settings for
  • user
  • group, and 
  • other users
When you do a long list (ls -l) of files and directories, the beginning 10 characters shown indicate what the item is (file, directory, character device, and so on) along with whether or not theitem can be read, written, or executed. Figure 4-1 illustrates the meaning of those 10 characters.
    To follow along with examples in this section, create a directory called /tmp/test and a file called /tmp/test/hello.txt. Then do a long listing of those two items, as follows:
$ mkdir /tmp/test
$ echo “some text” > /tmp/test/hello.txt
$ ls -ld /tmp/test/ /tmp/test/hello.txt
drwxrwxr-x 2 francois wheel 4096 Mar 21 13:11 /tmp/test
-rw-r--r-- 2 francois wheel 10 Mar 21 13:11 /tmp/test/hello.txt

After creating the directory and file, the first character of the long listing shows
/tmp/test as a directory (d) and hello.txt as a file (-).
    Other types of files available in BSD that would appear as the first character include character devices (c), block devices (b) or symbolic links (l), named pipes (p), and sockets (s).
    The next nine characters represent the permissions set on the file and directory.
  • The first rwx indicates that the owner (francois) has read, write, and execute permissions on the directory. Likewise, the group wheel has the same permission (rwx). Then all other users have only read and execute permission (r-x); the dash indicates the missing write permission. 
  • For the hello.txt file, the user and group have read permission (r--) and others have read permission (r--).
When you set out to change permissions, each permission can be represented by an octal number (where read is 4, write is 2, and execute is 1) or a letter (rwx).
    Generally speaking, read permission lets you view the contents of the directory, write lets you change (add or modify) the contents of the directory, and execute lets you change to (in other words, access) the directory.
    If you don’t like the permissions you see on files or directories you own, you can change those permissions using the chmod command.

Changing Permissions with chmod
The chmod command lets you change the access permissions of files and directories. Table 4-1 shows several chmod command lines and how access to the directory or file changes.
  • The first 0 in the mode line can usually be dropped (so you can use 777 instead of 0777). That placeholder has special meaning. It is an octal digit that can be used on commands (executables) to indicate that the command can run as a set-UID program (4), run as a set-GID program (2), or become a sticky program (1). 
  • With set-UID and set-GID, the command runs with the assigned user or group permissions (instead of running with permission of the user or group that launched the command).
WARNING! SUID should not be used on shell scripts. A shell script that is owned by the root user is vulnerable to being exploited, resulting in an attacker gaining access to a shell with root user permissions.

Having the sticky bit on for a directory keeps users from removing or renaming files from that directory that they don’t own (/tmp is an example). Given the right permission settings, however, users can change the contents of files they don’t own in a sticky bit directory. The final permission character is t instead of x on a sticky directory.
    A command with sticky bit on used to cause the command to stay in memory, even while not being used. This is an old UNIX feature that is not supported in most modern BSD, UNIX, and Linux systems.
    The -R option is a handy feature of the chmod command. With -R, you can recursively change permissions of all files and directories starting from a point in the file system.
Here are some examples:
# chmod -R 700 /tmp/test Open permission only to owner below /tmp/test
# chmod -R 000 /tmp/test Close all permissions below /tmp/test
# chmod -R a+rwx /tmp/test Open all permissions to all below /tmp/test

Note that the -R option is inclusive of the directory you indicate. So the permissions above, for example, would change for the /tmp/test directory itself, and not just for the files and directories below that directory.

Setting the umask
Permissions given to a file or directory are assigned originally at the time that item is created. How those permissions are set is based on the user’s current umask value. Using the umask command, you can set the permissions given to files and directories when you create them.
$ umask 0066 Make directories drwx--x--x  and files  -rw-------
$ umask 0077 Make directories drwx------  and files  -rw-------
$ umask 0022 Make directories drwxr-xr-x  and files  -rw-r--r--
$ umask 0777 Make directories d---------  and files  ----------

Changing Ownership
When you create a file or directory, your user account is assigned to that file or directory. So is your primary group. As root user, you can change the ownership (user) and group assigned to a file to a different user or group using the chown and chgrp commands. Here are some examples:
#chown chris test/   Change owner to chris
#chown chris:market test/  Change owner to chris and group to market
#chgrp  market test/    Change group to market
#chown -R chris test/   Change all files below test/ to owner chris

The recursive option to chown (-R) just shown is useful if you need to change the
ownership of an entire directory structure. As with chmod, using chown  recursively changes permissions for the directory named, along with its contents.
    You might use chown recursively when a person leaves a company or stops using your web service. You can use chown -R to reassign their entire /home directory to a different user.

Traversing the File System
Basic commands for changing directories (cd), checking the current directory (pwd) and listing directory content (ls) are well known to even casual shell users. So this section focuses on some less-common options to those commands, as well as other lesser-known features for moving around the file system. Here are some quick examples of cd for moving around the file system:
$ cd             Change to your home directory
$ cd $HOME       Change to your home directory
$ cd ~           Change to your home directory
$ cd ~francois   Change to francois home directory
$ cd -           Change to previous working directory
$ cd $OLDPWD      Change to previous working directory(bash shell)
$ cd ~/public_html  Change to /public_html in your home directory(if it
$ cd ..          Change to parent of current directory
$ cd /usr/bin    Change to usr/bin from root directory
$ cd usr/bin     Change to usr/bin beneath current directory

If you want to find out what your current directory is, use pwd (print working directory):
$ pwd/home/francois

Creating symbolic links is a way to access a file from other parts of the file system. 
However, symbolic links can cause some confusion about how parent directories are viewed. The following commands create a symbolic link to the /tmp directory from your home directory and show how to tell where you are related to a linked directory:
$ cd $HOME
$ ln -s /tmp tmp-link
$ ls -l tmp-link
lrwxrwxrwx 1 francois francois 13 Mar 24 12:41 tmp-link -> /tmp

$ cd tmp-link/
$ pwd

$ pwd -P    Show the permanent location
$ pwd -L   Show the link location

$ cd -L ..  Go to the parent of the link location
$ pwd

$ cd tmp-link
$ cd -P ..  Go to the parent of the permanent location
$ pwd

Using the -P and -L options to pwd and cd, you can work with symbolically linked directories in their permanent or link locations, respectively.
  • For example, cd -L .. takes you up one level to your home directory, whereas cd -P .. takes you up one level above the permanent directory (/). 
  • Likewise, the -P and -L options to pwd show permanent and link locations.
If you use the csh or bash shells, they can remember a list of working directories for you. Such a list can be useful if you want to return to previously visited directories. That list is organized in the form of a stack. Use pushd and popd to add and remove directories.
$ pwd
$ pushd /usr/share/man/
/usr/share/man ~
$ pushd /var/log/
/var/log /usr/share/man ~
$ dirs
/var/log /usr/share/man ~
$ dirs -v
0 /var/log
1 /usr/share/man
2 ~
$ popd
/usr/share/man ~
$ pwd
$ popd
$ pwd

The dirs, pushd, and popd commands can also be used to manipulate the order of
directories on the stack. For example, pushd -0 pushes the last directory on the
stack to the top of the stack (making it the current directory). The pushd -2 com-
mand pushes the third directory from the bottom of the stack to the top.

Copying Files
Provided you have write permission to the target directory, copying files and directories can be done with some fairly simple commands.
    The standard cp command will copy a file to a new name or the same name in a new directory, with a new timestamp associated with the new file. Other options to cp let you retain date/timestamps, copy recursively, and prompt before overwriting. Here are some examples:
# cd ; mkdir public_html ; touch index.html
# cp -i index.html public_html/    Copy with new timestamp
# cp -il index.html public_html/   Create hard link instead of copy
# cp -Rv public_html/ /mnt/usb/   Copy all files recursively (with verbose)

The above examples show ways of copying files related to a personal web server.
  1. In the first cp example above, if an index.html file exists in public_html, you are prompted before overwriting it with the new file. 
  2. In the next example, the index.html file is hard-linked to a file of the same name in the public_html directory. In that case, because both hard links point to the same file, editing the file from either location will change the contents of the file in both locations. (The link can only be done if public_html/ and your home directory are in the same file system.)
  3. The cp -Rv command copies all files below the public_html/ directory, updating ownership and permission settings to match those of the user running the command. It also uses current date- and timestamps. If, for example, /mnt/usb represented a USB flash drive, that command would be a way to copy the contents of your personal web server to that drive.
The dd command is another way to copy data. This command is very powerful because on BSD systems, everything is a file, including hardware peripherals. Here is an example:
$ dd if=/dev/zero of=/tmp/mynullfile count=1
1+0 records in
1+0 records out
512 bytes transferred in 0.000253 secs (2022113 bytes/sec)

/dev/zero is a special file that generates null characters. In the example just shown, the dd command takes /dev/zero as input file and outputs to /tmp/mynullfile. The count is the number of blocks. By default, a block is 512 bytes. The result is a 512-bytes long file full of null characters. You could use less or vi to view the contents of the file. However, a better tool to view the file would be the od (Octal Dump) command:
$ od -vt x1 /tmp/mynullfile   View an octal dump of a file

Here’s another example of the dd command. This time, we set the block size to 2 bytes and copied 10 blocks (20 bytes):
$ dd if=/dev/zero of=/tmp/mynullfile count=10 bs=2
10+0 records in
10+0 records out
20 bytes transferred in 0.000367 secs (54507 bytes/sec)

WARNING! The following dd commands overwrite the contents of your disk partitions. To be on the safe side, examples show data being written to USB drives.
That’s so you could use something like a USB memory stick, which we presume can be overwritten without harming the contents of your hard drives. Don’t try these commands if you have any confusion about the devices you are dealing with.
The following command line clones the first partition of the second IDE drive to the first USB drive. This can be useful for backing up a small partition to a USB memory stick.
Warning, the following command overwrites the contents of your USB drive
# dd if=/dev/ad1s1 of=/dev/da0s1 

The next example makes a compressed backup of the first partition of the primary master IDE drive. Typically the partition should be unmounted before a backup such as this.
# umount /dev/da0s1
# dd if=/dev/da0s1 | gzip > bootpart.gz

The following command copies a boot image (diskboot.img) to your USB flash drive (assuming the drive appears as /dev/da0):
# dd if=diskboot.img of=/dev/da0

This example copies the Master Boot Record from the second IDE hard drive to a file named mymbrfile:
# dd if=/dev/ad1s1 of=mymbrfile bs=512 count=1

If you add the dd_rescue program to your BSD system (pkg_add –r dd_rescue) you can create an ISO image with a command that is similar to dd but has many options and much more verbose feedback:
# dd_rescue /dev/acd0 myimage.iso
dd_rescue:       (info):  ipos:   139264.0k, opos:   139264.0k, xferd: 139264.0k8.0k
errs:  0, errxfer: 0.0k, succxfer:139264.0k +curr.rate:6702kB/s, avg.rate:  8312kB/s, avg.load: 16.6%

Changing File Attributes
Files and directories in BSD file systems have read, write, and execute permissions associated with user, group, and others. However, there are also other attributes that can be attached to files and directories that are specific to certain file system types.
    If you have added ext2 or ext3 file systems to your BSD system (possibly for Linux compatibility) you have special attributes that you may choose to use. Tools for creating and working with ext2 and ext3 file systems are available in FreeBSD from the e2fsprogs package (pkg_add -r e2fsprogs).
    You can list ext2/ext3 attributes with the lsattr command. Most attributes are obscure and not turned on by default. Here’s an example of using lsattr to see some files’ attributes:
# lsattr /mnt/usb/*
------------- /mnt/usb/01.txt
-------------  /mnt/usb/02.txt
------------- /mnt/usb/03.txt
-------------  /mnt/usb/04.txt
$ lsattr -aR /tmp/ | less   Recursively list all  /tmp attributes

The dashes represent 13 ext2/ext3 attributes that can be set. None are on by default. Those attributes are the following:
  • a (append only), 
  • c (compressed), 
  • d (no dump), 
  • i(immutable), 
  • j (data journaling), 
  • s (secure deletion), 
  • t (no tail-merging), 
  • u (undeletable),
  • A (no atime updates), 
  • D (synchronous directory updates), 
  • S (synchronous updates), and
  • T (top of directory hierarchy).
You can change these attributes using the chattr command. Here are some examples:
# chattr +i /mnt/usb/01.txt
$ chattr +a /mnt/usb/02.txt
$  chattr +d /mnt/usb/03.txt
$ lsattr /mnt/usb/*.txt
----i--------  /mnt/usb/01.txt
-----a------- /mnt/usb/02.txt
------d------  /mnt/usb/03.txt

As shown in the preceding example,
  • with the +i option set, the 01.txt file becomes immutable, meaning that it can’t be deleted, renamed, changed, or have a link created to it. Here, this prevents any arbitrary changes to that file. (The root user can’t even remove an immutable file without agreeing to override the i attribute.) 
  • With +a set, a file can only be appended to and not deleted. 
  • If you use the dump command to back up your ext2/ext3 file systems, the +d option can prevent selected files from being backed up.
To remove an attribute with chatter, use the minus sign (-). For example:
# chattr -i /mnt/usb/01.txt

NOTE Crackers who successfully break into a machine will often replace some system binaries (such as ls or ps) with corrupt versions and make them immutable. It’s a good idea to occasionally check the attributes set for your executables (in /bin, /usr/bin, /sbin, and /usr/sbin, for example).

Searching for Files
Your BSD system can be configured to keep a database of all the files in the file system (with a few exceptions defined in /etc/locate.rc) by periodically running
the /usr/libexec/locate.updatedb script. The locate command enables you to search that database.
    The results come back instantly, since the database is searched and not the actual file system. Before locate was available, most BSD users ran the find command to find files in the file system.

Generating the locate Database
You can generate the locate database by running the following script:
$ /usr/libexec/locate.updatedb

Note that by running this script as a regular user, the database will only include files that are accessible to all users, as well as that user in particular. You can run this script as root user to gather all files on your computer. But that could pose a security risk by allowing non-root users to see files you might otherwise want hidden from their sites.
    After you run the locate.updatedb script, the /var/db/locate.database is created. You could add that script to a cron job to run periodically. You are now ready to use the locate command to search for files.

Finding Files with locate
Because the database contains the name of every node in the file system, and not just commands, you can use locate to find commands, devices, man pages, data file or anything else identified by a name in the file system. Here is an example:
$ locate atapifd

The above example found the atapi.ko kernel module. locate is case sensitive unless you use the –i option. Here’s an example:
$ locate -i ImageMagick-6

Here are some examples using locate with regular expressions and with output limits:
$ locate *atapi*ko  Locate files with atapi and ko in the name
$ locate -l 5 kernel   Limit number of files found to five
locate: [show only 5 lines]

You can find information about the location and size of the locate database as follows:
$ locate -S
Database: /var/db/locate.database
Compression: Front: 21.64%, Bigram: 61.00%, Total: 15.57%
Filenames: 276585, Characters: 13071602, Database size: 2035326
Bigram characters: 793708, Integers: 9379, 8-Bit characters: 0

To update the locate database immediately, run the locate.updatedb command again manually:
$ /usr/libexec/locate.updatedb

Locating Files with find
Before the days of locate, the way to find files was with the find command. Although locate will come up with a file faster, find has many other powerful  options for finding files based on attributes other than the name.
NOTE Searching the entire file system can take a long time to complete. Before searching the whole file system, consider searching a subset of the file system or excluding certain directories or remotely mounted file systems.
This example searches the root file system (/) recursively for files named wlan_wep.ko:
$ find / -name “wlan_wep.ko” -printfind: /tmp/fam-root:  Permission denied
find: /usr/local/etc/samba: Permission denied

Running find as a normal user can result in long lists of Permission denied as
find tries to enter a directory you do not have permissions to. You can filter out the inaccessible directories:
$ find / -name wlan_wep.ko 2>&1 | grep -v “Permission denied”

Or send all errors to the /dev/null bit bucket:
$ find / -name wlan_wep.ko 2> /dev/null

Because searches with find are case sensitive and must match the name exactly
(wlan_wep.ko won’t match other instances of wlan_wep), you can use regular
expressions to make your searches more inclusive. Here’s an example:
$ find / -name ‘wlan_wep*’ 2> /dev/null/boot/kernel/wlan_wep.ko

You can also find files based on timestamps. This command line finds files in /usr/bin/ that have been accessed in the past two minutes:
$ find /usr/bin/ -amin -2

This finds files that have not been accessed in /home/chris for over 60 days:
$ find /home/chris/ -atime +60

Use the -type d option to find directories. The following command line finds all directories under /etc and redirects stderr to the bit bucket (/dev/null):
$ find /etc -type d -print 2> /dev/null

This command line finds files in /sbin with permissions that match 555:
$ find /sbin/ -perm 555

The exec option to find is very powerful, because it lets you act on the files found with the find command. The following command finds all the files in /var owned by the user francois (must be a valid user) and executes the ls -l command on each one:
$ find /var -user francois -exec ls -l {} \;

An alternative to the find command’s exec option is xargs:
$ find /var -user francois | xargs ls –l

There are big differences on how the two commands just shown operate, leading to very different performance.
  • The find -exec spawns the command ls for each result it finds. 
  • The xargs command works more efficiently by passing many results as input to a single ls command.
To negate a search criterion, place an exclamation point (!) before that criterion. The next example finds all the files that are not owned by the group root and are regular files, and then does an ls -l on each:
$ find / ! -group wheel -type f 2> /dev/null | xargs ls –l

The next example finds the files in /sbin that are regular files and are not executable by others, then feeds them to an ls -l command:
$ find /sbin/ -type f ! -perm o+x | xargs ls –l

Finding files by size is a great way to determine what is filling up your hard disks. The following command line finds all files that are greater than 10 MB (+10M), lists those files from largest to smallest (ls -lS) and directs that list to a file (/tmp/bigfiles.txt):
$ find / -xdev -size +10M 66 | xargs ls -lS > /tmp/bigfiles.txt

In this example, the -xdev option prevents any mounted file systems, besides the root file system, from being searched. This is a good way to keep the find command from searching special file systems (such as the /proc file system, if that is mounted) and any remotely mounted file systems, as well as other locally mounted file systems.

Using Other Commands to Find Files
Other commands for finding files include the whereis and which commands. Here
are some examples of those commands:
$ whereis man
man: /usr/bin/man /usr/share/man/man1/man1.gz

The whereis command is useful because
  • it not only finds commands, 
  • it also finds man pages and 
  • configuration files associated with a command.
From the example of whereis for the word man, you can see the man executable, its configuration file, and the location of man pages for the man command.
    The which command is useful when you’re looking for the actual location of an executable file in your PATH, as in this example:
$ pkg_info -W `which mkfs.ext2`
/usr/local/sbin/mkfs.ext2 was installed by package e2fsprogs-1.40.2_1

Finding Out More About Files
Now that you know how to find files, you can get more information about those files. Using less-common options to the ls command lets you list information about a file that you won’t see when you run ls without options. Commands such as file help you identify a file’s type. With md5sum and sha1sum, you can verify the validity of a file.

Listing Files
Although you are probably quite familiar with the ls command, you may not be
familiar with many of the useful options for ls that can help you find out a lot about the files on your system. Here are some examples of using ls to display long lists (-l) of files and directories:
$ls -l    Files and directories in current directory
$ls -la   Includes (hidden)files/directories beginning with dot (.)
$ls -lt   Orders files by time recently changed
$ls -lS   Orders files by size (largest first)
$ls -li   Lists the inode associated with each file
$ls -ln   List numeric user/group IDs, instead of names
$ls -lh   List file sizes in human-readable form (K, M, etc.)
$ls -lR   List files recursively, from current and subdirectories
$ ls -F   Add a character to indicate file type
$ ls -G   Show file types as different colors
$ ls -C   Show files listing in columns

Verifying Files
When files such as software packages and CD or DVD images are shared over the Internet, often a sha1sum or md5sum file is published with it. Those files contain checksums that can be used to make sure that the file you downloaded is exactly the one that the repository published.
    The following are examples of downloading an ISO image file, then using the md5 and sha256 commands to verify checksums of the file:
$ wget -c
$  md5 6.3-RELEASE-i386-disc1.iso
MD5 (6.3-RELEASE-i386-disc1.iso) =  cdb0dfa4b2db3e4c9cc19138f4fb2ada
$ sha256  6.3-RELEASE-i386-disc1.iso
SHA156 (6.3-RELEASE-i386-disc1.iso) =  15081a56d184a18c7cc3a5c3cd0d7d5b7d9304c9cc1d5fc40d875b0fd3047721

Which command you choose depends on whether the provider of the file you are
checking distributed md5sum or sha1sum information. FreeBSD offers both md5 (CHECKSUM.MD5) and sha1 files.
    With all the ISO files listed in this CHECKSUM.MD5 file contained in the current directory, you can verify them all at once using the -c option and the Linux-compatible md5sum command. Here is an example:
$ /usr/compat/linux/usr/bin/md5sum -c CHECKSUM.MD5
6.3-RELEASE-i386-bootonly.iso: OK
6.3-RELEASE-i386-disc1.iso: OK
6.3-RELEASE-i386-disc2.iso: OK
6.3-RELEASE-i386-disc3.iso: OK
6.3-RELEASE-i386-docs.iso: OK 

To verify only one of the files listed in the checksum file, you could do something like the following:
$ grep bootonly CHECKSUM.MD5 | /usr/compat/linux/usr/bin/md5sum -c
6.3-RELEASE-i386-bootonly.iso: OK

If you had a SHA1SUM file instead of an MD5SUM file to check against, you could use the sha1sum command in the same way. By combining the find command described earlier in this chapter with the m5 command, you can verify any part of your file system. For example, here’s how to create an MD5 checksum for every file in the /etc directory so they can be checked later to see if any have changed:
# find /etc -type f -exec md5 {} \; 2>/dev/null > /tmp/md5.list

The result of the previous command line is a /tmp/md5.list file that contains a 128-bit checksum for every file in the /etc directory. Later, you could type the following command to see if any of those files have changed:
# cd /etc
# /usr/compat/linux/usr/bin/md5sum -c /tmp/md5.list | grep -v ‘OK’
./hosts.allow: FAILED
md5sum: WARNING: 1 of 1668 computed checksums did NOT match

As you can see from the output only one file changed (hosts.allow). So the next step is to check the changed file and see if the changes to that file were intentional.


  •  BSD UNIX TOOLBOX 1000+ Commands for FreeBSD, OpenBSD, and NetBSD®Power Users (2008 by Wiley Publishing) by Christopher Negus,   François Caen ISBN: 978-0-470-37603-4