DragonFly Handbook The DragonFly Documentation Project Copyright (c) 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 The FreeBSD Documentation Project Copyright (c) 2004, 2005, 2006 The DragonFly Documentation Project Welcome to DragonFly! This handbook covers the installation and day to day use of the DragonFly operating system. This manual is a work in progress and is the work of many individuals. Many sections do not yet exist and some of those that do exist need to be updated. If you are interested in helping with this project, send email to the DragonFly Documentation project mailing list. The latest version of this document is always available from the DragonFly web site or mirror sites, in a variety of formats. Portions of this document originally documented use of the FreeBSD operating system. While many functions should be similar on DragonFly, some differences should be expected. If you find instructions here that no longer apply to DragonFly, please contact the documentation mailing list at DragonFly Documentation project mailing list . 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 conditions and 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 other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Important: THIS DOCUMENTATION IS PROVIDED BY THE DRAGONFLYBSD PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE DRAGONFLYBSD PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. DragonFlyBSD is a registered trademark of the DragonFlyBSD Project. FreeBSD is a registered trademark of Wind River Systems, Inc. This is expected to change soon. NetBSD is a registered trademark of The NetBSD Foundation, Inc. 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 in the United States. 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, FrontPage, 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. pkgsrc is a registered trademark of The NetBSD Foundation, Inc. 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 ``(TM)'' or the ``(R)'' symbol. -------------------------------------------------------------- Table of Contents Preface I. Getting Started 1 Introduction 1.1 Synopsis 1.2 Welcome to DragonFly! 1.3 About the DragonFly Project 2 Installation from CD 2.1 CD Installation Overview 2.2 CD Installation - Making room 2.3 CD Installation - Disk setup 2.4 Installing to Disk from CD 2.5 CD Installation - Post-install cleanup 2.6 CD Installation - New system setup 3 UNIX Basics 3.1 Synopsis 3.2 Virtual Consoles and Terminals 3.3 Permissions 3.4 Directory Structure 3.5 Disk Organization 3.6 Mounting and Unmounting File Systems 3.7 Processes 3.8 Daemons, Signals, and Killing Processes 3.9 Shells 3.10 Text Editors 3.11 Devices and Device Nodes 3.12 Binary Formats 3.13 For More Information 4 Installing Applications using NetBSD's pkgsrc framework 4.1 Synopsis 4.2 Overview of Software Installation 4.3 Finding Your Application 4.4 Using the Binary Packages System 4.5 Using the pkgsrc(R) Source Tree 4.6 Post-installation Activities 4.7 Dealing with Broken Packages 5 The X Window System 5.1 Synopsis 5.2 Understanding X 5.3 Installing X11 5.4 X11 Configuration 5.5 Using Fonts in X11 5.6 The X Display Manager 5.7 Desktop Environments II. System Administration 6 Configuration and Tuning 6.1 Synopsis 6.2 Initial Configuration 6.3 Core Configuration 6.4 Application Configuration 6.5 Starting Services 6.6 Configuring the cron Utility 6.7 Using rc under DragonFly 6.8 Setting Up Network Interface Cards 6.9 Virtual Hosts 6.10 Configuration Files 6.11 Tuning with sysctl 6.12 Tuning Disks 6.13 Tuning Kernel Limits 6.14 Adding Swap Space 6.15 Power and Resource Management 6.16 Using and Debugging DragonFly ACPI 7 The DragonFly Booting Process 7.1 Synopsis 7.2 The Booting Problem 7.3 The Boot Manager and Boot Stages 7.4 Kernel Interaction During Boot 7.5 Init: Process Control Initialization 7.6 Shutdown Sequence 8 Users and Basic Account Management 8.1 Synopsis 8.2 Introduction 8.3 The Superuser Account 8.4 System Accounts 8.5 User Accounts 8.6 Modifying Accounts 8.7 Limiting Users 8.8 Personalizing Users 8.9 Groups 9 Configuring the DragonFly Kernel 9.1 Synopsis 9.2 Why Build a Custom Kernel? 9.3 Building and Installing a Custom Kernel 9.4 The Configuration File 9.5 Making Device Nodes 9.6 If Something Goes Wrong 10 Security 10.1 Synopsis 10.2 Introduction 10.3 Securing DragonFly 10.4 DES, MD5, and Crypt 10.5 One-time Passwords 10.6 Kerberos5 10.7 Firewalls 10.8 OpenSSL 10.9 VPN over IPsec 10.10 OpenSSH 11 Printing 11.1 Synopsis 11.2 Introduction 11.3 Basic Setup 11.4 Advanced Printer Setup 11.5 Using Printers 11.6 Alternatives to the Standard Spooler 11.7 Troubleshooting 12 Storage 12.1 Synopsis 12.2 Device Names 12.3 Adding Disks 12.4 RAID 12.5 Creating and Using Optical Media (CDs) 12.6 Creating and Using Optical Media (DVDs) 12.7 Creating and Using Floppy Disks 12.8 Creating and Using Data Tapes 12.9 Backups to Floppies 12.10 Backup Basics 12.11 Network, Memory, and File-Backed File Systems 12.12 File System Quotas 13 The Vinum Volume Manager 13.1 Synopsis 13.2 Disks Are Too Small 13.3 Access Bottlenecks 13.4 Data Integrity 13.5 Vinum Objects 13.6 Some Examples 13.7 Object Naming 13.8 Configuring Vinum 13.9 Using Vinum for the Root Filesystem 14 Localization - I18N/L10N Usage and Setup 14.1 Synopsis 14.2 The Basics 14.3 Using Localization 14.4 Compiling I18N Programs 14.5 Localizing DragonFly to Specific Languages 15 Desktop Applications 15.1 Synopsis 15.2 Browsers 15.3 Productivity 15.4 Document Viewers 15.5 Finance 15.6 Summary 16 Multimedia 16.1 Synopsis 16.2 Setting Up the Sound Card 16.3 MP3 Audio 16.4 Video Playback 16.5 Setting Up TV Cards 17 Serial Communications 17.1 Synopsis 17.2 Introduction 17.3 Terminals 17.4 Dial-in Service 17.5 Dial-out Service 17.6 Setting Up the Serial Console 18 PPP and SLIP 18.1 Synopsis 18.2 Using User PPP 18.3 Using Kernel PPP 18.4 Troubleshooting PPP Connections 18.5 Using PPP over Ethernet (PPPoE) 18.6 Using SLIP 19 Advanced Networking 19.1 Synopsis 19.2 Gateways and Routes 19.3 Wireless Networking 19.4 Bluetooth 19.5 Bridging 19.6 NFS 19.7 Diskless Operation 19.8 ISDN 19.9 NIS/YP 19.10 DHCP 19.11 DNS 19.12 NTP 19.13 Network Address Translation 19.14 The inetd ``Super-Server'' 19.15 Parallel Line IP (PLIP) 19.16 IPv6 20 Electronic Mail 20.1 Synopsis 20.2 Using Electronic Mail 20.3 sendmail Configuration 20.4 Changing Your Mail Transfer Agent 20.5 Troubleshooting 20.6 Advanced Topics 20.7 SMTP with UUCP 20.8 Setting up to send only 20.9 Using Mail with a Dialup Connection 20.10 SMTP Authentication 20.11 Mail User Agents 20.12 Using fetchmail 20.13 Using procmail 21 Updating DragonFly 21.1 Initial Setup 21.2 Configuration 21.3 Preparing to Update 21.4 Updating the System 22 Linux Binary Compatibility 22.1 Synopsis 22.2 Installation 22.3 Installing Mathematica(R) 22.4 Installing Maple(TM) 22.5 Installing MATLAB(R) 22.6 Installing Oracle(R) 22.7 Installing SAP(R) R/3(R) 22.8 Advanced Topics III. Appendices A. Obtaining DragonFly A.1 CDROM and DVD Publishers A.2 FTP Sites A.3 Using CVSup A.4 CVS Tags B. Bibliography B.1 Books & Magazines Specific to BSD B.2 Users' Guides B.3 Administrators' Guides B.4 Programmers' Guides B.5 Operating System Internals B.6 Security Reference B.7 Hardware Reference B.8 UNIX History B.9 Magazines and Journals C. Resources on the Internet C.1 Mailing Lists C.2 Usenet Newsgroups C.3 World Wide Web Servers D. PGP Keys D.1 Developers Colophon List of Tables 3-1. Disk Device Codes 12-1. Physical Disk Naming Conventions 13-1. Vinum Plex Organizations 19-1. Wiring a Parallel Cable for Networking 19-2. Reserved IPv6 addresses List of Figures 13-1. Concatenated Organization 13-2. Striped Organization 13-3. RAID-5 Organization 13-4. A Simple Vinum Volume 13-5. A Mirrored Vinum Volume 13-6. A Striped Vinum Volume 13-7. A Mirrored, Striped Vinum Volume List of Examples 3-1. Sample Disk, Slice, and Partition Names 3-2. Conceptual Model of a Disk 4-1. Downloading a Package Manually and Installing It Locally 6-1. Creating a Swapfile 7-1. boot0 Screenshot 7-2. boot2 Screenshot 7-3. An Insecure Console in /etc/ttys 8-1. Configuring adduser and adding a user 8-2. rmuser Interactive Account Removal 8-3. Interactive chpass by Superuser 8-4. Interactive chpass by Normal User 8-5. Changing Your Password 8-6. Changing Another User's Password as the Superuser 8-7. Adding a Group Using pw(8) 8-8. Adding Somebody to a Group Using pw(8) 8-9. Using id(1) to Determine Group Membership 10-1. Using SSH to Create a Secure Tunnel for SMTP 12-1. Using dump over ssh 12-2. Using dump over ssh with RSH set 12-3. A Script for Creating a Bootable Floppy 12-4. Using vnconfig to Mount an Existing File System Image 12-5. Creating a New File-Backed Disk with vnconfig 12-6. md Memory Disk 17-1. Adding Terminal Entries to /etc/ttys 19-1. Mounting an Export with amd 19-2. Branch Office or Home Network 19-3. Head Office or Other LAN 19-4. Sending inetd a HangUP Signal 20-1. Configuring the sendmail Access Database 20-2. Mail Aliases 20-3. Example Virtual Domain Mail Map -------------------------------------------------------------- Preface Intended Audience The DragonFly newcomer will find that the first section of this book guides the user through the DragonFly installation process and gently introduces the concepts and conventions that underpin UNIX(R). Working through this section requires little more than the desire to explore, and the ability to take on board new concepts as they are introduced. Once you have travelled this far, the second, far larger, section of the Handbook is a comprehensive reference to all manner of topics of interest to DragonFly system administrators. Some of these chapters may recommend that you do some 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. Organization of This Book This book is split into three logically distinct sections. The first section, Getting Started, covers the installation and basic usage of DragonFly. It is expected that the reader will follow these chapters in sequence, possibly skipping chapters covering familiar topics. The second section, System Administration, covers a broad collection of subjects that are of interest to more advanced DragonFly users. Each section begins with a succinct synopsis that describes what the chapter covers and what the reader is expected to already know. This is meant to allow the casual reader to skip around to find chapters of interest. The third section contains appendices of reference information. Chapter 1, Introduction Introduces DragonFly to a new user. It describes the history of the DragonFly Project, its goals and development model. Chapter 2, Installation Walks a user through the entire installation process. Some advanced installation topics, such as installing through a serial console, are also covered. Chapter 3, UNIX Basics Covers the basic commands and functionality of the DragonFly operating system. If you are familiar with Linux or another flavor of UNIX then you can probably skip this chapter. Chapter 4, Installing Applications Covers the installation of third-party software using NetBSD(R)'s Packages Collection pkgsrc(R). Chapter 5, The X Window System Describes the X Window System in general and using XFree86(TM) and X.org on DragonFly in particular. Also describes common desktop environments such as KDE and GNOME. Chapter 6, Configuration and Tuning Describes the parameters available for system administrators to tune a DragonFly system for optimum performance. Also describes the various configuration files used in DragonFly and where to find them. Chapter 7, Booting Process Describes the DragonFly boot process and explains how to control this process with configuration options. Chapter 8, Users and Basic Account Management Describes the creation and manipulation of user accounts. Also discusses resource limitations that can be set on users and other account management tasks. Chapter 9, Configuring the DragonFly Kernel Explains why you might need to configure a new kernel and provides detailed instructions for configuring, building, and installing a custom kernel. Chapter 10, Security Describes many different tools available to help keep your DragonFly system secure, including Kerberos, IPsec, OpenSSH, and network firewalls. Chapter 11, Printing Describes managing printers on DragonFly, including information about banner pages, printer accounting, and initial setup. Chapter 12, Storage Describes how to manage storage media and filesystems with DragonFly. This includes physical disks, RAID arrays, optical and tape media, memory-backed disks, and network filesystems. Chapter 13, Vinum Describes how to use Vinum, a logical volume manager which provides device-independent logical disks, and software RAID-0, RAID-1 and RAID-5. Chapter 14, Localization Describes how to use DragonFly in languages other than English. Covers both system and application level localization. Chapter 15, Desktop Applications Lists some common desktop applications, such as web browsers and productivity suites, and describes how to install them on DragonFly. Chapter 16, Multimedia Shows how to set up sound and video playback support for your system. Also describes some sample audio and video applications. Chapter 17, Serial Communications Explains how to connect terminals and modems to your DragonFly system for both dial in and dial out connections. Chapter 18, PPP and SLIP Describes how to use PPP, SLIP, or PPP over Ethernet to connect to remote systems with DragonFly. Chapter 19, Advanced Networking Describes many networking topics, including sharing an Internet connection with other computers on your LAN, using network filesystems, sharing account information via NIS, setting up a name server, and much more. Chapter 20, Electronic Mail Explains the different components of an email server and dives into simple configuration topics for the most popular mail server software: sendmail. Section 21.1, Updating DragonFly Describes the development paths of DragonFly, and how to stay up-to-date. Chapter 22, Linux Binary Compatibility Describes the Linux compatibility features of DragonFly. Also provides detailed installation instructions for many popular Linux applications such as Oracle(R), SAP(R) R/3(R), and Mathematica(R). Appendix A, Obtaining DragonFly Lists different sources for obtaining DragonFly media on CDROM or DVD as well as different sites on the Internet that allow you to download and install DragonFly. Appendix B, Bibliography This book touches on many different subjects that may leave you hungry for a more detailed explanation. The bibliography lists many excellent books that are referenced in the text. Appendix C, Resources on the Internet Describes the many forums available for DragonFly users to post questions and engage in technical conversations about DragonFly. Appendix D, PGP Keys Lists the PGP fingerprints of several DragonFly Developers. Conventions used in this book To 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. User Input Keys are shown in bold to stand out from other text. Key combinations that are meant to be typed simultaneously are shown 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 S keys simultaneously. Examples Examples starting with # indicate a command that must be invoked as the superuser in DragonFly. You can login as root 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 otherwise noted, C-shell syntax is used for setting environment variables and other shell commands. % top Examples starting with E:\> indicate a MS-DOS(R) command. Unless otherwise noted, these commands may be executed from a ``Command Prompt'' window in a modern Microsoft(R) Windows(R) environment. E:\> tools\fdimage floppies\kern.flp A: Acknowledgments The book you are holding represents the efforts of many hundreds of people around the world. Whether they sent in fixes for typos, or submitted complete chapters, all the contributions have been useful. The DragonFly Handbook was originally built from an edition of the FreeBSD Handbook. The FreeBSD Handbook was created by the collective hard work of hundreds of people, and the DragonFly Documentation Team appreciates all their labor. Included here is a list of all individually identified people and corporations that contributed resources to this handbook. Eric Anderson, Satoshi Asami, Bojan Bistrovic, Neil Blakey-Milner, Andrew Boothman, Harti Brandt, Jim Brown, BSDi, Andrey A. Chernov, Peter Childs, Munish Chopra, Joe Marcus Clarke, Nik Clayton, Mark Dapoz, Matt Dillon, Jean-Franc,ois Dockes, Alex Dupre, Josef El-Rayes, Udo Erdelhoff, Marc Fonvieille, Dirk Fro:mberg, Robert Getschmann, James Gorham, Lucky Green, Coranth Gryphon, Jake Hamby, Brian N. Handy, Guy Helmer, Al Hoang, Tillman Hodgson, Jordan Hubbard, Robert Huff, Tom Hukins, Christophe Juniet, Poul-Henning Kamp, Aaron Kaplan, Martin Karlsson, Sean Kelly, Seth Kingsley, Holger Kipp, Nate Lawson, Chern Lee, Greg Lehey, John Lind, Ross Lippert, Bill Lloyd, Pav Lucistnik, Julio Merino, Mike Meyer, Hellmuth Michaelis, Jim Mock, Marcel Moolenaar, Moses Moore, Bill Moran, Rich Murphey, Mark Murray, Alex Nash, Gregory Neil Shapiro, David O'Brien, Eric Ogren, Gary Palmer, Hiten M. Pandya, Bill Paul, Dan Pelleg, Steve Peterson, John Polstra, Andy Polyakov, Randy Pratt, Jeremy C. Reed, Tom Rhodes, Trev Roydhouse, Peter Schultz, Piero Serini, Christopher Shumway, Marc Silver, Mike Smith, Brian Somers, Gennady B. Sorokopud, Wylie Stilwell, Murray Stokely, Greg Sutter, Bill Swingle, Valentino Vaschetto, Robert Watson, Wind River Systems, Michael C. Wu, and Kazutaka YOKOTA. I. Getting Started This part of the DragonFly Handbook is for users and administrators who are new to DragonFly. These chapters: * Introduce you to DragonFly. * 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 DragonFly. * Introduce you to X, the UNIX windowing system, and detail how to configure a desktop environment that makes you 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 of the Handbook from front to back with the minimum page flipping required. Table of Contents 1 Introduction 2 Installation from CD 3 UNIX Basics 4 Installing Applications using NetBSD's pkgsrc framework 5 The X Window System -------------------------------------------------------------- Chapter 1 Introduction Restructured, reorganized, and parts rewritten by Jim Mock. 1.1 Synopsis Thank you for your interest in DragonFly! The following chapter covers various aspects of the DragonFly Project, such as its history, goals, development model, and so on. After reading this chapter, you will know: * How DragonFly relates to other computer operating systems. * The history of the DragonFly Project. * The goals of the DragonFly Project. * The basics of the DragonFly open-source development model. * And of course: where the name ``DragonFly'' comes from. -------------------------------------------------------------- 1.2 Welcome to DragonFly! DragonFly is a 4.4BSD-Lite based operating system for Intel (x86). A port to AMD64 is in progress. You can also read about the history of DragonFly, or the current release. -------------------------------------------------------------- 1.2.1 What Can DragonFly Do? DragonFly has many noteworthy features. Some of these are: * Preemptive multitasking with dynamic priority adjustment to ensure smooth and fair sharing of the computer between applications and users, even under the heaviest of loads. * Multi-user facilities which allow many people to use a DragonFly system simultaneously for a variety of things. This means, for example, that system peripherals such as printers and tape drives are properly shared between all users 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. This means that your DragonFly 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 the Internet with WWW, FTP, routing and firewall (security) services. * Memory protection ensures that applications (or users) cannot interfere with each other. One application crashing will not affect others in any way. * DragonFly is a 32-bit operating system. * The industry standard X Window System (X11R6) provides a graphical user interface (GUI) for the cost of a common 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 applications are available from the pkgsrc packages collection. Why search the net when you can find it all right here? * Thousands of additional and easy-to-port applications are available on the Internet. DragonFly is source code compatible with most popular commercial UNIX systems and thus most applications require few, if any, changes to compile. * Demand paged virtual memory and ``merged VM/buffer cache'' design efficiently satisfies applications with large appetites for memory while still maintaining interactive response to other users. * SMP support for machines with multiple CPUs. * A full complement of C, C++, Fortran, and Perl development tools. Many additional languages for advanced research and development are also available in the ports and packages collection. * Source code for the entire system means you have the greatest degree of control over your environment. Why be locked into a proprietary solution at the mercy of your vendor when you can have a truly open system? * Extensive online documentation. * And many more! DragonFly is based on the 4.4BSD-Lite release from Computer Systems Research Group (CSRG) at the University of California at Berkeley, along with later development of FreeBSD by the FreeBSD Project. It carries on the distinguished tradition of BSD systems development. In addition to the fine work provided by CSRG, the DragonFly Project has put in many thousands of hours in fine tuning the system for maximum performance and reliability in real-life load situations. As many of the commercial giants struggle to field PC operating systems with such features, performance and reliability, DragonFly can offer them now! The applications to which DragonFly can be put are truly limited only by your own imagination. From software development to factory automation, inventory control to azimuth correction of remote satellite antennae; if it can be done with a commercial UNIX product then it is more than likely that you can do it with DragonFly too! DragonFly also benefits significantly from literally thousands of high quality applications developed by research centers and universities around the world, often available at little to no cost. Commercial applications are also available and appearing in greater numbers every day. Because the source code for DragonFly itself is generally available, the system can also be customized to an almost unheard of degree for special applications or projects, and in ways not generally possible with operating systems from most major commercial vendors. Here is just a sampling of some of the applications in which people are currently using DragonFly: * Internet Services: The robust TCP/IP networking built into DragonFly makes it an ideal platform for a variety of Internet services such as: * FTP servers * World Wide Web servers (standard or secure [SSL]) * Firewalls and NAT (``IP masquerading'') gateways * Electronic Mail servers * USENET News or Bulletin Board Systems * And more... With DragonFly, you can easily start out small with an inexpensive 386 class PC and upgrade all the way up to a quad-processor Xeon with RAID storage as your enterprise grows. * Education: Are you a student of computer science or a related engineering field? There is no better way of learning about operating systems, computer architecture and networking than the hands on, under the hood experience that DragonFly can provide. A number of freely available CAD, mathematical and graphic design packages also make it highly useful to those whose primary interest in a computer is to get other work done! * Research: With source code for the entire system available, DragonFly is an excellent platform for research in operating systems as well as other branches of computer science. DragonFly's freely available nature also makes it possible for remote groups to collaborate on ideas or shared development without having to worry about special licensing agreements or limitations on what may be discussed in open forums. * Networking: Need a new router? A name server (DNS)? A firewall to keep people out of your internal network? DragonFly can easily turn that unused older PC sitting in the corner into an advanced router with sophisticated packet-filtering capabilities. * X Window workstation: DragonFly is a fine choice for an inexpensive X terminal solution, either using the freely available XFree86 or X.org servers or one of the excellent commercial servers provided by Xi Graphics. Unlike an X terminal, DragonFly allows many applications to be run locally if desired, thus relieving the burden on a central server. DragonFly can even boot ``diskless'', making individual workstations even cheaper and easier to administer. * Software Development: The basic DragonFly system comes with a full complement of development tools including the renowned GNU C/C++ compiler and debugger. DragonFly is available via anonymous FTP or CVS. Please see Appendix A for more information about obtaining DragonFly. -------------------------------------------------------------- 1.3 About the DragonFly Project The following section provides some background information on the project, including a brief history, project goals, and the development model of the project. -------------------------------------------------------------- 1.3.1 A Brief History of DragonFly Matthew Dillon, one of the developers for FreeBSD, was growing increasingly frustrated with the FreeBSD Project's direction for release 5. The FreeBSD 5 release had been delayed multiple times, and had performance problems compared to earlier releases of FreeBSD. DragonFly was announced in June of 2003. The code base was taken from the 4.8 release of FreeBSD, which offered better performance and more complete features. Development has proceeded at a very quick rate since then, with Matt Dillon and a small group of developers fixing longstanding BSD bugs and modernizing the new DragonFly system. -------------------------------------------------------------- 1.3.2 DragonFly Project Goals DragonFly is an effort to maintain the traditional BSD format -- lean, stable code -- along with modern features such as lightweight threads, a workable packaging system, and a revised VFS. Underpinning all this work is efficient support for multiple processors, something rare among open source systems. Because DragonFly is built on an existing very stable code base, it is possible to make these radical changes as part of an incremental process. -------------------------------------------------------------- 1.3.3 The DragonFly Development Model Written by Justin Sherrill. DragonFly is developed by many people around the world. There is no qualification process; anyone may submit his or her code, documentation, or designs, for use in the Project. Here is a general description of the Project's organizational structure. The CVS repository Source for DragonFly is kept in CVS (Concurrent Versions System), which is available with each DragonFly install. The primary CVS repository resides on a machine in California, USA. Documentation on obtaining the DragonFly source is available elsewhere in this book. Commit access The best way of getting changes made to the DragonFly source is to mail the submit mailing list. Including desired source code changes (unified diff format is best) is the most useful format. A certain number of developers have access to commit changes to the DragonFly source, and can do so after review on that list. The DragonFly development model is loose; changes to the code are generally peer-reviewed and added when any objections have been corrected. There is no formal entry/rejection process, though final say on all code submissions goes to Matt Dillon, as originator of this project. -------------------------------------------------------------- 1.3.4 The Current DragonFly Release DragonFly is a freely available, full source 4.4BSD-Lite based release for Intel i386(TM), i486(TM), Pentium(R), Pentium Pro, Celeron(R), Pentium II, Pentium III, Pentium 4 (or compatible), and Xeon(TM) based computer systems. It is based primarily on FreeBSD 4.8, and includes enhancements from U.C. Berkeley's CSRG group, NetBSD, OpenBSD, 386BSD, and the Free Software Foundation. A number of additional documents which you may find very helpful in the process of installing and using DragonFly may now also be found in the /usr/share/doc directory on any machine. The most up-to-date documentation can be found at http://www.dragonflybsd.org/. -------------------------------------------------------------- 1.3.5 "DragonFly" Origin Matthew Dillon happened to take a picture of a dragonfly in his garden while trying to come up with a name for this new branch of BSD. Taking this as inspiration, "DragonFly" became the new name. -------------------------------------------------------------- Chapter 2 Installation from CD Written by Markus Schatzl and Justin Sherrill. 2.1 CD Installation Overview This document describes the installation of DragonFly BSD on a plain i386 machine. This process uses a bootable DragonFly CD, usually referred to as a 'live CD'. This CD is available at one of the current mirrors, which distribute the images by various protocols. The authorative list can be found at the DragonFly website. This document may be superseded by the /README file located on the live CD, which may reflect changes made after this document was last updated. Check that README for any last-minute changes and for an abbreviated version of this installation process. The DragonFly development team is working on an automatic installation tool, which simplifies the partitioning and installation processes. Until this tool is in place, the manual process here is required. Some experience with BSD-style tools is recommended. Caution: While this guide covers installing to a computer with an existing non-DragonFly operating system, take no chances! Back up any data on your disk drives that you want to save. When installing to an old machine, it may not be possible to boot from a CD. Use a bootmanager on a floppy in those cases, such as Smart Bootmanager. Caution: Always be sure of the target disk for any command. Unless otherwise specified, each command here assumes the first disk in the IDE chain is the target. (ad0) Adjust commands as needed. -------------------------------------------------------------- 2.2 CD Installation - Making room 2.2.1 DragonFly as the only operating system If DragonFly is to be the only operating system on the target computer, preparing the disk is a short and simple process. Boot with the live CD, and log in as root to reach a command prompt. First, the master boot record (MBR) must be cleared of any old information. This command clears all old data off your disk by writing zeros (if=/dev/zero) onto the system's master ata drive (of=/dev/ad0). # dd if=/dev/zero of=/dev/ad0 bs=32k count=16 The now-empty disk must be formatted. Important: This will destroy any existing data on a disk. Do this only if you plan to dedicate this disk to DragonFly. # fdisk -I ad0 # fdisk -B ad0 -------------------------------------------------------------- 2.2.2 Multiple operating systems on one hard disk This example assumes that the target computer for installation has at least one operating system installed that needs to survive the installation process. A new partition for DragonFly needs to be created from the existing partition(s) that otherwise fill the disk. There must be unused space within the existing partition in order to resize it. Important: The new partition is created from empty space in an existing partition. For example, an 18 gigabyte disk that has 17 gigabytes of existing data in the existing partition will only have 1 gigabyte available for the new partition. Partition resizing needs to be accomplished with a third-party tool. Commercial programs such as Partition Magic can accomplish these tasks. Free tools exist that can be adapted to this task, such as 'GNU parted', found on the Knoppix CD, or PAUD. Create a new partition of at least 5-6 gigabytes. It is possible to install within a smaller amount of disk space, but this will create problems not covered by this document. The newly created partition does not need to be formatted; the rest of the installation process treats that new partiton as a new disk. -------------------------------------------------------------- 2.2.3 Multiple operating systems, multiple hard disks Installing DragonFly to a separate disk removes the need for partition resizing, and is generally safer when trying to preserve an existing operating system installation. This type of installation is very similar to installing DragonFly as the only operating system. The only difference is the disk named in each command. -------------------------------------------------------------- 2.3 CD Installation - Disk setup 2.3.1 Disk formatting The slice layout on the newly formatted disk or partition needs to be set up, using this command. # fdisk -u If there are multiple operating systems on the disk, pick the correct partition judging by what partitions were created earlier with a resizing tool. -------------------------------------------------------------- 2.3.2 Boot block installation The 'ad0' here refers to the first disk on the first IDE bus of a computer. Increment the number if the target disk is farther down the chain. For example, the master disk on the second IDE controller would be 'ad2'. # boot0cfg -B ad0 # boot0cfg -v ad0 -s SLICE, where SLICE is a number, controls which slice on disk is used by boot0cfg to start from. By default, this number is 1, and will only need modification if a different slice contains DragonFly. Use -o packet as an option to boot0cfg if the DragonFly partition is located beyond cylinder 1023 on the disk. This location problem usually only happens when another operating system is taking up more than the first 8 gigabytes of disk space. This problem cannot happen if DragonFly is installed to a dedicated disk -------------------------------------------------------------- 2.3.3 Disklabel If DragonFly is installed anywhere but the first partition of the disk, the device entry for that partition will have to be created. Otherwise, the device entry is automatically created. Refer to this different partition instead of the 'ad0s1a' used in later examples. # cd /dev; ./MAKEDEV ad0s2 The partition needs to be created on the DragonFly disk. # disklabel -B -r -w ad0s1 auto Using /etc/disklabel.ad0s1 as an example, issue the following command to edit the disklabel for the just-created partition. # disklabel -e ad0s1 +----------------------------------------------------------------+ | Partition | Size | Mountpoint | |-----------+-------------+--------------------------------------| | ad0s2a | 256m | / | |-----------+-------------+--------------------------------------| | ad0s2b | 1024m | swap | |-----------+-------------+--------------------------------------| | ad0s2c | leave alone | This represents the whole slice. | |-----------+-------------+--------------------------------------| | ad0s2d | 256m | /var | |-----------+-------------+--------------------------------------| | ad0s2e | 256m | /tmp ! | |-----------+-------------+--------------------------------------| | ad0s2f | 8192m | /usr - This should be at least 4096m | |-----------+-------------+--------------------------------------| | ad0s2g | * | /home - This holds 'everything else' | +----------------------------------------------------------------+ -------------------------------------------------------------- 2.3.4 Partition Format newfs will format each individual partition. # newfs /dev/ad0s1a # newfs -U /dev/ad0s1d # newfs -U /dev/ad0s1e # newfs -U /dev/ad0s1f # newfs -U /dev/ad0s1g Note: The -U option is not used for the root partition, since / is usually relatively small. Softupdates can cause it to run out of space while under a lot of disk activity, such as a buildworld. Note: The command listing skips directly from ad0s1a to ad0s1d. This is because /dev/ad0s1b is used as swap and does not require formatting; ad0s1c refers to the entire disk and should not be formatted. -------------------------------------------------------------- 2.4 Installing to Disk from CD Since the Live CD contains all needed data to create a running DragonFly system, the simplest installation possible is to copy the Live CD data to the newly formatted disk/partition created in previous steps. These commands mount the newly created disk space and create the appropriate directories on it. # mount /dev/ad0s1a /mnt # mkdir /mnt/var # mkdir /mnt/tmp # mkdir /mnt/usr # mkdir /mnt/home # mount /dev/ad0s1d /mnt/var # mount /dev/ad0s1e /mnt/tmp # mount /dev/ad0s1f /mnt/usr # mount /dev/ad0s1g /mnt/home cpdup duplicates data from one volume to another. These commands copy data from the Live CD to the newly created directories on the mounted disk. Each step can take some time, depending on disk speed. # cpdup / /mnt # cpdup /var /mnt/var # cpdup /etc /mnt/etc # cpdup /dev /mnt/dev # cpdup /usr /mnt/usr Note: Nothing is copied to the /tmp directory that was created in the previous step. This is not an error, since /tmp is intended only for temporary storage. -------------------------------------------------------------- 2.5 CD Installation - Post-install cleanup /tmp and /var/tmp are both often used as temporary directories. Since use is not consistent from application to application, it is worthwhile to create /tmp as a link to /var/tmp so space is not wasted in duplication. # chmod 1777 /mnt/tmp # rm -fr /mnt/var/tmp # ln -s /tmp /mnt/var/tmp Note: /tmp will not work until the computer is rebooted. The file /etc/fstab describes the disk partition layout. However, the version copied to the target disk only reflects the Live CD layout. The installed /mnt/fstab.example can be used as a starting point for creating a new /etc/fstab. # vi /mnt/etc/fstab.example # mv /mnt/etc/fstab.example /mnt/etc/fstab A corrupted disklabel will render a disk useless. While this is thankfully very rare, having a backup of the new install's disklabel may stave off disaster at some point in the future. This is optional. (Adjust the slice name to reflect the actual installation.) # disklabel ad0s1 > /mnt/etc/disklabel.backup Note: Nothing is copied to the /tmp directory that was created in the previous step. This is not an error, since /tmp is intended only for temporary storage. Remove some unnecessary files copied over from the Live CD. # rm /mnt/boot/loader.conf # rm /mnt/boot.catalog # rm -r /mnt/rr_moved The system can now be rebooted. Be sure to remove the Live CD from the CDROM drive so that the computer can boot from the newly-installed disk. # reboot Note: Use the reboot command so that the disk can be unmounted cleanly. Hitting the power or reset buttons, while it won't hurt the Live CD, can leave the mounted disk in a inconsistent state. If the system refuses to boot, there are several options to try: * Old bootblocks can interfere with the initialization-process. To avoid this, zero-out the MBR. "of" should be changed to the correct disk entry if ad0 is not the targeted installation disk. # dd if=/dev/zero of=/dev/ad0 bs=32 count=16 * It is possible that the DragonFly slice is beyond cylinder 1023 on the hard disk, and can't be detected. Packet mode can fix this problem. # boot0cfg -o packet ad0 * If you can select CHS or LBA mode in your BIOS, try changing the mode to LBA. After a successful boot from the newly installed hard drive, the timezone should be set. Use the command tzsetup to set the appropriate time zone. # tzsetup -------------------------------------------------------------- 2.6 CD Installation - New system setup Once the new DragonFly system is booting from disk, there are a number of steps that may be useful before working further. The file /etc/rc.conf controls a number of options for booting the system. -------------------------------------------------------------- 2.6.1 Setting up rc.conf Depending on location, a different keyboard map may be needed. This is only necessary for computers outside of North America. # kbdmap Pick the appropriate keyboard map and remember the name. Place this name in /etc/rc.conf. For example: keymap="german.iso.kbd" The file /etc/rc.conf matches the one on the Live CD. Since it is now on an installed system are no longer running in a read-only environment, some changes should be made. Changes to this file will take effect after the next boot of the machine. These lines can be removed. syslogd_enable="NO" xntpd_enable="NO" cron_enable="NO" For a system which uses USB, this line will need to be modified to a value of "YES": usbd_enable="NO" inetd controls various small servers like telnet or ftp. By default, all servers are off, and must be individually uncommented in /etc/inetd.conf to start them. This is optional. inetd_enable="YES" # Run the network daemon dispatcher (YES/NO). inetd_program="/usr/sbin/inetd" # path to inetd, if you want a different one. inetd_flags="-wW" # Optional flags to inetd -------------------------------------------------------------- 2.6.2 Network Setup For acquiring an IP address through DHCP, place this entry in /etc/rc.conf, using the appropriate card name. (ep0 is used as an example here.) ifconfig_ep0="DHCP" For a fixed IP, /etc/rc.conf requires a few more lines of data. (Again, ep0 is used as an example here.) Supply the correct local values for IP, netmask, and default router. The hostname should reflect what is entered in DNS for this computer. ifconfig_ep0="inet 123.234.345.456 netmask 255.255.255.0" hostname="myhostname" defaultrouter="654.543.432.321" -------------------------------------------------------------- Chapter 3 UNIX Basics Rewritten by Chris Shumway. 3.1 Synopsis The following chapter will cover the basic commands and functionality of the DragonFly operating system. Much of this material is relevant for any UNIX-like operating system. Feel free to skim over this chapter if you are familiar with the material. If you are new to DragonFly, then you will definitely want to read through this chapter carefully. After reading this chapter, you will know: * How to use the ``virtual consoles'' of DragonFly. * How UNIX file permissions work along with understanding file flags in DragonFly. * The default DragonFly file system layout. * The DragonFly disk organization. * How to mount and unmount file systems. * What processes, daemons, and signals are. * What a shell is, and how to change your default login environment. * How to use basic text editors. * What devices and device nodes are. * What binary format is used under DragonFly. * How to read manual pages for more information. -------------------------------------------------------------- 3.2 Virtual Consoles and Terminals DragonFly can be used in various ways. One of them is typing commands to a text terminal. A lot of the flexibility and power of a UNIX operating system is readily available at your hands when using DragonFly this way. This section describes what ``terminals'' and ``consoles'' are, and how you can use them in DragonFly. -------------------------------------------------------------- 3.2.1 The Console If you have not configured DragonFly to automatically start a graphical environment during startup, the system will present you with a login prompt after it boots, right after the startup scripts finish running. You will see something similar to: Additional ABI support:. Local package initialization:. Additional TCP options:. Fri Sep 20 13:01:06 EEST 2002 DragonFlyBSD/i386 (pc3.example.org) (ttyv0) login: The messages might be a bit different on your system, but you will see something similar. The last two lines are what we are interested in right now. The second last line reads: DragonFlyBSD/i386 (pc3.example.org) (ttyv0) This line contains some bits of information about the system you have just booted. You are looking at a ``DragonFlyBSD'' console, running on an Intel or compatible processor of the x86 architecture[1]. The name of this machine (every UNIX machine has a name) is pc3.example.org, and you are now looking at its system console--the ttyv0 terminal. Finally, the last line is always: login: This is the part where you are supposed to type in your ``username'' to log into DragonFly. The next section describes how you can do this. -------------------------------------------------------------- 3.2.2 Logging into DragonFly DragonFly is a multiuser, multiprocessing system. This is the formal description that is usually given to a system that can be used by many different people, who simultaneously run a lot of programs on a single machine. Every multiuser system needs some way to distinguish one ``user'' from the rest. In DragonFly (and all the UNIX-like operating systems), this is accomplished by requiring that every user must ``log into'' the system before being able to run programs. Every user has a unique name (the ``username'') and a personal, secret key (the ``password''). DragonFly will ask for these two before allowing a user to run any programs. Right after DragonFly boots and finishes running its startup scripts[2], it will present you with a prompt and ask for a valid username: login: For the sake of this example, let us assume that your username is john. Type john at this prompt and press Enter. You should then be presented with a prompt to enter a ``password'': login: john Password: Type in john's password now, and press Enter. The password is not echoed! You need not worry about this right now. Suffice it to say that it is done for security reasons. If you have typed your password correctly, you should by now be logged into DragonFly and ready to try out all the available commands. You should see the MOTD or message of the day followed by a command prompt (a #, $, or % character). This indicates you have successfully logged into DragonFly. -------------------------------------------------------------- 3.2.3 Multiple Consoles Running UNIX commands in one console is fine, but DragonFly can run many programs at once. Having one console where commands can be typed would be a bit of a waste when an operating system like DragonFly can run dozens of programs at the same time. This is where ``virtual consoles'' can be very helpful. DragonFly can be configured to present you with many different virtual consoles. You can switch from one of them to any other virtual console by pressing a couple of keys on your keyboard. Each console has its own different output channel, and DragonFly takes care of properly redirecting keyboard input and monitor output as you switch from one virtual console to the next. Special key combinations have been reserved by DragonFly for switching consoles[3]. You can use Alt-F1, Alt-F2, through Alt-F8 to switch to a different virtual console in DragonFly. As you are switching from one console to the next, DragonFly takes care of saving and restoring the screen output. The result is an ``illusion'' of having multiple ``virtual'' screens and keyboards that you can use to type commands for DragonFly to run. The programs that you launch on one virtual console do not stop running when that console is not visible. They continue running when you have switched to a different virtual console. -------------------------------------------------------------- 3.2.4 The /etc/ttys File The default configuration of DragonFly will start up with eight virtual consoles. This is not a hardwired setting though, and you can easily customize your installation to boot with more or fewer virtual consoles. The number and settings of the virtual consoles are configured in the /etc/ttys file. You can use the /etc/ttys file to configure the virtual consoles of DragonFly. Each uncommented line in this file (lines that do not start with a # character) contains settings for a single terminal or virtual console. The default version of this file that ships with DragonFly configures nine virtual consoles, and enables eight of them. They are the lines that start with ttyv: # name getty type status comments # ttyv0 "/usr/libexec/getty Pc" cons25 on secure # Virtual terminals ttyv1 "/usr/libexec/getty Pc" cons25 on secure ttyv2 "/usr/libexec/getty Pc" cons25 on secure ttyv3 "/usr/libexec/getty Pc" cons25 on secure ttyv4 "/usr/libexec/getty Pc" cons25 on secure ttyv5 "/usr/libexec/getty Pc" cons25 on secure ttyv6 "/usr/libexec/getty Pc" cons25 on secure ttyv7 "/usr/libexec/getty Pc" cons25 on secure ttyv8 "/usr/pkg/xorg/bin/xdm -nodaemon" xterm off secure For a detailed description of every column in this file and all the options you can use to set things up for the virtual consoles, consult the ttys(5) manual page. -------------------------------------------------------------- 3.2.5 Single User Mode Console A detailed description of what ``single user mode'' is can be found in Section 7.5.2. It is worth noting that there is only one console when you are running DragonFly in single user mode. There are no virtual consoles available. The settings of the single user mode console can also be found in the /etc/ttys file. Look for the line that starts with console: # name getty type status comments # # If console is marked "insecure", then init will ask for the root password # when going to single-user mode. console none unknown off secure Note: As the comments above the console line indicate, you can edit this line and change secure to insecure. If you do that, when DragonFly boots into single user mode, it will still ask for the root password. Be careful when changing this to insecure. If you ever forget the root password, booting into single user mode is a bit involved. It is still possible, but it might be a bit hard for someone who is not very comfortable with the DragonFly booting process and the programs involved. -------------------------------------------------------------- 3.3 Permissions DragonFly, being a direct descendant of BSD UNIX, is based on several key UNIX concepts. The first and most pronounced is that DragonFly is a multi-user operating system. The system can handle several users all working simultaneously on completely unrelated tasks. The system is responsible for properly sharing and managing requests for hardware devices, peripherals, memory, and CPU time fairly to each user. Because the system is capable of supporting multiple users, everything the system manages has a set of permissions governing who can read, write, and execute the resource. These permissions are stored as three octets broken into three pieces, one for the owner of the file, one for the group that the file belongs to, and one for everyone else. This numerical representation works like this: Value Permission Directory Listing 0 No read, no write, no execute --- 1 No read, no write, execute --x 2 No read, write, no execute -w- 3 No read, write, execute -wx 4 Read, no write, no execute r-- 5 Read, no write, execute r-x 6 Read, write, no execute rw- 7 Read, write, execute rwx You can use the -l command line argument to ls(1) to view a long directory listing that includes a column with information about a file's permissions for the owner, group, and everyone else. For example, a ls -l in an arbitrary directory may show: % ls -l total 530 -rw-r--r-- 1 root wheel 512 Sep 5 12:31 myfile -rw-r--r-- 1 root wheel 512 Sep 5 12:31 otherfile -rw-r--r-- 1 root wheel 7680 Sep 5 12:31 email.txt ... Here is how the first column of ls -l is broken up: -rw-r--r-- The first (leftmost) character tells if this file is a regular file, a directory, a special character device, a socket, or any other special pseudo-file device. In this case, the - indicates a regular file. The next three characters, rw- in this example, give the permissions for the owner of the file. The next three characters, r--, give the permissions for the group that the file belongs to. The final three characters, r--, give the permissions for the rest of the world. A dash means that the permission is turned off. In the case of this file, the permissions are set so the owner can read and write to the file, the group can read the file, and the rest of the world can only read the file. According to the table above, the permissions for this file would be 644, where each digit represents the three parts of the file's permission. This is all well and good, but how does the system control permissions on devices? DragonFly actually treats most hardware devices as a file that programs can open, read, and write data to just like any other file. These special device files are stored on the /dev directory. Directories are also treated as files. They have read, write, and execute permissions. The executable bit for a directory has a slightly different meaning than that of files. When a directory is marked executable, it means it can be traversed into, that is, it is possible to ``cd'' (change directory) into it. This also means that within the directory it is possible to access files whose names are known (subject, of course, to the permissions on the files themselves). In particular, in order to perform a directory listing, read permission must be set on the directory, whilst to delete a file that one knows the name of, it is necessary to have write and execute permissions to the directory containing the file. There are more permission bits, but they are primarily used in special circumstances such as setuid binaries and sticky directories. If you want more information on file permissions and how to set them, be sure to look at the chmod(1) manual page. -------------------------------------------------------------- 3.3.1 Symbolic Permissions Contributed by Tom Rhodes. Symbolic permissions, sometimes referred to as symbolic expressions, use characters in place of octal values to assign permissions to files or directories. Symbolic expressions use the syntax of (who) (action) (permissions), where the following values are available: Option Letter Represents (who) u User (who) g Group owner (who) o Other (who) a All (``world'') (action) + Adding permissions (action) - Removing permissions (action) = Explicitly set permissions (permissions) r Read (permissions) w Write (permissions) x Execute (permissions) t Sticky bit (permissions) s Set UID or GID These values are used with the chmod(1) command just like before, but with letters. For an example, you could use the following command to block other users from accessing FILE: % chmod go= FILE A comma separated list can be provided when more than one set of changes to a file must be made. For example the following command will remove the groups and ``world'' write permission on FILE, then it adds the execute permissions for everyone: % chmod go-w,a+x FILE -------------------------------------------------------------- 3.3.2 DragonFly File Flags Contributed by Tom Rhodes. In addition to file permissions discussed previously, DragonFly supports the use of ``file flags.'' These flags add an additional level of security and control over files, but not directories. These file flags add an additional level of control over files, helping to ensure that in some cases not even the root can remove or alter files. File flags are altered by using the chflags(1) utility, using a simple interface. For example, to enable the system undeletable flag on the file file1, issue the following command: # chflags sunlink file1 And to disable the system undeletable flag, simply issue the previous command with ``no'' in front of the sunlink. Observe: # chflags nosunlink file1 To view the flags of this file, use the ls(1) with the -lo flags: # ls -lo file1 The output should look like the following: -rw-r--r-- 1 trhodes trhodes sunlnk 0 Mar 1 05:54 file1 Several flags may only added or removed to files by the root user. In other cases, the file owner may set these flags. It is recommended an administrator read over the chflags(1) and chflags(2) manual pages for more information. -------------------------------------------------------------- 3.4 Directory Structure The DragonFly directory hierarchy is fundamental to obtaining an overall understanding of the system. The most important concept to grasp is that of the root directory, ``/''. This directory is the first one mounted at boot time and it contains the base system necessary to prepare the operating system for multi-user operation. The root directory also contains mount points for every other file system that you may want to mount. A mount point is a directory where additional file systems can be grafted onto the root file system. This is further described in Section 3.5. Standard mount points include /usr, /var, /tmp, /mnt, and /cdrom. These directories are usually referenced to entries in the file /etc/fstab. /etc/fstab is a table of various file systems and mount points for reference by the system. Most of the file systems in /etc/fstab are mounted automatically at boot time from the script rc(8) unless they contain the noauto option. Details can be found in Section 3.6.1. A complete description of the file system hierarchy is available in hier(7). For now, a brief overview of the most common directories will suffice. Directory Description / Root directory of the file system. /bin/ User utilities fundamental to both single-user and multi-user environments. /boot/ Programs and configuration files used during operating system bootstrap. /boot/defaults/ Default bootstrapping configuration files; see loader.conf(5). /dev/ Device nodes; see intro(4). /etc/ System configuration files and scripts. /etc/defaults/ Default system configuration files; see rc(8). /etc/mail/ Configuration files for mail transport agents such as sendmail(8). /etc/namedb/ named configuration files; see named(8). /etc/periodic/ Scripts that are run daily, weekly, and monthly, via cron(8); see periodic(8). /etc/ppp/ ppp configuration files; see ppp(8). /mnt/ Empty directory commonly used by system administrators as a temporary mount point. /proc/ Process file system; see procfs(5), mount_procfs(8). /root/ Home directory for the root account. System programs and administration utilities /sbin/ fundamental to both single-user and multi-user environments. Temporary files. The contents of /tmp are usually NOT preserved across a system reboot. A /tmp/ memory-based file system is often mounted at /tmp. This can be automated with an entry in /etc/fstab; see mfs(8). /usr/ The majority of user utilities and applications. /usr/bin/ Common utilities, programming tools, and applications. /usr/include/ Standard C include files. /usr/lib/ Archive libraries. /usr/libdata/ Miscellaneous utility data files. /usr/libexec/ System daemons & system utilities (executed by other programs). Local executables, libraries, etc. Within /usr/local, the general layout sketched out by /usr/local/ hier(7) for /usr should be used. An exceptions is the man directory, which is directly under /usr/local rather than under /usr/local/share. /usr/obj/ Architecture-specific target tree produced by building the /usr/src tree. Used as the default destination for the files /usr/pkg installed via the pkgsrc tree or pkgsrc packages (optional). The configuration directory is tunable, but the default location is /usr/pkg/etc. /usr/pkg/xorg/ X11R6 distribution executables, libraries, etc (optional). /usr/pkgsrc The pkgsrc tree for installing packages (optional). /usr/sbin/ System daemons & system utilities (executed by users). /usr/share/ Architecture-independent files. /usr/src/ BSD and/or local source files. Multi-purpose log, temporary, transient, and spool /var/ files. A memory-based file system is sometimes mounted at /var. This can be automated with an entry in /etc/fstab; see mfs(8). /var/log/ Miscellaneous system log files. /var/mail/ User mailbox files. /var/spool/ Miscellaneous printer and mail system spooling directories. Temporary files. The files are usually preserved /var/tmp/ across a system reboot, unless /var is a memory-based file system. /var/yp NIS maps. -------------------------------------------------------------- 3.5 Disk Organization The smallest unit of organization that DragonFly uses to find files is the filename. Filenames are case-sensitive, which means that readme.txt and README.TXT are two separate files. DragonFly does not use the extension (.txt) of a file to determine whether the file is a program, or a document, or some other form of data. Files are stored in directories. A directory may contain no files, or it may contain many hundreds of files. A directory can also contain other directories, allowing you to build up a hierarchy of directories within one another. This makes it much easier to organize your data. Files and directories are referenced by giving the file or directory name, followed by a forward slash, /, followed by any other directory names that are necessary. If you have directory foo, which contains directory bar, which contains the file readme.txt, then the full name, or path to the file is foo/bar/readme.txt. Directories and files are stored in a file system. Each file system contains exactly one directory at the very top level, called the root directory for that file system. This root directory can then contain other directories. So far this is probably similar to any other operating system you may have used. There are a few differences; for example, MS-DOS uses \ to separate file and directory names, while Mac OS(R) uses :. DragonFly does not use drive letters, or other drive names in the path. You would not write c:/foo/bar/readme.txt on DragonFly. Instead, one file system is designated the root file system. The root file system's root directory is referred to as /. Every other file system is then mounted under the root file system. No matter how many disks you have on your DragonFly system, every directory appears to be part of the same disk. Suppose you have three file systems, called A, B, and C. Each file system has one root directory, which contains two other directories, called A1, A2 (and likewise B1, B2 and C1, C2). Call A the root file system. If you used the ls command to view the contents of this directory you would see two subdirectories, A1 and A2. The directory tree looks like this: / | +--- A1 | `--- A2 A file system must be mounted on to a directory in another file system. So now suppose that you mount file system B on to the directory A1. The root directory of B replaces A1, and the directories in B appear accordingly: / | +--- A1 | | | +--- B1 | | | `--- B2 | `--- A2 Any files that are in the B1 or B2 directories can be reached with the path /A1/B1 or /A1/B2 as necessary. Any files that were in /A1 have been temporarily hidden. They will reappear if B is unmounted from A. If B had been mounted on A2 then the diagram would look like this: / | +--- A1 | `--- A2 | +--- B1 | `--- B2 and the paths would be /A2/B1 and /A2/B2 respectively. File systems can be mounted on top of one another. Continuing the last example, the C file system could be mounted on top of the B1 directory in the B file system, leading to this arrangement: / | +--- A1 | `--- A2 | +--- B1 | | | +--- C1 | | | `--- C2 | `--- B2 Or C could be mounted directly on to the A file system, under the A1 directory: / | +--- A1 | | | +--- C1 | | | `--- C2 | `--- A2 | +--- B1 | `--- B2 If you are familiar with MS-DOS, this is similar, although not identical, to the join command. This is not normally something you need to concern yourself with. Typically you create file systems when installing DragonFly and decide where to mount them, and then never change them unless you add a new disk. It is entirely possible to have one large root file system, and not need to create any others. There are some drawbacks to this approach, and one advantage. Benefits of Multiple File Systems * Different file systems can have different mount options. For example, with careful planning, the root file system can be mounted read-only, making it impossible for you to inadvertently delete or edit a critical file. Separating user-writable file systems, such as /home, from other file systems also allows them to be mounted nosuid; this option prevents the suid/guid bits on executables stored on the file system from taking effect, possibly improving security. * DragonFly automatically optimizes the layout of files on a file system, depending on how the file system is being used. So a file system that contains many small files that are written frequently will have a different optimization to one that contains fewer, larger files. By having one big file system this optimization breaks down. * DragonFly's file systems are very robust should you lose power. However, a power loss at a critical point could still damage the structure of the file system. By splitting your data over multiple file systems it is more likely that the system will still come up, making it easier for you to restore from backup as necessary. Benefit of a Single File System * File systems are a fixed size. If you create a file system when you install DragonFly and give it a specific size, you may later discover that you need to make the partition bigger. The growfs(8) command makes it possible to increase the size of a file system on the fly. File systems are contained in partitions. This does not have the same meaning as the common usage of the term partition (for example, MS-DOS partition), because of DragonFly's UNIX heritage. Each partition is identified by a letter from a through to h. Each partition can contain only one file system, which means that file systems are often described by either their typical mount point in the file system hierarchy, or the letter of the partition they are contained in. DragonFly also uses disk space for swap space. Swap space provides DragonFly with virtual memory. This allows your computer to behave as though it has much more memory than it actually does. When DragonFly runs out of memory it moves some of the data that is not currently being used to the swap space, and moves it back in (moving something else out) when it needs it. Some partitions have certain conventions associated with them. Partition Convention a Normally contains the root file system b Normally contains swap space Normally the same size as the enclosing slice. This allows utilities that need to work on the entire slice c (for example, a bad block scanner) to work on the c partition. You would not normally create a file system on this partition. Partition d used to have a special meaning associated d with it, although that is now gone. To this day, some tools may operate oddly if told to work on partition d. Each partition-that-contains-a-file-system is stored in what DragonFly calls a slice. Slice is DragonFly's term for what the common call partitions, and again, this is because of DragonFly's UNIX background. Slices are numbered, starting at 1, through to 4. Slice numbers follow the device name, prefixed with an s, starting at 1. So ``da0s1'' is the first slice on the first SCSI drive. There can only be four physical slices on a disk, but you can have logical slices inside physical slices of the appropriate type. These extended slices are numbered starting at 5, so ``ad0s5'' is the first extended slice on the first IDE disk. These devices are used by file systems that expect to occupy a slice. Slices, ``dangerously dedicated'' physical drives, and other drives contain partitions, which are represented as letters from a to h. This letter is appended to the device name, so ``da0a'' is the a partition on the first da drive, which is ``dangerously dedicated''. ``ad1s3e'' is the fifth partition in the third slice of the second IDE disk drive. Finally, each disk on the system is identified. A disk name starts with a code that indicates the type of disk, and then a number, indicating which disk it is. Unlike slices, disk numbering starts at 0. Common codes that you will see are listed in Table 3-1. When referring to a partition DragonFly requires that you also name the slice and disk that contains the partition, and when referring to a slice you should also refer to the disk name. Do this by listing the disk name, s, the slice number, and then the partition letter. Examples are shown in Example 3-1. Example 3-2 shows a conceptual model of the disk layout that should help make things clearer. In order to install DragonFly you must first configure the disk slices, then create partitions within the slice you will use for DragonFly, and then create a file system (or swap space) in each partition, and decide where that file system will be mounted. Table 3-1. Disk Device Codes Code Meaning ad ATAPI (IDE) disk da SCSI direct access disk acd ATAPI (IDE) CDROM cd SCSI CDROM fd Floppy disk Example 3-1. Sample Disk, Slice, and Partition Names Name Meaning ad0s1a The first partition (a) on the first slice (s1) on the first IDE disk (ad0). da1s2e The fifth partition (e) on the second slice (s2) on the second SCSI disk (da1). Example 3-2. Conceptual Model of a Disk This diagram shows DragonFly's view of the first IDE disk attached to the system. Assume that the disk is 4 GB in size, and contains two 2 GB slices (MS-DOS partitions). The first slice contains a MS-DOS disk, C:, and the second slice contains a DragonFly installation. This example DragonFly installation has three partitions, and a swap partition. The three partitions will each hold a file system. Partition a will be used for the root file system, e for the /var directory hierarchy, and f for the /usr directory hierarchy. .-----------------. --. | | | | DOS / Windows | | : : > First slice, ad0s1 : : | | | | :=================: ==: --. | | | Partition a, mounted as / | | | > referred to as ad0s2a | | | | | :-----------------: ==: | | | | Partition b, used as swap | | | > referred to as ad0s2b | | | | | :-----------------: ==: | Partition c, no | | | Partition e, used as /var > file system, all | | > referred to as ad0s2e | of DragonFly slice, | | | | ad0s2c :-----------------: ==: | | | | | : : | Partition f, used as /usr | : : > referred to as ad0s2f | : : | | | | | | | | --' | `-----------------' --' -------------------------------------------------------------- 3.6 Mounting and Unmounting File Systems The file system is best visualized as a tree, rooted, as it were, at /. /dev, /usr, and the other directories in the root directory are branches, which may have their own branches, such as /usr/local, and so on. There are various reasons to house some of these directories on separate file systems. /var contains the directories log/, spool/, and various types of temporary files, and as such, may get filled up. Filling up the root file system is not a good idea, so splitting /var from / is often favorable. Another common reason to contain certain directory trees on other file systems is if they are to be housed on separate physical disks, or are separate virtual disks, such as Network File System mounts, or CDROM drives. -------------------------------------------------------------- 3.6.1 The fstab File During the boot process, file systems listed in /etc/fstab are automatically mounted (unless they are listed with the noauto option). The /etc/fstab file contains a list of lines of the following format: device /mount-point fstype options dumpfreq passno device A device name (which should exist), as explained in Section 12.2. mount-point A directory (which should exist), on which to mount the file system. fstype The file system type to pass to mount(8). The default DragonFly file system is ufs. options Either rw for read-write file systems, or ro for read-only file systems, followed by any other options that may be needed. A common option is noauto for file systems not normally mounted during the boot sequence. Other options are listed in the mount(8) manual page. dumpfreq This is used by dump(8) to determine which file systems require dumping. If the field is missing, a value of zero is assumed. passno This determines the order in which file systems should be checked. File systems that should be skipped should have their passno set to zero. The root file system (which needs to be checked before everything else) should have its passno set to one, and other file systems' passno should be set to values greater than one. If more than one file systems have the same passno then fsck(8) will attempt to check file systems in parallel if possible. Consult the fstab(5) manual page for more information on the format of the /etc/fstab file and the options it contains. -------------------------------------------------------------- 3.6.2 The mount Command The mount(8) command is what is ultimately used to mount file systems. In its most basic form, you use: # mount device mountpoint There are plenty of options, as mentioned in the mount(8) manual page, but the most common are: Mount Options -a Mount all the file systems listed in /etc/fstab. Except those marked as ``noauto'', excluded by the -t flag, or those that are already mounted. -d Do everything except for the actual mount system call. This option is useful in conjunction with the -v flag to determine what mount(8) is actually trying to do. -f Force the mount of an unclean file system (dangerous), or forces the revocation of write access when downgrading a file system's mount status from read-write to read-only. -r Mount the file system read-only. This is identical to using the rdonly argument to the -o option. -t fstype Mount the given file system as the given file system type, or mount only file systems of the given type, if given the -a option. ``ufs'' is the default file system type. -u Update mount options on the file system. -v Be verbose. -w Mount the file system read-write. The -o option takes a comma-separated list of the options, including the following: nodev Do not interpret special devices on the file system. This is a useful security option. noexec Do not allow execution of binaries on this file system. This is also a useful security option. nosuid Do not interpret setuid or setgid flags on the file system. This is also a useful security option. -------------------------------------------------------------- 3.6.3 The umount Command The umount(8) command takes, as a parameter, one of a mountpoint, a device name, or the -a or -A option. All forms take -f to force unmounting, and -v for verbosity. Be warned that -f is not generally a good idea. Forcibly unmounting file systems might crash the computer or damage data on the file system. -a and -A are used to unmount all mounted file systems, possibly modified by the file system types listed after -t. -A, however, does not attempt to unmount the root file system. -------------------------------------------------------------- 3.7 Processes DragonFly is a multi-tasking operating system. This means that it seems as though more than one program is running at once. Each program running at any one time is called a process. Every command you run will start at least one new process, and there are a number of system processes that run all the time, keeping the system functional. Each process is uniquely identified by a number called a process ID, or PID, and, like files, each process also has one owner and group. The owner and group information is used to determine what files and devices the process can open, using the file permissions discussed earlier. Most processes also have a parent process. The parent process is the process that started them. For example, if you are typing commands to the shell then the shell is a process, and any commands you run are also processes. Each process you run in this way will have your shell as its parent process. The exception to this is a special process called init(8). init is always the first process, so its PID is always 1. init is started automatically by the kernel when DragonFly starts. Two commands are particularly useful to see the processes on the system, ps(1) and top(1). The ps command is used to show a static list of the currently running processes, and can show their PID, how much memory they are using, the command line they were started with, and so on. The top command displays all the running processes, and updates the display every few seconds, so that you can interactively see what your computer is doing. By default, ps only shows you the commands that are running and are owned by you. For example: % ps PID TT STAT TIME COMMAND 298 p0 Ss 0:01.10 tcsh 7078 p0 S 2:40.88 xemacs mdoc.xsl (xemacs-21.1.14) 37393 p0 I 0:03.11 xemacs freebsd.dsl (xemacs-21.1.14) 48630 p0 S 2:50.89 /usr/local/lib/netscape-linux/navigator-linux-4.77.bi 48730 p0 IW 0:00.00 (dns helper) (navigator-linux-) 72210 p0 R+ 0:00.00 ps 390 p1 Is 0:01.14 tcsh 7059 p2 Is+ 1:36.18 /usr/local/bin/mutt -y 6688 p3 IWs 0:00.00 tcsh 10735 p4 IWs 0:00.00 tcsh 20256 p5 IWs 0:00.00 tcsh 262 v0 IWs 0:00.00 -tcsh (tcsh) 270 v0 IW+ 0:00.00 /bin/sh /usr/X11R6/bin/startx -- -bpp 16 280 v0 IW+ 0:00.00 xinit /home/nik/.xinitrc -- -bpp 16 284 v0 IW 0:00.00 /bin/sh /home/nik/.xinitrc 285 v0 S 0:38.45 /usr/X11R6/bin/sawfish As you can see in this example, the output from ps(1) is organized into a number of columns. PID is the process ID discussed earlier. PIDs are assigned starting from 1, go up to 99999, and wrap around back to the beginning when you run out. The TT column shows the tty the program is running on, and can safely be ignored for the moment. STAT shows the program's state, and again, can be safely ignored. TIME is the amount of time the program has been running on the CPU--this is usually not the elapsed time since you started the program, as most programs spend a lot of time waiting for things to happen before they need to spend time on the CPU. Finally, COMMAND is the command line that was used to run the program. ps(1) supports a number of different options to change the information that is displayed. One of the most useful sets is auxww. a displays information about all the running processes, not just your own. u displays the username of the process' owner, as well as memory usage. x displays information about daemon processes, and ww causes ps(1) to display the full command line, rather than truncating it once it gets too long to fit on the screen. The output from top(1) is similar. A sample session looks like this: % top last pid: 72257; load averages: 0.13, 0.09, 0.03 up 0+13:38:33 22:39:10 47 processes: 1 running, 46 sleeping CPU states: 12.6% user, 0.0% nice, 7.8% system, 0.0% interrupt, 79.7% idle Mem: 36M Active, 5256K Inact, 13M Wired, 6312K Cache, 15M Buf, 408K Free Swap: 256M Total, 38M Used, 217M Free, 15% Inuse PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND 72257 nik 28 0 1960K 1044K RUN 0:00 14.86% 1.42% top 7078 nik 2 0 15280K 10960K select 2:54 0.88% 0.88% xemacs-21.1.14 281 nik 2 0 18636K 7112K select 5:36 0.73% 0.73% XF86_SVGA 296 nik 2 0 3240K 1644K select 0:12 0.05% 0.05% xterm 48630 nik 2 0 29816K 9148K select 3:18 0.00% 0.00% navigator-linu 175 root 2 0 924K 252K select 1:41 0.00% 0.00% syslogd 7059 nik 2 0 7260K 4644K poll 1:38 0.00% 0.00% mutt ... The output is split into two sections. The header (the first five lines) shows the PID of the last process to run, the system load averages (which are a measure of how busy the system is), the system uptime (time since the last reboot) and the current time. The other figures in the header relate to how many processes are running (47 in this case), how much memory and swap space has been taken up, and how much time the system is spending in different CPU states. Below that are a series of columns containing similar information to the output from ps(1). As before you can see the PID, the username, the amount of CPU time taken, and the command that was run. top(1) also defaults to showing you the amount of memory space taken by the process. This is split into two columns, one for total size, and one for resident size--total size is how much memory the application has needed, and the resident size is how much it is actually using at the moment. In this example you can see that Netscape(R) has required almost 30 MB of RAM, but is currently only using 9 MB. top(1) automatically updates this display every two seconds; this can be changed with the s option. -------------------------------------------------------------- 3.8 Daemons, Signals, and Killing Processes When you run an editor it is easy to control the editor, tell it to load files, and so on. You can do this because the editor provides facilities to do so, and because the editor is attached to a terminal. Some programs are not designed to be run with continuous user input, and so they disconnect from the terminal at the first opportunity. For example, a web server spends all day responding to web requests, it normally does not need any input from you. Programs that transport email from site to site are another example of this class of application. We call these programs daemons. Daemons were characters in Greek mythology; neither good or evil, they were little attendant spirits that, by and large, did useful things for mankind. Much like the web servers and mail servers of today do useful things. This is why the mascot for a number of BSD-based operating systems has, for a long time, been a cheerful looking daemon with sneakers and a pitchfork. There is a convention to name programs that normally run as daemons with a trailing ``d''. BIND is the Berkeley Internet Name Daemon (and the actual program that executes is called named), the Apache web server program is called httpd, the line printer spooling daemon is lpd and so on. This is a convention, not a hard and fast rule; for example, the main mail daemon for the Sendmail application is called sendmail, and not maild, as you might imagine. Sometimes you will need to communicate with a daemon process. These communications are called signals, and you can communicate with a daemon (or with any other running process) by sending it a signal. There are a number of different signals that you can send--some of them have a specific meaning, others are interpreted by the application, and the application's documentation will tell you how that application interprets signals. You can only send a signal to a process that you own. If you send a signal to someone else's process with kill(1) or kill(2) permission will be denied. The exception to this is the root user, who can send signals to everyone's processes. DragonFly will also send applications signals in some cases. If an application is badly written, and tries to access memory that it is not supposed to, DragonFly sends the process the Segmentation Violation signal (SIGSEGV). If an application has used the alarm(3) system call to be alerted after a period of time has elapsed then it will be sent the Alarm signal (SIGALRM), and so on. Two signals can be used to stop a process, SIGTERM and SIGKILL. SIGTERM is the polite way to kill a process; the process can catch the signal, realize that you want it to shut down, close any log files it may have open, and generally finish whatever it is doing at the time before shutting down. In some cases a process may even ignore SIGTERM if it is in the middle of some task that can not be interrupted. SIGKILL can not be ignored by a process. This is the ``I do not care what you are doing, stop right now'' signal. If you send SIGKILL to a process then DragonFly will stop that process there and then[4]. The other signals you might want to use are SIGHUP, SIGUSR1, and SIGUSR2. These are general purpose signals, and different applications will do different things when they are sent. Suppose that you have changed your web server's configuration file--you would like to tell the web server to re-read its configuration. You could stop and restart httpd, but this would result in a brief outage period on your web server, which may be undesirable. Most daemons are written to respond to the SIGHUP signal by re-reading their configuration file. So instead of killing and restarting httpd you would send it the SIGHUP signal. Because there is no standard way to respond to these signals, different daemons will have different behavior, so be sure and read the documentation for the daemon in question. Signals are sent using the kill(1) command, as this example shows. Sending a Signal to a Process This example shows how to send a signal to inetd(8). The inetd configuration file is /etc/inetd.conf, and inetd will re-read this configuration file when it is sent SIGHUP. 1. Find the process ID of the process you want to send the signal to. Do this using ps(1) and grep(1). The grep(1) command is used to search through output, looking for the string you specify. This command is run as a normal user, and inetd(8) is run as root, so the ax options must be given to ps(1). % ps -ax | grep inetd 198 ?? IWs 0:00.00 inetd -wW So the inetd(8) PID is 198. In some cases the grep inetd command might also occur in this output. This is because of the way ps(1) has to find the list of running processes. 2. Use kill(1) to send the signal. Because inetd(8) is being run by root you must use su(1) to become root first. % su Password: # /bin/kill -s HUP 198 In common with most UNIX commands, kill(1) will not print any output if it is successful. If you send a signal to a process that you do not own then you will see ``kill: PID: Operation not permitted''. If you mistype the PID you will either send the signal to the wrong process, which could be bad, or, if you are lucky, you will have sent the signal to a PID that is not currently in use, and you will see ``kill: PID: No such process''. Why Use /bin/kill?: Many shells provide the kill command as a built in command; that is, the shell will send the signal directly, rather than running /bin/kill. This can be very useful, but different shells have a different syntax for specifying the name of the signal to send. Rather than try to learn all of them, it can be simpler just to use the /bin/kill ... command directly. Sending other signals is very similar, just substitute TERM or KILL in the command line as necessary. Important: Killing random process on the system can be a bad idea. In particular, init(8), process ID 1, is very special. Running /bin/kill -s KILL 1 is a quick way to shutdown your system. Always double check the arguments you run kill(1) with before you press Return. -------------------------------------------------------------- 3.9 Shells In DragonFly, a lot of everyday work is done in a command line interface called a shell. A shell's main job is to take commands from the input channel and execute them. A lot of shells also have built in functions to help everyday tasks such as file management, file globbing, command line editing, command macros, and environment variables. DragonFly comes with a set of shells, such as sh, the Bourne Shell, and tcsh, the improved C-shell. Many other shells are available from pkgsrc, such as zsh and bash. Which shell do you use? It is really a matter of taste. If you are a C programmer you might feel more comfortable with a C-like shell such as tcsh. If you have come from Linux or are new to a UNIX command line interface you might try bash. The point is that each shell has unique properties that may or may not work with your preferred working environment, and that you have a choice of what shell to use. One common feature in a shell is filename completion. Given the typing of the first few letters of a command or filename, you can usually have the shell automatically complete the rest of the command or filename by hitting the Tab key on the keyboard. Here is an example. Suppose you have two files called foobar and foo.bar. You want to delete foo.bar. So what you would type on the keyboard is: rm fo[Tab].[Tab]. The shell would print out rm foo[BEEP].bar. The [BEEP] is the console bell, which is the shell telling me it was unable to totally complete the filename because there is more than one match. Both foobar and foo.bar start with fo, but it was able to complete to foo. If you type in ., then hit Tab again, the shell would be able to fill in the rest of the filename for you. Another feature of the shell is the use of environment variables. Environment variables are a variable key pair stored in the shell's environment space. This space can be read by any program invoked by the shell, and thus contains a lot of program configuration. Here is a list of common environment variables and what they mean: Variable Description USER Current logged in user's name. PATH Colon separated list of directories to search for binaries. DISPLAY Network name of the X11 display to connect to, if available. SHELL The current shell. TERM The name of the user's terminal. Used to determine the capabilities of the terminal. TERMCAP Database entry of the terminal escape codes to perform various terminal functions. OSTYPE Type of operating system. e.g., DragonFly. MACHTYPE The CPU architecture that the system is running on. EDITOR The user's preferred text editor. PAGER The user's preferred text pager. MANPATH Colon separated list of directories to search for manual pages. Setting an environment variable differs somewhat from shell to shell. For example, in the C-Style shells such as tcsh and csh, you would use setenv to set environment variables. Under Bourne shells such as sh and bash, you would use export to set your current environment variables. For example, to set or modify the EDITOR environment variable, under csh or tcsh a command like this would set EDITOR to /usr/pkg/bin/emacs: % setenv EDITOR /usr/pkg/bin/emacs Under Bourne shells: % export EDITOR="/usr/pkg/bin/emacs" You can also make most shells expand the environment variable by placing a $ character in front of it on the command line. For example, echo $TERM would print out whatever $TERM is set to, because the shell expands $TERM and passes it on to echo. Shells treat a lot of special characters, called meta-characters as special representations of data. The most common one is the * character, which represents any number of characters in a filename. These special meta-characters can be used to do filename globbing. For example, typing in echo * is almost the same as typing in ls because the shell takes all the files that match * and puts them on the command line for echo to see. To prevent the shell from interpreting these special characters, they can be escaped from the shell by putting a backslash (\) character in front of them. echo $TERM prints whatever your terminal is set to. echo \$TERM prints $TERM as is. -------------------------------------------------------------- 3.9.1 Changing Your Shell The easiest way to change your shell is to use the chsh command. Running chsh will place you into the editor that is in your EDITOR environment variable; if it is not set, you will be placed in vi. Change the ``Shell:'' line accordingly. You can also give chsh the -s option; this will set your shell for you, without requiring you to enter an editor. For example, if you wanted to change your shell to bash, the following should do the trick: % chsh -s /usr/pkg/bin/bash Note: The shell that you wish to use must be present in the /etc/shells file. If you have installed a shell from the pkgsrc tree , then this should have been done for you already. If you installed the shell by hand, you must do this. For example, if you installed bash by hand and placed it into /usr/local/bin, you would want to: # echo "/usr/local/bin/bash" >> /etc/shells Then rerun chsh. -------------------------------------------------------------- 3.10 Text Editors A lot of configuration in DragonFly is done by editing text files. Because of this, it would be a good idea to become familiar with a text editor. DragonFly comes with a few as part of the base system, and many more are available in the pkgsrc tree. The easiest and simplest editor to learn is an editor called ee, which stands for easy editor. To start ee, one would type at the command line ee filename where filename is the name of the file to be edited. For example, to edit /etc/rc.conf, type in ee /etc/rc.conf. Once inside of ee, all of the commands for manipulating the editor's functions are listed at the top of the display. The caret ^ character represents the Ctrl key on the keyboard, so ^e expands to the key combination Ctrl+e. To leave ee, hit the Esc key, then choose leave editor. The editor will prompt you to save any changes if the file has been modified. DragonFly also comes with more powerful text editors such as vi as part of the base system, while other editors, like emacs and vim, are part of the pkgsrc tree. These editors offer much more functionality and power at the expense of being a little more complicated to learn. However if you plan on doing a lot of text editing, learning a more powerful editor such as vim or emacs will save you much more time in the long run. -------------------------------------------------------------- 3.11 Devices and Device Nodes A device is a term used mostly for hardware-related activities in a system, including disks, printers, graphics cards, and keyboards. When DragonFly boots, the majority of what DragonFly displays are devices being detected. You can look through the boot messages again by viewing /var/run/dmesg.boot. For example, acd0 is the first IDE CDROM drive, while kbd0 represents the keyboard. Most of these devices in a UNIX operating system must be accessed through special files called device nodes, which are located in the /dev directory. -------------------------------------------------------------- 3.11.1 Creating Device Nodes with MAKEDEV When adding a new device to your system, or compiling in support for additional devices, you may need to create one or more device nodes for the new devices. Device nodes are created using the MAKEDEV(8) script as shown below: # cd /dev # sh MAKEDEV ad1 This example would make the proper device nodes for the second IDE drive when installed. -------------------------------------------------------------- 3.12 Binary Formats To understand why DragonFly uses the elf(5) format, you must first know a little about the three currently ``dominant'' executable formats for UNIX: * a.out(5) The oldest and ``classic'' UNIX object format. It uses a short and compact header with a magic number at the beginning that is often used to characterize the format (see a.out(5) for more details). It contains three loaded segments: .text, .data, and .bss plus a symbol table and a string table. * COFF The SVR3 object format. The header now comprises a section table, so you can have more than just .text, .data, and .bss sections. * elf(5) The successor to COFF, featuring multiple sections and 32-bit or 64-bit possible values. One major drawback: ELF was also designed with the assumption that there would be only one ABI per system architecture. That assumption is actually quite incorrect, and not even in the commercial SYSV world (which has at least three ABIs: SVR4, Solaris, SCO) does it hold true. DragonFly tries to work around this problem somewhat by providing a utility for branding a known ELF executable with information about the ABI it is compliant with. See the manual page for brandelf(1) for more information. DragonFly runs ELF. So, why are there so many different formats? Back in the dim, dark past, there was simple hardware. This simple hardware supported a simple, small system. a.out was completely adequate for the job of representing binaries on this simple system (a PDP-11). As people ported UNIX from this simple system, they retained the a.out format because it was sufficient for the early ports of UNIX to architectures like the Motorola 68k, VAXen, etc. Then some bright hardware engineer decided that if he could force software to do some sleazy tricks, then he would be able to shave a few gates off the design and allow his CPU core to run faster. While it was made to work with this new kind of hardware (known these days as RISC), a.out was ill-suited for this hardware, so many formats were developed to get to a better performance from this hardware than the limited, simple a.out format could offer. Things like COFF, ECOFF, and a few obscure others were invented and their limitations explored before things seemed to settle on ELF. In addition, program sizes were getting huge and disks (and physical memory) were still relatively small so the concept of a shared library was born. The VM system also became more sophisticated. While each one of these advancements was done using the a.out format, its usefulness was stretched more and more with each new feature. In addition, people wanted to dynamically load things at run time, or to junk parts of their program after the init code had run to save in core memory and swap space. Languages became more sophisticated and people wanted code called before main automatically. Lots of hacks were done to the a.out format to allow all of these things to happen, and they basically worked for a time. In time, a.out was not up to handling all these problems without an ever increasing overhead in code and complexity. While ELF solved many of these problems, it would be painful to switch from the system that basically worked. So ELF had to wait until it was more painful to remain with a.out than it was to migrate to ELF. ELF is more expressive than a.out and allows more extensibility in the base system. The ELF tools are better maintained, and offer cross compilation support, which is important to many people. ELF may be a little slower than a.out, but trying to measure it can be difficult. There are also numerous details that are different between the two in how they map pages, handle init code, etc. None of these are very important, but they are differences. -------------------------------------------------------------- 3.13 For More Information 3.13.1 Manual Pages The most comprehensive documentation on DragonFly is in the form of manual pages. Nearly every program on the system comes with a short reference manual explaining the basic operation and various arguments. These manuals can be viewed with the man command. Use of the man command is simple: % man command command is the name of the command you wish to learn about. For example, to learn more about ls command type: % man ls The online manual is divided up into numbered sections: 1. User commands. 2. System calls and error numbers. 3. Functions in the C libraries. 4. Device drivers. 5. File formats. 6. Games and other diversions. 7. Miscellaneous information. 8. System maintenance and operation commands. 9. Kernel internals. In some cases, the same topic may appear in more than one section of the online manual. For example, there is a chmod user command and a chmod() system call. In this case, you can tell the man command which one you want by specifying the section: % man 1 chmod This will display the manual page for the user command chmod. References to a particular section of the online manual are traditionally placed in parenthesis in written documentation, so chmod(1) refers to the chmod user command and chmod(2) refers to the system call. This is fine if you know the name of the command and simply wish to know how to use it, but what if you cannot recall the command name? You can use man to search for keywords in the command descriptions by using the -k switch: % man -k mail With this command you will be presented with a list of commands that have the keyword ``mail'' in their descriptions. This is actually functionally equivalent to using the apropos command. So, you are looking at all those fancy commands in /usr/bin but do not have the faintest idea what most of them actually do? Simply do: % cd /usr/bin % man -f * or % cd /usr/bin % whatis * which does the same thing. -------------------------------------------------------------- 3.13.2 GNU Info Files DragonFly includes many applications and utilities produced by the Free Software Foundation (FSF). In addition to manual pages, these programs come with more extensive hypertext documents called info files which can be viewed with the info command or, if you installed emacs, the info mode of emacs. To use the info(1) command, simply type: % info For a brief introduction, type h. For a quick command reference, type ?. -------------------------------------------------------------- Chapter 4 Installing Applications using NetBSD's pkgsrc framework 4.1 Synopsis DragonFly is bundled with a rich collection of system tools as part of the base system. However, there is only so much one can do before needing to install an additional third-party application to get real work done. DragonFly utilizes NetBSD's pkgsrc framework (pkgsrc.org) for installing third party software on your system. This system may be used to install the newest version of your favorite applications from local media or straight off the network. After reading this chapter, you will know: * How to install third-party binary software packages from the pkgsrc collection. * How to build third-party software from the pkgsrc collection. * Where to find DragonFly-specific changes to packages. * How to remove previously installed packages. * How to override the default values that the pkgsrc collection uses. * How to upgrade your packages. -------------------------------------------------------------- 4.2 Overview of Software Installation If you have used a UNIX system before you will know that the typical procedure for installing third party software goes something like this: 1. Download the software, which might be distributed in source code format, or as a binary. 2. Unpack the software from its distribution format (typicall