The Project Gutenberg EBook of Debian GNU/Linux: Guide to Installation and Usage by John Goerzen and Ossama Othman Copyright laws are changing all over the world. Be sure to check the copyright laws for your country before downloading or redistributing this or any other Project Gutenberg eBook. This header should be the first thing seen when viewing this Project Gutenberg file. Please do not remove it. Do not change or edit the header without written permission. Please read the "legal small print," and other information about the eBook and Project Gutenberg at the bottom of this file. Included is important information about your specific rights and restrictions in how the file may be used. You can also find out about how to make a donation to Project Gutenberg, and how to get involved. **Welcome To The World of Free Plain Vanilla Electronic Texts** **eBooks Readable By Both Humans and By Computers, Since 1971** *****These eBooks Were Prepared By Thousands of Volunteers!***** Title: Debian GNU/Linux: Guide to Installation and Usage Author: John Goerzen and Ossama Othman Release Date: September, 2004 [EBook #6527] [Yes, we are more than one year ahead of schedule] [This file was first posted on December 25, 2002] Edition: 10 Language: English Character set encoding: ASCII *** START OF THE PROJECT GUTENBERG EBOOK, DEBIAN GNU/LINUX: GUIDE TO INSTALLATION AND USAGE *** Debian GNU/Linux: Guide to Installation and Usage John Goerzen and Ossama Othman (c) 1998, 1999 Software in the Public Interest, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided also that the sections that reprint ``The GNU General Public License'' and other clearly marked sections held under separate copyright are reproduced under the conditions given within them, and provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language under the conditions for modified versions. ``The GNU General Public License'' may be included in a translation approved by the Free Software Foundation instead of in the original English. At your option, you may distribute verbatim and modified versions of this document under the terms of the GNU General Public License, excepting the clearly marked sections held under separate copyright. Contents * List of Figures * List of Tables * Acknowledgments * Preface * Guide * Introduction * What Is Debian? * Who Creates Debian? * A Multiuser, Multitasking Operating System * What Is Free Software? * About This Book * How to Read This Book * Conventions * Getting Started * Supported Hardware * Memory and Disk Space Requirements * Before You Start * Information You Will Need * Partitioning Your Hard Drive * Background * Planning Use of the System * PC Disk Limitations * Device Names in Linux * Recommended Partitioning Scheme * Partitioning Prior to Installation * Debian Installation Steps * Choosing Your Installation Media * Installing from a CD-ROM * Booting from Floppies * Booting the Installation System * Step-by-Step Installation * Select Color or Monochrome Display * Debian GNU/Linux Installation Main Menu * Configure the Keyboard * Last Chance to Back Up! * Partition a Hard Disk * Initialize and Activate a Swap Partition * Initialize a Linux Partition * Mount a Previously-Initialized Partition * Install Operating System Kernel and Modules * Configure PCMCIA Support * Configure Device Driver Modules * Configure the Network * Install the Base System * Configure the Base System * Make Linux Bootable Directly from the Hard Disk * Make a Boot Floppy * The Moment of Truth * Set the Root Password * Create an Ordinary User * Shadow Password Support * Remove PCMCIA * Select and Install Profiles * Package Installation with dselect * Introduction * Once dselect Is Launched * A Few Hints in Conclusion * Glossary * Logging In * First Steps * Command History and Editing the Command Line * Working as Root * Virtual Consoles * Shutting Down * The Basics * The Command Line and Man Pages * Describing the Command Line * Files and Directories * Using Files: A Tutorial * Dot Files and ls -a * Processes * The Shell * Managing Processes with bash * A Few bash Features * Tab Completion * Managing Your Identity * Using the Shell * Environment Variables * Where Commands Reside: The PATH Variable * Configuration Files * System-Wide Versus User-Specific Configuration * Aliases * Controlling Input and Output * stdin, stdout, Pipelines, and Redirection * Filename Expansion * More on Files * Permissions * File Ownership * Mode * Permissions in Practice * Files Present and Their Locations * File Compression with gzip * Finding Files * Determining a File's Contents * Using a File Manager * Working with Text Files * Viewing Text Files * Text Editors * Using ae * The X Window System * Introduction to X * Starting the X Environment * Basic X Operations * The Mouse * X Clients * Troubleshooting * Leaving the X Environment * Customizing Your X Startup * Filesystems * Concepts * mount and /etc/fstab * Mounting a Filesystem * Example: Mounting a CD-ROM * /etc/fstab: Automating the Mount Process * Removable Disks (Floppies, Zip Disks, Etc.) * Backup Tools * tar * Networking * PPP * Introduction * Preparation * The Easy Way: wvdial * Ethernet * Removing and Installing Software * What a Package Maintenance Utility Does * dpkg * dselect * Compiling Software * Advanced Topics * Regular Expressions * Advanced Files * The Real Nature of Files: Hard Links and Inodes * Types of Files * The proc Filesystem * Large-Scale Copying * Security * Software Development with Debian * Reference * Reading Documentation and Getting Help * Kinds of Documentation * Using info * HOWTOs * Personal Help * Getting Information from the System * Troubleshooting * Common Difficulties * Working with Strangely-Named Files * Printing * X Problems * Troubleshooting the Boot Process * Booting the System * The GNU General Public License * Index * About this document ... List of Figures 1. cfdisk screenshot 2. dselect Access screen 3. Sample session with su 4. Sample printenv output 5. Changing the prompt 6. Redirecting output List of Tables 1. Linux Device Names 2. Special dselect keys 3. dselect Package States 4. Expected Package Category States 5. Permissions in Linux Acknowledgments Many people have helped with this manual. We'd like to thank everyone involved, and we try to do that here. Thanks to Havoc Pennington, Ardo van Rangelrooij, Larry Greenfield, Thalia Hooker, Day Irmiter, James Treacy, Craig Sawyer, Oliver Elphick, Ivan E. Moore II, Eric Fischer, Mike Touloumtzis, and the Linux Documentation Project for their work on what became the Debian Tutorial document. Thanks to Richard Stallman of the Free Software Foundation for advice and editing. Thanks to Bruce Perens, Sven Rudolph, Igor Grobman, James Treacy, Adam Di Carlo, Tapio Lehtonen, and Stephane Bortzmeyer for their work on what became a collection of installation documents. Of course, it's impossible to thank the hundreds of Debian developers and thousands of free software authors who gave us something to write about and use. Preface ``Freedom is still the most radical idea of all.'' This quote, penned by Nathaniel Branden, seems fitting nowhere moreso than with the freewheeling computing industry. In the space of just a few decades, lives the world over have been changed by computing technology. We, the people behind the Free Software movement, are seeking to continue this trend by truly opening up software to everyone - not just the few people working for the companies that write it - but everyone. As part of this goal, this book and CD contain a treasure chest of Free Software. Over one thousand packages, including things such as the world's most popular web server, can be found here. You can use this software for everything from graphic design to SQL databases. The Free Software revolution has taken the industry by storm. Linux, started from scratch not even 10 years ago, has been the favorite kernel of the Free Software world. The ideas and experience gained from Free Software have truly sent Linux and the Free Software Foundation's GNU tools all over the world. Free systems such as Debian GNU/Linux ship with literally thousands of applications, and they have more power and stability, and outperform some of the industry's traditional best-selling proprietary operating systems. Today, GNU/Linux plays a dominant role in Internet servers and among ISPs, in academia, among computer hobbyists, and in computer science research. Debian GNU/Linux has brought the power of Free Software to everything from laptops to flights aboard the Space Shuttle. As I write this, companies the world over are experiencing the joy and benefits that are Free Software. The unprecedented power, the ability to speak directly to the people who write the software you use, the capability to modify programs at will, and the phenomenal expertise of the online support mechanism all combine to make Free Software a vibrant and wonderful way to use your computing resources. Starting with a Free Software such as Debian GNU/Linux can be the best thing you've done with your computer in a long time. It's fast, powerful, stable, versatile, and fun! Welcome to the revolution! - John Goerzen Guide Introduction We're glad to have this opportunity to introduce you to Debian! As we begin our journey down the road of GNU/Linux, we'd like to first talk a bit about what exactly Debian is - what it does, and how it fits in with the vast world of Free Software. Then, we talk a bit about the phenomenon that is Free Software and what it means for Debian and you. Finally, we close the chapter with a bit of information about this book itself. What Is Debian? Debian is a free operating system (OS) for your computer. An operating system is the set of basic programs and utilities that make your computer run. At the core of an operating system is the kernel. The kernel is the most fundamental program on the computer: It does all the basic housekeeping and lets you start other programs. Debian uses the Linux kernel, a completely free piece of software started by Linus Torvalds and supported by thousands of programmers worldwide. A large part of the basic tools that fill out the operating system come from the GNU Project, and these tools are also free. Another facet of an operating system is application software: programs that help get work done, from editing documents to running a business to playing games to writing more software. Debian comes with more than 1,500 packages (precompiled software bundled up in a nice format for easy installation on your machine) - all for free. The Debian system is a bit like a pyramid. At the base is Linux. On top of that are all the basic tools, mostly from GNU. Next is all the application software that you run on the computer; many of these are also from GNU. The Debian developers act as architects and coordinators - carefully organizing the system and fitting everything together into an integrated, stable operating system: Debian GNU/Linux. The design philosophy of GNU/Linux is to distribute its functionality into small, multipurpose parts. That way, you can easily achieve new functionality and new features by combining the small parts (programs) in new ways. Debian is like an erector set: You can build all sorts of things with it. When you're using an operating system, you want to minimize the amount of work you put into getting your job done. Debian supplies many tools that can help, but only if you know what these tools do. Spending an hour trying to get something to work and then finally giving up isn't very productive. This guide will teach you about the core tools that make up Debian: what tools to use in certain situations and how to tie these various tools together. Who Creates Debian? Debian is an all-volunteer Internet-based development project. There are hundreds of volunteers working on it. Most are in charge of a small number of software packages and are very familiar with the software they package. These volunteers work together by following a strict set of guidelines governing how packages are assembled. These guidelines are developed cooperatively in discussions on Internet mailing lists. A Multiuser, Multitasking Operating System As we mentioned earlier in section 1.1, the design of Debian GNU/Linux comes from the Unix operating system. Unlike common desktop operating systems such as DOS, Windows, and MacOS, GNU/Linux is usually found on large servers and multiuser systems. This means that Debian has features those other operating systems lack. It allows a large number of people to use the same computer at once, as long as each user has his or her own terminal.1.1 To permit many users to work at once, Debian must allow many programs and applications to run simultaneously. This feature is called multitasking. Much of the power (and complexity) of GNU/Linux systems stems from these two features. For example, the system must have a way to keep users from accidentally deleting each other's files. The operating system also must coordinate the many programs running at once to ensure that they don't all use the same resource, such as a hard drive, at the same time. If you keep in mind what Debian was originally designed to do, many aspects of it will make a lot more sense. You'll learn to take advantage of the power of these features. What Is Free Software? When Debian developers and users speak of ``Free Software,'' they refer to freedom rather than price. Debian is free in this sense: You are free to modify and redistribute it and will always have access to the source code for this purpose. The Debian Free Software Guidelines describe in more detail exactly what is meant by ``free.'' The Free Software Foundation, originator of the GNU Project, is another excellent source of information. You can find a more detailed discussion of free software on the Debian web site. One of the most well-known works in this field is Richard M. Stallman's essay, Why Software Should Be Free; take a look at it for some insight into why we support Free Software as we do. Recently, some people have started calling Free Software ``Open Source Software''; the two terms are interchangable. You may wonder why would people spend hours of their own time writing software and carefully packaging it, only to give it all away. The answers are as varied as the people who contribute. Many believe in sharing information and having the freedom to cooperate with one another, and they feel that free software encourages this. A long tradition that upholds these values, sometimes called the Hacker1.2 Ethic, started in the 1950s. The Debian GNU/Linux Project was founded based on these Free Software ethics of freedom, sharing, and cooperation. Others want to learn more about computers. More and more people are looking for ways to avoid the inflated price of proprietary software. A growing community contributes in appreciation for all the great free software they've received from others. Many in academia create free software to help get the results of their research into wider use. Businesses help maintain free software so they can have a say in how it develops - there's no quicker way to get a new feature than to implement it yourself or hire a consultant to do so! Business is also interested in greater reliability and the ability to choose between support vendors. Still others see free software as a social good, democratizing access to information and preventing excessive centralization of the world's information infrastructure. Of course, a lot of us just find it great fun. Debian is so committed to free software that we thought it would be useful if it was formalized in a document of some sort. Our Social Contract promises that Debian will always be 100% free software. When you install a package from the Debian main distribution, you can be sure it meets our Free Software Guidelines. Although Debian believes in free software, there are cases where people want to put proprietary software on their machine. Whenever possible Debian will support this; though proprietary software is not included in the main distribution, it is sometimes available on the FTP site in the non-free directory, and there is a growing number of packages whose sole job is to install proprietary software we are not allowed to distribute ourselves. It is important to distinguish commercial software from proprietary software. Proprietary software is non-free software; commercial software is software sold for money. Debian permits commercial software, but not proprietary software, to be a part of the main distribution. Remember that the phrase ``free software'' does not refer to price; it is quite possible to sell free software. For more clarification of the terminology, see http://www.opensource.org/or http://www.fsf.org/philosophy/categories.html. About This Book This book is aimed at readers who are new to Debian GNU/Linux. It assumes no prior knowledge of GNU/Linux or other Unix-like systems, but it does assume very basic general knowledge about computers and hardware; you should know what the basic parts of a computer are, and what one might use a computer to do. In general, this tutorial tries to help you understand what happens inside a Debian system. The idea is to empower you to solve new problems and get the most out of your computer. Thus there's plenty of theory and fun facts thrown in with the ``How To'' aspects of the manual. We'd love to hear your comments about this book! You can reach the authors at debian-guide@complete.org. We're especially interested in whether it was helpful to you and how we could make it better. Whether you have a comment or think this book is the greatest thing since sliced bread, please send us e-mail. Please do not send the authors technical questions about Debian, because there are other forums for that; see Appendix A on page [*] for more information on the documentation and getting help. Only send mail regarding the book itself to the above address. How to Read This Book The best way to learn about almost any computer program is by using it. Most people find that reading a book without using the program isn't beneficial. The best way to learn about Unix and GNU/Linux is by using them. Use GNU/Linux for everything you can. Feel free to experiment! Debian isn't as intuitively obvious as some other operating systems. You will probably end up reading at least the first few chapters of this book. GNU/Linux's power and complexity make it difficult to approach at first, but far more rewarding in the long run. The suggested way to learn is to read a little, and then play a little. Keep playing until you're comfortable with the concepts, and then start skipping around in the book. You'll find a variety of topics are covered, some of which you might find interesting. After a while, you should feel confident enough to start using commands without knowing exactly what they do. This is a good thing. Tip: If you ever mistakenly type a command or don't know how to exit a program, press CTRL-c (the Ctrl key and the lowercase letter c pressed simultaneously). This will often stop the program. Conventions Before going on, it's important to be familiar with the typographical conventions used in this book. When you should simultaneously hold down multiple keys, a notation like CTRL-a will be used. This means ``press the Ctrl key and press lowercase letter a.'' Some keyboards have both Alt and Meta; most home computers have only Alt, but the Alt key behaves like a Meta key. So if you have no Meta key, try the Alt key instead. Keys like Alt and Meta are called modifier keys because they change the meaning of standard keys like the letter A. Sometimes you need to hold down more than one modifier; for example, Meta-Ctrl-a means to simultaneously press Meta, Ctrl, and lowercase a. Some keys have a special notation - for example, Ret (Return/Enter), Del (Delete or sometimes Backspace), Esc (Escape). These should be fairly self-explanatory. Spaces used instead of hyphens mean to press the keys in sequential order. For example, CTRL-a x RET means to simultaneously type Ctrl and lowercase a, followed by the letter x, followed by pressing Return. (On some keyboards, this key is labeled Enter. Same key, different name.) In sample sessions, bold face text denotes characters typed by the user, italicized text denotes comments about a given part of the sample session, and all other text is output from entering a command. For shorter commands, you'll sometimes find that the command can be found within other text, highlighed with a monospace font. Getting Started ``A journey of a thousand miles must begin with a single step.'' - Lao-Tsu Now that you've read about the ideas and philosophy behind Linux and Debian, it's time to start putting it on your computer! We start by talking about how to prepare for a Debian install, then about partitioning your disk, and finally, how to start up the installation system. Supported Hardware Debian does not impose hardware requirements beyond the requirements of the Linux kernel and the GNU tools. Rather than attempting to describe all the different hardware configurations that are supported for the PC platform, this section contains general information and pointers to where additional information can be found. There are two excellent places to check for detailed information: the Debian System Requirements list and the Linux Documentation Project Hardware Compatibility HOWTO. For information on video card support, you may also want to look at the XFree86 Project web site. Memory and Disk Space Requirements You must have at least 4MB of memory and 35MB of available hard disk space. If you want to install a reasonable amount of software, including the X Window system, and some development programs and libraries, you'll need at least 300MB. For an essentially full installation, you'll need around 800MB. To install everything available in Debian, you'll probably need around 2GB. Actually, installing everything doesn't make sense because some packages provide the same services. Before You Start Before you start, make sure to back up every file that is now on your system. The installation procedure can wipe out all of the data on a hard disk! The programs used in installation are quite reliable and most have seen years of use; still, a false move can cost you. Even after backing up, be careful and think about your answers and actions. Two minutes of thinking can save hours of unnecessary work. Debian makes it possible to have both Debian GNU/Linux and another operating system installed on the same system. If you plan to use this option, make sure that you have on hand the original CD-ROM or floppies of the other installed operating systems. If you repartition your boot drive, you may find that you have to reinstall your existing operating system's boot loader2.1 or the entire operating system itself. Information You Will Need If your computer is connected to a network 24 hours a day (i.e., an Ethernet or similar LAN connection - not a PPP connection), you should ask your network's system administrator for the following information: * Your host name (you may be able to decide this on your own) * Your domain name * Your computer's IP address * The IP address of your network * The netmask to use with your network * The broadcast address to use on your network * The IP address of the default gateway system you should route to, if your network has a gateway * The system on your network that you should use as a DNS server * Whether you connect to the network using Ethernet * Whether your Ethernet interface is a PCMCIA card, and if so, the type of PCMCIA controller you have If your only network connection is a telephone line using PPP or an equivalent dialup connection, you don't need to worry about getting your network set up until your system is already installed. See section 11.1 on page [*] for information on setting up PPP under Debian. Partitioning Your Hard Drive Before you install Debian on your computer, it is generally a good idea to plan how the contents of your hard drive will be arranged. One part of this process involves partitioning your hard drive. Background Partitioning your disk simply refers to the act of breaking up your disk into sections. Each section is then independent of the others. It's roughly equivalent to putting up walls in a house; after that, adding furniture to one room doesn't affect any other room. If you already have an operating system on your system (Windows 95, Windows NT, DOS, etc.) and you want to install Debian GNU/Linux on the same disk, you will probably need to repartition the disk. In general, changing a partition that already has a filesystem on it will destroy any information in that filesystem. Therefore, you should always make backups before doing any repartitioning. Using the analogy of the house, you would probably want to move all the furniture out of the way before moving a wall or you risk destroying your furniture. Luckily, there is an alternative for some users; see section 2.3.6 on page [*] for more information. At a bare minimum, GNU/Linux needs one partition for itself. You can have a single partition containing the entire operating system, applications, and your personal files. Most people choose to give GNU/Linux more than the minimum number of partitions, however. There are two reasons you might want to break up the filesystem into a number of smaller partitions. The first is for safety. If something happens to corrupt the filesystem, generally only one partition is affected. Thus, you only have to replace (from the backups you've been carefully keeping) a portion of your system. At the very least, you should consider creating what is commonly called a ``root partition.'' This contains the most essential components of the system. If any other partitions get corrupted, you can still boot into GNU/Linux to fix the system. This can save you the trouble of having to reinstall the system from scratch. The second reason is generally more important in a business setting, but it really depends on your use of the machine. Suppose something runs out of control and starts eating disk space. If the process causing the problem happens to have root privileges (the system keeps a percentage of the disk away from users), you could suddenly find yourself out of disk space. This is not good since the operating system needs to use real files (besides swap space) for many things. It may not even be a problem of local origin. For example, unsolicited e-mail (``spam'') can easily fill a partition. By using more partitions, you protect the system from many of these problems. Using e-mail as an example again, by putting the directory /var/spool/mail on its own partition, the bulk of the system will work even if unsolicited e-mail fills that partition. Another reason applies only if you have a large IDE disk drive and are using neither LBA addressing nor overlay drivers2.2. In this case, you will have to put the root partition into the first 1,024 cylinders of your hard drive, usually around 524 megabytes. See section 2.3.3 on page [*] for more information on this issue. Most people feel that a swap partition is also a necessity, although this isn't strictly true. ``Swap'' is scratch space for an operating system, which allows the system to use disk storage as ``virtual memory'' in addition to physical memory. Putting swap on a separate partition allows Linux to make much more efficient use of it. It is possible to force Linux to use a regular file as swap, but this is not recommended. The only real drawback to using more partitions is that it is often difficult to know in advance what your needs will be. If you make a partition too small, either you will have to reinstall the system, or you will be constantly moving things around to make room in the undersized partition. On the other hand, if you make the partition too big, you may be wasting space that could be used elsewhere. Planning Use of the System Disk space requirements and your partitioning scheme are influenced by the type of installation you decide to create. For your convenience, Debian offers a number of default ``profiles'' some of which are listed later in this section. Profiles are simply preselected sets of packages designed to provide certain desired capabilities on your system. Installation is easier since packages that fit your desired profile are automatically marked for installation. Each given profile lists the size of the resulting system after installation is complete. Even if you don't use these profiles, this discussion is important for planning, since it will give you a sense of how large your partition or partitions need to be. The following are some of the available profiles and their sizes: Server_std. This is a small server profile, useful for a stripped-down server, that does not have a lot of niceties for shell users. It basically has an FTP server, a web server, DNS, NIS, and POP. It will take up around 50MB. Of course, this is just the size of the software; any data you serve would be additional. Dialup. This profile would be good for a standard desktop box, including the X Window system, graphics applications, sound, editors, etc. The size of the packages will be around 500MB. Work_std. This profile is suitable for a stripped-down user machine without the X Window system or X applications. It is also suitable for a laptop or mobile computer. The size is around 140MB. It is possible to have a simple laptop setup including X with less than 100MB. Devel_comp. This is a desktop setup profile with all the popular development packages, such as Perl, C, and C++. It requires around 475MB. Assuming you are adding X and some additional packages for other uses, you should plan for approximately 800MB of disk space for this type of installation. Remember that these sizes don't include all the other materials that are normally found, such as user files, mail, and data. It is always best to be generous when considering the space for your own files and data. Notably, the Debian /var directory contains a lot of state information. The installed package management files can easily consume 20MB of disk space. In general, you should allocate at least 50MB for the /var directory because system log files are also stored there. PC Disk Limitations A PC BIOS generally adds additional constraints for disk partitioning. There is a limit to how many ``primary'' and ``logical'' partitions a drive can contain. Additionally, there are limits to where on the drive the BIOS looks for boot information. More information can be found in the Linux Partition mini-HOWTO. This section will include a brief overview to help you plan most situations. ``Primary'' partitions are the original partitioning scheme for PC hard disks. However, there can be only four of them. To get past this limitation, ``extended'' or ``logical'' partitions were invented. By setting one of your primary partitions as an extended partition, you can subdivide all the space allocated to that partition into logical partitions. The number of logical partitions you can create is much less limited than the number of primary partitions you can create; however, you can have only one extended partition per drive. Linux limits the number of partitions per drive to 15 partitions for SCSI drives (3 usable primary partitions, 12 logical partitions), and 63 partitions for IDE drives (3 usable primary partitions, 60 logical partitions). The last issue you need to know about a PC BIOS is that your boot partition - that is, the partition containing your kernel image - needs to be contained within the first 1,024 cylinders of the drive. Because the root partition is usually your boot partition, you need to make sure your root partition fits into the first 1,024 cylinders. If you have a large disk, you may have to use cylinder translation techniques, which you can set in your BIOS, such as LBA translation mode. (More information about large disks can be found in the Large Disk mini-HOWTO.) If you are using a cylinder translation scheme, your boot partition must fit within the translated representation of cylinder 1,024. Device Names in Linux Linux disks and partition names may be different from those in other operating systems. You should know the names that Linux uses when you create and mount partitions. The basic scheme can be found in Table 2.1 on page [*]. Table 2.1: Linux Device Names +------------------------------------------------------------------------------+ | Device | Linux Name | |-----------------------------------------------+------------------------------| | First floppy drive | /dev/fd0 | |-----------------------------------------------+------------------------------| | Second floppy drive | /dev/fd1 | |-----------------------------------------------+------------------------------| | First partition on /dev/hda (typically C: in | /dev/hda1 | | other OSs) | | |-----------------------------------------------+------------------------------| | Fifth partition on /dev/hdc | /dev/hdc5 | |-----------------------------------------------+------------------------------| | Second partition on /dev/sdb | /dev/sdb2 | |-----------------------------------------------+------------------------------| | Entire Primary-Master IDE hard disk or CD-ROM | /dev/hda | |-----------------------------------------------+------------------------------| | Entire Primary-Slave IDE hard disk or CD-ROM | /dev/hdb | |-----------------------------------------------+------------------------------| | Entire Secondary-Master IDE hard disk or | /dev/hdc | | CD-ROM | | |-----------------------------------------------+------------------------------| | Entire Secondary-Slave IDE hard disk or | /dev/hdd | | CD-ROM | | |-----------------------------------------------+------------------------------| | First SCSI disk | /dev/sda | |-----------------------------------------------+------------------------------| | Second and remaining SCSI disks | /dev/sdb and so forth | |-----------------------------------------------+------------------------------| | First serial port (COM1 in other OSs) | /dev/ttyS0 | |-----------------------------------------------+------------------------------| | Second, third, etc. serial ports | /dev/ttyS1, /dev/ttyS2, etc. | |-----------------------------------------------+------------------------------| | SCSI tape units (automatic rewind) | /dev/st0, /dev/st1, etc. | |-----------------------------------------------+------------------------------| | SCSI tape units (no automatic rewind) | /dev/nst0, /dev/nst1, etc. | |-----------------------------------------------+------------------------------| | SCSI CD-ROMs | /dev/scd0, /dev/scd1, etc. | +------------------------------------------------------------------------------+ The partitions on each disk are represented by appending a number to the disk name. For example, the names hda1 and hda2 represent the first and second partitions of the first IDE disk drive in your system. Linux represents the primary partitions with the drive name plus the numbers 1 through 4. For example, the first primary partition on the first IDE drive is /dev/hda1. The logical partitions are numbered starting at 5, so the first logical partition on that same drive is /dev/hda5. Remember that the extended partition - that is, the primary partition holding the logical partitions - is not usable by itself. This applies to SCSI drives as well as IDE drives. Let's assume you have a system with two SCSI disks, one at SCSI address 2 and the other at SCSI address 4. The first disk (at address 2) is then named sda and the second sdb. If the sda drive has three partitions on it, these will be named sda1, sda2, and sda3. The same applies to the sdb disk and its partitions. Note that if you have two SCSI host bus adapters (i.e., controllers), the order of the drives can get confusing. The best solution in this case is to watch the boot messages, assuming you know the drive models. Recommended Partitioning Scheme As described above, you should have a separate smaller root partition and a larger /usr partition if you have the space. For most users, the two partitions initially mentioned are sufficient. This is especially appropriate when you have a single small disk, because creating lots of partitions can waste space. In some cases, you might need a separate /usr/local partition if you plan to install many programs that are not part of the Debian distribution. If your machine will be a mail server, you may need to make /var/spool/mail a separate partition. Putting /tmp on its own 20 to 32MB partition, for instance, is a good idea. If you are setting up a server with lots of user accounts, it's generally good to have a separate, large /home partition to store user home directories. In general, the partitioning situation varies from computer to computer depending on its uses. For very complex systems, you should see the Multi Disk HOWTO. It contains in-depth information, mostly of interest to people setting up servers. Swap partition sizes should also be considered. There are many views about swap partition sizes. One rule of thumb that works well is to use as much swap as you have system memory, although there probably isn't much point in going over 64MB of swap for most users. It also shouldn't be smaller than 16MB, in most cases. Of course, there are exceptions to these rules. If you are trying to solve 10,000 simultaneous equations on a machine with 256MB of memory, you may need a gigabyte (or more) of swap space. As an example, consider a machine that has 32MB of RAM and a 1.7GB IDE drive on /dev/hda. There is a 500MB partition for another operating system on /dev/hda1. A 32MB swap partition is used on /dev/hda3 and the rest, about 1.2GB, on /dev/hda2 is the Linux partition. Partitioning Prior to Installation There are two different times that you can partition: prior to or during the installation of Debian. If your computer will be solely dedicated to Debian you should partition during installation as described in section 3.5 on page [*]. If you have a machine with more than one operating system on it, you should generally let the other operating system create its own partitions. The following sections contain information regarding partitioning in your native operating system prior to Debian installation. Note that you'll have to map between how the other operating system names partitions and how Linux names partitions; see Table 2.1 on page [*]. Partitioning from DOS or Windows If you are manipulating existing FAT or NTFS partitions, it is recommended that you use either the scheme below or native Windows or DOS tools. Otherwise, it is not really necessary to partition from DOS or Windows; the Linux partitioning tools will generally do a better job. Lossless Repartitioning One of the most common installations is onto a system that already contains DOS (including Windows 3.1), Win32 (such as Windows 95, 98, NT), or OS/2 and it is desired to put Debian onto the same disk without destroying the previous system. As explained in section 2.3.1 on page [*], decreasing the size of an existing partition will almost certainly damage the data on that partition unless certain precautions are taken. The method described here, while not guaranteed to protect your data, works extremely well in practice. As a precaution, you should make a backup. Before going any further, you should have decided how you will divide up the disk. The method in this section will only split a partition into two pieces. One will contain the original operating system, and the other will be used for Debian. During the installation of Debian, you will be given the opportunity to use the Debian portion of the disk as you see fit, i.e., as swap or as a filesystem. The idea is to move all the data on the partition to the beginning before changing the partition information, so that nothing will be lost. It is important that you do as little as possible between the data movement and repartitioning to minimize the chance of a file being written near the end of the partition as this will decrease the amount of space you can take from the partition. The first thing you need is a copy of FIPS, which is available in the tools directory on your Debian CD-ROM. This disk must be bootable. Under DOS, a bootable floppy can be created using the command sys a: for a previously formatted floppy or format a: /s for an unformatted floppy. Unzip the archive and copy the files RESTORRB.EXE, FIPS.EXE and ERRORS.TXT to the bootable floppy. FIPS comes with very good documentation that you may want to read. You should definitely read the documentation if you use a disk compression driver or a disk manager. Create the disk and read the documentation before you continue. The next thing to be done is to move all the data to the beginning of the partition. DEFRAG, which comes standard with DOS 6.0 and later, can easily do the job. See the FIPS documentation for a list of other software that may also work. Note that if you have Windows 95 or higher, you must run DEFRAG from there, because DOS doesn't understand VFAT, which is used to support long filenames in Windows 95 and higher. After running the defragmenter (which can take a while on a large disk), reboot with the FIPS floppy disk you created. Simply type a:\ fips and follow the directions. Note that there are many other other partition managers out there, in case FIPS doesn't work for you. Debian Installation Steps As you initially install Debian, you will proceed through several different steps: 1. Boot the installation system 2. Initial system configuration 3. Install the base system 4. Boot the newly installed base system 5. Install the rest of the system Booting the Debian installation system, the first step, is generally done with the Rescue Floppy or from the CD-ROM. Once you've booted into Linux, the dbootstrap program will launch and guide you through the second step, the initial system configuration. This step is described in detail in section 3 on page [*]. The ``Debian base system'' is a core set of packages that are required to run Debian in a minimal, stand-alone fashion. dbootstrap will install it from your CD-ROM, as described in section 3.12 on page [*]. Once you have configured and installed the base system, your machine can ``stand on its own.'' The final step is the installation of the remainder of the Debian system. This would include the applications and documents that you actually use on your computer, such as the X Window system, editors, shells, and development environments. The rest of the Debian system can be installed from CD-ROM. At this point, you'll be using the standard Debian package management tools, such as dselect. This step is described in section 3.20 on page [*]. Choosing Your Installation Media First, choose the boot media for the installation system. Next, choose the method you will use to install the base system. To boot the installation system, you have the following choices: bootable CD-ROM, floppies, or a non-Linux boot loader. CD-ROM booting is one of the easiest ways to install. Not all machines can boot directly from the CD-ROM so you may still need to use floppies. Booting from floppies is supported for most platforms. Floppy booting is described in section 2.4.2 on page [*]. Installing from a CD-ROM If your system supports booting from a CD-ROM, you don't need any floppies. Put the CD-ROM into the drive, turn your computer off, and then turn it back on. You should see a Welcome screen with a boot prompt at the bottom. Now you can skip down to section 2.5. If your computer didn't ``see'' the Debian CD-ROM, the easiest option is to make two floppies for booting (described in section 2.4.2) and then use them to start Debian. Don't worry; after Debian is finished with those two floppies, it will find your CD-ROM with no trouble. Booting from Floppies It's not hard at all to boot from floppies. In fact, your CD-ROM contains all the information necessary to create boot disks for you. For these instructions, you will need to get two disks. Label the first one ``Debian 2.1 Install/Rescue Disk'' and the second ``Debian 2.1 Modules/Drivers Disk.'' Creating Floppies from Disk Images Disk images are files containing the complete contents of a floppy disk in raw form. Disk images, such as resc1440.bin, cannot simply be copied to floppy drives. A special program is used to write the image files to floppy disk in raw mode. First, you need to get to a DOS prompt. In Windows 95 and above, you can do this by double-clicking on an MS-DOS icon or by going to Start\( \rightarrow \)Programs\( \rightarrow \)MS-DOS prompt. Then, insert your Debian GNU/Linux CD-ROM into your CD-ROM drive. First, you change to your CD-ROM drive. In most cases, this is D:. C:\WINDOWS>D: Now, change to the directory containing the disk images. D:\>CD \DISTS\SLINK\MAIN\DISKS-I386\2.1.8-1999-02-22 If you get an error, double-check what you're typing. If the error persists, manually issue CD \DISTS\SLINK\MAIN\DISKS-I386, then run DIR, and then CD into the directory indicated. Note that the above commands, and some other examples below, may appear as a single line on your display even if they are wrapped here. Now, you're ready to create the first of two disks. Start the program to write them out, rawrite2: D:\DISTS\SLINK\MAIN\DISKS-I386\ 2.1.8-1999-02-22>rawrite2 RaWrite 2.0 - Write disk file to raw floppy diskette Rawrite2 starts and displays its welcome message. Next, it asks for the filename and diskette drive. You tell it to write resc1440.bin to a: Enter disk image source file name: resc1440.bin Enter target diskette drive: a: Rawrite2 now asks you to insert a disk into the floppy drive. Do so and press Enter. Plese insert a formatted diskette into drive A: and press -ENTER- : At this point, rawrite2 will create the first of the two disks. Now, you need to repeat the process for the second disk: D:\DISTS\SLINK\MAIN\DISKS-I386\ 2.1.8-1999-02-22>rawrite2 RaWrite 2.0 - Write disk file to raw floppy diskette Enter disk image source file name: drv1440.bin Enter target diskette drive: a: Please insert a formatted diskette into drive A: and press -ENTER- : By now, your disks are created. You can now use the first one to boot. Booting Debian You are now ready to boot into Debian! Shut down your existing operating system, turn off your computer, and place the Install/Rescue Disk into the floppy drive. Now turn your computer back on. You should get a Welcome screen with a boot prompt at the bottom. Booting the Installation System You should now have the boot prompt. Simply press Enter at this point. Once you press Enter, you should see the message Loading..., and then Uncompressing Linux..., and then a screenful or so of information about the hardware in your system. In general, you can ignore these messages. Linux will look for various hardware devices and will tell you what it finds and doesn't find. Don't worry about messages at this point. Just wait until you see the Color Selection screen. If you have trouble, see section B.2 on page [*]. Step-by-Step Installation dbootstrap is the name of the program that is run after you have booted into the installation system. It is responsible for initial system configuration and the installation of the ``base system.'' The main job of dbootstrap and the main purpose of your initial system configuration is to configure certain core elements of your system. For instance, this includes your IP address, host name, and other aspects of your networking setup, if any. This also includes the configuration of ``kernel modules,'' which are drivers that are loaded into the kernel. These modules include storage hardware drivers, network drivers, special language support, and support for other peripherals. Configuring these fundamental things is done first, because it is often necessary for the system to function properly for the next steps of installation. dbootstrap is a simple, character-based application. It is very easy to use; generally, it will guide you through each step of the installation process in a linear fashion. You can also go back and repeat steps if you made a mistake. Navigation within dbootstrap is accomplished with the arrow keys, Enter, and Tab. Select Color or Monochrome Display Once the system has finished booting, dbootstrap is invoked. The first thing that dbootstrap asks about is your display. You should see the ``Select Color or Monochrome display'' dialog box. If your monitor is capable of displaying color, press Enter. The display should change from black-and-white to color. Then press Enter again, on the ``Next'' item, to continue with the installation. If your monitor can display only black and white, use the arrow keys to move the cursor to the ``Next'' menu item, and then press Enter to continue with the installation. Debian GNU/Linux Installation Main Menu You may see a dialog box that says ``The installation program is determining the current state of your system and the next installation step that should be performed.'' This is a phase in which the installation program automatically figures out what you probably need to do next. In some cases, you may not even see this box. During the entire installation process, you will be presented with the main menu, titled ``Debian GNU/Linux Installation Main Menu.'' The choices at the top of the menu will change to indicate your progress in installing the system. Phil Hughes wrote in the Linux Journal that you could teach a chicken to install Debian! He meant that the installation process was mostly just pecking at the Enter key. The first choice on the installation menu is the next action that you should perform according to what the system detects you have already done. It should say ``Next,'' and at this point the next step in installing the system will be taken. Configure the Keyboard Make sure the highlight is on the ``Next'' item and press Enter to go to the keyboard configuration menu. Move the highlight to the keyboard selection you desire and press Enter. Use the arrow keys to move the highlight. In most cases, you can just use the default U.S. layout. Last Chance to Back Up! Did we tell you to back up your disks? Here's your first chance to wipe out all of the data on your disks and your last chance to save your old system. If you haven't backed up all of your disks, remove the floppy from the drive, reset the system, and run backups. Partition a Hard Disk Whatever the ``Next'' menu selection is, you can use the down-arrow key to select ``Partition a Hard Disk.'' Go ahead and do this now, then press Enter. The ``Partition a Hard Disk'' menu item presents you with a list of disk drives you can partition and runs a partitioning application called cfdisk. You must create at least one ``Linux native'' (type 83) disk partition, and you probably want at least one ``Linux swap'' (type 82) partition, as explained in later in this section. You will now create the partitions that you need to install Debian. For this example, the assumption is that you are partitioning an empty hard disk. The boot partition must reside within the first 1,024 of cylinders of your hard disk (see section 2.3.3 on page [*]). Keeping that in mind, use the right-arrow key to highlight the ``New'' menu selection, and then press Enter. You will be presented with the choice of creating a primary partition or a logical partition. To help ensure that the partition containing the boot information is within the first 1,024 cylinders, create a primary partition first. This primary partition will be your ``Linux native'' partition. Highlight the ``Primary'' menu selection and press Enter. Next you will need to enter how large you want that partition to be. Review section 2.3.2 on page [*] if you're not sure how large it should be. Remember to leave enough space for your swap partition (see section 2.3.5 on page [*]). Enter the parition size you want and then press Enter. Next you will be asked if you want to place the partition at the beginning of free space or at the end. Place it at the beginning to help ensure that it lies within the first 1,024 cylinders. Highlight ``Beginning'' and press Enter. At this point you will be brought back to the main screen. Notice that the partition you created is listed. By default, a Linux native partition was created. This partition must now be made bootable. Make sure that the ``Bootable'' menu selection is highlighted and press Enter. The partition should now have the word ``Boot'' listed under the ``Flags'' column. With the remaining space, create another primary partition. Using the down-arrow key, highlight the free space entry in the partition list. Now highlight the ``New'' menu selection and proceed just as you did when you created the first primary partition. Notice that the partition is listed as a Linux native partition. Because this partition will be your swap partition, it must be denoted as such. Make sure the partition you just created (your swap partition) is highlighted and then press the left-arrow key until the ``Type'' menu selection is highlighted, then press Enter. You will be presented with a list of supported partition types. The Linux swap partition type should already be selected. If it is not, enter the number from the list that corresponds to the Linux swap partition (82), and then press Enter. Your swap partition should now be listed as a Linux swap partition under the ``FS Type'' column in the main screen. Your cfdisk screen should look something like the screenshot in Figure 3.1 on page [*]. The numbers may not be the same, but the Flags and FS Type column shoulds be similar. Until now, nothing on your disk has been altered. If you are satisfied that the partition scheme you created is what you want, press the left-arrow key until ``Write'' is highlighted, and press Enter. Your hard disk has now been partitioned. Quit the cfdisk application by selecting the ``Quit'' menu selection. Once you have left cfdisk, you should be back in Debian's dbootstrap installation application. Figure 3.1: cfdisk screenshot \resizebox*{4in}{!}{\includegraphics{images/cfdisk.eps}} Initialize and Activate a Swap Partition This will be the ``Next'' menu item once you have created one disk partition. You have the choice of initializing and activating a new swap partition, activating a previously-initialized one, or doing without a swap partition. A swap partition is strongly recommended, but you can do without one if you insist and if your system has more than 4MB RAM. If you wish to do this, select the ``Do Without a Swap Partition'' item from the menu and move on to the next section. It's always permissible to reinitialize a swap partition, so select ``Initialize and Activate a Swap Partition'' unless you are sure you know what you are doing. This menu choice will first present you with a dialog box reading ``Please select the partition to activate as a swap device.'' The default device presented should be the swap partition you've already set up; if so, just press Enter. Next you have the option to scan the entire partition for unreadable disk blocks caused by defects on the surface of the hard disk platters. This is useful if you have MFM, RLL, or older SCSI disks, and it never hurts (although it can be time-consuming). Properly working disks in most modern systems don't require this step, because they have their own internal mechanisms for mapping out bad disk blocks. Finally, there is a confirmation message because initialization will destroy any data previously on the partition. If all is well, select ``Yes.'' The screen will flash as the initialization program runs. Initialize a Linux Partition At this point, the next menu item presented should be ``Initialize a Linux Partition.'' If it isn't, either you haven't completed the disk partitioning process, or you haven't made one of the menu choices dealing with your swap partition. You can initialize a Linux partition, or alternately you can mount a previously initialized one. Note that dbootstrap will not upgrade an old system without destroying it. If you're upgrading, Debian can usually upgrade itself, and you won't need to use dbootstrap. The Debian 2.1 release notes contain upgrade instructions. If you are using old disk partitions that are not empty, i.e., if you want to just throw away what is on them, you should initialize them (which erases all files). Moreover, you must initialize any partitions that you created in the disk partitioning step. About the only reason to mount a partition without initializing it at this point would be to mount a partition upon which you have already performed some part of the installation process using this same set of installation floppies. Select the ``Next'' menu item to initialize and mount the / disk partition. The first partition that you mount or initialize will be the one mounted as / (pronounced ``root''). You will be offered the choice to scan the disk partition for bad blocks, as you were when you initialized the swap partition. It never hurts to scan for bad blocks, but it could take 10 minutes or more to do so if you have a large disk. Once you've mounted the / partition, the ``Next'' menu item will be ``Install Operating System Kernel and Modules'' unless you've already performed some of the installation steps. You can use the arrow keys to select the menu items to initialize or to mount disk partitions if you have any more partitions to set up. If you have created separate partitions for /var, /usr, or other filesystems, you should initialize or mount them now. Mount a Previously-Initialized Partition An alternative to the ``Initialize a Partition'' step is the ``Mount a Previously-Initialized Partition'' step. Use this if you are resuming an installation that was interrupted or if you want to mount partitions that have already been initialized. Install Operating System Kernel and Modules This should be the next menu step after you've mounted your root partition, unless you've already performed this step in a previous run of dbootstrap. First, you will be asked to confirm that the device you have mounted on root is the proper one. Next, you will be offered a menu of devices from which you can install the kernel. Choose the appropriate device from which to install the kernel and modules; this will either be a CD-ROM device or the first floppy device. If you're installing from floppies, you'll need to feed in the Rescue Floppy (which is probably already in the drive), followed by the Drivers Floppy. Configure PCMCIA Support There is an alternate step, before the ``Configure Device Driver Modules'' menu selection, called ``Configure PCMCIA Support.'' This menu is used to enable PCMCIA support. If you do have PCMCIA but are not installing your Debian system using it (i.e., installation with a PCMCIA Ethernet card), you need not configure PCMCIA at this point. You can easily configure and enable PCMCIA at a later point, after installation is complete. However, if you are installing by way of a PCMCIA network device, this alternate must be selected, and PCMCIA support must be configured prior to configuring the network. If you need to install PCMCIA, select the alternate below ``Configure Device Driver Modules.'' You will be asked which PCMCIA controller your system contains. In most cases, this will be i82365. In some cases, it will be tcic; your laptop's vendor-supplied specifications should provide the information. You can generally leave the next few sets of options blank. Again, certain hardware has special needs; the Linux PCMCIA HOWTO contains plenty of information in case the default doesn't work. In some unusual cases, you may also need to modify the file /etc/pcmcia/config.opts. You can open your second virtual terminal (Left Alt-F2) and edit the file there and then reconfigure your PCMCIA, or you can manually force a reload of the modules using insmod and rmmod. Once PCMCIA is properly configured and installed, you should configure your device drivers as described in the next section. Configure Device Driver Modules Select the ``Configure Device Driver Modules'' menu item and look for devices that are on your system. Configure those device drivers, and they will be loaded whenever your system boots. You don't have to configure all your devices at this point; what is crucial is that any device configuration required for the installation of the base system is done here. At any point after the system is installed, you can reconfigure your modules with the modconf program. Configure the Network You'll have to configure the network even if you don't have a network, but you'll only have to answer the first two questions - ``Choose the Host name,'' and ``Is your system connected to a network?'' If you are connected to a network, you'll need the information you collected from 2.2.1. However, if your primary connection to the network will be PPP, you should choose NOT to configure the network. dbootstrap will ask you a number of questions about your network; fill in the answers from 2.2.1. The system will also summarize your network information and ask you for confirmation. Next, you need to specify the network device that your primary network connection uses. Usually, this will be eth0 (the first Ethernet device). On a laptop, it's more likely that your primary network device is pcmcia. Here are some technical details you may find handy: The program assumes the network IP address is the bitwise AND of your system's IP address and your netmask. It will guess the broadcast address is the bitwise OR of your system's IP address with the bitwise negation of the netmask. It will guess that your gateway system is also your DNS server. If you can't find any of these answers, use the system's guesses. You can change them once the system has been installed, if necessary, by editing /etc/init.d/network. (On a Debian system, daemons are started by scripts in the directory /etc/init.d/.) Install the Base System During the ``Install the Base System'' step, you'll be offered a menu of devices from which you may install the base system. Here, you need to select your CD-ROM device. You will be prompted to specify the path to the base2_1.tgz file. If you have official Debian media, the default value should be correct. Otherwise, enter the path where the base system can be found, relative to the media's mount point. As with the ``Install Operating System Kernel and Modules'' step, you can either let dbootstrap find the file itself or type in the path at the prompt. Configure the Base System At this point you've read in all of the files that make up a minimal Debian system, but you must perform some configuration before the system will run. You'll be asked to select your time zone. There are many ways to specify your time zone; we suggest you go to the ``Directories:'' pane and select your country (or continent). That will change the available time zones, so go ahead and select your geographic locality (i.e., country, province, state, or city) in the ``Timezones:'' pane. Next, you'll be asked if your system clock is to be set to GMT or local time. Select GMT (i.e., ``Yes'') if you will only be running Linux on your computer; select local time (i.e., ``No'') if you will be running another operating system as well as Debian. Unix (and Linux is no exception) generally keeps GMT time on the system clock and converts visible time to the local time zone. This allows the system to keep track of daylight savings time and leap years, and even allows a user who is logged in from another time zone to individually set the time zone used on his or her terminal. Make Linux Bootable Directly from the Hard Disk If you elect to make the hard disk boot directly to Linux, you will be asked to install a master boot record. If you aren't using a boot manager (and this is probably the case if you don't know what a boot manager is) and you don't have another different operating system on the same machine, answer ``Yes'' to this question. Note that if you answer ``Yes,'' you won't be able to boot into DOS normally on your machine, for instance. Be careful. If you answer ``Yes,'' the next question will be whether you want to boot Linux automatically from the hard disk when you turn on your system. This sets Linux to be the bootable partition - the one that will be loaded from the hard disk. Note that multiple operating system booting on a single machine is still something of a black art. This book does not even attempt to document the various boot managers, which vary by architecture and even by sub-architecture. You should see your boot manager's documentation for more information. Remember: When working with the boot manager, you can never be too careful. The standard i386 boot loader is called ``LILO.'' It is a complex program that offers lots of functionality, including DOS, NT, and OS/2 boot management. To find out more about this functionality, you can read the documentation in /usr/doc/lilo after your system is set up. Make a Boot Floppy You should make a boot floppy even if you intend to boot the system from the hard disk. The reason is that it's possible for the hard disk bootstrap to be mis-installed, but a boot floppy will almost always work. Select ``Make a Boot Floppy'' from the menu and feed the system a blank floppy as directed. Make sure the floppy isn't write-protected, because the software will format and write it. Mark this the ``Custom Boot'' floppy and write-protect it once it has been written. The Moment of Truth You system's first boot on its own power is what electrical engineers call the ``smoke test.'' If you have any floppies in your floppy drive, remove them. Select the ``Reboot the System'' menu item. If are booting directly into Debian and the system doesn't start up, either use your original installation boot media (for instance, the Rescue Floppy) or insert the Custom Boot floppy if you created one, and then reset your system. If you are not using the Custom Boot floppy, you will probably need to add some boot arguments. If booting with the Rescue Floppy or similar technique, you need to specify rescue root=rootfs, where rootfs is your root partition, such as /dev/sda1. Debian should boot, and you should see the same messages as when you first booted the installation system, followed by some new messages. Set the Root Password The root account is also called the superuser; it is a login that bypasses all security protection on your system. The root account should be used only to perform system administration and for as short a time as possible. Any password you create should contain from six to eight characters, and it should contain both uppercase and lowercase characters, as well as punctuation characters. Take extra care when setting your root password, since it is such a powerful account. Avoid dictionary words or use of any personal information that could be guessed. If anyone ever tells you he needs your root password, be extremely wary. You should normally never give out your root account, unless you are administering a machine with more than one system administrator. Create an Ordinary User The system will ask you to create an ordinary user account. This account should be your main personal login. You should not use the root account for daily use or as your personal login. Why not? It's a lot harder to do damage to the system as an ordinary user than as root; system files are protected. Another reason is that you might be tricked into running a Trojan horse program - that is, a program that takes advantage of your superuser powers to compromise the security of your system behind your back. Any good book on Unix system administration will cover this topic in more detail. Consider reading one if this topic is new to you. Name the user account anything you like. If your name is John Smith, you might use ``smith,'' ``john,'' ``jsmith,'' or ``js.'' Shadow Password Support Next, the system will ask whether you want to enable shadow passwords. This is an authentication system that makes your Linux system a bit more secure. Therefore, we recommend that you enable shadow passwords. Reconfiguration of the shadow password system can also be done later with the shadowconfig program. Remove PCMCIA If you have no use for PCMCIA, you can choose to remove it at this point. This will make your startup cleaner; also, it will make it easier to replace your kernel (PCMCIA requires a lot of correlation between the version of the PCMCIA drivers, the kernel modules, and the kernel itself). In general, you will not need PCMCIA unless you're using a laptop. Select and Install Profiles The system will now ask you if you want to use the pre-rolled software configurations offered by Debian. You can always choose package-by-package what you want to install on your new machine. This is the purpose of the dselect program, described below. But this can be a long task with the thousands of packages available in Debian! So, you have the ability to choose tasks or profiles instead. A task is work you will do with the machine, such as ``Perl programming'' or ``HTML authoring'' or ``Chinese word processing.'' You can choose several tasks. A profile is a category your machine will be a member of, such as ``Network server'' or ``Personal workstation.'' Unlike with tasks, you can choose only one profile. To summarize, if you are in a hurry, choose one profile. If you have more time, choose the Custom profile and select a set of tasks. If you have plenty of time and want very precise control on what is or is not installed, skip this step and use the full power of dselect. Soon, you will enter into dselect. If you selected tasks or profiles, remember to skip the ``Select'' step of dselect, because the selections have already been made. A word of warning about the size of the tasks as they are displayed: The size shown for each task is the sum of the sizes of its packages. If you choose two tasks that share some packages, the actual disk requirement will be less than the sum of the sizes for the two tasks. Once you've added both logins (root and personal), you'll be dropped into the dselect program. dselect allows you to select packages to be installed on your system. If you have a CD-ROM or hard disk containing the additional Debian packages that you want to install on your system, or if you are connected to the Internet, this will be useful to you right away. Otherwise, you may want to quit dselect and start it later after you have transported the Debian package files to your system. You must be the superuser (root) when you run dselect. Information on how to use dselect is given in section 3.20. Package Installation with dselect It is now time to install the software packages of your choice on your Debian system. This is done using Debian's package management tool, dselect. Introduction This section documents dselect for first-time users. It makes no attempt to explain everything, so when you first meet dselect, work through the help screens. dselect is used to select which packages you wish to install (there are currently about 2,250 packages in Debian 2.1). It will be run for you during the installation. It is a very powerful and somewhat complex tool. As such, having some knowledge of it beforehand is highly recommended. Careless use of dselect can wreak havoc on your system. dselect will step you through the package installation process outlined here: 1. Choose the access method to use. 2. Update list of available packages, if possible. 3. Select the packages you want on your system. 4. Install and upgrade wanted packages. 5. Configure any packages that are unconfigured. 6. Remove unwanted software. As each step is completed successfully, dselect will lead you on to the next. Go through them in order without skipping any steps. Here and there in this document we talk of starting another shell. Linux has six console sessions or shells available at any one time. You switch between them by pressing Left Alt-F1 through Left Alt-F6, after which you log in on your new shell and go ahead. The console used by the install process is the first one, a.k.a. tty1, so press Left Alt-F1 when you want to return to that process. Once dselect Is Launched Once in dselect, you will get this screen: Debian Linux `dselect' package handling frontend. 0. [A]ccess Choose the access method to use. 1. [U]pdate Update list of available packages, if possible. 2 [S]elect Request which packages you want on your system. 3. [I]nstall Install and upgrade wanted packages. 4. [C]onfig Configure any packages that are unconfigured. 5. [R]emove Remove unwanted software. 6. [Q]uit Quit dselect. Let's look at these one by one. Access The Access screen is shown in Figure 3.2 on page [*]. Figure 3.2: dselect Access screen \resizebox*{4in}{!}{\includegraphics{images/dselect-access.eps}} Here we tell dselect where our packages are. Ignore the order that these appear in. It is very important that you select the proper method for installation. You may have a few more methods listed, or a few less, or you may see them listed in a different order; just don't worry about it. In the following list, we describe the different methods. multi_cd. Quite large and powerful, this complex method is the recommended way of installing a recent version of Debian from a set of multiple binary CDs. Each of these CDs should contain information about the packages in itself and all prior CDs (in the file Packages.cd). When you first select this method, be sure the CD-ROM you will be using is not mounted. Place the last binary disk of the set (we don't need the source CDs) in the drive and answer the questions you are asked: CD-ROM drive location Confirmation that you are using a multi-cd set The location of the Debian distribution on the disk(s) [ Possibly ] the location(s) of the Packages file(s) Once you have updated the available list and selected the packages to be installed, the multi_cd method diverges from normal procedure. You will need to run an ``install'' step for each of the CDs you have, in turn. Unfortunately, due to the limitations of dselect, it will not be able to prompt you for a new disk at each stage; the way to work for each disk is outlined here: 1. Insert the CD in your CD-ROM drive. 2. From the main dselect menu, select ``Install.'' 3. Wait until dpkg finishes installing from this CD. (It may report installation successful, or possibly installation errors. Don't worry about these until later.) 4. Press Return to go back to the main dselect menu. 5. Repeat with the next CD in the set. It may be necessary to run the installation step more than once to cover the order of package installation; some packages installed early may need to have later packages installed before they will configure properly. Running a ``Configure'' step is recommended to help fix any packages that may end up in this state. multi_nfs, multi_mount. These are similar to the multi_cd method and are refinements on the theme of coping with changing media - for example, installing from a multi_cd set exported via NFS from another machine's CD-ROM drive. indexdselect!multi-NFS, multi-mount installation apt. One of the best options for installation from a local mirror of the Debian archive or from the network. This method uses the ``apt'' system to do complete dependency analysis and ordering, so it's most likely to install packages in the optimal order. Configuration of this method is straightforward. You may select any number of different locations, mixing and matching file: URLs (local disks or NFS mounted disks), http: URLs, or ftp: URLs. Note, however, that the HTTP and FTP options do not support local authenticating proxies. If you have proxy server for either HTTP or FTP (or both), make sure you set the http_proxy and ftp_proxy environment variables, respectively. Set them from your shell before starting dselect by using the following command: # export http_proxy=http://gateway:3128/ # dselect Update dselect will read the Packages or Packages.gz files from the mirror and create a database on your system of all available packages. This may take a while as it downloads and processes the files. Select Hang on to your hat. This is where it all happens. The object of the exercise is to select just which packages you wish to have installed. Press Enter. If you have a slow machine, be aware that the screen will clear and can remain blank for 15 seconds. So don't start bashing keys at this point. The first thing that comes up on the screen is page 1 of the Help file. You can get to this help by pressing ? at any point in the ``Select'' screens, and you can page through the help screens by hitting the . (full stop) key. Before you dive in, note these points: * To exit the ``Select'' screen after all selections are complete, press Enter. This will return you to the main screen if there is no problem with your selection. Otherwise, you will be asked to deal with that problem. When you are happy with any given screen, press Enter to get out. * Problems are quite normal and are to be expected. If you select package A and that package requires package B to run, dselect will warn you of the problem and will most likely suggest a solution. If package A conflicts with package B (i.e., if they are mutually exclusive), you will be asked to decide between them. Let's look at the top two lines of the Select screen. This header reminds us of some of the special keys listed in Table 3.1. Table 3.1: Special dselect keys +------------------------------------------------------+ | Key | Description | |------+-----------------------------------------------| | + | Select a package for installation. | |------+-----------------------------------------------| | = | Place a package on hold | |------+-----------------------------------------------| | - | Remove a package. | |------+-----------------------------------------------| | _ | Remove a package and its configuration files. | |------+-----------------------------------------------| | i, I | Toggle/cycle information displays. | |------+-----------------------------------------------| | o, O | Cycle through the sort options. | |------+-----------------------------------------------| | v, V | A terse/verbose toggle. | +------------------------------------------------------+ Table 3.2 lists the states that dselect uses to denote the status of each package it is aware of. Table 3.2: dselect Package States +-----------------------------------------------+ | Flag | Meaning | Possible values | |------+-----------------+----------------------| | E | Error | Space, R, I | |------+-----------------+----------------------| | I | Installed State | Space, *, -, U, C, I | |------+-----------------+----------------------| | O | Old Mark | *, -, =, _, n | |------+-----------------+----------------------| | M | Mark | *, -, =, _, n | +-----------------------------------------------+ Rather than spell all this out here, I refer you to the Help screens where all is revealed. One example, though. You enter dselect and find a line like this: EIOM Pri Section Package Description ** Opt misc loadlin a loader (running under DOS) for LINUX This is saying that loadlin was selected when you last ran dselect and that it is still selected, but it is not installed. Why not? The answer must be that the loadlin package is not physically available. It is missing from your mirror. The information that dselect uses to get all the right packages installed is buried in the packages themselves. Nothing in this world is perfect, and it does sometimes happen that the dependencies built into a package are incorrect, which means that dselect simply cannot resolve the situation. A way out is provided where the user can regain control; it takes the form of the commands Q and X, which are available in the Select screen. Q An override. Forces dselect to ignore the built-in dependencies and to do what you have specified. The results, of course, will be on your own head. X Use X if you get totally lost. It puts things back the way they were and exits. Select screen (dselect) Keys that help you not to get lost (!) are R, U, and D. R Cancels all selections at this level. Does not affect selections made at the previous level. U If dselect has proposed changes and you have made further changes U will restore dselect's selections. D Removes the selections made by dselect, leaving only yours. An example follows. The boot-floppies package (not an example for beginners, I know, but it was chosen because it has a lot of dependencies) depends on these packages: * libc6-pic * slang1-pic * sysutils * makedev * newt0.25 * newt0.25-dev * popt * zlib1g * zlib1g-dev * recode The person maintaining boot-floppies also thinks that the following packages should be installed. These are not, however, essential: * lynx * debiandoc-sgml * unzip When you select boot-floppies, dselect brings up the conflict resolution screen. You'll notice that all the required packages have been selected. Pressing the R key puts things back to the starting point. EIOM Pri Section Package Description __ Opt admin boot-floppie Scripts to create the Debian __ Opt devel newt0.25-dev Developer's toolkit for newt __ Opt devel slang1-dev The S-Lang programming library __ Opt devel slang1-pic The S-Lang programming library If you decide now that you don't want boot-floppies, just press Enter. Pressing the D key puts things the way I selected them in the first place: EIOM Pri Section Package Description _* Opt admin boot-floppie Scripts to create the Debian __ Opt devel newt0.25-dev Developer's toolkit for newt __ Opt devel slang1-dev The S-Lang programming library __ Opt devel slang1-pic The S-Lang programming library Pressing the U key restores dselect's selections: EIOM Pri Section Package Description _* Opt admin boot-floppie Scripts to create the Debian installation _* Opt devel newt0.25-dev Developer's toolkit for newt _* Opt devel slang1-dev The S-Lang programming library _* Opt devel slang1-pic The S-Lang programming library I suggest running with the defaults for now; you will have ample opportunities to add more later. Whatever you decide, press Enter to accept and return to the main screen. If this results in unresolved problems, you will be bounced right back to another problem resolution screen. The R, U, and D keys are very useful in ``what if'' situations. You can experiment at will and then restore everything and start again. Don't look on them as being in a glass box labeled ``Break in Case of Emergency.'' After making your selections in the Select screen, press I to give you a big window, press t to take you to the beginning, and then use the Page Down key to look quickly through the settings. This way you can check the results of your work and spot glaring errors. Some people have deselected whole groups of packages by mistake and not noticed the error until too late. dselect is a very powerful tool; don't misuse it. You should now have the situation shown in Table 3.3. Table 3.3: Expected Package Category States +--------------------------------------+ | Package category | Status | |------------------+-------------------| | Required | all selected | |------------------+-------------------| | Important | all selected | |------------------+-------------------| | Standard | mostly selected | |------------------+-------------------| | Optional | mostly deselected | |------------------+-------------------| | Extra | mostly deselected | +--------------------------------------+ Happy? Press Enter to exit the Select process. You can come back and run Select again if you wish. Install dselect runs through the entire set of packages and installs those selected. Expect to be asked to make decisions as you go. It is often useful to switch to a different shell to compare, say, an old configuration with a new one. If the old file is conf.modules, the new one will be conf.modules.dpkg-dist. The screen scrolls past fairly quickly on a fast machine. You can stop and start it with Ctrl-s and Ctrl-q, respectively, and at the end of the run, you will get a list of any uninstalled packages. It can happen that a package does not get installed because it depends on some other package that is listed for installation but is not yet installed. The answer here is to run Install again. Cases have been reported where it was necessary to run it four times before everything slipped into place. This will vary by your acquisition method. Configure Most packages get configured in step 3, but anything left hanging can be configured here. Remove Removes packages that are installed but no longer required. Quit I suggest running /etc/cron.daily/find at this point, because you have a lot of new files on your system. Then you can use locate to get the location of any given file. A Few Hints in Conclusion When the install process runs dselect for you, you will doubtless be eager to get Debian running as soon as possible. Well, please be prepared to take an hour or so to learn your way around and then get it right. When you enter the Select screen for the first time, don't make any selections at all - just press Enter and see what dependency problems there are. Try fixing them. If you find yourself back at the main screen, run Select again. You can get an idea of the size of a package by pressing i twice and looking for the ``Size'' figure. This is the size of the compressed package, so the uncompressed files will be a lot bigger (see ``Installed-Size,'' which is in kilobytes, to know it). Installing a new Debian system is a complex thing, but dselect can do it for you as easy as can be. So take the time to learn how to drive it. Read the help screens and experiment with i, I, o, and O. Use the R key. It's all there, but it's up to you to use it effectively. Glossary The following terms will be useful to you throughout this book and in general when you're talking about Debian. Package. A file that contains everything needed to install, de-install, and run a particular program. The program that handles packages is dpkg. dselect is a front-end to dpkg. Experienced users often use dpkg to install or remove a package. Package names. All package names have the form xxxxxxxxxxx.deb. Sample package names include the following: * efax_08a-1.deb * lrzsz_0.12b-1.deb * mgetty_0.99.2-6.deb * minicom_1.75-1.deb * term_2.3.5-5.deb * uucp_1.06.1-2.deb * uutraf_1.1-1.deb * xringd_1.10-2.deb * xtel_3.1-2.deb Logging In Your system is now installed! Pat yourself on the back for a job well done! Now it's time to start using the system. In this chapter, we introduce you to the Debian command line, some security principles, and how to exit the system. In later chapters, we'll go into more detail on these topics and introduce you to the Debian graphical interface, X11. First Steps After you quit dselect, you'll be presented with the login: prompt. You can now log in using the personal login and password you selected; your system is now ready to use. Let's examine what it means to log in and how this process works. To use Debian, you must identify yourself to the system. This is so it knows who you are, what you have permission to do, and what your preferences are. To this end, you have a username or login. If you installed Debian yourself, you should have been asked to give such a name during installation. If you are logging on to a system administered by someone else, you'll have to ask him for an account on the system and a corresponding username. You also have a password, so no one else can pretend to be you. If you don't have a password, anyone can log on to your computer from the Internet and do bad things. If you're worried about security, you should have a password. Many people prefer to trust others not to do anything malicious with their account; hopefully your work environment doesn't encourage paranoia. This is a perfectly reasonable attitude; it depends on your personal priorities and your environment. Obviously a home system does not need to be as secure as a military installation. Debian allows you to be as secure or as insecure as you like. When you start Debian, you'll see a prompt: a request from the computer for some information. In this case, the prompt is login:. You should type your username and, when requested, your password. The password does not appear on the screen as you type it. Press Enter after both the username and the password. If you type your username or password incorrectly, you'll have to start over. If you do it correctly, you'll see a brief message and then a $ prompt. The $ is printed by a special program called the shell and is thus called a shell prompt. This is where you give commands to the system. Try entering the command whoami now. There is a cursor to the right of the shell prompt. Your cursor is a small underscore or rectangle that indicates where you're typing; it should move as you type. Always press Enter when you're done typing a shell command. whoami tells your username. You'll then get a new shell prompt. For the rest of the book, when we say to enter a command, you should type it at the shell prompt and press the Enter key. When you're done working, you may want to log out of the system. To exit the shell, enter the exit command. Keep in mind that if you remain logged in, someone could come along and use your account. Hopefully you can trust those in your office or home not to do this; but if you do not trust your environment, you should be certain to log out when you leave. Command History and Editing the Command Line Whatever you type after the shell prompt and before pressing Enter is called a command line. It's a line of text that commands the computer to do something. The Debian default shell offers several features to make entering command lines easy. You can scroll up to previous commands to run them again, or you can modify them slightly and then run them again. Try this: Enter any command, such as whoami; then press the Up Arrow key. The whoami command will reappear at the prompt. You can then press Enter to run whoami a second time. If you've entered several commands, you can keep pressing the Up Arrow key to go back through them. This feature is handy if you're doing the same thing several times, or if you type a command incorrectly and want to go back to fix it. You can press the Down Arrow key to move in the other direction, toward your more recent commands. If there are no more commands to move to, the computer will beep. You can also move around on the command line to make changes. The easiest way is with the Left and Right Arrow keys. Try typing whoasmi instead of whoami, and then use the Left Arrow key to move back to the s. You can erase the s with the Backspace or Delete keys. There are more advanced features as well (no need to memorize them all now, though). Try pressing Ctrl-a. This moves you to the beginning of the line. Ctrl-k (the k stands for ``kill'') deletes all characters until the end of the line; try it from the middle of the command line. Using Ctrl-a followed by Ctrl-k, you can delete the entire command line. Ctrl-y pastes the last thing you killed, reinserting it at the current cursor position (y stands for ``yank,'' as in ``yank it back''). Ctrl-e will move the cursor to the end of the command line. Go ahead and play around with command-line editing to get a feel for it. Experiment. Working as Root Because Debian is a multiuser system, it's designed to keep any one user or program from breaking the entire system. The kernel will not allow normal users to change important system files. This means that things stay the way they're supposed to, safe from accidents, viruses, and even malicious pranks. Unlike other operating systems, Debian is safe from these threats. You won't need an anti-virus program. However, sometimes you need to change important system files; for example, you might want to install new software or configure your network connection. To do so, you have to have greater powers than a normal user; you must become the root user (also called the superuser). To become root, just log on with the username root and the root password; this was set during installation, as described in section 3.15 on page [*]. At many sites, only the system administrator has the root password, and only the system administrator can do the things that one must be root to do. If you're using your own personal computer, you are the system administrator, of course. If you don't have root privileges, you will have to rely on your system administrator to perform any tasks that require root privileges. Sometimes you'll have the root password even on a shared corporate or educational server, because the system administrator trusts you to use it properly. In that case, you'll be able to help administer the system and customize it for your needs. But you should be sure to use the password responsibly, respecting other users at all times. If you have the password, try logging on as root now. Enter the whoami command to verify your identity. Then log out immediately. When you're root, the kernel will not protect you from yourself, because root has permission to do anything at all to the system. Don't experiment while you're root. In fact, don't do anything as root unless absolutely necessary. This isn't a matter of security, but rather of stability. Your system will run much better if it can keep you from making mistakes. You may find the su command more convenient than logging in as root. su allows you to assume the identity of another user, usually root unless you specify someone else. (You can remember that su stands for Super User, though some say it stands for Set UserID.) Here's something to try. Log on as yourself - that is, not as root. Then your session will look something like the one in Figure 4.1. When you're doing system administration tasks, you should do as much as possible as yourself. Then use su, do the part that requires root privileges, and use the exit command to turn off privileges so you can no longer harm anything. You can use su to assume the identity of any user on the system, not just root. To do this, type su user where user is the user you want to become. You'll have to know the user's password, of course, unless you're root at the time or the user has no password. Figure 4.1: Sample session with su \begin{figure}\par\par\begin{list}{}{ \setlength{\rightmargin}{\leftmargin} \ra... ...~~~~~~~~~~~~~}\textrm{\textit{Exit your \lq\lq normal'' shell}}\end{list}\end{figure} Virtual Consoles The Linux kernel supports virtual consoles. These provide a way of making your single screen and keyboard seem like multiple terminals that are connected to the same system. Thankfully, using virtual consoles is one of the simplest things about Debian: There are ``hot keys'' for switching among the consoles quickly. To try it, log in to your system and press Alt-F2 (simultaneously press the left Alt key, and F2, that is, function key number 2). You should find yourself at another login prompt. Don't panic: You are now on virtual console (VC) number 2! Log in here and do some things - more whoami commands or whatever - to confirm that this is a real login shell. Now you can return to virtual console number 1 by pressing Alt-F1. Or you can move on to a third virtual console, in the obvious way (Alt-F3). Debian comes with six virtual consoles enabled by default, which you access with the Alt key and function keys F1 through F6. (Technically, there are more virtual consoles enabled, but only six of them allow you to log in. The others are used for the X Window system or other special purposes.) If you're using the X Window system, it will generally start up on the first unused virtual console - probably VC 7. Also, to switch from the X virtual console to one of the first six, you'll have to add Ctrl to the key sequence. So that's Ctrl-Alt-F1 to get to VC 1. But you can go from a text VC to the X virtual console using only Alt. If you never leave X, you won't have to worry about this; X automatically switches you to its virtual console when it starts up. Once you get used to them, virtual consoles will probably become an indispensable tool for getting many things done at once. (The X Window system serves much the same purpose, providing multiple windows rather than multiple consoles.) You can run a different program on each VC or log on as root on one VC and as yourself on another. Or everyone in the family can use his or her own VC; this is especially handy if you use X, in which case you can run several X sessions at once on different virtual consoles. Shutting Down Do not just turn off the computer! You risk losing valuable data! If you are the only user of your computer, you might want to turn the computer off when you're done with it. To avoid possibly weakening some hardware components, only turn off the computer when you're done for the day. Power up and power down are the two greatest contributors to wear and tear on computer components. Turning the computer on and off once a day is probably the best compromise between your electric bill and your computer's lifespan. It's a bad thing to just press the power switch when you're done using the computer. It is also bad to reboot the machine (with the Reset button) without first taking proper precautions. The Linux kernel, in order to improve performance, has a disk cache. This means it temporarily stores information meant for permanent storage in RAM. Because memory is thousands of times faster than a disk, this makes many file operations move more quickly. Periodically, the information Linux has in memory is actually written to the disk. This is called syncing. In order to turn off or reboot the computer safely, you'll have to tell the computer to clear everything out of memory and put it in permanent storage. To reboot, just type reboot or press Ctrl-Alt-Del (that's Ctrl, Alt, and Delete). To shut down, you'll have to log in as root. As root, just type the command shutdown -h now. The sytem will go through the entire shutdown procedure, including the sync command, which clears the disk cache as described above. When you see System halted, it's safe to turn off the computer. If you have Advanced Power Management (APM) support in your kernel and BIOS, the computer might shut itself off and save you the trouble. APM is common in laptops and is also found in certain desktop mainboards. The Basics It's now time to explore the system in more detail. You've seen how to log in and shut down the system. In this chapter, we explore the Linux comand line, how Linux deals with files and directories, and some basics on identifying yourself to others. The Command Line and Man Pages We've already discussed the command line - that is, commands you type after the shell prompt. This section describes the structure of more complicated command lines. A minimal command line contains just a command name, such as whoami. But other things are possible. For example, you might type: man whoami. This command requests the online manual for the whoami program (you may have to press the space bar to scroll through the documentation or press q to quit). A more complicated example is man -k PostScript. This command line has three parts. It begins with the command name, man. Then it has an option or switch, -k, followed by an argument, PostScript. Some people refer to everything except the command name as the parameters of the command. So, options and arguments are both parameters. Options change the behavior of a command, switching on particular features or functionality. They usually have a - before them. The GNU utilities also have ``long forms'' for the options; the long form of -k is -apropos. You can enter man -h or man -help to get a full list of options for the man command. Every command will have its own set of options, though most have -help and -version options. Some commands, such as tar, do not require the ``-'' before their options for historical reasons. Anything that isn't an option and isn't the command name is an argument (in this case, PostScript). Arguments can serve many purposes; most commonly, they are filenames that the command should operate on. In this case, PostScript is the word you want man to search for. In the case of man whoami, the argument was the command you wanted information about. Here's a breakdown of the man -k PostScript command line: man. The command name, tells the computer to look at the manual pages. These provide documentation for commands. For example, man whoami will give you documentation on the whoami command. -k. The option, changes the behavior of man. Normally man expects a command name, such as whoami, for an argument and looks for documentation of that command. But with the -k or -apropos option, it expects the argument to be a keyword. It then gives a list of all manual pages with that keyword in their description. PostScript. is the argument; because we used the -k option, it's the keyword to search for. -k and PostScript are both parameters. Go ahead and type man -k PostScript, and you will see a list of all the manual pages on your system that have something to do with PostScript. If you haven't installed much software, you might see the message PostScript: nothing appropriate instead. Describing the Command Line Note: You can skip this section if you want to move on. There's a traditional, concise way of describing command syntax. Syntax means the correct ways to combine various options and arguments. For example, if you type man man to get the manual page about man, you'll see several syntax descriptions beginning with the command name man. One of them will look like this: man -k [-M path] keyword ... Anything in brackets ([]) is an optional unit. In this case you don't have to use the -M option, but if you do, you must use a path argument. You must use the -k option and the keyword argument. The ... means that you could have more of whatever came before it, so you could look up several keywords. Let's look at one of the more complex descriptions from the man manual page: man [-c|-w|-tZT device] [-adhu7V] [-m system[,...]] [-L locale] [-p string] [-M path] [-P pager] [-r prompt] [-S list] [-e extension] [[section] page ...] ... There's no need to go through all of this (and don't worry about what it all means), but do pay attention to the organization of the description. First, clusters of options usually mean you can use one or more of them in different combinations, so -adhu7V means you can also use -h. However, you can't always use all combinations; this description doesn't make that clear. For example, -h is incompatible with other options, but you could do man -du. Unfortunately, the description's format does not make this clear. Second, the | symbol means ``or.'' So you can use the -c, the -w, or the -tZT option, followed by a device argument. Third, notice that you can nest the brackets, because they indicate optional units. So if you have a section, you must also have a page, because e page is not optional within the [[section] page] unit. There's no need to memorize any of this, just refer to this section as you read documentation. Files and Directories Files are a facility for storing and organizing information, analogous to paper documents. They're organized into directories, which are called folders on some other systems. Let's look at the organization of files on a Debian system: /. A simple / represents the root directory. All other files and directories are contained in the root directory. If you are coming from the DOS/Windows world, / is very similar to what C:is for DOS, that is the root of the filesystem. A notable difference between DOS and Linux however, is that DOS keeps several filesystems: C: (first hard disk), A: (first floppy disk), and D: (either CD-ROM or second hard disk), whereas Linux has all its files organized above the same / root. /home/janeq. This is the home directory of user ``janeq.'' Reading left to right, to get to this directory you start in the root directory, enter directory home, and then enter directory janeq. /etc/X11/XF86Config. This is the configuration file for the X Window system. It resides in the X11 subdirectory of the /etc directory. /etc is in turn a subdirectory of the root directory, /. Things to note: * Filenames are case-sensitive. That is, MYFILE and MyFile are different files. * The root directory is referred to as simply /. Don't confuse this ``root'' with the root user, the user on your system with ``super powers.'' * Every directory has a name, which can contain any letters or symbols except /. The root directory is an exception; its name is / (pronounced ``slash'' or ``the root directory''), and it cannot be renamed. * While you can use almost any letters or symbols in a filename, in practice it's a bad idea. It is better to avoid characters that often have special meanings on the command line, including: { } ( ) [ ] ' ` " \/ > < | ; ! # & ^ * % * Also avoid putting spaces in filenames. If you want to separate words in a name, good choices are the period, hyphen, and underscore. You could also capitalize each word, LikeThis. * Each file or directory is designated by a fully-qualified filename, absolute filename, or path, giving the sequence of directories which must be passed through to reach it. The three terms are synonymous. All absolute filenames begin with the / directory, and there's a / before each directory or file in the filename. The first / is the name of a directory, but the others are simply separators to distinguish the parts of the filename. * The words used here can be confusing. Take the following example: /usr/share/keytables/us.map.gz. This is a fully-qualified filename; some people call it a path. However, people will also refer to us.map.gz alone as a filename. * There is also another use for the word ``path.'' The intended meaning is usually clear from the context. * Directories are arranged in a tree structure. All absolute filenames start with the root directory. The root directory has a number of branches, such as /etc and /usr. These subdirectories in turn branch into still more subdirectories, such as /etc/init.d and /usr/local. The whole thing together is called the ``directory tree.'' * You can think of an absolute filename as a route from the base of the tree (/) to the end of some branch (a file). You'll also hear people talk about the directory tree as if it were a family tree: Thus subdirectories have ``parent,'' and a path shows the complete ancestry of a file. * There are also relative paths that begin somewhere other than the root directory. More on this later. * No directory corresponds to a physical device, such as your hard disk. This differs from DOS and Windows, in which all paths begin with a device name such as C:\. The directory tree is meant to be an abstraction of the physical hardware, so you can use the system without knowing what the hardware is. All your files could be on one disk - or you could have 20 disks, some of them connected to a different computer elsewhere on the network. You can't tell just by looking at the directory tree, and nearly all commands work just the same way no matter what physical device(s) your files are really on. Don't worry if all this isn't completely clear yet. There are many examples to come. Using Files: A Tutorial To use your system, you'll have to know how to create, move, rename, and delete files and directories. This section describes how to do so with the standard Debian commands. The best way to learn is to try things. As long as you aren't root (and haven't yet created any important personal files), you cannot mess up too seriously. Jump in - type each of these commands at the prompt and press Enter. pwd One directory is always considered the current working directory for the shell you're using. You can view this directory with the pwd command, which stands for Print Working Directory. pwd prints the name of the directory you're working in - probably /home/yourname. ls ls stands for ``list,'' as in ``list files.'' When you type ls, the system displays a list of all the files in your current working directory. If you've just installed Debian, your home directory may well be empty. If your working directory is empty, ls produces no output, because there are no files to list. cd / cd means ``change directory.'' In this case, you've asked to change to the root directory. pwd This verifies that you're working in the root directory. ls Lets you see what's in /. cd Typing cd with no arguments selects your home directory - /home/ yourname - as the current working directory. Try pwd to verify this. Before continuing, you should know that there are actually two different kinds of filenames. Some of them begin with /, the root directory, such as /etc/profile. These are called absolute filenames because they refer to the same file no matter what your current directory is. The other kind of filename is relative. Two directory names are used only in relative filenames: . and ... The directory . refers to the current directory, and .. is the parent directory. These are ``shortcut'' directories. They exist in every directory. Even the root directory has a parent directory - it's its own parent! So filenames that include . or .. are relative, because their meaning depends on the current directory. If I'm in /usr/bin and type ../etc, I'm referring to /usr/etc. If I'm in /var and type ../etc, I'm referring to /etc. Note that a filename without the root directory at the front implicitly has ./ at the front. So you can type local/bin, or ./local/bin and it means the same thing. A final handy tip: The tilde ~ is equivalent to your home directory. So typing cd ~ is the same as typing cd with no arguments. Also, you can type things like cd ~/practice/mysubdirectory to change to the directory /home/yourname/practice/mysubdirectory. In a similar way, ~myuser is equivalent to the home directory of the user ``myuser,'' which is probably something like /home/myuser; so ~myuser/docs/debian.ps is equivalent to /home/myuser/doc/debian.ps. Here are some more file commands to try out, now that you know about relative filenames. cd to your home directory before you begin. mkdir practice In your home directory, make a directory called practice. You'll use this directory to try out some other commands. You might type ls to verify that your new directory exists. cd practice Changes the directory to practice. mkdir mysubdirectory Creates a subdirectory of practice. cp /etc/profile . cp is short for ``copy.'' /etc/profile is just a random file on your system, don't worry about what it is for now. We've copied it to . (recall that . just means ``the directory I'm in now,'' or the current working directory). So this creates a copy of /etc/profile and puts it in your practice directory. Try typing ls to verify that there's indeed a file called profile in your working directory, alongside the new mysubdirectory. more profile This lets you view the contents of the file profile. more is used to view the contents of text files. It's called more because it shows one screenful of the file at a time, and you press the space bar to see more. more will exit when you get to the end of the file, or when you press q (quit). more /etc/profile Verifies that the original looks just like the copy you made. mv profile mysubdirectory mv stands for ``move.'' You've moved the file profile from the current directory into the subdirectory you created earlier. ls Verifies that profile is no longer in the current directory. ls mysubdirectory Verifies that profile has moved to mysubdirectory. cd mysubdirectory Changes to the subdirectory. mv profile myprofile Note that unlike some operating systems, there is no difference between moving a file and renaming it. Thus there's no separate rename command. Note that the second argument to mv can be a directory to move the file or directory into, or it can be a new filename. cp works the same way. As usual, you can type ls to see the result of mv. mv myprofile .. Just as . means ``the directory I'm in now,'' .. means ``parent of the current directory,'' in this case the practice directory you created earlier. Use ls to verify that that's where myprofile is now. cd .. Changes directories to the parent directory - in this case practice, where you just put myprofile. rm myprofile rm means ``remove,'' so this deletes myprofile. Be careful! Deleting a file on a GNU/Linux system is permanent - there is no undelete. If you rm it, it's gone, forever. Be careful! To repeat, deleting a file on a GNU/Linux system is permanent - there is no undelete. If you rm it, it's gone, forever. rmdir mysubdirectory rmdir is just like rm, only it's for directories. Notice that rmdir only works on empty directories. If the directory contains files, you must delete those files first, or alternatively you can use rm -r in place of rmdir. cd .. This moves out of the current directory, and into its parent directory. Now you can type the following: rmdir practice This will delete the last remnants of your practice session. So now you know how to create, copy, move, rename, and delete files and directories. You also learned some shortcuts, like typing simply cd to jump to your home directory, and how . and .. refer to the current directory and its parent, respectively. You should also remember the concept of the root directory, or /, and the alias ~ for your home directory. Dot Files and ls -a When you type ls, files beginning with a dot are not listed. Traditionally, files that contain configuration information, user preferences, and so on begin with a dot; these are hidden and out of your way while you do your day-to-day work. Sample dot files are ~/.emacs, ~/.newsrc, ~/.bashrc, ~/.xsession, and ~/.fvwmrc. These are used by Emacs, news readers, the Bash shell, the X Window system, and the fvwm window manager, respectively. It is conventional to end the dot filename with rc, but some programs don't. There are also directories beginning with a dot, such as ~/.gimp and ~/.netscape, which store preferences for the Gimp and Netscape. Sometimes a program will create a dot file automatically; for example, Netscape allows you to edit your preferences w