the freebsd documentation project - internodejohncoom/pdf/freebsd-handbook.pdf · 2005-06-22 ·...

923
FreeBSD Handbook The FreeBSD Documentation Project

Upload: others

Post on 03-Apr-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

  • FreeBSD Handbook

    The FreeBSD Documentation Project

  • FreeBSD Handbookby The FreeBSD Documentation ProjectPublished February 1999Copyright © 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 The FreeBSD DocumentationProject

    Welcome to FreeBSD! This handbook covers the installation and day to day use of FreeBSD 4.11-RELEASE andFreeBSD 5.3-RELEASE. This manual is a work in progress and is the work of many individuals. Many sections donot yet exist and some of those that do exist need to be updated. If you are interested in helping with this project, sendemail to the FreeBSD documentation project mailing list (http://lists.FreeBSD.org/mailman/listinfo/freebsd-doc).The latest version of this document is always available from the FreeBSD web site (http://www.FreeBSD.org/). Itmay also be downloaded in a variety of formats and compression options from the FreeBSD FTP server(ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/) or one of the numerous mirror sites. If you would prefer to have a hardcopy of the handbook, you can purchase one at the FreeBSD Mall (http://www.freebsdmall.com/). You may alsowant to search the handbook (http://www.FreeBSD.org/search/index.html).

    Redistribution and use in source (SGML DocBook) and ’compiled’ forms (SGML, HTML, PDF, PostScript, RTF and so forth) with or without

    modification, are permitted provided that the following conditions are met:

    1. Redistributions of source code (SGML DocBook) must retain the above copyright notice, this list of conditionsand the following disclaimer as the first lines of this file unmodified.

    2. Redistributions in compiled form (transformed to other DTDs, converted to PDF, PostScript, RTF and otherformats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in thedocumentation and/or other materials provided with the distribution.

    Important: THIS DOCUMENTATION IS PROVIDED BY THE FREEBSD DOCUMENTATION PROJECT "AS IS"AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIEDWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. INNO EVENT SHALL THE FREEBSD DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT,INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITEDTO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; ORBUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER INCONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANYWAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCHDAMAGE.

    FreeBSD is a registered trademark of the FreeBSD Foundation.

    3Com and HomeConnect are registered trademarks of 3Com Corporation.

    3ware and Escalade are registered trademarks of 3ware Inc.

    ARM is a registered trademark of ARM Limited.

    Adaptec is a registered trademark of Adaptec, Inc.

  • Adobe, Acrobat, Acrobat Reader, and PostScript are either registered trademarks or trademarks of Adobe Systems Incorporated in the United

    States and/or other countries.

    Apple, FireWire, Mac, Macintosh, Mac OS, Quicktime, and TrueType are trademarks of Apple Computer, Inc., registered in the United States and

    other countries.

    Corel and WordPerfect are trademarks or registered trademarks of Corel Corporation and/or its subsidiaries in Canada, the United States and/or

    other countries.

    Sound Blaster is a trademark of Creative Technology Ltd. in the United States and/or other countries.

    CVSup is a registered trademark of John D. Polstra.

    Heidelberg, Helvetica, Palatino, and Times Roman are either registered trademarks or trademarks of Heidelberger Druckmaschinen AG in the

    U.S. and other countries.

    IBM, AIX, EtherJet, Netfinity, OS/2, PowerPC, PS/2, S/390, and ThinkPad are trademarks of International Business Machines Corporation in the

    United States, other countries, or both.

    IEEE, POSIX, and 802 are registered trademarks of Institute of Electrical and Electronics Engineers, Inc. in the United States.

    Intel, Celeron, EtherExpress, i386, i486, Itanium, Pentium, and Xeon are trademarks or registered trademarks of Intel Corporation or its

    subsidiaries in the United States and other countries.

    Intuit and Quicken are registered trademarks and/or registered service marks of Intuit Inc., or one of its subsidiaries, in the United States and other

    countries.

    Linux is a registered trademark of Linus Torvalds.

    LSI Logic, AcceleRAID, eXtremeRAID, MegaRAID and Mylex are trademarks or registered trademarks of LSI Logic Corp.

    M-Systems and DiskOnChip are trademarks or registered trademarks of M-Systems Flash Disk Pioneers, Ltd.

    Macromedia, Flash, and Shockwave are trademarks or registered trademarks of Macromedia, Inc. in the United States and/or other countries.

    Microsoft, IntelliMouse, MS-DOS, Outlook, Windows, Windows Media and Windows NT are either registered trademarks or trademarks of

    Microsoft Corporation in the United States and/or other countries.

    Netscape and the Netscape Navigator are registered trademarks of Netscape Communications Corporation in the U.S. and other countries.

    GateD and NextHop are registered and unregistered trademarks of NextHop in the U.S. and other countries.

    Motif, OSF/1, and UNIX are registered trademarks and IT DialTone and The Open Group are trademarks of The Open Group in the United States

    and other countries.

    Oracle is a registered trademark of Oracle Corporation.

    PowerQuest and PartitionMagic are registered trademarks of PowerQuest Corporation in the United States and/or other countries.

    RealNetworks, RealPlayer, and RealAudio are the registered trademarks of RealNetworks, Inc.

    Red Hat, RPM, are trademarks or registered trademarks of Red Hat, Inc. in the United States and other countries.

    SAP, R/3, and mySAP are trademarks or registered trademarks of SAP AG in Germany and in several other countries all over the world.

    Sun, Sun Microsystems, Java, Java Virtual Machine, JavaServer Pages, JDK, JSP, JVM, Netra, Solaris, StarOffice, Sun Blade, Sun Enterprise, Sun

    Fire, SunOS, and Ultra are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries.

    Symantec and Ghost are registered trademarks of Symantec Corporation in the United States and other countries.

    MATLAB is a registered trademark of The MathWorks, Inc.

    SpeedTouch is a trademark of Thomson

    U.S. Robotics and Sportster are registered trademarks of U.S. Robotics Corporation.

    VMware is a trademark of VMware, Inc.

    Waterloo Maple and Maple are trademarks or registered trademarks of Waterloo Maple Inc.

    Mathematica is a registered trademark of Wolfram Research, Inc.

    XFree86 is a trademark of The XFree86 Project, Inc.

    Ogg Vorbis and Xiph.Org are trademarks of Xiph.Org.

    Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations

    appear in this document, and the FreeBSD Project was aware of the trademark claim, the designations have been followed by the “™” or the “®”

    symbol.

  • Table of ContentsPreface............................................................................................................................................................................. i

    I. Getting Started ........................................................................................................................................................... i

    1 Introduction ........................................................................................................................................................ 11.1 Synopsis................................................................................................................................................. 11.2 Welcome to FreeBSD! ........................................................................................................................... 11.3 About the FreeBSD Project ................................................................................................................... 4

    2 Installing FreeBSD............................................................................................................................................. 92.1 Synopsis................................................................................................................................................. 92.2 Pre-installation Tasks............................................................................................................................. 92.3 Starting the Installation........................................................................................................................ 152.4 Introducing Sysinstall .......................................................................................................................... 242.5 Allocating Disk Space ......................................................................................................................... 292.6 Choosing What to Install ..................................................................................................................... 412.7 Choosing Your Installation Media ....................................................................................................... 432.8 Committing to the Installation ............................................................................................................. 442.9 Post-installation ................................................................................................................................... 452.10 Supported Hardware .......................................................................................................................... 862.11 Troubleshooting................................................................................................................................. 862.12 Advanced Installation Guide ............................................................................................................. 882.13 Preparing Your Own Installation Media ............................................................................................ 89

    3 UNIX Basics .................................................................................................................................................... 953.1 Synopsis............................................................................................................................................... 953.2 Virtual Consoles and Terminals........................................................................................................... 953.3 Permissions .......................................................................................................................................... 983.4 Directory Structure ............................................................................................................................ 1003.5 Disk Organization.............................................................................................................................. 1023.6 Mounting and Unmounting File Systems .......................................................................................... 1083.7 Processes............................................................................................................................................ 1113.8 Daemons, Signals, and Killing Processes.......................................................................................... 1123.9 Shells.................................................................................................................................................. 1143.10 Text Editors...................................................................................................................................... 1163.11 Devices and Device Nodes .............................................................................................................. 1163.12 Binary Formats ................................................................................................................................ 1173.13 For More Information...................................................................................................................... 119

    4 Installing Applications: Packages and Ports .................................................................................................. 1214.1 Synopsis............................................................................................................................................. 1214.2 Overview of Software Installation ..................................................................................................... 1214.3 Finding Your Application .................................................................................................................. 1234.4 Using the Packages System ............................................................................................................... 1244.5 Using the Ports Collection ................................................................................................................. 1264.6 Post-installation Activities ................................................................................................................. 1334.7 Dealing with Broken Ports................................................................................................................. 134

    5 The X Window System .................................................................................................................................. 1355.1 Synopsis............................................................................................................................................. 1355.2 Understanding X................................................................................................................................ 135

    iv

  • 5.3 Installing X11 .................................................................................................................................... 1385.4 X11 Configuration ............................................................................................................................. 1395.5 Using Fonts in X11............................................................................................................................ 1425.6 The X Display Manager..................................................................................................................... 1465.7 Desktop Environments....................................................................................................................... 149

    II. Common Tasks ..................................................................................................................................................... 154

    6 Desktop Applications ..................................................................................................................................... 1556.1 Synopsis............................................................................................................................................. 1556.2 Browsers ............................................................................................................................................ 1556.3 Productivity........................................................................................................................................ 1596.4 Document Viewers............................................................................................................................. 1616.5 Finance............................................................................................................................................... 1636.6 Summary............................................................................................................................................ 164

    7 Multimedia ..................................................................................................................................................... 1667.1 Synopsis............................................................................................................................................. 1667.2 Setting Up the Sound Card ................................................................................................................ 1667.3 MP3 Audio......................................................................................................................................... 1707.4 Video Playback .................................................................................................................................. 1737.5 Setting Up TV Cards ......................................................................................................................... 1817.6 Image Scanners.................................................................................................................................. 182

    8 Configuring the FreeBSD Kernel ................................................................................................................... 1878.1 Synopsis............................................................................................................................................. 1878.2 Why Build a Custom Kernel?............................................................................................................ 1878.3 Building and Installing a Custom Kernel .......................................................................................... 1888.4 The Configuration File....................................................................................................................... 1908.5 Making Device Nodes ....................................................................................................................... 2048.6 If Something Goes Wrong................................................................................................................. 205

    9 Printing ........................................................................................................................................................... 2089.1 Synopsis............................................................................................................................................. 2089.2 Introduction........................................................................................................................................ 2089.3 Basic Setup ........................................................................................................................................ 2099.4 Advanced Printer Setup ..................................................................................................................... 2229.5 Using Printers .................................................................................................................................... 2499.6 Alternatives to the Standard Spooler ................................................................................................. 2569.7 Troubleshooting................................................................................................................................. 257

    10 Linux Binary Compatibility ......................................................................................................................... 26010.1 Synopsis........................................................................................................................................... 26010.2 Installation ....................................................................................................................................... 26010.3 Installing Mathematica® ................................................................................................................. 26310.4 Installing Maple™ ........................................................................................................................... 26510.5 Installing MATLAB®...................................................................................................................... 26710.6 Installing Oracle® ........................................................................................................................... 27010.7 Installing SAP® R/3® ..................................................................................................................... 27310.8 Advanced Topics.............................................................................................................................. 293

    v

  • III. System Administration ...................................................................................................................................... 295

    11 Configuration and Tuning............................................................................................................................. 29611.1 Synopsis........................................................................................................................................... 29611.2 Initial Configuration......................................................................................................................... 29611.3 Core Configuration .......................................................................................................................... 29711.4 Application Configuration ............................................................................................................... 29811.5 Starting Services .............................................................................................................................. 29911.6 Configuring the cron Utility ........................................................................................................... 30111.7 Using rc under FreeBSD 5.X........................................................................................................... 30311.8 Setting Up Network Interface Cards................................................................................................ 30411.9 Virtual Hosts .................................................................................................................................... 30811.10 Configuration Files ........................................................................................................................ 30911.11 Tuning with sysctl.......................................................................................................................... 31311.12 Tuning Disks.................................................................................................................................. 31411.13 Tuning Kernel Limits..................................................................................................................... 31711.14 Adding Swap Space ....................................................................................................................... 31911.15 Power and Resource Management................................................................................................. 32111.16 Using and Debugging FreeBSD ACPI .......................................................................................... 322

    12 The FreeBSD Booting Process..................................................................................................................... 32812.1 Synopsis........................................................................................................................................... 32812.2 The Booting Problem....................................................................................................................... 32812.3 The MBR, and Boot Stages One, Two, and Three .......................................................................... 32912.4 Kernel Interaction During Boot ....................................................................................................... 33312.5 Device Hints .................................................................................................................................... 33312.6 Init: Process Control Initialization................................................................................................... 33412.7 Shutdown Sequence......................................................................................................................... 335

    13 Users and Basic Account Management........................................................................................................ 33613.1 Synopsis........................................................................................................................................... 33613.2 Introduction...................................................................................................................................... 33613.3 The Superuser Account.................................................................................................................... 33713.4 System Accounts ............................................................................................................................. 33813.5 User Accounts.................................................................................................................................. 33813.6 Modifying Accounts ........................................................................................................................ 33813.7 Limiting Users ................................................................................................................................. 34313.8 Personalizing Users ......................................................................................................................... 34613.9 Groups.............................................................................................................................................. 346

    14 Security......................................................................................................................................................... 34814.1 Synopsis........................................................................................................................................... 34814.2 Introduction...................................................................................................................................... 34814.3 Securing FreeBSD ........................................................................................................................... 35014.4 DES, MD5, and Crypt ..................................................................................................................... 35614.5 One-time Passwords ........................................................................................................................ 35714.6 TCP Wrappers ................................................................................................................................. 36214.7 KerberosIV ..................................................................................................................................... 36514.8 Kerberos5 ....................................................................................................................................... 37214.9 OpenSSL.......................................................................................................................................... 37914.10 VPN over IPsec.............................................................................................................................. 38214.11 OpenSSH ....................................................................................................................................... 393

    vi

  • 14.12 File System Access Control Lists .................................................................................................. 39714.13 Monitoring Third Party Security Issues......................................................................................... 39914.14 FreeBSD Security Advisories........................................................................................................ 40014.15 Process Accounting ....................................................................................................................... 402

    15 Mandatory Access Control........................................................................................................................... 40415.1 Synopsis........................................................................................................................................... 40415.2 Key Terms in this Chapter ............................................................................................................... 40515.3 Explanation of MAC........................................................................................................................ 40615.4 Understanding MAC Labels ............................................................................................................ 40715.5 Module Configuration...................................................................................................................... 41215.6 The MAC bsdextended Module....................................................................................................... 41215.7 The MAC ifoff Module.................................................................................................................... 41315.8 The MAC portacl Module................................................................................................................ 41415.9 MAC Policies with Labeling Features............................................................................................. 41515.10 The MAC partition Module ........................................................................................................... 41615.11 The MAC Multi-Level Security Module ....................................................................................... 41715.12 The MAC Biba Module ................................................................................................................. 41915.13 The MAC LOMAC Module .......................................................................................................... 42015.14 Implementing a Secure Environment with MAC .......................................................................... 42015.15 Another Example: Using MAC to Constrain a Web Server ..........................................................42515.16 Troubleshooting the MAC Framework.......................................................................................... 427

    16 Storage.......................................................................................................................................................... 42916.1 Synopsis........................................................................................................................................... 42916.2 Device Names .................................................................................................................................. 42916.3 Adding Disks ................................................................................................................................... 43016.4 RAID................................................................................................................................................ 43216.5 USB Storage Devices....................................................................................................................... 43716.6 Creating and Using Optical Media (CDs) ....................................................................................... 43816.7 Creating and Using Optical Media (DVDs) .................................................................................... 44416.8 Creating and Using Floppy Disks.................................................................................................... 44816.9 Creating and Using Data Tapes ....................................................................................................... 45016.10 Backups to Floppies....................................................................................................................... 45216.11 Backup Basics................................................................................................................................ 45416.12 Network, Memory, and File-Backed File Systems ........................................................................ 46016.13 File System Snapshots ................................................................................................................... 46416.14 File System Quotas ........................................................................................................................ 46516.15 Encrypting Disk Partitions............................................................................................................. 468

    17 The Vinum Volume Manager ....................................................................................................................... 47317.1 Synopsis........................................................................................................................................... 47317.2 Disks Are Too Small........................................................................................................................ 47317.3 Access Bottlenecks .......................................................................................................................... 47317.4 Data Integrity ................................................................................................................................... 47517.5 Vinum Objects ................................................................................................................................. 47617.6 Some Examples ............................................................................................................................... 47817.7 Object Naming................................................................................................................................. 48417.8 Configuring Vinum .......................................................................................................................... 48717.9 Using Vinum for the Root Filesystem ............................................................................................. 488

    18 Localization - I18N/L10N Usage and Setup ................................................................................................ 494

    vii

  • 18.1 Synopsis........................................................................................................................................... 49418.2 The Basics........................................................................................................................................ 49418.3 Using Localization........................................................................................................................... 49518.4 Compiling I18N Programs............................................................................................................... 50018.5 Localizing FreeBSD to Specific Languages .................................................................................... 500

    19 The Cutting Edge ......................................................................................................................................... 50419.1 Synopsis........................................................................................................................................... 50419.2 FreeBSD-CURRENT vs. FreeBSD-STABLE................................................................................. 50419.3 Synchronizing Your Source ............................................................................................................. 50719.4 Rebuilding “world” .......................................................................................................................... 50819.5 Tracking for Multiple Machines ...................................................................................................... 522

    IV. Network Communication................................................................................................................................... 524

    20 Serial Communications ................................................................................................................................ 52520.1 Synopsis........................................................................................................................................... 52520.2 Introduction...................................................................................................................................... 52520.3 Terminals ......................................................................................................................................... 52920.4 Dial-in Service ................................................................................................................................. 53420.5 Dial-out Service ............................................................................................................................... 54120.6 Setting Up the Serial Console.......................................................................................................... 544

    21 PPP and SLIP ............................................................................................................................................... 55321.1 Synopsis........................................................................................................................................... 55321.2 Using User PPP................................................................................................................................ 55321.3 Using Kernel PPP ............................................................................................................................ 56521.4 Troubleshooting PPP Connections .................................................................................................. 57221.5 Using PPP over Ethernet (PPPoE)................................................................................................... 57521.6 Using PPP over ATM (PPPoA)....................................................................................................... 57721.7 Using SLIP....................................................................................................................................... 581

    22 Electronic Mail ............................................................................................................................................. 59122.1 Synopsis........................................................................................................................................... 59122.2 Using Electronic Mail...................................................................................................................... 59122.3 sendmail Configuration................................................................................................................... 59322.4 Changing Your Mail Transfer Agent ............................................................................................... 59622.5 Troubleshooting............................................................................................................................... 59822.6 Advanced Topics.............................................................................................................................. 60122.7 SMTP with UUCP ........................................................................................................................... 60322.8 Setting Up to Send Only .................................................................................................................. 60522.9 Using Mail with a Dialup Connection............................................................................................. 60622.10 SMTP Authentication .................................................................................................................... 60722.11 Mail User Agents........................................................................................................................... 60822.12 Using fetchmail.............................................................................................................................. 61522.13 Using procmail............................................................................................................................... 616

    23 Network Servers ........................................................................................................................................... 61823.1 Synopsis........................................................................................................................................... 61823.2 The inetd “Super-Server” ................................................................................................................ 61823.3 Network File System (NFS) ............................................................................................................ 62223.4 Network Information System (NIS/YP) .......................................................................................... 62823.5 Automatic Network Configuration (DHCP) .................................................................................... 642

    viii

  • 23.6 Domain Name System (DNS) ......................................................................................................... 64723.7 BIND9 and FreeBSD....................................................................................................................... 65923.8 Apache HTTP Server....................................................................................................................... 66123.9 File Transfer Protocol (FTP)............................................................................................................ 66423.10 File and Print Services for Microsoft® Windows clients (Samba) ...............................................66523.11 Clock Synchronization with NTP.................................................................................................. 667

    24 Firewalls ....................................................................................................................................................... 67124.1 Introduction...................................................................................................................................... 67124.2 Firewall Concepts ............................................................................................................................ 67124.3 Firewall Software Applications ....................................................................................................... 67224.4 The OpenBSD Packet Filter (PF) and ALTQ .................................................................................. 67224.5 The IPFILTER (IPF) Firewall.......................................................................................................... 67424.6 IPFW................................................................................................................................................ 693

    25 Advanced Networking.................................................................................................................................. 71025.1 Synopsis........................................................................................................................................... 71025.2 Gateways and Routes....................................................................................................................... 71025.3 Wireless Networking ....................................................................................................................... 71625.4 Bluetooth.......................................................................................................................................... 72325.5 Bridging ........................................................................................................................................... 73025.6 Diskless Operation........................................................................................................................... 73225.7 ISDN ................................................................................................................................................ 74025.8 Network Address Translation .......................................................................................................... 74425.9 Parallel Line IP (PLIP) .................................................................................................................... 74725.10 IPv6................................................................................................................................................ 74925.11 Asynchronous Transfer Mode (ATM) on FreeBSD 5.X................................................................754

    V. Appendices ............................................................................................................................................................ 756

    A. Obtaining FreeBSD ...................................................................................................................................... 757A.1 CDROM and DVD Publishers .......................................................................................................... 757A.2 FTP Sites........................................................................................................................................... 760A.3 Anonymous CVS .............................................................................................................................. 769A.4 Using CTM ....................................................................................................................................... 772A.5 Using CVSup .................................................................................................................................... 776A.6 CVS Tags .......................................................................................................................................... 798A.7 AFS Sites .......................................................................................................................................... 802A.8 rsync Sites ......................................................................................................................................... 802

    B. Bibliography ................................................................................................................................................. 805B.1 Books & Magazines Specific to FreeBSD ........................................................................................ 805B.2 Users’ Guides.................................................................................................................................... 806B.3 Administrators’ Guides ..................................................................................................................... 806B.4 Programmers’ Guides ....................................................................................................................... 807B.5 Operating System Internals............................................................................................................... 807B.6 Security Reference ............................................................................................................................ 808B.7 Hardware Reference.......................................................................................................................... 808B.8 UNIX History.................................................................................................................................... 809B.9 Magazines and Journals .................................................................................................................... 809

    C. Resources on the Internet ............................................................................................................................. 811C.1 Mailing Lists ..................................................................................................................................... 811

    ix

  • C.2 Usenet Newsgroups........................................................................................................................... 826C.3 World Wide Web Servers .................................................................................................................. 828C.4 Email Addresses................................................................................................................................ 836C.5 Shell Accounts .................................................................................................................................. 836

    D. PGP Keys...................................................................................................................................................... 837D.1 Officers.............................................................................................................................................. 837D.2 Core Team Members......................................................................................................................... 837D.3 Developers ........................................................................................................................................ 838

    FreeBSD Glossary..................................................................................................................................................... 871

    Index........................................................................................................................................................................... 892

    Colophon.................................................................................................................................................................... 903

    x

  • List of Tables2-1. Sample Device Inventory....................................................................................................................................... 102-2. Partition Layout for First Disk............................................................................................................................... 352-3. Partition Layout for Subsequent Disks .................................................................................................................. 362-4. Possible Security Profiles ...................................................................................................................................... 522-5. FreeBSD ISO Image Names and Meanings .......................................................................................................... 903-1. Disk Device Codes .............................................................................................................................................. 10616-1. Physical Disk Naming Conventions .................................................................................................................. 42917-1. Vinum Plex Organizations................................................................................................................................. 47725-1. Wiring a Parallel Cable for Networking ............................................................................................................ 74725-2. Reserved IPv6 addresses ................................................................................................................................... 750

    List of Figures2-1. Kernel Configuration Menu................................................................................................................................... 182-2. The Kernel Device Configuration Visual Interface ............................................................................................... 192-3. Expanded Driver List............................................................................................................................................. 202-4. Driver Configuration With No Conflicts ............................................................................................................... 212-5. Sysinstall Main Menu............................................................................................................................................ 212-6. Typical Device Probe Results ................................................................................................................................ 222-7. Select Sysinstall Exit ............................................................................................................................................. 232-8. Selecting Usage from Sysinstall Main Menu ........................................................................................................ 242-9. Selecting Documentation Menu ............................................................................................................................ 252-10. Sysinstall Documentation Menu.......................................................................................................................... 252-11. Sysinstall Main Menu.......................................................................................................................................... 262-12. Sysinstall Keymap Menu..................................................................................................................................... 272-13. Sysinstall Main Menu.......................................................................................................................................... 272-14. Sysinstall Options ................................................................................................................................................ 272-15. Begin Standard Installation ................................................................................................................................. 282-16. Select Drive for FDisk ......................................................................................................................................... 312-17. Typical Fdisk Partitions before Editing ............................................................................................................... 322-18. Fdisk Partition Using Entire Disk........................................................................................................................ 322-19. Sysinstall Boot Manager Menu ........................................................................................................................... 332-20. Exit Select Drive.................................................................................................................................................. 342-21. Sysinstall Disklabel Editor .................................................................................................................................. 372-22. Sysinstall Disklabel Editor with Auto Defaults................................................................................................... 382-23. Free Space for Root Partition .............................................................................................................................. 392-24. Edit Root Partition Size ....................................................................................................................................... 392-25. Choose the Root Partition Type........................................................................................................................... 402-26. Choose the Root Mount Point ............................................................................................................................. 402-27. Sysinstall Disklabel Editor .................................................................................................................................. 412-28. Choose Distributions ........................................................................................................................................... 412-29. Confirm Distributions .......................................................................................................................................... 422-30. Choose Installation Media ................................................................................................................................... 432-31. Selecting an Ethernet Device............................................................................................................................... 46

    xi

  • 2-32. Set Network Configuration for ed0 ..................................................................................................................... 462-33. Editing inetd.conf........................................................................................................................................... 492-34. Default Anonymous FTP Configuration.............................................................................................................. 492-35. Edit the FTP Welcome Message.......................................................................................................................... 502-36. Editing exports ................................................................................................................................................. 512-37. Security Profile Options....................................................................................................................................... 532-38. System Console Configuration Options .............................................................................................................. 542-39. Screen Saver Options........................................................................................................................................... 552-40. Screen Saver Timeout .......................................................................................................................................... 552-41. System Console Configuration Exit .................................................................................................................... 562-42. Select Your Region .............................................................................................................................................. 572-43. Select Your Country............................................................................................................................................. 572-44. Select Your Time Zone ........................................................................................................................................ 582-45. Select Mouse Protocol Type ................................................................................................................................ 592-46. Set Mouse Protocol.............................................................................................................................................. 592-47. Configure Mouse Port.......................................................................................................................................... 602-48. Setting the Mouse Port ........................................................................................................................................ 602-49. Enable the Mouse Daemon.................................................................................................................................. 612-50. Test the Mouse Daemon ...................................................................................................................................... 612-51. Network Configuration Upper-level .................................................................................................................... 622-52. Select a default MTA ........................................................................................................................................... 632-53. Ntpdate Configuration ......................................................................................................................................... 642-54. Network Configuration Lower-level.................................................................................................................... 652-55. Select Configuration Method Menu .................................................................................................................... 672-56. Select Default Desktop ........................................................................................................................................ 752-57. Select Package Category...................................................................................................................................... 762-58. Select Packages.................................................................................................................................................... 772-59. Install Packages ................................................................................................................................................... 782-60. Confirm Package Installation............................................................................................................................... 782-61. Select User........................................................................................................................................................... 792-62. Add User Information.......................................................................................................................................... 792-63. Exit User and Group Management ...................................................................................................................... 812-64. Exit Install............................................................................................................................................................ 8217-1. Concatenated Organization................................................................................................................................ 47417-2. Striped Organization.......................................................................................................................................... 47417-3. RAID-5 Organization ........................................................................................................................................ 47517-4. A Simple Vinum Volume................................................................................................................................... 47917-5. A Mirrored Vinum Volume................................................................................................................................ 48017-6. A Striped Vinum Volume .................................................................................................................................. 48217-7. A Mirrored, Striped Vinum Volume .................................................................................................................. 484

    List of Examples2-1. Using an Existing Partition Unchanged................................................................................................................. 112-2. Shrinking an Existing Partition.............................................................................................................................. 113-1. Sample Disk, Slice, and Partition Names ............................................................................................................ 1073-2. Conceptual Model of a Disk................................................................................................................................ 107

    xii

  • 4-1. Downloading a Package Manually and Installing It Locally............................................................................... 12411-1. Creating a Swapfile on FreeBSD 4.X................................................................................................................ 32011-2. Creating a Swapfile on FreeBSD 5.X................................................................................................................ 32012-1. boot0 Screenshot.............................................................................................................................................. 32912-2. boot2 Screenshot.............................................................................................................................................. 33012-3. An Insecure Console in /etc/ttys ................................................................................................................. 33413-1. Configuring adduser and adding a user on FreeBSD 4.X............................................................................... 33913-2. Adding a user on FreeBSD 5.X ......................................................................................................................... 34013-3. rmuser Interactive Account Removal .............................................................................................................. 34113-4. Interactive chpass by Superuser ...................................................................................................................... 34213-5. Interactive chpass by Normal User ................................................................................................................. 34213-6. Changing Your Password................................................................................................................................... 34313-7. Changing Another User’s Password as the Superuser....................................................................................... 34313-8. Adding a Group Using pw(8) ............................................................................................................................ 34613-9. Adding Somebody to a Group Using pw(8)...................................................................................................... 34713-10. Using id(1) to Determine Group Membership ................................................................................................ 34714-1. Using SSH to Create a Secure Tunnel for SMTP.............................................................................................. 39616-1. Using dump over ssh.......................................................................................................................................... 45416-2. Using dump over ssh with RSH set..................................................................................................................... 45416-3. A Script for Creating a Bootable Floppy........................................................................................................... 45716-4. Using vnconfig to Mount an Existing File System Image under FreeBSD 4.X................................................46116-5. Creating a New File-Backed Disk with vnconfig........................................................................................... 46116-6. Using mdconfig to Mount an Existing File System Image under FreeBSD 5.X.............................................46116-7. Creating a New File-Backed Disk with mdconfig........................................................................................... 46216-8. Configure and Mount a File-Backed Disk with mdmfs ..................................................................................... 46216-9. md Memory Disk under FreeBSD 4.X.............................................................................................................. 46316-10. Creating a New Memory-Based Disk with mdconfig ................................................................................... 46316-11. Creating a New Memory-Based Disk with mdmfs .......................................................................................... 46320-1. Adding Terminal Entries to /etc/ttys ........................................................................................................... 53122-1. Configuring the sendmail Access Database...................................................................................................... 59422-2. Mail Aliases....................................................................................................................................................... 59522-3. Example Virtual Domain Mail Map .................................................................................................................. 59523-1. Sending inetd a HangUP Signal........................................................................................................................ 62023-2. Mounting an Export with amd .......................................................................................................................... 62625-1. Branch Office or Home Network....................................................................................................................... 74225-2. Head Office or Other LAN ................................................................................................................................ 743A-1. Checking Out Something from -CURRENT (ls(1)) and Deleting It Again: ......................................................771A-2. Using SSH to check out the src/ tree: .............................................................................................................. 771A-3. Checking Out the Version of ls(1) in the 3.X-STABLE Branch:........................................................................ 771A-4. Creating a List of Changes (as Unified Diffs) to ls(1) ........................................................................................ 772A-5. Finding Out What Other Module Names Can Be Used: .................................................................................... 772

    xiii

  • Preface

    Intended AudienceThe FreeBSD newcomer will find that the first section of this book guides the user through the FreeBSD installationprocess and gently introduces the concepts and conventions that underpin UNIX®. Working through this sectionrequires little more than the desire to explore, and the ability to take on board new concepts as they are introduced.

    Once you have traveled this far, the second, far larger, section of the Handbook is a comprehensive reference to allmanner of topics of interest to FreeBSD system administrators. Some of these chapters may recommend that you dosome prior reading, and this is noted in the synopsis at the beginning of each chapter.

    For a list of additional sources of information, please see Appendix B.

    Changes from the Second EditionThis third edition is the culmination of over two years of work by the dedicated members of the FreeBSDDocumentation Project. The following are the major changes in this new edition:

    • Chapter 11, Configuration and Tuning, has been expanded with new information about the ACPI power andresource management, the cron system utility, and more kernel tuning options.

    • Chapter 14, Security, has been expanded with new information about virtual private networks (VPNs), file systemaccess control lists (ACLs), and security advisories.

    • Chapter 15, Mandatory Access Control (MAC), is a new chapter with this edition. It explains what MAC is andhow this mechanism can be used to secure a FreeBSD system.

    • Chapter 16, Storage, has been expanded with new information about USB storage devices, file system snapshots,file system quotas, file and network backed filesystems, and encrypted disk partitions.

    • Chapter 17, Vinum, is a new chapter with this edition. It describes how to use Vinum, a logical volume managerwhich provides device-independent logical disks, and software RAID-0, RAID-1 and RAID-5.

    • A troubleshooting section has been added to Chapter 21, PPP and SLIP.

    • Chapter 22, Electronic Mail, has been expanded with new information about using alternative transport agents,SMTP authentication, UUCP, fetchmail, procmail, and other advanced topics.

    • Chapter 23, Network Servers, is all new with this edition. This chapter includes information about setting up theApache HTTP Server, FTPd, and setting up a server for Microsoft Windows clients with Samba. Some sectionsfrom Chapter 25, Advanced Networking, were moved here to improve the presentation.

    • Chapter 25, Advanced Networking, has been expanded with new information about using Bluetooth devices withFreeBSD, setting up wireless networks, and Asynchronous Transfer Mode (ATM) networking.

    • A glossary has been added to provide a central location for the definitions of technical terms used throughout thebook.

    • A number of aesthetic improvements have been made to the tables and figures throughout the book.

    i

  • Preface

    Changes from the First EditionThe second edition was the culmination of over two years of work by the dedicated members of the FreeBSDDocumentation Project. The following were the major changes in this edition:

    • A complete Index has been added.

    • All ASCII figures have been replaced by graphical diagrams.

    • A standard synopsis has been added to each chapter to give a quick summary of what information the chaptercontains, and what the reader is expected to know.

    • The content has been logically reorganized into three parts: “Getting Started”, “System Administration”, and“Appendices”.

    • Chapter 2 (“Installing FreeBSD”) was completely rewritten with many screenshots to make it much easier for newusers to grasp the text.

    • Chapter 3 (“ UNIX Basics”) has been expanded to contain additional information about processes, daemons, andsignals.

    • Chapter 4 (“Installing Applications”) has been expanded to contain additional information about binary packagemanagement.

    • Chapter 5 (“The X Window System”) has been completely rewritten with an emphasis on using modern desktoptechnologies such as KDE and GNOME on XFree86™ 4.X.

    • Chapter 12 (“The FreeBSD Booting Process”) has been expanded.

    • Chapter 16 (“Storage”) has been written from what used to be two separate chapters on “Disks” and “Backups”.We feel that the topics are easier to comprehend when presented as a single chapter. A section on RAID (bothhardware and software) has also been added.

    • Chapter 20 (“Serial Communications”) has been completely reorganized and updated for FreeBSD 4.X/5.X.

    • Chapter 21 (“PPP and SLIP”) has been substantially updated.

    • Many new sections have been added to Chapter 25 (“Advanced Networking”).

    • Chapter 22 (“Electronic Mail”) has been expanded to include more information about configuring sendmail.

    • Chapter 10 (“ Linux® Compatibility”) has been expanded to include information about installing Oracle® andSAP® R/3®.

    • The following new topics are covered in this second edition:

    • Configuration and Tuning (Chapter 11).

    • Multimedia (Chapter 7)

    Organization of This BookThis book is split into five logically distinct sections. The first section, Getting Started, covers the installation andbasic usage of FreeBSD. It is expected that the reader will follow these chapters in sequence, possibly skippingchapters covering familiar topics. The second section, Common Tasks, covers some frequently used features ofFreeBSD. This section, and all subsequent sections, can be read out of order. Each chapter begins with a succinct

    ii

  • Preface

    synopsis that describes what the chapter covers and what the reader is expected to already know. This is meant toallow the casual reader to skip around to find chapters of interest. The third section, System Administration, coversadministration topics. The fourth section, Network Communication, covers networking and server topics. The fifthsection contains appendices of reference information.

    Chapter 1, Introduction

    Introduces FreeBSD to a new user. It describes the history of the FreeBSD Project, its goals and developmentmodel.

    Chapter 2, Installation

    Walks a user through the entire installation process. Some advanced installation topics, such as installingthrough a serial console, are also covered.

    Chapter 3, UNIX Basics

    Covers the basic commands and functionality of the FreeBSD operating system. If you are familiar with Linuxor another flavor of UNIX then you can probably skip this chapter.

    Chapter 4, Installing Applications

    Covers the installation of third-party software with both FreeBSD’s innovative “Ports Collection” and standardbinary packages.

    Chapter 5, The X Window System

    Describes the X Window System in general and using X11 on FreeBSD in particular. Also describes commondesktop environments such as KDE and GNOME.

    Chapter 6, Desktop Applications

    Lists some common desktop applications, such as web browsers and productivity suites, and describes how toinstall them on FreeBSD.

    Chapter 7, Multimedia

    Shows how to set up sound and video playback support for your system. Also describes some sample audio andvideo applications.

    Chapter 8, Configuring the FreeBSD Kernel

    Explains why you might need to configure a new kernel and provides detailed instructions for configuring,building, and installing a custom kernel.

    Chapter 9, Printing

    Describes managing printers on FreeBSD, including information about banner pages, printer accounting, andinitial setup.

    Chapter 10, Linux Binary Compatibility

    Describes the Linux compatibility features of FreeBSD. Also provides detailed installation instructions formany popular Linux applications such as Oracle, SAP R/3, and Mathematica®.

    iii

  • Preface

    Chapter 11, Configuration and Tuning

    Describes the parameters available for system administrators to tune a FreeBSD system for optimumperformance. Also describes the various configuration files used in FreeBSD and where to find them.

    Chapter 12, Booting Process

    Describes the FreeBSD boot process and explains how to control this process with configuration options.

    Chapter 13, Users and Basic Account Management

    Describes the creation and manipulation of user accounts. Also discusses resource limitations that can be set onusers and other account management tasks.

    Chapter 14, Security

    Describes many different tools available to help keep your FreeBSD system secure, including Kerberos, IPsecand OpenSSH.

    Chapter 15, Mandatory Access Control

    Explains what Mandatory Access Control (MAC) is and how this mechanism can be used to secure a FreeBSDsystem.

    Chapter 16, Storage

    Describes how to manage storage media and filesystems with FreeBSD. This includes physical disks, RAIDarrays, optical and tape media, memory-backed disks, and network filesystems.

    Chapter 17, Vinum

    Describes how to use Vinum, a logical volume manager which provides device-independent logical disks, andsoftware RAID-0, RAID-1 and RAID-5.

    Chapter 18, Localization

    Describes how to use FreeBSD in languages other than English. Covers both system and application levellocalization.

    Chapter 19, The Cutting Edge

    Explains the differences between FreeBSD-STABLE, FreeBSD-CURRENT, and FreeBSD releases. Describeswhich users would benefit from tracking a development system and outlines that process.

    Chapter 20, Serial Communications

    Explains how to connect terminals and modems to your FreeBSD system for both dial in and dial outconnections.

    Chapter 21, PPP and SLIP

    Describes how to use PPP, SLIP, or PPP over Ethernet to connect to remote systems with FreeBSD.

    Chapter 22, Electronic Mail

    Explains the different components of an email server and dives into simple configuration topics for the mostpopular mail server software: sendmail.

    iv

  • Preface

    Chapter 23, Network Servers

    Provides detailed instructions and example configuration files to set up your FreeBSD machine as a networkfilesystem server, domain name server, network information system server, or time synchronization server.

    Chapter 24, Firewalls

    Explains the philosophy behind software-based firewalls and provides detailed information about theconfiguration of the different firewalls available for FreeBSD.

    Chapter 25, Advanced Networking

    Describes many networking topics, including sharing an Internet connection with other computers on yourLAN, advanced routing topics, wireless networking, bluetooth, ATM, IPv6, and much more.

    Appendix A, Obtaining FreeBSD

    Lists different sources for obtaining FreeBSD media on CDROM or DVD as well as different sites on theInternet that allow you to download and install FreeBSD.

    Appendix B, Bibliography

    This book touches on many different subjects that may leave you hungry for a more detailed explanation. Thebibliography lists many excellent books that are referenced in the text.

    Appendix C, Resources on the Internet

    Describes the many forums available for FreeBSD users to post questions and engage in technical conversationsabout FreeBSD.

    Appendix D, PGP Keys

    Lists the PGP fingerprints of several FreeBSD Developers.

    Conventions used in this bookTo provide a consistent and easy to read text, several conventions are followed throughout the book.

    Typographic Conventions

    Italic

    An italic font is used for filenames, URLs, emphasized text, and the first usage of technical terms.

    Monospace

    A monospaced font is used for error messages, commands, environment variables, names of ports, hostnames,user names, group names, device names, variables, and code fragments.

    Bold

    A bold font is used for applications, commands, and keys.

    v

  • Preface

    User InputKeys are shown in bold to stand out from other text. Key combinations that are meant to be typed simultaneously areshown with ‘+’ between the keys, such as:

    Ctrl+Alt+Del

    Meaning the user should type the Ctrl, Alt, and Del keys at the same time.

    Keys that are meant to be typed in sequence will be separated with commas, for example:

    Ctrl+X, Ctrl+S

    Would mean that the user is expected to type the Ctrl and X keys simultaneously and then to type the Ctrl and Skeys simultaneously.

    ExamplesExamples starting with E:\> indicate a MS-DOS® command. Unless otherwise noted, these commands may beexecuted from a “Command Prompt” window in a modern Microsoft® Windows® environment.

    E:\> tools\fdimage floppies\kern.flp A:

    Examples starting with # indicate a command that must be invoked as the superuser in FreeBSD. You can login asroot to type the command, or login as your normal account and use su(1) to gain superuser privileges.

    # dd if=kern.flp of=/dev/fd0

    Examples starting with % indicate a command that should be invoked from a normal user account. Unless otherwisenoted, C-shell syntax is used for setting environment variables and other shell commands.

    % top

    AcknowledgmentsThe book you are holding represents the efforts of many hundreds of people around the world. Whether they sent infixes for typos, or submitted complete chapters, all the contributions have been useful.

    Several companies have supported the development of this document by paying authors to work on it full-time,paying for publication, etc. In particular, BSDi (subsequently acquired by Wind River Systems(http://www.windriver.com)) paid members of the FreeBSD Documentation Project to work on improving this bookfull time leading up to the publication of the first printed edition in March 2000 (ISBN 1-57176-241-8). Wind RiverSystems then paid several additional authors to make a number of improvements to the print-output infrastructureand to add additional chapters to the text. This work culminated in the publication of the second printed edition inNovember 2001 (ISBN 1-57176-303-1). In 2003-2004, FreeBSD Mall, Inc (http://www.freebsdmall.com), paidseveral contributors to improve the Handbook in preparation for the third printed edition.

    vi

  • I. Getting StartedThis part of the FreeBSD Handbook is for users and administrators who are new to FreeBSD. These chapters:

    • Introduce you to FreeBSD.

    • Guide you through the installation process.

    • Teach you UNIX basics and fundamentals.

    • Show you how to install the wealth of third party applications available for FreeBSD.

    • Introduce you to X, the UNIX windowing system, and detail how to configure a desktop environment that makesyou more productive.

    We have tried to keep the number of forward references in the text to a minimum so that you can read this section ofthe Handbook from front to back with the minimum page flipping required.

  • Chapter 1 IntroductionRestructured, reorganized, and parts rewritten by Jim Mock.

    1.1 SynopsisThank you for your interest in FreeBSD! The following chapter covers various aspects of the FreeBSD Project, suchas its history, goals, development model, and so on.

    After reading this chapter, you will know:

    • How FreeBSD relates to other computer operating systems.

    • The history of the FreeBSD Project.

    • The goals of the FreeBSD Project.

    • The basics of the FreeBSD open-source development model.

    • And of course: where the name “FreeBSD” comes from.

    1.2 Welcome to FreeBSD!FreeBSD is a 4.4BSD-Lite based operating system for Intel (x86 and Itanium®), AMD64, Alpha™, SunUltraSPARC® computers. Ports to other architectures are also underway. You can also read aboutthe history of FreeBSD, or the current release. If you are interested in contributing something to the Project (code,hardware, unmarked bills), see the Contributing to FreeBSD(http://www.FreeBSD.org/doc/en_US.ISO8859-1/articles/contributing/index.html) article.

    1.2.1 What Can FreeBSD Do?

    FreeBSD has many noteworthy features. Some of these are:

    • Preemptive multitasking with dynamic priority adjustment to ensure smooth and fair sharing of the computerbetween applications and users, even under the heaviest of loads.

    • Multi-user facilities which allow many people to use a FreeBSD system simultaneously for a variety of things.This means, for example, that system peripherals such as printers and tape drives are properly shared between allusers on the system or the network and that individual resource limits can be placed on users or groups of users,protecting critical system resources from over-use.

    • Strong TCP/IP networking with support for industry standards such as SLIP, PPP, NFS, DHCP, and NIS. Thismeans that your FreeBSD machine can interoperate easily with other systems as well as act as an enterprise server,providing vital functions such as NFS (remote file access) and email services or putting your organization on theInternet with WWW, FTP, routing and firewall (security) services.

    • Memory protection ensures that applications (or users) cannot interfere with each other. One application crashingwill not affect others in any way.

    • FreeBSD is a 32-bit operating system (64-bit on the Alpha, Itanium, AMD64, and UltraSPARC) and was designedas such from the ground up.

    1

  • Chapter 1 Introduction

    • The industry standard X Window System (X11R6) provides a graphical user interface (GUI) for the cost of acommon VGA card and monitor and comes with full sources.

    • Binary compatibility with many programs built for Linux, SCO, SVR4, BSDI and NetBSD.

    • Thousands of ready-to-run a