InstallGetStarted Guide
InstallGetStarted Guide
Version 3.2, 20 February 1998. This book is meant for UNIX novices and gurus alike. It contains information on how to obtain Linux, software installation, a tutorial for new Linux users, and an introduction to system administration. It is meant to be general enough to be applicable to any distribution of Linux. You may freely copy and redistribute this book under certain conditions. Please see the copyright and distribution statement.
TOC
Names of all products herein are used for identication purposes only and are trademarks and/or registered trademarks of their respective owners. Specialized Systems Consultants, Inc., makes no claim of ownership or corporate association with the products or companies that own them. Copyright c 1992-1996 Matt Welsh Copyright c 1998 Specialized Systems Consultants, Inc (SSC) P.O. Box 55549 Seattle, WA 98155-0549 USA Phone: +1-206-782-7733 Fax: +1-206-782-7191 E-mail: [email protected] URL: http://www.ssc.com/
Linux Installation and Getting Started is a free document; you may reproduce and/or modify it under the terms of version 2 (or, at your option, any later version) of the GNU General Public License as published by the Free Software Foundation. This book is distributed in the hope it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details, in Appendix C. The authors encourage wide distribution of this book for personal or commercial use, provided the above copyright notice remains intact and the method adheres to the provisions of the GNU General Public License (see Appendix C). In summary, you may copy and distribute this book free of charge or for a prot. No explicit permission is required from the author for reproduction of this book in any medium, physical or electronic. Note, derivative works and translations of this document must be placed under the GNU General Public License, and the original copyright notice must remain intact. If you have contributed new A TEX source) available for your revimaterial to this book, you must make the source code (e.g., L sions. Please make revisions and updates available directly to the document maintainers, Specialized Systems Consultants. This will allow for the merging of updates and provide consistent revisions to the Linux community. If you plan to publish and distribute this book commercially, donations, royalties, and/or printed copies are greatly appreciated by the authors and the Linux Documentation Project. Contributing in this way shows your support for free software and the Linux Documentation Project. If you have questions or comments, please contact SSC.
TOC
Contents
Preface Hints for UNIX novices. Hints for UNIX gurus. . Audience. . . . . . . . . Organization. . . . . . . Acknowledgments. . . . Cedits and legalese. . . . Conventions. . . . . . . ix x xi xii xii xiii xiv xv 1 2 3 5 6 8 11 12 13 14 15 16 17 18 19 21 25
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
. . . . . . .
1 Introduction to Linux 1.1 About this book. . . . . . . . . . . . . . . . . . . . . . . 1.2 A brief history of Linux. . . . . . . . . . . . . . . . . . 1.3 System features. . . . . . . . . . . . . . . . . . . . . . . 1.4 Software features. . . . . . . . . . . . . . . . . . . . . . 1.4.1 Text processing and word processing. . . . . . . 1.4.2 Programming languages and utilities. . . . . . . 1.4.3 Introduction to the X Window System. . . . . . . 1.4.4 Introduction to Networking. . . . . . . . . . . . 1.4.5 Telecommunications and BBS software. . . . . . 1.4.6 World Wide Web. . . . . . . . . . . . . . . . . . 1.4.7 Interfacing and MS-DOS. . . . . . . . . . . . . 1.4.8 Other applications. . . . . . . . . . . . . . . . . 1.5 Copyright issues. . . . . . . . . . . . . . . . . . . . . . 1.6 The design and philosophy of Linux. . . . . . . . . . . . 1.7 Differences between Linux and other operating systems. 1.8 Hardware requirements. . . . . . . . . . . . . . . . . . i
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
ii
CONTENTS
TOC
1.9 Sources of Linux information. . . . . . . 1.9.1 Online documents. . . . . . . . . 1.9.2 Linux on the World Wide Web. . . 1.9.3 Books and other published works. 1.9.4 Usenet newsgroups. . . . . . . . 1.9.5 Internet mailing lists. . . . . . . . 1.10 Getting Help with Linux. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 29 30 30 31 33 33 36 36 37 37 38 39 39 40 41 42 42 43 44 44 47 47 48 49 50 50 50 51 53 54 54 54 56 56
2 Obtaining and Installing Linux 2.1 Generic installation. . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.1 Major Linux distributions. . . . . . . . . . . . . . . . . . 2.1.2 Common concerns. . . . . . . . . . . . . . . . . . . . . . 2.1.3 Hardware. . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.4 Planning. . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.5 System planning worksheet. . . . . . . . . . . . . . . . . 2.1.6 Mice. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.7 Considering Hard drives and CD-ROMs. . . . . . . . . . 2.1.8 Disk drives under Linux. . . . . . . . . . . . . . . . . . . 2.1.9 Installing The X Window System . . . . . . . . . . . . . 2.1.10 Networking hardware. . . . . . . . . . . . . . . . . . . . 2.1.11 Planning, Part 2. . . . . . . . . . . . . . . . . . . . . . . 2.1.12 Partitioning strategies. . . . . . . . . . . . . . . . . . . . 2.1.13 The swap partition. . . . . . . . . . . . . . . . . . . . . . 2.1.14 Repartitioning. . . . . . . . . . . . . . . . . . . . . . . . 2.1.15 Backing up your old system. . . . . . . . . . . . . . . . . 2.1.16 FIPS.EXE . . . . . . . . . . . . . . . . . . . . . . . . . 2.1.17 Preparing to boot Linux. . . . . . . . . . . . . . . . . . . 2.1.18 Creating a Linux boot disk under DOS. . . . . . . . . . . 2.1.19 Creating a Linux boot disk under Linux. . . . . . . . . . . 2.1.20 Partitioning the hard disk: fdisk and cfdisk. . . . . . 2.2 Linux distributions. . . . . . . . . . . . . . . . . . . . . . . . . . 2.3 Debian GNU/Linux. . . . . . . . . . . . . . . . . . . . . . . . . 2.3.1 Debian GNU/Linux installation features. . . . . . . . . . 2.3.2 Getting oppy images. . . . . . . . . . . . . . . . . . . . 2.3.3 Downloading the packages. . . . . . . . . . . . . . . . . 2.3.4 Booting from oppies and installing Debian GNU/Linux. .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS
iii
TOC
2.3.5 Running Debian GNU/Linux. . . . . . . . . . . 2.3.6 dselect. . . . . . . . . . . . . . . . . . . . . 2.3.7 dpkg. . . . . . . . . . . . . . . . . . . . . . . . 2.3.8 About Debian GNU/Linux. . . . . . . . . . . . . 2.3.9 Mailing lists. . . . . . . . . . . . . . . . . . . . 2.3.10 Bug tracking system. . . . . . . . . . . . . . . . 2.3.11 Debian Acknowledgments. . . . . . . . . . . . . 2.3.12 Last note. . . . . . . . . . . . . . . . . . . . . . Red Hat Linux. . . . . . . . . . . . . . . . . . . . . . . 2.4.1 Red Hat Linux installation features. . . . . . . . 2.4.2 The RPM package management system. . . . . . 2.4.3 A note about upgrading Red Hat Linux. . . . . . 2.4.4 Creating the installation oppies. . . . . . . . . 2.4.5 Installation media. . . . . . . . . . . . . . . . . 2.4.6 Customizing your NFS or hard drive installation. 2.4.7 Recommended minimal installation. . . . . . . . 2.4.8 How much space do you really need? . . . . . . 2.4.9 Installation. . . . . . . . . . . . . . . . . . . . . 2.4.10 Installation media revisited. . . . . . . . . . . . 2.4.11 Walking through the rest of the installation. . . . 2.4.12 After installation. . . . . . . . . . . . . . . . . . Caldera OpenLinux . . . . . . . . . . . . . . . . . . . . 2.5.1 Obtaining Caldera OpenLinux. . . . . . . . . . . 2.5.2 Preparing to install Caldera OpenLinux. . . . . . 2.5.3 Creating boot/modules oppies. . . . . . . . . . 2.5.4 Preparing the hard disks. . . . . . . . . . . . . . Slackware . . . . . . . . . . . . . . . . . . . . . . . . . 2.6.1 Slackware is not for you. (Or maybe it is.) . . . . 2.6.2 A quick history. . . . . . . . . . . . . . . . . . . 2.6.3 Why, then? . . . . . . . . . . . . . . . . . . . . 2.6.4 Upgrade? Think twice! . . . . . . . . . . . . . . 2.6.5 Select an installation method. . . . . . . . . . . 2.6.6 Boot disks: always a good thing. . . . . . . . . . 2.6.7 Slackware setup worksheet. . . . . . . . . . . . 2.6.8 Making Slackware happen. . . . . . . . . . . . . 2.6.9 Build some boot disks. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64 67 69 71 71 72 72 73 73 73 73 74 75 76 77 79 80 80 80 82 84 85 85 86 86 87 87 88 88 89 89 90 92 92 102 103
2.4
2.5
2.6
iv
CONTENTS
TOC
2.6.10 Boot into action. . . . . . . . . . . . . . . . 2.6.11 The Slackware setup program. . . . . . . . 2.6.12 Is that all? . . . . . . . . . . . . . . . . . . . 2.6.13 Troubleshooting difcult deliveries. . . . . . 2.6.14 Basking in the afterglow. . . . . . . . . . . . 2.6.15 Consider reinstalling! . . . . . . . . . . . . . 2.6.16 Secure the system. . . . . . . . . . . . . . . S.u.S.E. . . . . . . . . . . . . . . . . . . . . . . . . 2.7.1 Beginning the installation. . . . . . . . . . . 2.7.2 S.u.S.E Post-installation. . . . . . . . . . . . 2.7.3 Getting X up and running. . . . . . . . . . . 2.7.4 Later upgrades. . . . . . . . . . . . . . . . . Post-installation procedures. . . . . . . . . . . . . . Running into trouble. . . . . . . . . . . . . . . . . . 2.9.1 Problems with booting the installation media 2.9.2 Hardware problems. . . . . . . . . . . . . . 2.9.3 Problems installing the software. . . . . . . . 2.9.4 Problems after installing Linux. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 103 104 105 106 106 107 109 109 110 111 112 112 113 113 116 120 122 131 131 131 132 132 133 133 135 135 135 136 137 138 138 139 140 142
2.7
2.8 2.9
3 Linux Tutorial 3.1 Introduction. . . . . . . . . . . . . . . . . . . 3.2 Basic Linux concepts. . . . . . . . . . . . . . 3.2.1 Creating an account. . . . . . . . . . 3.2.2 Logging in. . . . . . . . . . . . . . . 3.2.3 Virtual consoles. . . . . . . . . . . . 3.2.4 Shells and commands. . . . . . . . . 3.2.5 Logging out. . . . . . . . . . . . . . 3.2.6 Changing your password. . . . . . . . 3.2.7 Files and directories. . . . . . . . . . 3.2.8 The directory tree. . . . . . . . . . . 3.2.9 The current working directory. . . . . 3.2.10 Referring to home directories. . . . . 3.3 First steps into Linux. . . . . . . . . . . . . . 3.3.1 Moving around. . . . . . . . . . . . . 3.3.2 Looking at the contents of directories. 3.3.3 Creating new directories. . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . .
CONTENTS
TOC
3.3.4 Copying les. . . . . . . . . . . . . . 3.3.5 Moving les. . . . . . . . . . . . . . 3.3.6 Deleting les and directories. . . . . 3.3.7 Looking at les. . . . . . . . . . . . 3.3.8 Getting online help. . . . . . . . . . . Accessing MS-DOS les. . . . . . . . . . . . Summary of basic UNIX commands. . . . . . Exploring the le system. . . . . . . . . . . . Types of shells. . . . . . . . . . . . . . . . . Wildcards. . . . . . . . . . . . . . . . . . . . Linux plumbing. . . . . . . . . . . . . . . . 3.9.1 Standard input and standard output. . 3.9.2 Redirecting input and output. . . . . . 3.9.3 Using pipes. . . . . . . . . . . . . . 3.9.4 Non-destructive redirection of output. File permissions. . . . . . . . . . . . . . . . 3.10.1 Concepts of le permissions. . . . . . 3.10.2 Interpreting le permissions. . . . . . 3.10.3 Permissions Dependencies. . . . . . . 3.10.4 Changing permissions. . . . . . . . . Managing le links. . . . . . . . . . . . . . . 3.11.1 Hard links. . . . . . . . . . . . . . . 3.11.2 Symbolic links. . . . . . . . . . . . . Job control. . . . . . . . . . . . . . . . . . . 3.12.1 Jobs and processes. . . . . . . . . . . 3.12.2 Foreground and background. . . . . . 3.12.3 Backgrounding and killing jobs. . . . 3.12.4 Stopping and restarting jobs. . . . . . Using the vi editor. . . . . . . . . . . . . . . 3.13.1 Concepts. . . . . . . . . . . . . . . . 3.13.2 Starting vi. . . . . . . . . . . . . . . 3.13.3 Inserting text. . . . . . . . . . . . . . 3.13.4 Deleting text. . . . . . . . . . . . . . 3.13.5 Changing text. . . . . . . . . . . . . 3.13.6 Commands for moving the cursor. . . 3.13.7 Saving les and quitting vi. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 143 143 143 144 145 146 148 153 154 157 157 158 159 161 161 161 162 163 164 164 164 166 166 166 167 168 170 172 173 173 174 175 176 177 178
3.10
3.11
3.12
3.13
vi
CONTENTS
TOC
3.13.8 Editing another le. . . . . . . . . . 3.13.9 Including other les. . . . . . . . . 3.13.10 Running shell commands. . . . . . 3.13.11 Getting vi help. . . . . . . . . . . 3.14 Customizing your environment. . . . . . . 3.14.1 Shell scripts. . . . . . . . . . . . . 3.14.2 Shell variables and the environment. 3.14.3 Shell initialization scripts. . . . . . 3.15 So you want to strike out on your own? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 178 179 179 180 180 181 182 185 186 187 187 188 189 191 192 196 196 198 199 200 201 201 202 204 205 205 206 206 207 207 208 208 209 210 211
4 System Administration 4.1 The root account. . . . . . . . . . . . . . . . 4.2 Booting the system. . . . . . . . . . . . . . . . 4.2.1 Using LILO. . . . . . . . . . . . . . . 4.3 Shutting down. . . . . . . . . . . . . . . . . . 4.3.1 The /etc/inittab le. . . . . . . . 4.4 Managing le systems. . . . . . . . . . . . . . 4.4.1 Mounting le systems. . . . . . . . . . 4.4.2 Device driver names. . . . . . . . . . . 4.4.3 Checking le systems. . . . . . . . . . 4.5 Using a swap le. . . . . . . . . . . . . . . . . 4.6 Managing users. . . . . . . . . . . . . . . . . . 4.6.1 User management concepts. . . . . . . 4.6.2 Adding users. . . . . . . . . . . . . . . 4.6.3 Deleting users. . . . . . . . . . . . . . 4.6.4 Setting user attributes. . . . . . . . . . 4.6.5 Groups. . . . . . . . . . . . . . . . . . 4.6.6 System administration responsibilities. 4.6.7 Coping with users. . . . . . . . . . . . 4.6.8 Setting the rules. . . . . . . . . . . . . 4.6.9 What it all means. . . . . . . . . . . . 4.7 Archiving and compressing les. . . . . . . . . 4.7.1 Using tar. . . . . . . . . . . . . . . . 4.7.2 gzip and compress. . . . . . . . . . 4.7.3 Putting them together. . . . . . . . . . 4.8 Using oppies and making backups. . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . .
CONTENTS
vii
TOC
4.8.1 Using oppies for backups. . . . . . . . 4.8.2 Backups with a Zip drive. . . . . . . . 4.8.3 Making backups to tape devices. . . . . 4.8.4 Using oppies as le systems. . . . . . 4.9 Upgrading and installing new software. . . . . 4.9.1 Upgrading the kernel . . . . . . . . . . 4.9.2 Adding a device driver to the kernel. . . 4.9.3 Installing a device driver module. . . . 4.9.4 Upgrading the libraries. . . . . . . . . 4.9.5 Upgrading gcc. . . . . . . . . . . . . 4.9.6 Upgrading other software. . . . . . . . 4.10 Miscellaneous tasks. . . . . . . . . . . . . . . 4.10.1 System startup les. . . . . . . . . . . 4.10.2 Setting the host name. . . . . . . . . . 4.11 What to do in an emergency. . . . . . . . . . . 4.11.1 Recovery with a maintenance diskette. . 4.11.2 Fixing the root password. . . . . . . . . 4.11.3 Trashed le systems. . . . . . . . . . . 4.11.4 Recovering lost les. . . . . . . . . . . 4.11.5 Trashed libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 212 213 214 215 216 217 219 221 223 224 224 224 225 225 226 227 227 228 228 228 229 230 230 231 231 234 235 235 244 247 248
5 The X Window System 5.1 X Window Hardware requirements. . . . . . . . 5.1.1 Video display. . . . . . . . . . . . . . . . 5.1.2 Memory, CPU, and disk space. . . . . . . 5.2 XFree86 installation. . . . . . . . . . . . . . . . 5.3 Probing the hardware conguration. . . . . . . . 5.4 Automatically generating the XF86Config le. 5.5 Conguring XFree86. . . . . . . . . . . . . . . . 5.6 Filling in video card information. . . . . . . . . . 5.7 Running XFree86. . . . . . . . . . . . . . . . . . 5.8 When you run into trouble. . . . . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
. . . . . . . . . .
6 Networking 250 6.1 Networking with TCP/IP. . . . . . . . . . . . . . . . . . . . . . . . . . . . 250 6.1.1 Conguring TCP/IP on your system. . . . . . . . . . . . . . . . . . 251 6.1.2 SLIP conguration. . . . . . . . . . . . . . . . . . . . . . . . . . . 260
viii
CONTENTS
TOC
6.2 Dial-up networking and PPP. . . . . . . . . . . . . . . . . . . . . . . . . 6.2.1 What you need to get started. . . . . . . . . . . . . . . . . . . . . 6.2.2 An overview of the steps involved. . . . . . . . . . . . . . . . . . 6.2.3 Creating the connection scripts. . . . . . . . . . . . . . . . . . . 6.2.4 Editing the supplied PPP startup scripts. . . . . . . . . . . . . . . 6.2.5 Starting PPP at the server end. . . . . . . . . . . . . . . . . . . . 6.2.6 If your PPP server uses PAP (Password Authentication Protocol). 6.2.7 Using MSCHAP. . . . . . . . . . . . . . . . . . . . . . . . . . . 6.2.8 Shutting down the PPP link. . . . . . . . . . . . . . . . . . . . . 6.2.9 Troubleshooting common problems once the link is working. . . . Networking with UUCP. . . . . . . . . . . . . . . . . . . . . . . . . . . Networking with Microsoft Systems. . . . . . . . . . . . . . . . . . . . . Electronic mail. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . News and Usenet. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 266 266 267 279 282 284 285 286 289 289 291 292 292 293 296 310 318
A Sources of Linux Information B FTP Tutorial and Site List C The GNU General Public License
TOC
Preface
Linux Installation and Getting Started (LIGS) has been the shepherding work for countless new users of the Linux operating system. Linux continues to evolve and so, too, must this guide. Matt Welsh, the original author, has turned the book over to the care and management of Specialized Systems Consultants, Inc. (SSC), publishers of Linux Journal, computer books, and references. Linux Installation and Getting Started is still covered by the GNU General Public Licenseit is still freely redistributable, like the operating system it describes. This new version becomes a collaborative effort of individuals separated by geography but brought together on the Internet, much like Linux itself. If you believe you could expand or update a section of Linux Installation and Getting Started or have something new and wonderful to add, please send e-mail to [email protected] and tell us how youd like to contribute. For this edition, weve added distribution-specic instructions for obtaining and installing S.u.S.E. Linux, Debian GNU/Linux, Linux Slackware, Caldera OpenLinux, and Red Hat Linux. Please read through the acknowledgements, and if you should meet someone named there on line or in person, thank them for the help. Specialized Systems Consultants, Inc. (SSC) February 1998
ix
Preface
TOC
heritage, and although the development of Linux may appear to be a disorganized volunteer effort, the system is powerful, fast, and free. It is a true 32-bit operating system solution. My own experiences with Linux began several years ago when I sat down to gure out how to install the only distribution available at the timea couple of diskettes made available by H. J. Lu. I downloaded a slew of les and read page upon page of looselyorganized installation notes. Somehow, I managed to install this basic system and get everything to work together. This was long before you could buy the Linux software on CD-ROM from worldwide distributors; before, in fact, Linux was able to access a CDROM drive. This was before XFree86, before Emacs, before commercial software support, and before Linux became a true rival to MS-DOS, Microsoft Windows, and OS/2 in the personal computer market. You hold in your hands a map and guidebook to the world of Linux. It is my hope that this book will help you get rolling with what I consider to be the fastest, most powerful operating system for the personal computer. Setting up your own Linux system can be great funso grab a cup of coffee, sit back, and read on. Matt Welsh January 1994
xi
TOC
xii
Preface
TOC
Audience.
This book is for personal computer users who want to install and use Linux. We assume that you have basic knowledge about personal computers and operating systems like MSDOS, but no previous knowledge of Linux or UNIX. Despite this, we strongly suggest that UNIX novices invest in one of the many good UNIX books out there. You still need UNIX know-how to install and run a complete system. No distribution of Linux is completely bug-free. You may be required to x small problems by hand. Running a UNIX system is not an easy task, even with commercial versions of UNIX. If youre serious about Linux, bear in mind that it takes considerable effort and attention to keep the system running. This is true of any UNIX system. Because of the diversity of the Linux community and the many needs which the software attempts to meet, not everything can be taken care of for you all of the time.
Organization.
This book contains the following chapters: Chapter 1, Introduction to Linux, is a general introduction to Linux, its capabilities, and requirements for running it on your system. It also provides hints for getting help and reducing your stress level. Chapter 2, Obtaining and Installing Linux, explains how to obtain and install Linux software, beginning with drive repartitioning, creating lesystems, and installing software packages. The chapter contains instructions that are meant to be general for any Linux distribution and relies for specics on the documentation provided by your particular release. Chapter 3, Linux Tutorial, is a complete introduction for UNIX novices. If you have previous UNIX experience, most of this material should be familiar. Chapter 4, System Administration, introduces important concepts for system administration under Linux. This will be of interest to UNIX system administrators who want to know about the Linux-specic issues for running a system. Chapters 5 and 6, X Windows and Networking, introduce a number of advanced options that Linux supports, like the X Window System and TCP/IP networking. We also provide a complete guide to conguring XFree86-3.1. Appendix A, Sources of Linux Information, is a list of further documentation sources like newsgroups, mailing lists, on-line documents, and books. Appendix B, FTP Tutorial and Site List, is a tutorial for downloading les from the Internet with FTP. This appendix also lists FTP archive sites that carry Linux software.
xiii
TOC
Appendix C, The GNU General Public License, is the license agreement under which Linux is distributed. It is important that Linux users understand the GPL. Many disagreements over the terms in describes have been raised.
Acknowledgments.
This edition builds on the work of those who have gone before, and they are thanked below in Matt Welshs original acknowledgement. Additionally, we owe thanks to Larry Ayers, Boris Beletsky, Sean Dreilinger, Evan Leibovitch, and Henry Pierce for contributing the information in Chapter 2 on S.u.S.E. Linux, Debian GNU/Linux, Linux Slackware, Caldera OpenLinux, and Red Hat Linux, respectively. David Bandel updated Chapter 2 and added a section describing a generic Linux installation. Vernard Martin updated and added to Chapter 5. Thanks are also due to Belinda Frazier for editing and to Jay Painter for the update to Chapter 4 on systems administration.
xiv
Preface
TOC
xv
TOC
Conventions.
We have attempted to use the following documentation conventions in this guide: Bold italics Used to mark new concepts, WARNINGS, and keywords in a language. Used for emphasis in text, and occasionally for quotes or introductions at the beginnings of sections. Used to mark meta-variables in the text, especially in command lines. For example, in ls -l foo
slanted
Also used for code examples, whether C code, shell scripts, or to display les like conguration les. When necessary for the sake of clarity, these examples or gures are enclosed in thin boxes.
Key
A diamond in the margin, like a black diamond on a ski hill, marks danger or caution. Carefully read the paragraphs so marked.
TOC
Chapter 1
Introduction to Linux
Linux is quite possibly the most important free software achievement since the original Space War, or, more recently, Emacs. It has developed into an operating system for business, education, and personal productivity. Linux is no longer only for UNIX wizards who sit for hours in front of a glowing console (although we assure you that many users fall into this category). This book will help you get the most from Linux. Linux (pronounced with a short i, as in LIH-nucks) is a UNIX operating system clone which runs on a variety of platforms, especially personal computers with Intel 80386 or better processors. It supports a wide range of software, from TEX, to the X Window System, to the GNU C/C++ compiler, to TCP/IP. Its a versatile, bona de implementation of UNIX, freely distributed under the terms of the GNU General Public License (see Appendix C). Linux can turn any 80386 or better personal computer into a workstation that puts the full power of UNIX at your ngertips. Businesses install Linux on entire networks of machines, and use the operating system to manage nancial and hospital records, distributed computing environments, and telecommunications. Universities worldwide use Linux to teach courses on operating system programming and design. Computing enthusiasts everywhere use Linux at home for programming, productivity, and all-around hacking. What makes Linux so different is that it is a free implementation of UNIX. It was and still is developed cooperatively by a group of volunteers, primarily on the Internet, who exchange code, report bugs, and x problems in an open-ended environment. Anyone is welcome to join the Linux development effort. All it takes is interest in hacking a free UNIX clone, and some programming know-how. The book in your hands is your tour guide.
Introduction to Linux
TOC
TOC
Introduction to Linux
TOC
of 1991): it wasnt pretty, it had no oppy driver, and it couldnt do much of anything. I dont think anybody ever compiled that version. But by then I was hooked, and didnt want to stop until I could chuck out Minix. No announcement was ever made for Linux version 0.01. The 0.01 sources werent even executable. They contained only the bare rudiments of the kernel source and assumed that you had access to a Minix machine to compile and experiment with them. On October 5, 1991, Linus announced the rst ofcial version of Linux, which was version 0.02. At that point, Linus was able to run bash (the GNU Bourne Again Shell) and gcc (the GNU C compiler), but not much else. Again, this was intended as a hackers system. The primary focus was kernel developmentuser support, documentation, and distribution had not yet been addressed. Today, the Linux community still seems to treat these issues as secondary to real programmingkernel development. As Linus wrote in comp.os.minix, Do you pine for the nice days of Minix-1.1, when men were men and wrote their own device drivers? Are you without a nice project and just dying to cut your teeth on an OS you can try to modify for your needs? Are you nding it frustrating when everything works on Minix? No more all-nighters to get a nifty program working? Then this post might be just for you. As I mentioned a month ago, Im working on a free version of a Minixlook-alike for AT-386 computers. It has nally reached the stage where its even usable (though may not be, depending on what you want), and I am willing to put out the sources for wider distribution. It is just version 0.02. . . but Ive successfully run bash, gcc, gnu-make, gnu-sed, compress, etc. under it. After version 0.03, Linus bumped up the version number to 0.10, as more people started to work on the system. After several further revisions, Linus increased the version number to 0.95 in March, 1992, to reect his expectation that the system was ready for an ofcial release soon. (Generally, software is not assigned the version number 1.0 until it is theoretically complete or bug-free.). Almost a year and a half later, in late December of 1993, the Linux kernel was still at version 0.99.pl14asymptotically approaching 1.0. At the time of this writing, the current stable kernel version is 2.0 patchlevel 33, and version 2.1 is under development. Most of the major, free UNIX software packages have been ported to Linux, and commercial software is also available. More hardware is supported than in the original kernel versions. Many people have executed benchmarks on 80486 Linux systems and found them
TOC
comparable with mid-range workstations from Sun Microsystems and Digital Equipment Corporation. Who would have ever guessed that this little UNIX clone would have grown up to take on the entire world of personal computing?
Introduction to Linux
TOC
The complete range of TCP/IP clients and services is also supported, which includes FTP, telnet, NNTP, and SMTP. Well talk more about networking in Chapter ??. The Linux kernel is developed to use protected-mode features of Intel 80386 and better processors. In particular, Linux uses the protected-mode, descriptor based, memorymanagement paradigm, and other advanced features. Anyone familiar with 80386 protected-mode programming knows that this chip was designed for multitasking systems like UNIX. Linux exploits this functionality. The kernel supports demand-paged, loaded executables. Only those segments of a program which are actually in use are read into memory from disk. Also, copy-on-write pages are shared among executables. If several instances of a program are running at once, they share physical memory, which reduces overall usage. In order to increase the amount of available memory, Linux also implements disk paging. Up to one gigabyte of swap space1 may be allocated on disk (upt to 8 partitions of 128 megabytes each). When the system requires more physical memory, it swaps inactive pages to disk, letting you run larger applications and support more users. However, swapping data to disk is no substitute for physical RAM, which is much faster. The Linux kernel also implements a unied memory pool for user programs and disk cache. All free memory is used by the cache, which is reduced when running large programs. Executables use dynamically linked, shared libraries: code from a single library on disk. This is not unlike the SunOS shared library mechanism. Executable les occupy less disk space, especially those which use many library functions. There are also statically linked libraries for object debugging and maintaining complete binary les when shared libraries are not installed. The libraries are dynamically linked at run time, and the programmer can use his or her own routines in place of the standard library routines. To facilitate debugging, the kernel generates core dumps for post-mortem analysis. A core dump and an executable linked with debugging support allows a developer to determine what caused a program to crash.
Software Features
TOC
commands and utilities are included. (Novice UNIX or Linux users should see Chapter 3 for an introduction to basic UNIX commands.) Many text editors are available, including vi, ex, pico, jove, and GNU emacs, and variants like Lucid emacs, which incorporates extensions of the X Window System, and joe. The text editor youre accustomed to using has more than likely been ported to Linux. The choice of a text editor is an interesting one. Many UNIX users prefer simple editors like vi. (The original author wrote this book with vi.) But vi has many limitations due to its age, and modern editors like emacs have gained popularity. emacs supports a complete, Lisp based macro language and interpreter, powerful command syntax, and other extensions. There are emacs macro packages which let you read electronic mail and news, edit directory contents, and even engage in articially intelligent psychotherapy sessions (indispensible for stressed-out Linux hackers). Most of the basic Linux utilities are GNU software. GNU utilities support advanced features that are not found in the standard versions of BSD and UNIX System Vprograms. For example, the GNU vi clone, elvis, includes a structured macro language that differs from the original implementation. However, GNU utilities are intended to remain compatible with their BSD and System V counterparts. Many people consider the GNU versions to be superior to the originals. A shell is a program which reads and executes commands from the user. In addition, many shells provide features like job control, managing several processes at once, input and output redirection, and a command language for writing shell scripts. A shell script is a program in the shells command language and is analogous to a MS-DOS batch le. Many types of shells are available for Linux. The most important difference between shells is the command language. For example, the C SHell (csh) uses a command language similar to the C programming language. The classic Bourne SHell sh uses another command language. The choice of a shell is often based on the command language it provides, and determines, to a large extent, the qualities of your working environment under Linux. The GNU Bourne Again Shell (bash) is a variation of the Bourne Shell which includes many advanced features like job control, command history, command and lename completion, an emacs-like interface for editing command lines, and other powerful extensions to the standard Bourne Shell language. Another popular shell is tcsh, a version of the C Shell with advanced functionality similar to that found in bash. Other shells include zsh, a small Bourne-like shell; the Korn Shell (ksh); BSDs ash; and rc, the Plan 9 shell. If youre the only person using the system and refer to use vi and bash exclusively
Introduction to Linux
TOC
as your editor and shell, theres no reason to install other editors or shells. This do it yourself attitude is prevalent among Linux hackers and users.
Software Features
TOC
processor itself. Because a source document is not stored in an obscure format that only one word processor can read, programmers can write parsers and translators for the formatting language, and thus extend the system. What does a formatting language look like? In general, a formatted source le consists mostly of the text itself, with control codes to produce effects like font and margin changes, and list formatting. Consider the following text: Mr. Torvalds: We are very upset with your current plans to implement post-hypnotic suggestions in the Linux terminal driver code. We feel this way for three reasons: 1. Planting subliminal messages in the terminal driver is not only immoral, it is a waste of time; 2. It has been proven that post-hypnotic suggestions are ineffective when used upon unsuspecting UNIX hackers; 3. We have already implemented high-voltage electric shocks, as a security measure, in the code for login. We hope you will reconsider.
A TEX formatting language as the following: This text might appear in the L
\begin{quote} Mr. Torvalds: We are very upset with your current plans to implement {\em post-hypnotic suggestions\/} in the {\bf Linux} terminal driver code. We feel this way for three reasons: \begin{enumerate} \item Planting subliminal messages in the kernel driver is not only immoral, it is a waste of time; \item It has been proven that post-hypnotic suggestions are ineffective when used upon unsuspecting UNIX hackers; \item We have already implemented high-voltage electric shocks, as a security measure, in the code for {\tt login}. \end{enumerate} We hope you will reconsider.
10
Introduction to Linux
TOC
\end{quote} The author enters the text using any text editor and generates formatted output by proA TEX. At rst glance, the typesetting language may appear to be cessing the source with L obscure, but its actually quite easy to understand. Using a text processing system enforces typographical standards when writing. All the enumerated lists within a document will look the same, unless the author modies the denition of an enumerated list. The goal is to allow the author to concentrate on the text, not typesetting conventions. When writing with a text editor, one generally does not think about how the printed text will appear. The writer learns to visualize the nished texts appearance from the formatting commands in the source. WYSIWYG word processors are attractive for many reasons. They provide an easyto-use visual interface for editing documents. But this interface is limited to aspects of text layout which are accessible to the user. For example, many word processors still provide a special format language for producing complicated expressions like mathematical formulae. This is text processing, albeit on a much smaller scale. A not-so-subtle benet of text processing is that you specify exactly which format you need. In many cases, the text processing system requires a format specication. Text processing systems also allow source text to be edited with any text editor, instead of relying on format codes which are hidden beneath a word processors opaque user interface. Further, the source text is easily converted to other formats. The tradeoff for this exibility and power is the lack of WYSIWYG formatting. Some programs let you preview the formatted document on a graphics display device before printing. The xdvi program displays a device independent le generated by the TEX system under X. Applications like xfig and gimp provide WYSIWYG graphics interfaces for drawing gures and diagrams, which are subsequently converted to text processing language for inclusion in your document. Text processors like troff were around long before WYSIWYG word processing was available. Many people still prefer their versatility and independence from a graphics environment. Many text-processing-related utilities are available. The powerful METAFONT system, which is used to design fonts for TEX, is included in the Linux port of TEX. Other programs include ispell, an interactive spelling checker and corrector; makeindex, A TEX documents; and many other groff and TEXbased macro which generates indices in L packages which format many types of technical and mathematical texts. Conversion programs that translate between TEX or groff source to a myriad of other formats are also available.
Software Features
11
TOC
A newcomer to text formatting is YODL, written by Karel Kubat. YODL is an easyA to-learn language with lters to produce various output formats, like L TEX, SGML, and HTML.
12
Introduction to Linux
TOC
RCS, a system for source code locking and revision control. Finally, Linux supports dynamically linked, shared libraries (DLLs), which result in much smaller binaries. The common subroutine code is linked at run-time. These DLLs let you override function denitions with your own code. For example, if you wish to write your own version of the malloc() library routine, the linker will use your new routine instead of the one in the libraries.
Software Features
13
TOC
advanced window managers like the Open Look Virtual Window Manager (olvwm) are available. Popular among Linux users is fvwma small window manager that requires less than half the memory of twm. It provides a 3-dimensional appearance for windows and a virtual desktop. The user moves the mouse to the edge of the screen, and the desktop shifts as though the display were much larger than it really is. fvwm is greatly customizable and allows access to functions from the keyboard as well as mouse. Many Linux distributions use fvwm as the standard window manager. A version of fvwm called fvwm95-2 offers Microsoft Windows 95-like look and feel. The XFree86 distribution includes programming libraries for wily programmers who wish to develop X applications. Widget sets like Athena, Open Look, and Xaw3D are supported. All of the standard fonts, bitmaps, manual pages, and documentation are included. PEX (a programming interface for 3-dimensional graphics) is also supported. Many X application programmers use the proprietary Motif widget set for development. Several vendors sell single and multiple user licenses for binary versions of Motif. Because Motif itself is relatively expensive, not many Linux users own it. However, binaries statically linked with Motif routines can be freely distributed. If you write a program using Motif, you may provide a binary so users without the Motif libraries can use the program. A major caveat to using the X Window System is its hardware requirements. A 80386based CPU with 4 megabytes of RAM is capable of running X, but 16 megabytes or more of physical RAM is needed for comfortable use. A faster processor is nice to have as well, but having enough physical RAM is much more important. In addition, to achieve really slick video performance, we recommend getting an accelerated video card, like a VESA Local Bus (VLB) S3 chipset card. Performance ratings in excess of 300,000 xstones have been achieved with Linux and XFree86. Using adequate hardware, youll nd that running X and Linux is as fast, or faster, than running X on other UNIX workstations. In Chapter ?? we discuss how to install and use X on your system.
14
Introduction to Linux
TOC
many popular Ethernet cards and interfaces for personal computers, including pocket and PCMCIA Ethernet adaptors. However, because not everyone has an Ethernet connection at home, Linux also supports SLIP (Serial Line Internet Protocol) and PPP (Point-to-Point Protocol), which provide Internet access via modem. Many businesses and universities provide SLIP and PPP servers. In fact, if your Linux system has an Ethernet connection to the Internet and a modem, your system can become a SLIP or PPP server for other hosts. NFS (Network File System) lets your system seamlessly share le systems with other machines on the network. FTP (File Transfer Protocol) lets you transfer les with other machines. sendmail sends and receives electronic mail via the SMTP protocol; C-News and INN are NNTP based new systems; and telnet, rlogin, and rsh let you log in and execute commands on other machines on the network. finger lets you get information about other Internet users. Linux also supports Microsoft Windows connectivity via Samba2 , and Macintosh connectivity with AppleTalk and LocalTalk. Support for Novells IPX protocol is also included. The full range of mail and news readers is available for Linux, including elm, pine, rn, nn, and tin. Whatever your preference, you can congure a Linux system to send and receive electronic mail and news from all over the world. The system provides a standard UNIX socket programming interface. Virtually any program that uses TCP/IP can be ported to Linux. The Linux X server also supports TCP/IP, and applications running on other systems may use the display of your local system. In Chapter ??, we discuss the installation of TCP/IP software, including SLIP and PPP. UUCP (UNIX-to-UNIX Copy) is an older mechanism to transfer les, electronic mail, and electronic news between UNIX machines. Historically, UUCP machines are connected over telephone lines via modem, but UUCP is able to transfer data over a TCP/IP network as well. If you do not have access to a TCP/IP network or a SLIP or PPP server, you can congure your system to send and receive les and electronic mail using UUCP. See Chapter ?? for more information.
Software Features
15
TOC
Prodigy, CompuServe, and America Online. People use modems to connect to UNIX systems at work or school. Modems can send and receive faxes. A popular communications package for Linux is seyon, which provides a customizable, ergonomic interface undex X and has built-in support for the Kermit and ZModem le transfer protocols. Other telecommunications programs include C-Kermit, pcomm, and minicom. These are similar to communications programs found on other operating systems, and are quite easy to use. If you do not have access to a SLIP or PPP server (see the previous section), you can use term to multiplex your serial line. The term program allows you to open more than one login session over a modem connection. It lets you redirect X client connections to your local X server via a serial line. Another software package, KA9Q, implements a similar, SLIP-like interface. Operating a Bulletin Board System (BBS) is a favorite hobby and means of income for many people. Linux supports a wide range of BBS software, most of which is more powerful than that available for other operating systems. With a phone line, modem, and Linux, you can turn your system into a BBS and provide dial-in access for users worldwide. BBS software for Linux includes XBBS and UniBoard BBS packages. Most BBS software locks the user into a menu based system where only certain functions and applications are available. An alternative to BBS access is full UNIX access, which lets users dial into your system and log in normally. This requires a fair amount of maintenance by the system administrator, but providing public UNIX access is not difcult. In addition to TCP/IP networking, you can make electronic mail and news access available on your system. If you do not have access to a TCP/IP network or UUCP feed, Linux lets you communicate with BBS networks like FidoNet, which let you exchange electronic news and mail over a telephone line. You can nd more information on telecommunications and BBS software under Linux in Chapter ??.
16
Introduction to Linux
TOC
Linux provides complete support for Java and CGI applets, and Perl is a standard tool in the Linux programming environment.
Software Features
17
18
Introduction to Linux
TOC
commercial application, there may be a free clone available. Or, you can encourage the software company to consider releasing a binary version for Linux. Several individuals have contacted software companies and asked them to port their applications to Linux, with various degrees of success.
19
TOC
This may sound like a contradiction. Why sell software when the GPL allows you to get it for free? Lets say that a company decided to bundle a large amount of free software on a CD-ROM and distribute it. That company would need to charge for the overhead of producing and distributing the CD-ROM, and may even decide to prot from the sales of the software. This is allowed by the GPL. Organizations that sell free software must follow certain restrictions set forth in the GPL. They cannot restrict the rights of users who purchase the software. If you buy a CD-ROM that contains GPL software, you can copy and distribute the CD-ROM free of charge, or resell it yourself. Distributors must make obvious to users that the software is covered by the GPL. Distributors must also provide, free of charge, the complete source code to the software distributed. This permits anyone who purchases GPL software to make modications to that software. Allowing a company to distribute and sell free software is a good thing. Not everyone has access to the Internet and the ability to download software for free. Many organizations sell Linux on diskette, tape, or CD-ROM via mail order, and prot from the sales. Linux developers may never see any of this prot; that is the understanding reached between the developer and the distributor when software is licensed by the GPL. In other words, Linus Torvalds knew that companies may wish to sell Linux, and that he might not see a penny of the prots. In the free software world, the important issue is not money. The goal of free software is always to develop and distribute fantastic software and allow anyone to obtain and use it. In the next section, well discuss how this applies to the development of Linux.
20
Introduction to Linux
TOC
Organizationally, a quality assurance department runs rigorous tests on each new version of the operating system and reports any bugs. The developers x these bugs as reported. A complex system of statistical analysis is used to ensure that a certain percentage of bugs are xed before the next release, and that the operating system as a whole passes certain release criteria. The software company, quite reasonably, must have quantitative proof that the next revision of the operating system is ready to be shipped; hence, the gathering and analysis of statistics about the performance of the operating system. It is a big job to develop a commercial UNIX system, often large enough to employ hundreds, if not thousands, of programmers, testers, documenters, and administrative personnel. Of course, no two commercial UNIX vendors are alike, but that is the general picture. The Linux model of software development discards the entire concept of organized development, source code control systems, structured bug reporting, and statistical quality control. Linux is, and likely always will be, a hackers operating system. (By hacker, I mean a feverishly dedicated programmer who enjoys exploiting computers and does interesting things with them. This is the original denition of the term, in contrast to the connotation of hacker as a computer wrongdoer, or outlaw.) There is no single organization responsible for developing Linux. Anyone with enough know-how has the opportunity to help develop and debug the kernel, port new software, write documentation, and help new users. For the most part, the Linux community communicates via mailing lists and Usenet newsgroups. Several conventions have sprung up around the development effort. Anyone who wishes to have their code included in the ofcial kernel, mails it to Linus Torvalds. He will test and include the code in the kernel as long as it doesnt break things or go against the overall design of the system. The system itself is designed using an open-ended, feature-minded approach. The number of new features and critical changes to the system has recently diminished, and the general rule is that a new version of the kernel will be released every few weeks. Of course, this is a rough gure. New release criteria include the number of bugs to be xed, feedback from users testing pre-release versions of the code, and the amount of sleep Linus Torvalds has had this week. Sufce it to say that not every bug is xed, nor is every problem ironed out between releases. As long as the revision appears to be free of critical or recurring bugs, it is considered to be stable, and the new version is released. The thrust behind Linux development is not to release perfect, bug-free code: it is to develop a free UNIX implementation. Linux is for the developers, more than anyone else. Anyone who has a new feature or software application generally makes it available in an
21
TOC
alpha versionthat is, a test version, for those brave users who want to hash out problems in the initial code. Because the Linux community is largely based on the Internet, alpha software is usually uploaded to one or more Linux FTP sites (see Appendix B), and a message is posted to one of the Linux Usenet newsgroups about how to obtain and test the code. Users who download and test alpha software can then mail results, bug xes, and questions to the author. After the initial bugs have been xed, the code enters a beta test stage, in which it is usually considered stable but not complete. It works, but not all of the features may be present. The software may also go directly to a nal stage, in which the software is considered complete and usable. Keep in mind that these are only conventionsnot rules. Some developers may feel so condent of their software that they decide it isnt necessary to release alpha or test versions. It is always up to the developer to make these decisions. You might be amazed at how such an unstructured system of volunteers who program and debug a complete UNIX system gets anything done at all. As it turns out, this is one of the most efcient and motivated development efforts ever employed. The entire Linux kernel is written from scratch, without code from proprietary sources. It takes a huge amount of work to port all the free software under the sun to Linux. Libraries are written and ported, le systems are developed, and hardware drivers are written for many popular devicesall due to the work of volunteers. Linux software is generally released as a distribution, a set of prepackaged software which comprises an entire system. It would be difcult for most users to build a complete system from the ground up, starting with the kernel, adding utilities, and installing all of the necessary software by hand. Instead, many software distributions are available which include everything necessary to install and run a complete system. There is no single, standard distributionthere are many, and each has its own advantages and disadvantages. We describe installation of the various Linux distributions starting on page 53.
22
Introduction to Linux
TOC
are even ways to interact between various operating systems, as well see. Why use Linux? Why use Linux, instead of a well known, well tested, and well documented commercial operating system? We could give you a thousand reasons. One of the most important, however, is that Linux is an excellent choice for personal UNIX computing. If youre a UNIX software developer, why use MS-DOS at home? Linux allows you to develop and test UNIX software on your PC, including database and X Window System applications. If youre a student, chances are that your university computing systems run UNIX. You can run your own UNIX system and tailor it to your needs. Installing and running Linux is also an excellent way to learn UNIX if you dont have access to other UNIX machines. But lets not lose sight. Linux isnt only for personal UNIX users. It is robust and complete enough to handle large tasks, as well as distributed computing needs. Many businessesespecially small oneshave moved their systems to Linux in lieu of other UNIX based, workstation environments. Universities have found that Linux is perfect for teaching courses in operating systems design. Large, commercial software vendors have started to realize the opportunities which a free operating system can provide. Linux vs. MS-DOS. Its not uncommon to run both Linux and MS-DOS on the same system. Many Linux users rely on MS-DOS for applications like word processing. Linux provides its own analogs for these applications, but you might have a good reason to run MS-DOS as well as Linux. If your dissertation is written using WordPerfect for MS-DOS, you may not be able to convert it easily to TEX or some other format. Many commercial applications for MS-DOS arent available for Linux yet, but theres no reason that you cant use both. MS-DOS does not fully utilize the functionality of 80386 and 80486 processors. On the other hand, Linux runs completely in the processors protected mode, and utilizes all of its features. You can directly access all of your available memory (and beyond, with virtual RAM). Linux provides a complete UNIX interface which is not available under MS-DOS. You can easily develop and port UNIX applications to Linux, but under MS-DOS you are limited to a subset of UNIX functionality. Linux and MS-DOS are different entities. MS-DOS is inexpensive compared to other commercial operating systems and has a strong foothold in the personal computer world. No other operating system for the personal computer has reached the level of popularity of MS-DOS, because justifying spending $1,000 for other operating systems alone is unrealistic for many users. Linux, however, is free, and you may nally have the chance to decide
23
TOC
for yourself. You can judge Linux vs. MS-DOS based on your expectations and needs. Linux is not for everybody. If you always wanted to run a complete UNIX system at home, without the high cost of other UNIX implementations for personal computers, Linux may be what youre looking for. Linux vs. The Other Guys. A number of other advanced operating systems have become popular in the PC world. Specically, IBMs OS/2 and Microsoft Windows have become popular for users upgrading from MS-DOS. Both OS/2 and Windows NT are full featured multitasking operating systems, like Linux. OS/2, Windows NT, and Linux support roughly the same user interface, networking, and security features. However, the real difference between Linux and The Other Guys is the fact that Linux is a version of UNIX, and benets from contributions of the UNIX community at large. What makes UNIX so important? Not only is it the most popular operating system for multiuser machines, it is a foundation of the free software world. Much of the free software available on the Internet is written specically for UNIX systems. There are many implementations of UNIX from many vendors. No single organization is responsible for its distribution. There is a large push in the UNIX community for standardization in the form of open systems, but no single group controls this design. Any vendor (or, as it turns out, any hacker) may develop a standard implementation of UNIX. OS/2 and Microsoft operating systems, on the other hand, are proprietary. The interface and design are controlled by a single corporation, which develops the operating system code. In one sense, this kind of organization is benecial because it sets strict standards for programming and user interface design, unlike those found even in the open systems community. Several organizations have attempted the difcult task of standardizing the UNIX programming interface. Linux, in particular, is mostly compliant with the POSIX.1 standard. As time goes by, it is expected that the Linux system will adhere to other standards, but standardization is not the primary goal of Linux development. Linux vs. other implementations of UNIX. Several other implementations of UNIX exist for 80386 or better personal computers. The 80386 architecture lends itself to UNIX, and vendors have taken advantage of this. Oher implementations of UNIX for the personal computer are similar to Linux. Almost all commercial versions of UNIX support roughly the same software, programming
24
Introduction to Linux
TOC
environment, and networking features. However, there are differences between Linux and commercial versions of UNIX. Linux supports a different range of hardware than commercial implementations. In general, Linux supports most well-known hardware devices, but support is still limited to hardware which the developers own. Commercial UNIX vendors tend to support more hardware at the outset, but the list of hardware devices which Linux supports is expanding continuously. Well cover the hardware requirements for Linux in Section 1.8. Many users report that Linux is at least as stable as commercial UNIX systems. Linux is still under development, but the two-pronged release philosophy has made stable versions available without impeding development. The most important factor for many users is price. Linux software is free if you can download it from the Internet or another computer network. If you do not have Internet access, you can still purchase Linux inexpensively via mail order on diskette, tape, or CDROM. Of course, you may copy Linux from a friend who already has the software, or share the purchase cost with someone else. If you plan to install Linux on a large number of machines, you need only purchase a single copy of the softwareLinux is not distributed with a single machine license. The value of commercial UNIX implementations should not be demeaned. In addition to the price of the software itself, one often pays for documentation, support, and quality assurance. These are very important factors for large institutions, but personal computer users may not require these benets. In any case, many businesses and universities have found that running Linux in a lab of inexpensive personal computers is preferable to running a commercial version of UNIX in a lab of workstations. Linux can provide workstation functionality on a personal computer at a fraction of the cost. Linux systems have travelled the high seas of the North Pacic, and manage telecommunications and data analysis for an oceanographic research vessel. Linux systems are used at research stations in Antarctica. Several hospitals maintain patient records on Linux systems. Other free or inexpensive implementations of UNIX are available for the 80386 and 80486. One of the best known is 386BSD, an implementation of BSD UNIX for the 80386. The 386BSD package is comparable to Linux in many ways, but which one is better depends on your needs and expectations. The only strong distinction we can make is that Linux is developed openly, and any volunteer can aid in the development process, while 386BSD is developed by a closed team of programmers. Because of this, serious philosophical and design differences exist between the two projects. The goal of Linux is to
25
TOC
develop a complete UNIX system from scratch (and have a lot of fun in the process), and the goal of 386BSD is in part to modify the existing BSD code for use on the 80386. NetBSD is another port of the BSD NET/2 distribution to several machines, including the 80386. NetBSD has a slightly more open development structure, and is comparable to 386BSD in many respects. Another project of note is HURD, an effort by the Free Software Foundation to develop and distribute a free version of UNIX for many platforms. Contact the Free Software Foundation (the address is given in Appendix C) for more information about this project. At the time of this writing, HURD is still under development. Other inexpensive versions of UNIX exist as well, like Minix, an academic but useful UNIX clone upon which early development of Linux was based. Some of these implementations are mostly of academic interest, while others are full edged systems.
26
Introduction to Linux
TOC
of hardware supported by Linux. Disclaimer: Much hardware support for Linux is in the development stage. Some distributions may or may not support experimental features. This section lists hardware which has been supported for some time and is known to be stable. When in doubt, consult the documentation of your Linux distribution. See Section 2.2 for more information about Linux distributions. Linux is available for many platforms in addition to Intel 80x86 systems. These include Macintosh, Amiga, Sun SparcStation, and Digital Equipment Corporation Alpha based systems. In this book, however, we focus on garden-variety Intel 80386, 80486, and Pentium processors, and clones by manufacturers like AMD, Cyrix, and IBM. Motherboard and CPU requirements. Linux currently supports systems with the Intel 80386, 80486, or Pentium CPU, including all variations like the 80386SX, 80486SX, 80486DX, and 80486DX2. Non-Intel clones work with Linux as well. Linux has also been ported to the DEC Alpha and the Apple PowerMac. If you have an 80386 or 80486SX, you may also wish to use a math coprocessor, although one isnt required. The Linux kernel can perform FPU emulation if the machine doesnt have a coprocessor. All standard FPU couplings are supported, including IIT, Cyrix FasMath, and Intel. Most common PC motherboards are based on the PCI bus but also offer ISA slots. This conguration is supported by Linux, as are EISA and VESA-bus systems. IBMs MicroChannel (MCA) bus, found on most IBM PS/2 systems, is signicantly different, and support has been recently added. Memory requirements. Linux requires very little memory, compared to other advanced operating systems. You should have 4 megabytes of RAM at the very least, and 16 megabytes is strongly recommended. The more memory you have, the faster the system will run. Some distributions require more RAM for installation. Linux supports the full 32-bit address range of the processor. In other words, it uses all of your RAM automatically. Linux will run with only 4 megabytes of RAM, including bells and whistles like the X Window System and emacs. However, having more memory is almost as important as having a faster processor. For general use, 16 megabytes is enough, and 32 megabytes, or more, may be needed for systems with a heavy user load. Most Linux users allocate a portion of their hard drive as swap space, which is used as virtual RAM. Even if your machine has more than 16 megabytes of physical RAM, you
Hardware Requirements
27
TOC
may wish to use swap space. It is no replacement for physical RAM, but it can let your system run larger applications by swapping inactive portions of code to disk. The amount of swap space that you should allocate depends on several factors; well come back to this question in Chapter 2. Hard drive controller requirements. It is possible to run Linux from a oppy diskette, or, for some distributions, a live le system on CD-ROM, but for good performance you need hard disk space. Linux can co-exist with other operating systemsit only needs one or more disk partitions. Linux supports all IDE and EIDE controllers as well as older MFM and RLL controllers. Most, but not all, ESDI controllers are supported. The general rule for non-SCSI hard drive and oppy controllers is that if you can access the drive from MS-DOS or another operating system, you should be able to access it from Linux. Linux also supports a number of popular SCSI drive controllers. This includes most Adaptec and Buslogic cards as well as cards based on the NCR chip sets. Hard drive space requirements. Of course, to install Linux, you need to have some amount of free space on your hard drive. Linux will support more than one hard drive on the same machine; you can allocate space for Linux across multiple drives if necessary. How much hard drive space depends on your needs and the software youre installing. Linux is relatively small, as UNIX implementations go. You could run a system in 20 megabytes of disk space. However, for expansion and larger packages like X, you need more space. If you plan to let more than one person use the machine, you need to allocate storage for their les. Realistic space requirements range from 200 megabytes to one gigabyte or more. Also, you will likely want to allocate disk space as virtual RAM. We will discuss installing and using swap space in Chapter 2. Each Linux distribution comes with literature to help you gauge the precise amount of storage required for your software conguration. Look at the information which comes with your distribution or the appropriate installation section in Chapter 2. Monitor and video adaptor requirements. Linux supports standard Hercules, CGA, EGA, VGA, IBM monochrome, Super VGA, and many accelerated video cards, and monitors for the default, text-based interface. In general, if the video card and monitor work under an operating system like MS-DOS, the combination should work ne under Linux. However, original IBM CGA cards suffer from snow under Linux, which is not pleasant
28
Introduction to Linux
TOC
to view. Graphical environments like X have video hardware requirements of their own. Rather than list them here, we relegate that discussion to Section 5.1. Popular video cards are supported and new card support is added regularly. Miscellaneous hardware. You may also have devices like a CD-ROM drive, mouse, or sound card, and may be interested in whether or not this hardware is supported by Linux. Mice and other pointing devices. Typically, a mouse is used only in graphical environments like X. However, several Linux applications that are not associated with a graphical environment also use mice. Linux supports standard serial mice like Logitech, MM series, Mouseman, Microsoft (2-button), and Mouse Systems (3-button). Linux also supports Microsoft, Logitech, and ATIXL bus mice, and the PS/2 mouse interface. Pointing devices that emulate mice, like trackballs and touchpads, should work also. CD-ROM drives. Many common CD-ROM drives attach to standard IDE controllers. Another common interface for CD-ROM is SCSI. SCSI support includes multiple logical units per device so you can use CD-ROM jukeboxes. Additionally, a few proprietary interfaces, like the NEC CDR-74, Sony CDU-541 and CDU-31a, Texel DM-3024, and Mitsumi are supported. Linux supports the standard ISO 9660 le system for CD-ROMs, and the High Sierra le system extensions. Tape drives. Any SCSI tape drive, including quarter inch, DAT, and 8MM are supported, if the SCSI controller is supported. Devices that connect to the oppy controller like oppy tape drives are supported as well, as are some other interfaces, like QIC-02. Printers. Linux supports the complete range of parallel printers. If MS-DOS or some other operating system can access your printer from the parallel port, Linux should be able to access it, too. Linux printer software includes the UNIX standard lp and lpr software. This software allows you to print remotely via a network, if you have one. Linux also includes software that allows most printers to handle PostScript les. Modems. As with printer support, Linux supports the full range of serial modems, both internal and external. A great deal of telecommunications software is available for
29
TOC
Linux, including Kermit, pcomm, minicom, and seyon. If your modem is accessible from another operating system on the same machine, you should be able to access it from Linux with no difculty. Ethernet cards. Many popular Ethernet cards and LAN adaptors are supported by Linux. Linux also supports some FDDI, frame relay, and token ring cards, and all Arcnet cards. A list of supported network cards is included in the kernel source of your distribution.
30
Introduction to Linux
TOC
ments, which describe specic aspects of the system, like the Installation HOWTO, Printing HOWTO, and Ethernet HOWTO; and the Linux META-FAQ, which is a list of information sources on the Internet. Many of these documents are also regularly posted to one or more Linux-related Usenet newsgroups; see Section 1.9.4 below.
31
TOC
to Usenet news (see below). See Appendix A for information on subscribing to the Linux Journal.
32
Introduction to Linux
TOC
Postings to these newsgroups must be approved by the moderators, Matt Welsh and Lars Wirzenius. If you wish to submit an article, you simply post the article as you normally would; the news software will forward the article to the moderators for approval. However, if your news system is not set up correctly, you may need to mail the article directly to [email protected]. comp.os.linux.answers For posting Linux FAQs, How-Tos, READMEs and other documents that answer questions about Linux. This will help keep the trafc down in other c.o.l.* groups and will leave comp.os.linux.announce for true announcements. comp.os.linux.development.apps An unmoderated newsgroup for questions and discussion regarding the writing of applications for Linux and the porting of applications to Linux. comp.os.linux.development.system An unmoderated newsgroup for discussions about the development of the Linux system related to the kernel, device drivers, and loadable modules. comp.os.linux.hardware This newsgroup is for questions and discussion specic to a particular piece of hardware, e.g., can this system run Linux?, how do I use this disk drive with Linux?, etc. comp.os.linux.m68k This is to further interest in and development of the port of Linux to Motorola 680x0 architecture. comp.os.linux.misc All discussion which doesnt quite t into the other available Linux groups. Any nontechnical or metadiscourse about Linux should occur in comp.os.linux.misc. comp.os.linux.networking Discussion relating to networking and communications including Ethernet boards, SLIP, and PPP.
33
TOC
comp.os.linux.setup Questions and discussion relating to Linux installation and system administration. comp.os.linux.x Discussion of X Window System features unique to Linux, including servers, clients, fonts, and libraries. This list is by no means complete. New groups are created when a need for a subdivision of discussion is advisable, and there are linux groups in other hierarchies as well.
34
Introduction to Linux
TOC
to nd comparable Linux discussion forums on online services, like BBSs and CompuServe. Also available online are Linux Journals Best of Technical Support columns, at http://www.linuxjournal.com/techsup.html. Several businesses provide commercial support for Linux. These services allow you to pay a subscription fee that lets you call consultants for help with your Linux problems. Keeping the following suggestions in mind will greatly improve your experience with Linux and guarantee more success in nding help. Consult all available documentation. . . rst! You should do this when you rst encounter a problem. Various sources of information are listed in Section 1.9 and Appendix A. These documents are laboriously written for people who need help with the Linux system, like you. As mentioned above, books written for UNIX are applicable to Linux, and you should use them, too. If you have access to Usenet news, or any of the Linux-related mailing lists, be sure to read the information there before posting. Often, solutions to common problems that are not easy to nd in the documentation are well-covered in newsgroups and mailing lists. If you only post to these groups but dont read them, you are asking for trouble. Learn to appreciate self-reliance. You asked for it by running Linux in the rst place. Remember, Linux is all about hacking and xing problems. It is not a commercial operating system, nor does it try to be one. Hacking wont kill you. In fact, it will be enlightening to investigate and solve problems yourselfyou may even one day call yourself a Linux guru. Learn to appreciate the full value of hacking the system and xing problems yourself. You shouldnt expect to run a complete, homebrew Linux system without some handiwork. Remain calm. Nothing is earned by taking an axeor worse, a powerful electromagnetto your Linux box. A large punching bag or a long walk is a good way to relieve occasional stress attacks. As Linux matures and distributions become more reliable, we hope this problem will disappear. However, even commercial UNIX implementations can be tricky. When all else fails, sit back, take a few deep breaths, and return to the problem when you feel relaxed. Your mind and conscience will be clearer. Refrain from posting spuriously. Many people make the mistake of posting or mailing messages pleading for help prematurely. When encountering a problem, do not rush immediately to the nearest terminal and post a message to one of the Linux Usenet groups. First try to resolve the problem yourself, and be absolutely certain what the problem is. Does your system not respond when switched on? Perhaps it is unplugged. When you post for help, make it worthwhile. Remember that people who read your post are not necessarily there to help you. Therefore, it is important to remain as polite, terse, and informative as possible.
Getting Help
35
TOC
How does one accomplish this? First, you should include as much relevant information about your system and your problem as possible. Posting the simple request, I cannot seem to get e-mail to work will probably get you nowhere unless you include information about your system, what software youre using, what you have attempted to do so far, and what the results were. When you include technical information, it is also a good idea to include general information about the version of your software (the Linux kernel version, for example), as well as a brief summary of your hardware conguration. But dont overdo ityour monitor type and brand is probably irrelevant if youre trying to congure network software.
TOC
Chapter 2
36
Generic Installation
37
38
TOC
These assumptions are not extreme, and may even be a bit conservative. Some say that if your VCR still blinks 12:00, Linux isnt for you, but then that would leave me out as well. My VCR still blinks 12:00. Before we begin, we must know where we are going. While it is certainly possible to get from New York to California (eventually) by striking out in almost any random direction, most of us would opt to go in a more or less direct route. So it is with installing Linux.
2.1.3 Hardware.
This section explains all of the installation steps necessary short of the actual install. Each distribution handles this preparation slightly differently. While the installs look different, they accomplish the same things and have more in common than not. All require: planning; gathering system hardware information; backing up your old system (optional, but strongly recommended); preparing Linux partitions; deciding on a boot loader (for dual boot systems); booting a Linux kernel; installing the kernel; choosing and installing software packages; loading the software; making nal conguration adjustments; and rebooting into a running system. Now that Ive sufciently oversimplied the process, lets go down the list. Hang on, its not that bad when you learn from others mistakes.
Generic Installation
39
Chip Set: Chip Set: triton II Type: bus PS/2 serial port COM2 (ttyS1) IDE/MFM/RLL/ESDI SCSI
Make: Model: Make: BusLogic Model: 948 Linux DOS/Windows Partition: Size: Partition: Size: Partition: Size: Partition: Size: IDE/ATAPI SCSI Proprietary Model:
Other
40
TOC
X-Windows: Video Card: RAM: Monitor: Networking: Modem: Serial port: Computer hostname:
COM4 (ttyS3)
The following answers are only needed if using network interface card (NIC): (do not congure networking if you do not have a NIC installed) NIC Type: NIC Mfg: Network domain name: IP Address: Network address: Netmask: Broadcast address: Gateway(s): DNS(s): ethernet Model: token ring FDDI other
(Example: mountains.net) (Ex: 192.168.1.2) (Ex: 192.168.1.0) (Ex: 255.255.255.0) (Ex: 192.168.1.255) (Ex: none or 192.168.1.1) (Ex: 192.168.1.2)
Some of the General Section is there for future reference. Specically, we dont need to know right now our CPU processor type. We can also do without ever knowing what chip set we have on the motherboard. But if the information is available, it is good to have.
2.1.6 Mice.
Other information, beginning with the mouse, we do need, if we expect to use the mouse. We need to know the mouse manufacturer, because different brands implement internal signal functions differently. Here, attention to detail is everything. If you have a mouse with a Microsoft brand on it, it may have a serial or PS/2 interface. Looking at the connector for the computer wont help, either. A number of computers come with mice that look like serial mice and have a serial-type connector, but are connected to the motherboard internally as a PS/2 mouse.
Generic Installation
41
TOC
Read the print on the bottom of the mouse carefully before deciding. Also, if you have a mouse with three buttons, but it has a switch on the bottom which you can change between, say, Microsoft and PC systems, choose PC system. The Microsoft setting doesnt implement the middle button, which is useful in UNIX. For manufacturer, choose the switch setting, since that is the signaling protocol used. No drivers exist for a Cutie mouse, but do exist for the switch settings of Microsoft and Mouse System found on the bottom of the mouse. While not specically asked for, the only additional information you may want to add is the device through which the system accesses the mouse. Linux must know how the device is referred to. If you have a PS/2 mouse, you will normally use either /dev/psaux, the auxiliary port for a PS/2 pointing device, or /dev/psmouse, a synonym sometimes available for use. Bus mice are accessed through a le specically created for that proprietary mouse, like /dev/atibm ATI bus mice, /dev/logibm for Logitech bus mice, /dev/inportbm for InPort bus mice, or their respective synonyms of atimouse, logimouse, and so on. For serial mice, if you know the MS-DOS COM: port, substitute /dev/ttyS0 for COM1: and /dev/ttyS1 for COM2:. Ill refrain from explaining the origins of the tty name of ttyS0 since that will take up several paragraphs and is already explained in many UNIX references
42
TOC
run Microsoft Windows under OS/2. If you have MS-DOS and Microsoft Windows, or OS/2 on your computer, Linux should have its own partition. It can be loaded on a MSDOS partition with UMSDOS, which is not covered here. While Linux has DOS emulators and can read and even run some DOS programs, DOS cannot usually see what is on a Linux partition. If you have and want to keep MS-DOS (assumed), you must determine how much space to reserve for it. Subtract this number from the hard disk total and that is what you have to work with. For now, annotate the total size of the drive(s) you have and the second number with how much to dedicate to Linux. For your CD-ROM drive(s) you need similar information. A CD-ROM drive is either IDE/ATAPI, the most common in home systems marketed today; SCSI; or an older, proprietary drive, like those connected to sound cards. If you have an IDE or SCSI drive, so much the better. If you have a proprietary drive, you must know the make and model because Linux identies proprietary CD-ROM drives by manufacturer and the specic drive.
Generic Installation
43
TOC
You must know the manufacturer and specic model of your video card. Some cards can be probed for RAM or chip sets, others cant. In either case, knowing how much RAM is on the card and the chips used, like the S3 or S3-Virge, is important. This information saves much time and grief. The most difcult and frustrating part of any Linux installation and setup is the X Window System. The data for your monitor is often more difcult to obtain. If you have one of the more obscure brands of monitors, you may need to supply vertical and horizontal scan rates yourself. If in doubt, always err on the conservative side. Overdriving your system can result in damage to the monitor or video card. We already have most of the information that we need for the mouse, the only other subsystem the X server needs. The information that Linux needs to know about your mouse is described on page 40.
44
Generic Installation
45
TOC
install:
/bin /dev /etc /home /lib /lost+found /proc /root /sbin /usr /var
You may see others like /boot, /mnt, /cdrom, /floppy, /opt, and so on, but the above are essential. What about other partitions? Linux can use a directory name (say /usr) as a mount point. That is, the other partition on the disk (or on another disk) is mounted under it (in this case /usr). If you unmount the other partition and look in the subdirectory Linux uses as a mount point, you will (or should) see nothingno les or directories. When the other partition is mounted, you will see les and directories which are on that partition under the mount point. So if you have two drives, one with 120 MB and another with 840 MB, you can make one partition on the 120MB drive (lets say its the root partition) and mount any partitions you have created on the 840MB drive (this could be one big partition, or several smaller partitions) under their respective mount points, one partition per mount point, creating, in effect, one, 960-MB le system. The one restriction is that you cannot use certain directories on the root drive as mount points, because they contain les that are needed to either boot the system or mount other systems. Obviously if the command used to mount other partitions is located on another partition and you cant access that partition until youve mounted it, youll be like the dog chasing its tail. The directories you cannot use as mount points are: /bin, /dev, /etc, /lib, /lost+found, /proc, /root, and /sbin. A detailed description of what les are contained in these standard system directories is given on page 148. Lets look at a small example. You are an aspiring Internet Service Provider (ISP). You
46
TOC
have four machines, and each has a 1-gigabyte drive. So, you decide to allocate space as follows:
machine A: / = 120MB /usr = remainder of drive (exported) /home = 0 - mount point (mounted from B) /var/news = 0 - mount point (mounted from C) /var/spool/mail = 0 - mount point (mounted from D) machine B: / = 120MB /usr = 0 - mount point (mounted from A) /home = remainder of drive (exported) /var/news = 0 - mount point (mounted from C) /var/spool/mail = 0 - mount point (mounted from D) machine C: / = 120MB /usr = 0 - mount point (mounted from A) /home = 0 - mount point (mounted from B) /var/news = remainder of drive (exported) /var/spool/mail = 0 - mount point (mounted from D) machine D: (reader exercise)
You probably noticed that I arbitrarily assigned the root partition 120MB, and allocated the rest to whatever ( /usr, /home, /var/spool/mail and so forth). I also didnt allocate any space to a swap partition. So, lets look at what we will likely need, understanding that it depends, is key. I will discuss this from the perspective of a home situation with only a few users, lots of programs, and no other remarkable needs. The best place to start is to tell you what my primary home computer looks like. I have two drives, /dev/hda (1.2 GB) and /dev/hdb (540 MB). df (disk free) displays
File system /dev/hda1 /dev/hda3 /dev/hda2 /dev/hdb1 1024-blocks Used Available Capacity Mounted on 150259 69605 72894 49% / 723923 615452 71075 90% /usr 150291 93326 49204 65% /usr/X11R6 499620 455044 18773 96% /home
You can see that I have a half-used 150-MB root (/) partition, a nearly full /usr partition, a largely used /usr/X11R6 partition, and a large, but cramped, 500-MB /home partition. The remainder of the drive /dev/hdb is a swap partition.
Generic Installation
47
TOC
At a realistic minimum, I would suggest reserving 80100 MB for your root partition, about 10 MB per user on your /home partition, as much space as you can reserve for swap, within reason (see the next section), and the rest to /usr. I have a ve-user system at home, but I personally have over 400 MB of the /home directory tied up, much of that in graphicsa photo album of family and friends. Your /usr partition should probably be at least 250 MB, but the minimum will depend on what you decide to install. As you can see, it can rapidly ll with over 800 MB of programs, libraries, and data. Also remember that partitions give you exibility that you lose with one, giant partition.
2.1.14 Repartitioning.
At the beginning of this chapter I said Id make a few assumptions. One was that you would want to keep your comfortable MS-DOS and Microsoft Windows operating system around. And since the computer you bought only has MS-DOS on it, it doesnt make sense to have multiple partitions, so the one drive you have is probably entirely dedicated to MS-DOS. One way or another, then, we will have two operating systems on this computer. If you currently have nothing on your disk (lucky you), that is great, but youre not quite ready to skip ahead. Linux is comfortable wherever you put it. Your BIOS may not be capable of booting it, but once running, it will not complain if its relegated to the fourth partition of the fourth hard drive. But MS-DOS and Microsoft Windows arent so forgiving. They want the rst drive and the rst partition and may refuse to boot from any other position. I
48
TOC
have seen MS-DOS boot from the rst partition on the second hard drive, but the rst hard drive did not have any MS-DOS partitions, so MS-DOS didnt recognize the drive. The best strategy is often the path of least resistance. If at all possible, put MS-DOS on the rst drive and the rst partition. A second consideration in a multiple OS situation is which operating system to load rst. If youre tempted to partition the hard disk and install Linux rst (reserving /dev/hda1 for MS-DOS, then installing MS-DOS second, dont. Windows 95 is the worst offender, but Microsoft products in general will delete any previous boot loader you had installed on the master boot record (what the BIOS uses to point to bootable kernels). In fact, you may even hear this referred to as the Microsoft virus. This is not a virus in the true sense of the word, just arrogance on the part of Microsoft, that one would only want a Microsoft operating system to boot. Linux does not cause such problems, and in fact provides a way to choose the default boot image. It also allows you to intervene during the boot process to specify which operating system to boot. This is a standard part of Linux installation procedures.
which formats the oppy and puts the required system les on it, or, using a formatted disk, issue the command
C:>sys a:
Once you have created a boot oppy and tested it to insure that it works, copy the following les from your MS-DOS system to the boot oppy: FDISK.EXE,
Generic Installation
49
TOC
SCANDISK.EXE, and SYS.COM. Also copy the le RESTORRB.EXE from a Linux distribution CD or Linux FTP archive. (See Appendix B). Run a defragmentation program on your DOS drive to defragment and group the les together at the front of the disk. If defragmeter encounters any errors, you need to run SCANDISK.EXE to x the problems. Once you have defragmented the disk and ensured that the les are compressed toward the front of the drive (as indicated in the graphical portrayal of your disk), youre ready to run FIPS.EXE to shrink the MS-DOS partition.
2.1.16 FIPS.EXE
On your Linux distribution CD (or an Internet distribution site), youll nd a copy of FIPS.EXE, which can shrink the MS-DOS partition. Note that FIPS.EXE only works for MS-DOS partitions. If you have other partitions that you need to shrink, the program Partition Magic may help, but is not free. Copy FIPS.EXE to your boot oppy and reboot using this oppy. This accomplishes two things: it insures that the boot oppy works, and insures that you are booted into MS-DOS Real Mode and are not running Microsoft Windows. At the A:> prompt, type FIPS (upper or lower case). You will be greeted and asked which drive you want to operate on (if you have more than one). Select the drive to shrink. Once you conrm your choice, let FIPS.EXE make a copy of your boot and root sectors to the oppy in case something untoward happens. You will then be asked if all of the free space on your partition should be used to create a second partition. If you say, yes, you will not have any free space on the MSDOS partition to save data to, so say, no. You will then be able to alter the amount of space allocated between the rst and second partitions. Note that if you didnt properly defragment your drive, you wont have much to work with on the second partition. Also, if you use MS-DOS mirroring software, a le is created at the very end of the partition, and FIPS.EXE tells you that you have no space to create a second partition. Exit and correct the problem by deleting the MIRROR.FIL le, then restart FIPS.EXE. You can edit and re-edit the table until you are satised. Once you are happy with the distribution of space between the partitions, conrm your changes and write out the table. Once FIPS.EXE has nished, remove the boot oppy and reboot your computer. In this example, well destroy and recreate the second partition during installation to create at least two partitions for Linux: a swap partition and a Linux native partition. But you can create as many as you like.
50
3 3
Repeat this step for any additional disk images your system needs. If you can check the oppy disks with SCANDISK.EXE and do a surface scan before writing the images to the oppy, you may save yourself some time later. Most initial install failures come from boot disks that are bad, and RAWRITE2.EXE doesnt verify the disks. This is also true if you create boot disks under Linux. The badblocks(1) manual page describes how to check disks for errors. Label the disks that you create for future use.
Generic Installation
51
TOC
# dd if=diskimage of=boot oppy device bs=512 conv=sync ; sync
Substitute the disk image name for diskimage and the correct oppy device (almost always /dev/fd0), and repeat for each disk that you need. The dd arguments are: if for input le; of for output le, and here we want to use the oppy device; bs for block size, in this case 512 bytes; conv=sync ensures that the output le is exactly the same size as the input le. The trailing sync insures that we ush the buffers to disk immediately. An alternate method that works, though will often be shunned by real Linux administrators, is the cp (copy) command
cp diskimage boot oppy device ; sync
Again, substitute the disk image le name for diskimage, the correct boot oppy device, and repeat the step for each disk that you need. You may receive a message asking if you want to replace the boot oppy device with diskimage. Obviously this wont happen, since the oppy diskette is not a true le but a device, but cp doesnt pay attention to that detail. Just say, yes, if you are asked. With the Linux installation boot disks in hand, youre ready to install our system. Most distributions invoke fdisk, the Linux version, so you can create a native Linux partition and a swap partition. The install programs continue by creating the le system (the equivalent of formatting a MS-DOS disk) for both the Linux and swap partitions, and initialize the swap partition and mount the Linux partition. One question that you will be asked is whether you want to check your hard disk for bad blocks. If you are using a SCSI drive, answer no. SCSI drives have built-in error checking and correcting. IDE and similar drives dont have this and need to map out bad blocks. If you have an older drive you want to do this. If you say, yes, the installation program will invoke the badblocks program to maps out all of the bad blocks it nds. This takes time. If in doubt, say, yes.
52
TOC
to highlight the options you want, and press Enter to execute the command. The only time you use anything but the arrow and Enter keys is when you specify a number for the size of the partition. For starters, all Linux boot disks are created essentially equal. Reboot the computer with the boot oppy in the boot drive. You will be greeted with a screen with some instructions and a prompt
LILO boot:
and a ashing cursor. If you use the Tab key, you should see a list of names. The names differ depending on the distribution, but look for one that says rescue or expert. The install label starts the installation program after loading the kernel, so if you want to let the installation program walk you through the partitioning and lesystem initialization process, you can use the install label; otherwise, choose a different label. You may also need to provide Linux some boot parameters. For our purposes, this should not be necessary, but youll soon nd out if this is the case. Enter a label name and press /keyReturn. When the Linux kernel nishes the bootup process, you may be presented with any of a number of prompts, depending on the distribution. If you have a shell prompt, like the pound sign (#) or a dollar sign ($), youre where you need to be. If not, try presssing Alt - F2 or Alt - Shift -F2. You should be able to activate one of the systems virtual consoles. Once you have a prompt (you should not need to log in), you will be working as root (more on this in Chapter 4). Enter the command
# fdisk
If an error is returned, try cfdisk. This is the disk partition utility. It defaults to /dev/hda, so if you need to work on the second hard drive, use the command
# fdisk /dev/hdb
3 3
In fdisk, press m to see a menu. The commands you will use are: n to create a new partition; d to destroy a partition; t to change the partition type (83 is Linux Native, 82 is Linux Swap); p prints to the screen the partition information currently in memory (not whats on the disk); w writes the partition table to disk; and q quits. Until you issue the w command, you are not committed and can make changes or quit without making any changes. Pay attention to prexes and sufxes of the partition size. With the partition size you need to specify + if the size will be other than the ending partition number, and a sufx of k or M (case does not matter) to specify KB or MB.
53
TOC
One nal note on partitions: you can create up to four primary partitions. If you need more than four partitions, you will create three primary partitions and then extended partitions. The extended partition numbers begin with 5, so you may have /dev/hda1, /dev/hda2, /dev/hda3, /dev/hda5, and /dev/hda6 if you need ve partitions. As a nal check before you write the partition table, ensure that your partitions do not overlap. As long as the start and end segments dont overlap with any other start and end segments, you can be sure the partition boundaries are okay. A beginning number may be listed as 1024 for partitions with numbers starting higher than that. For now, just consider that a reminder that the BIOS will not be able to read (or boot from) that partition. cfdisk does exactly the same thing as fdisk, but displays on the screen the state of the partition table in memory (but not on the disk) at all times. Use the Up and Down arrow keys to select a partition to work on, and the Right and Left arrow keys to select the action to be performed. Then press Enter to perform the action. You will have to input numbers for the size you want to make the partition, but all information is given on the screen, just follow the instructions. cfdisk defaults to /dev/hda, so you must to give it the argument /dev/hdb if you want to change the partition table on a second disk drive. Remember to write the table before you quit. This is the hardest part of cfdisk. It doesnt ask for conrmation before exiting. So select Write and press Enter before you select Quit and press Enter .
54
TOC
table and articles). Even better, if you know someone who installed Linux, ask them for help and advice. There are many factors to consider when choosing a distribution; however, everyones needs and opinions are different. In actuality, most of the popular Linux distributions contain roughly the same set of software, so the distribution you select is more or less arbitrary.
For a base installation of Debian you need about 12 megabytes of disk space and some oppies. First, you need boot and driver oppy images. Debian provides two sets of boot oppy images, for 1.2 and 1.44 Mb oppy disks, and one set of the base images which work with either type of oppy. Check what oppy drive your system boots from, and download the appropriate disk set.
Choose the appropriate oppy set for your hardware from the table on page 55 and write the images to oppy as described on page 50.
Debian GNU/Linux
55
TOC
./stable/msdos-i386
Contents Latest stable Debian release. Debian packages for Intel i386 architecture. Boot and root disks needed for Debian installation. The current boot oppy set. Special kernels and boot oppy disks, for hardware. Congurations that refuse to work with our regular boot oppies. DOS short le names for Debian packages.
File Name rsc1440.bin drv1440.bin base-1.bin base-2.bin base-3.bin base-4.bin base-5.bin root.bin rsc1440r.bin
Label Rescue Floppy Device Drivers Base 1 Base 2 Base 3 Base 4 Base 5 Root Disk Rescue Floppy
Description
Floppy set for systems with 1.44MB oppy drive and at least 5MB RAM.
Optional Rescue Disk image for low memory systems (less then 5MB of RAM).
Rescue Floppy Device Drivers Base 1 Base 2 Base 3 Base 4 Root Disk
56
This le is a current list of Debian packages available in the stable Debian distribution. The le comes in a special format; every package has its own entry separated by a blank line. Each packages information is broken up into elds. The table on page 65 describes the elds and their possible values. It should give you an idea of how to build your personal download list. When you have the list of the packages you want, you need to decide how to download them. If you are an experienced user, you may want to download the netbase packageand SLIP and PPP, if necessaryso you can download packages later, via Linux. Otherwise, you can download all of the packages with your current operating system and install them later from a mounted partition.
The Rescue oppy. Place the Rescue oppy in the boot drive and reboot. In a minute or two, you should see a screen introduce the Rescue oppy and the boot prompt. Its called the Rescue oppy because you can use it to boot your system and perform repairs if there is a problem that makes your hard disk unbootable. Save this oppy after you install the system. You can do two things at the boot: prompt: press the function keys F1 through F10 to view a few pages of helpful information, or boot the system. If you have any hardware devices that Linux doesnt access correctly at boot time, you may nd a parameter to add to the boot command line in the screens you see by pressing F3 , F4 , and F5 . If you add parameters to the boot command line, be sure to type the word linux and a space before the rst parameter. If you simply press Enter , thats the same as typing linux without any special parameters. If this is the rst time youre booting the system, press Enter and see if it works correctly. It probably will. If not, you can reboot later and look for any special parameters that inform the system about your hardware. Once you press Enter , you should see the messages
Loading... Uncompressing Linux...
Debian GNU/Linux
57
TOC
then there is a page or so of cryptic information about the hardware in the system. There may be many messages in the form of, cant find something, something not present, cant initialize something, or even this driver release depends on something, Most of these are harmless. The installation boot disk is built to run on computers with many different peripheral devices. Obviously, no computer will have every possible peripheral device, and the operating system may emit a few complaints while it looks for peripherals you dont own. You may also see the system pause for a while. This happens if it is waiting for a device to respond that is not present on your system. If you nd that the time it takes to boot the system unacceptably long, you can create a custom kernel after you install the system which doesnt have the drivers for non-existent devices. Low memory systems. If your system has 4MB of RAM, you may see a paragraph about low memory and a text menu with three choices. If your system has enough RAM, you wont see this at all, and youll go directly to the color or monochrome dialog box. If you get the low-memory menu, you should go through its selections in order. Partition your disk, activate the swap partition, and start the graphical installation system. The program that is used to partition your disk is called cfdisk, and you should see the manual page for cfdisk and the instructions on page 51 for assistance. cfdisk is used to create a Linux Swap partition (type 82) on the hard drive. You need the swap partition for virtual memory during installation, because the procedure likely uses more memory than you have physical RAM for. Select the amount of virtual memory that you intend to use once your system is installed. It is exactly equal to the amount of disk space required. Sixteen megabytes is probably the smallest practical amount, but use 32 megabytes if you can spare the disk space, and 64 megabytes if the disk is large enough and you wont miss the space. The color or monochrome dialog box. Once the system nishes booting, you should see the color or monochrome dialog box. If your monitor displays black and white (monochrome), press Enter and continue with the installation. Otherwise, use the arrow key to move the cursor to the Color menu item and then press Enter . The display should change from black and white to color. Press Enter again to continue with the installation. The Main Menu You may see a dialog box that says,
58
TOC
The installation program is determining the current state of your system.
On some systems, this message ashes by too quickly to read. It is displayed between steps in the installation process. The installation program checks the state of the system after each step. This allows you to restart the installation without losing the work that you have already done, if you halt the system in the middle of the installation. If you need to restart an installation, you will be prompted to select color or monochrome again, congure the keyboard, reactivate the swap partition, and remount any disks that have been initialized. Any other installation on the system will be saved. During the entire process, you are presented with the main menu. The choices at the top of the menu change to indicate your progress in installing the system. Phil Hughes wrote in 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 rst choice on the installation menu is the next action you should perform according to what the system detects you have already done. It should say Next, and, at this point, the next item should be
Configure the Keyboard
Conguring the keyboard. Make sure that the highlight is on the Next item, and press Enter for the keyboard conguration menu. Select a keyboard that conforms to the layout used for your national language, or select something close to it if the keyboard layout you want isnt shown. After installation you can select a keyboard layout from a wider range of choices. Move the highlight to the keyboard selection and press Enter . Use the arrow keys to move the highlightthey are in the same place on all national language keyboard layouts and are independent of the keyboard conguration. The shell. If you are an experienced UNIX or Linux user, press LeftAlt and F2 in unison for the second virtual console. Thats the Alt key on the left-hand side of the Space bar and the F2 function key. Youll see a separate window running a Bourne shell clone called ash. At this point, the root le system is on the RAM disk, and there is a limited set of UNIX utilities available for your use. You can see what programs are available with the command
ls /bin /sbin /usr/bin /usr/sbin
The shell and commands are there only in case something goes wrong. In particular, you should always use the menus, not the shell, to activate your swap partition, because the
Debian GNU/Linux
59
TOC
menu software cant detect whether youve done this from the shell. Press LeftAlt - F1 to get back to menus. Linux provides up to 64 virtual consoles, but the Rescue oppy only uses a few of them. Last chance! Have you backed up your disks? Heres your rst chance to wipe out all of the data on your disks, and your last chance to save your old system. If you havent backed up all of your disks, remove the oppy from the drive, reset the system, and create a backup. Partition your hard disks. If you have not already partitioned your disks for Linux Native and Linux Swap le systems, the menu item Next will be
Partition a Hard Disk
If you have already created at least one Linux Native and one Linux Swap disk partition, the Next menu selection will be
Initialize and Activate the Swap Disk Partition
or you may even skip that step if your system has little RAM and the installation software asked you to activate the swap partition as soon as the system started. Whatever the Next menu selection is, you can use the down-arrow key to select
Partition a Hard Disk
The Partition a Hard Disk menu item presents you with a list of disk drives you can partition and runs the cfdisk program (see page 51), which allows you to create and edit disk partitions. You must create at least one Linux (type 83) disk partition. Your swap partition will be used to provide virtual memory for the system and should be between 16 and 128 megabytes in size, depending on how much disk space you have and how many large programs you want to run. Linux will not use more than 128 megabytes of swap, so theres no reason to make your swap partition larger than that. A swap partition is strongly recommended, but you can do without one if you insist and system has more than 16 Mb of RAM. Initialize and Activate the Swap Disk Partition. This is the Next menu item after you create one disk partition. You have the choice of initializing and activating a new swap partition, activating a previously initialized partition, and doing without a swap partition. Its always permissible to re-initialize a swap partition, so select Initialize and Activate the Swap Disk Partition unless you are sure
60
TOC
that you know what you are doing. This menu choice will give you 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 IDE disks, and checking the disk never hurts. Properly working SCSI disks dont need to be scanned. They have their own internal mechanism for mapping out bad disk blocks. The swap partition provides virtual memory to supplement the RAM in your system, and its even used while the system is being installed. Thats why we initialize it rst. Initialize a Linux disk partition. At this point, the Next menu item should be
Initialize a Linux Disk Partition
If it isnt, you havent completed the disk partitioning process, or you havent made one of the menu choices dealing with your swap partition. You can initialize a Linux disk partition, or alternately you can mount a previously initialized partition. The boot oppies will not upgrade an old system without removing the lesDebian provides a different procedure than using the boot oppies for upgrading existing Debian systems. Thus, if you are using old disk partitions that are not empty, you should initialize them, which erases all of the les. You must initialize any partition 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 user les, like /home, that you dont want deleted. Select the Next menu item, to initialize and mount the root (the / directory) disk partition. The rst partition you mount or initialize, after the swap partition, if youre using it, is the partition mounted as root. You will be offered the choice to scan the disk partition for bad blocks, as when you initialized the swap partition. It never hurts to scan for bad blocks. Keep in mind that this step can take 10 minutes or more if you have a large disk. Install the base system. Once youve mounted the root partition, the Next menu item will be
Install the Base System
unless you already performed some of the installation steps. You can use the arrow keys to select the menu items to initialize or mount disk partitions if you have additional partitions to set up. If you have created separate partitions for /var, /usr, or other le systems, you should initialize and mount them now.
Debian GNU/Linux
61
TOC
There will be a pause while the system looks for a local copy of the base system. This search is for CD-ROM installations and will not succeed. You are then offered a menu of drives from which to read the base oppies. Select the appropriate drive. Feed in the Base 1, Base 2, Base 3, and Base 4 oppiesand Base 5 if you are using 1.2MB oppiesas requested by the program. If one of the base oppies is unreadable, you need to create a replacement oppy and feed all ve oppies into the system again. After the oppies have been read, the system installs the les. This can take ten minutes or more on a slow system. Install the operating system kernel. At this point, the Next menu item should be
Install the Operating System Kernel
Select it, and you will be prompted to select a oppy drive and insert the Rescue oppy. This copies the kernel onto the hard disk. This kernel is used later to create a custom boot oppy for your system and make the hard disk bootable without a oppy. Install the device drivers. Select the menu item to install the device drivers. You will be prompted to insert the Device Drivers oppy, and the drivers will be copied onto your hard disk. Select the
Configure Device Drivers
menu item and look for devices which are on your system. Congure those device drivers, so they will be loaded whenever your system boots. There is a menu selection for PCMCIA device drivers, but you do not need to use it. After installation you can install the pcmcia-cs package. This detects PCMCIA cards automatically and congures those it nds. It also recognizes cards that are hot swapped when the system is runningthey will all be congured as they are plugged in, and decongured when unplugged. Congure the base system. At this point the system read in all of the les that make up a minimal Debian system, but you must perform some conguration before the system will run. Select
Configure the Base System
This asks you to select your time zone. Look for your time zone or region of the world in the menu, and type it at the prompt. This may lead to another menu where you can select more specic information.
62
TOC
Next, you are asked if your system clock should be set to Greenwich Mean Time (GMT) or local time. Select GMT if are running only Linux or another UNIX on your system. Select local time if you use another operating system like MS-DOS or Microsoft Windows. UNIX systems keep GMT time on the system clock and use software which converts it to the local time. This allows them to keep track of daylight savings time and leap years, and even allows users who are logged in from other time zones to individually set the time zone on their terminal. If you run the system clock on GMT and your locality uses daylight savings time, the system adjusts for daylight savings time properly on the days it starts and ends. Congure the network. You must congure the network even if you dont have one, but you only have to answer the rst two questions:
What is the name of your computer? Is your system connected to a network?
If you are connected to a network, check with your system administrator or ISP vendor if you dont know the following information: your computers host name; your computers or ISPs domain name; your computers IP address; the netmask to use with your network; the IP address of your network; the broadcast address to use on your network; if your network has a gateway, the IP address of the default gateway system to which you should route packets; the system on your network to use for Domain Name Service (DNS); and whether you connect to the network using Ethernet. The program will guess that the network IP address is the bitwise AND of your systems IP address and netmask. It will guess that the broadcast address is the bitwise OR of your systems IP address with the bitwise negation of the netmask. It will guess that
Debian GNU/Linux
63
TOC
your gateway system is also your DNS server. If you cant nd any of these answers, use the systems guessesif necessary, you can alter them after installation by editing the /etc/init.d/network le. Make the hard disk bootable. If you choose to make the hard disk boot directly to Linux, you are asked to install a master boot record. If you arent using a boot manager (this is probably the case if you dont know what a boot manager is), answer yes to this question. The next question is whether you want to boot Linux automatically from the hard disk when you turn on the system. This sets Linux to be the bootable partitionthe one that will be loaded from the hard disk. If you answer no to this question, you can set the bootable partition later using the MS-DOS FDISK.EXE program, or the Linux fdisk or activate programs. Make a boot oppy. You should make a boot oppy even if you intend to boot the system from the hard disk. The reason for this is that its possible for the hard disk bootstrap to be installed incorrectly. A boot oppy will almost always work. Select
Make a Boot Floppy
from the menu and feed the system a blank oppy as directed. Make sure that the oppy isnt write protected. The software attempts to format and write it. Mark this diskette the Custom Boot oppy and write-protect it once it has been written. The moment of truth. This is what electrical engineers call the smoke testwhat happens when you power up a new system for the rst time. Remove the oppy disk from the oppy drive and select
Reboot the System
from the menu. If the Linux system doesnt start up, insert the Custom Boot oppy you created in the previous step and reset the system. Linux should boot. You should see the same messages as when you rst booted the installation boot oppy, followed by some new messages. Add a user account and password. After youve added logins, (Chapter 4 discusses this in some detail), you are dropped into dselect, the Debian package management program. You should read the tutorial before attempting to install packages with dselect.
64
TOC
dselect allows you to select the packages that you want installed on your system. The Debian package management software is described in detail starting on page 64. If you have a CD-ROM or hard disk with the additional Debian packages or are connected to the Internet, you may want to read that section now. Otherwise, exit dselect. You can use the package management software after you have transferred the Debian package les to your system. You must be the superuser (root) to use dselect. If you install the X Window System and do not use a US keyboard, read the X11 Release note for non-US keyboards. Log in. After you exit dselect, you are at the login: prompt. Log in using the personal login and password you selected. Your system is ready to use.
3 3
Debian distributions come in archives called packages. Every package is a collection of les (programs, usually) that can be installed using dpkg or dselect. In addition, the package contains some information about itself that is read by the installation utilities. Package classications. The packages that are included with Debian GNU/Linux are classied according to how essential they are (priority) and their functionality (section). The priority of a package indicates how essential or necessary it is. Debian GNU/Linux classies all packages into four different priority levels: Required. These packages must be installed for the system to operate correctly and have been installed as part of the base system. Never remove a required package from the system unless you are absolutely sure of what you are doing. This bears repeating: Never, never, never remove a required package from the system unless you are absolutely sure of what you are doing. It is likely that doing so will render your system completely unusable. Required packages are abbreviated in dselect as Req.
Debian GNU/Linux
65
TOC
Package Priority Package Name Package Importance Required Important Optional Extra Section General Category Base Devel X11 Admin Doc Comm Editors Electronics Games Graphics Hamradio Mail Math
Should be installed for proper system operation. Not required but important. Not necessary but useful. Package may conict with other packages with higher priorities.
Base system. Development tools. Packages for the X Window System. Administration utilities. Documentation. Various communication utilities. Various editors. Electronics utilities. Games. (You knew that, didnt you?) Graphics utilities. Ytilities for Internet radio. Email clients and servers. Mathematics utilities. (Like calculators, etc.. . . ) Net Various tools to connect to the network (usually TCP/IP). News Servers and clients for Internet news (NNTP). Shells Shells, such as tcsh and bash. Sound Any sound application (like audio CD players). TeX Anything that can read, write, and convert TEX. Text Applications to manipulate texts (like nroff). Misc Everything else that doesnt t above. Name of the person who maintains the package and his or her e-mail address. Version of the package in the format upstream-versiondebian-version. A list of other packages upon which the current package depends and will not function without. Another level of package dependenciesit is strongly recommended the packages listed in this eld be installed if this package is to be used. Packages listed in this eld may be useful to the packages this entry describes. File name of the package via FTP or CD-ROM. File name of the package in short DOS format.
66
TOC
Important. Important packages are found on almost all UNIX-like operating systems. These packages include cron, man, and vi. Important packages are abbreviated in dselect as Imp. Standard. Standard packages are packages that, more or less, comprise the standard, character based, Debian GNU/Linux system. The Standard system includes a fairly complete software development environment and GNU Emacs. Standard packages are abbreviated in dselect as Std. Optional. Optional packages comprise a fairly complete system. The Optional system includes TEX and the X Window System. Optional packages are abbreviated in dselect as Opt. Extra Extra packages are only useful to a small or select group of people, or are installed for a specic purpose. Extra packages might include such programs as electronics and ham radio applications. Extra packages are abbreviated in dselect as Xtr. By default, dselect automatically selects the Standard system if the user doesnt want to individually select the packages to be installed. The section of a package indicates its functionality or use. Packages on the CD-ROM and in FTP archives are arranged in subdirectories according to function. The directory names are fairly self-explanatory: for example, the directory admin contains packages for system administration and the directory devel contains packages for software development and programming. Unlike priority levels, there are many sections, and more may be added in the future, so we do not individually describe them in this guide. Package relationships. Each package includes information about how it relates to the other packages included with the system. There are four package relationships in Debian GNU/Linux: conicts, dependencies, recommendations, and suggestions. A conict occurs when two or more packages cannot be installed on the same system at the same time. A good example of conicting packages are mail transfer agents (MTAs). A MTA is a program that delivers electronic mail to users on the system and other machines on the network. Debian GNU/Linux has two mail transfer agents: sendmail and smail. Only one mail transfer agent may be installed at a time. They both do the same job and are not designed to coexist. Therefore, the sendmail and smail packages conict. If you try to install sendmail when smail is already installed, the Debian GNU/Linux
Debian GNU/Linux
67
TOC
package maintenance system will refuse to install it. Likewise, if you try to install smail when sendmail is already installed, dselect (or dpkg; see below) will refuse to install it. A dependency occurs when one package requires another package to function properly. Using our electronic mail example, users read mail with programs called mail user agents (MUAs). Popular MUAs include elm, pine, and emacs RMAIL mode. It is normal to install several MUAs at once because they do not conict. But MUAs do not deliver mailthat is the job of the MTA. So all mail user agent packages depend on a mail transfer agent. A package can also recommend or suggest other related packages.
2.3.6 dselect.
This section is a brief tutorial on Debian dselect. For more detailed information, refer to the dselect manual at
ftp://ftp.debian.org/debian/Debian-1.2/disks-i386/current/dselect.beginn
dselect is simple, menu-driven interface which helps install packages. It takes you through the package installation process in the order of the on-screen menu:
Debian Linux dselect package handling front end. 0. 1. 2. 3. 4. 5. 6. [A]ccess Choose the access method to use. [U]pdate Update list of available packages, if [S]elect Request which packages you want on your [I]nstall Install and upgrade wanted packages. [C]onfig Configure any packages that are [R]emove Remove unwanted software. [Q]uit Quit dselect.
possible. system.
unconfigured.
There are two ways to select an option from the menu: choose it with arrows, or press the key of the corresponding letter in brackets. Access. In this menu you choose the method to obtain and install the packages.
68
TOC
Abbreviation cdrom nfs harddisk mounted oppy ftp Description install from a CD-ROM install from an NFS server (not yet mounted) install from a hard disk partition (not yet mounted) install from a le system which is already mounted install from a pile of oppy disks install using ftp
Update. dselect reads the Packages database (described above) and creates a database of the packages available on your system. Select. This section of the program selects the packages. Choose your the package you want and press Enter . If you have a slow machine, the screen may clear and remain blank for 15 seconds. The rst thing that appears is Page 1 of the Help le. You can view this screen by pressing ? at any point in the Select screens, and you can page through the help screens by pressing the . (period) key. To exit the Select screen after all of the selections are complete, press Enter . This returns you to the main screen if there are no problems with your selection. You must resolve those problems rst. When you are satised with any given screen, press Enter . Dependency conicts are quite normal and to be expected. If you select package A and that package requires the unselected package B in order to run, dselect warns you of the problem and will most likely suggest a solution. If package A conicts with package B, you must decide between them. Install dselect runs through the entire 800 packages and installs the ones that are selected. You will need to make decisions during this process. It is often useful to switch to a different shell to compare, for example, an old conguration le with a new one. If the old le is called conf.modules, for example the new le will be called conf.modules.dpkg-new. The screen scrolls by fairly quickly on faster machines. You can halt the display is by pressing Control - S and restart it with Control - Q . At the end of the run, there will be a list of any uninstalled packages. Congure. Most packages are congured in Step 3, but anything remaining can be congured here. Remove. Remove packages that are no longer needed.
Debian GNU/Linux
69
TOC
Quit. Au revoir.
2.3.7 dpkg.
This is a command line tool that installs and manipulates Debian packages. It has several options that allow you to install, congure, update, remove, and perform other operations on Debian packages. You can even build your own packages. dpkg also allows you to list the available packages, les owned by packages, which package owns a le, and so on. Installing or updating new or existing packages. Type the following command:
# dpkg -i lename.deb
where lename is the name of the le containing a Debian package, like tcsh 6.06-11 i386.deb. dpkg is partly interactive; during the installation it may ask additional questions, like whether to install the new version of a conguration le or keep the old version. You may also unpack a package without conguring it by entering:
# dpkg --unpack lename
If a package depends on an uninstalled package or a newer version of a package you already have, or if any other dependency problem occurs during the installation, dpkg will exit without conguring it. Conguring installed packages. If dpkg aborts during installation and leaves a package installed, the package is left uncongured. The Debian packaging system requires the package to be congured to avoid dependency problems. Some packages also require conguration to work properly. To congure a package, type:
dpkg --configure package
where package is the name of the package, like tcsh. (Notice that this is not the original name of the le from which tcsh was installed, which was longer, included a version number, and ended in .deb.)
70
TOC
Removing installed packages. In the Debian package system, there are two ways to eliminate packages: remove and purge. The remove option removes the specied package; the purge option removes both the specied package and its conguration les. The usage is:
# dpkg -r package # dpkg --purge package
If there are any installed packages that depend on the one you wish to remove, the package will not be removed, and dpkg will abort with an error message. Reporting package status. To report the status of the package (e.g., installed, not installed, or uncongured), enter:
# dpkg -s package
Listing available packages. To list the installed packages that match some pattern, type:
# dpkg -l package-name-pattern
where package-name-pattern is an optional argument specifying a pattern for the package names to match, like *sh. Normal shell wildcards are allowed. If you dont specify the pattern, all of the installed packages are listed. Listing les owned by packages. To list all the les owned by a particular package, simply type:
# dpkg -L package
However, this does not list les created by package-specic installation scripts. Finding the package that owns a le. To nd the package which owns a particular le, type the following command:
# dpkg -S lename-pattern
where lename-pattern is the pattern with which to search the package names for a match. Again, normal shell wildcards are allowed.
Debian GNU/Linux
71
TOC
Summary. dpkg is simple to use and is preferred over dselect when all that you need to do is install, upgrade, or remove a small number of packages. It also has some functionality that dselect (an interface to dpkg) doesnt have, like nding which package owns a le. For the full list of options, refer to the dpkg(8) manual page.
72
TOC
[email protected] Announcements of new package releases for the stable distribution. Usually several messages per day. [email protected] Announcements of new package releases for the unstable distribution. Usually several messages per day. [email protected] A mailing list where users of Debian ask for and get support. Usually about 50 packages per day. [email protected] [email protected] [email protected] Lists for those who are involved in porting Debian software to the SPARC, DEC Alpha, and Motorolla 680x0 platforms. There are also several mailing lists for Debian developers. You can subscribe to those mailing list by mail or the World Wide Web. For more information, please visit http://www.debian.org/.
73
TOC
their hard work. Lets hope that Debian GNU/Linux becomes even better.
74
TOC
porting issues can be tracked. Because RPM does this, you can install, upgrade, or remove packages with a single command line in text mode or a few clicks of the mouse in X Package Management Tool. Examples of using RPM from the command line are:
# rpm --install package.rpm # this installs package # rpm --upgrade package.rpm # this upgrades package # rpm --erase package.rpm # this removes or erases package
Package naming conventions. A properly built package .rpm has the following characteristics: its name identies the package, the version, the build revision, the architecture, and the extension .rpm, which identies it as a RPM package. Take, for example, bash-1.14.7-1.i386.rpm. The name itself contains useful information: the package is bash (the Bourne Again SHell), it is version 1.14.7, and it is build 1 of the current version for Red Hat Linux. It was built for Intel or compatible 80386 or higher CPUs, and it is in RPM format. So, if you see a package named bash-1.14.7-2.i386.rpm, you know that it is the second build of bash version 1.14.7, and probably contains xes for problems of the previous build and is more current. While the internal organization of a *.rpm le is beyond the scope of this section, a properly built package contains an executable le, any conguration les, the documentation (at least manual pages), any miscellaneous les directly related to the package, a record of where the packages les are to be installed, and a record of any required packages. After successful installation, information about the package is registered in the systems RPM database. A more thorough discussion of RPM package management system may be found in the RPM HOWTO (see Appendix A). It is also available at
http://www.redhat.com/support/docs/rpm/RPM-HOWTO/RPM-HOWTO.html
75
ftp//ftp.redhat.com/pub/redhat/current/i386/images/boot.img
or in the images directory of a Red Hat CD-ROM. 2. The Red Hat Supplemental diskette image, supp.img, which is available at
ftp://ftp.redhat.com/pub/redhat/current/i386/images/supp.img
or in the images directory of a Red Hat CD-ROM. This diskette is required if your method of installation is not CD-ROM based, or you need PCMCIA support for any device, like a CD-ROM on a laptop, to install properly. This diskette can also be used with the Boot diskette as an emergency start disk for an installed system. 3. The program RAWRITE.EXE, which is available at:
ftp://ftp.redhat.com/pub/redhat/current/i386/dosutils/rawrite.exe
or in the DOS directory of a Red Hat CD-ROM. 4. MS-DOS and Windows 95 users installing Red Hat Linux for the rst time on a machine that will have Linux installed as a second operating system should also obtain:
ftp://ftp.redhat.com/pub/redhat/dos/fdips11.zip
and unzip the les into: C: FIPS if you need to free space on your hard drive. 5. An Emergency Boot diskette for an existing operating system on the target machine on which Linux will be installed as a second operating system must be created.
76
NFS installation. For NFS installation, you will either need a Red Hat CD-ROM on a machine (such as an existing Linux box) that can support and export an ISO-9660 le system with Rockridge Extensions, or you need to mirror one of the Red Hat distributions with the directory tree organized as described aboveand of course, the proper les in each directory. The directory /RedHat needs to be exported to the machines on the network that are to have Red Hat Linux installed or upgraded. This machine must be on an Ethernet; you can not do an NFS install via dialup link. Hard drive installation. Hard drive installations must have the /RedHat directory created relative to the root directory of the partition (it doesnt matter which partition) that will contain the Red Hat distribution obtained either from CD-ROM or an FTP site. For example, on the primary DOS partition, the path to \RedHat should be C:\RedHat. On a MS-DOS le system, it does not matter that the package .rpm names are truncated. All you need to do is make sure the \RedHat\base directory contains the base les from a CD-ROM or FTP site and the \RedHat\RPMS directory contains all of the package .rpm les from the CD-ROM or FTP site. Then you can install or upgrade from that partition. If you have an existing Linux partition that is not needed for an installation or upgrade, you can set it up as outlined here and use it. FTP installation. To install via FTP over the Internet, all you need is the IP address of the FTP server and the root directory path for the Red Hat Linux system you wish to install. See Appendix B for a list of Linux FTP sites and mirrors. If you intend to do an FTP installation over a low-bandwidth connection (anything slower than a 128K ISDN link), it is highly recommended you copy the les to an existing MS-DOS hard
77
TOC
drive partition and then install from the hard drive. The total size of the packages in the /RedHat/RPMS directory is approximately 170MB and will take many hours to install. If something goes wrong with the installation, such as the link going down, you need to start from the beginning. If you get the les rst and set up your hard drive to install Linux, it is then less work and less confusing to recover from a failed installation. You dont even need to download all of the les in /RedHat/RPMS to successfully install a minimal system which can grow with your needs. See the next section for details.
78
TOC
are the minimum required for that section. NOTE: only the package part of a packages name (package-version-build.rpm) is listed in the le. This means the comps le is generally usable from one version of Red Hat to the next. A section in this le has the structure:
number category package ... end
That is a tag to identify the category number, the category, a list of the package names in the category, and the tag end to mark the end of the category. Without exception, everyone needs all of the software packages listed in the Base section of the le. The other sections, though, can generally be customized or eliminated to suit a particular need. For example, there are three types of Networked Stations: plain, management, and dial-up. An examination of these sections shows that many of the software packages are listed in all three categories, but some software packages are specic to the category. If you are creating a Dial-up Networked Station, then you can safely eliminate the Plain and Management sections and any software unique to those categories. Conversely, if you only need basic networking capability for networked work stations, the other sections can be eliminated from the le as well as the software unique to those sections. All you need to do is make sure that you have all of the software packages listed in that category. If you have local custom packages (those not provided by Red Hat Software), you should add them to an existing category that is appropriate rather than creating a new category. Because the list of packages in each category only contains the name of the package (i.e., not the entire package-name-version-build.rpm), you can substitute any updates Red Hat has made available in the updates directory on:
ftp://ftp.redhat.com/pub/redhat/current/updates
or one of Red Hats mirror sites for the original package found in the distributions original /RedHat/RPMS directory. The installation program is relatively version-insensitive. The only warning here is to insure that package dependencies are met. When an RPM package is built, RPM itself tries to determine what packages must be installed for the package to work (the RPM developer also has direct control of this as wellhe or she can add dependencies that RPM might not ordinarily detect). This is where a little experimentation
79
TOC
or research may be needed. For example, one way to determine package dependencies (if you have user access to your NFS server on an existing Red Hat Linux box) is to telnet or login into it (or if you have the CD-ROM, mount it and go to the RedHat/RPMS directory) and query the package for its dependencies:
[root@happy RPMS] rpm -q -p -R bash-1.14.7-1.i386.rpm libc.so.5 libtermcap.so.2
The -q puts rpm in query mode, the -p tells rpm to query an uninstalled package, and the -R tells rpm to list the target packages dependencies. In this example, we see libc.so.5 and libtermcap.so.2 are required. Since libc and termcap are part of the base of required software (as is bash), you must insure that the libc and libtermcap packages (the dependency packages) are present to be able to install bash (the target). As long as you get the entire base system installed, you can boot the system when the installation program completes. You can add additional packages to Red Hat Linux as required even if the installation program reports that a package failed to install because its dependencies were not met. The table on page 126 describes the categories of software found in /base/comps in Red Hat v4.0:
80
TOC
system and one of the Networked Station packages installed, and you can add anything you need or want later.
2.4.9 Installation.
By now, you should have created the Installation Floppy Kit, prepared your hard drive, and have your installation media ready. The details of the installation follow. You rst begin by booting your system and conguring the installation program to install from your selected medium. After this the installation proceeds with the same steps for everyone. You need to begin by booting your computer with the diskette labeled Boot diskette.
81
TOC
you will be asked if you wish to AUTOPROBE for it or SPECIFY OPTIONS. Most people should choose AUTOPROBE, which causes the program to scan for your SCSI card and enable the SCSI support for your card when found. After the Installation Program has successfully located the Red Hat CD-ROM, you should read the next section. Hard drive installation. To install from a hard drive, highlight this option and choose OK. If you have not already chosen PCMCIA support, you will be prompted to insert the Supplemental diskette. NFS installation. To install via NFS, highlight this option and choose OK. You must choose the Ethernet card installed on the target machine so the Installation Program can load the correct driver. Highlight the appropriate card from the list, and then select OK, allowing the Installation Program to AUTOPROBE for your card. If your machine locks up, you must press Ctrl - Alt - Delete to reboot the system. Most of the time, when this happens, it is because the probing interferes with a non-Ethernet card. If this happens, try again and choose SPECIFY OPTIONS, and give the data about your card in this form:
ether=IRQ,IO PORT,eth0
This instructs the probe to look at the location specied by the values IRQ and IO PORT for the Ethernet card. If your Ethernet card is congured for IRQ 11 and IO PORT 0x300, specify:
ether=11,0x300,eth0
After the card has been successfully found, you will be prompted for TCP/IP information about your machine and the NFS server with the Linux installation packages. First, you will be asked to provide the target machines IP Address, Netmask, Default Gateway, and Primary Name Server. For example:
IP Address: Netmask: Default Gateway: Primary Nameserver: 192.168.181.21 255.255.255.0 192.168.181.1 192.168.181.2
After you select OK, you are prompted for the target machines Domain name and Host name. For example, if your domain name is infomagic.com and host name is vador, enter:
82
TOC
Domainname: Host name: Secondary nameserver IP: Tertiary nameserver IP: infomagic.com vador.infomagic.com Enter if needed Enter if needed
The last screen prompts you for the NFS server and the exported directory containing the Red Hat distribution. For example, if your NFS server is redhat.infomagic.com, enter:
NFS Server name: Red Hat Directory: redhat.infomagic.com /pub/mirrors/linux/RedHat
If you do not know these values, ask your system administrator. After you enter the values, select OK to continue. If the installation program reports an error locating the Red Hat distribution, make sure that you have the correct values lled in above and that your network administrator has given you export permission for the target machine. FTP installation. FTP installation is similar to the NFS installation described above. You are prompted for the Ethernet card and your machines TCP/IP information. However, you will be asked for the FTP site name and Red Hat directory on the Red Hat mirror site, instead of NFS server information. One warning about performing an FTP installation: nd the closest and least busy FTP site to your location. See Appendix B for a list of Linux FTP sites. If your hardware isnt detected, you may need to provide an override for the hardware to be enabled properly. You may also want to check:
http://www.redhat.com/pub/redhat/updates/version/images
to see if Red Hat has updated boot diskettes for your hardware.
83
TOC
for the rst time, you need to partition your hard disk with the free space determined above. 3. After you create the necessary Linux Native and Linux Swap partitions, you must initialize and enable the swap partition. You will then be asked to which partition(s) you intend to install Linux If upgrading, select the root partition. You must congure and choose at least one partition, which will be the root partition. Highlight the root partition. Then, unless you are upgrading, you are presented with a table of other available partitions. Choose the appropriate partitions and EDIT to indicate which partitions will be used for which directories. If you have more than one partition for the Linux installation, now is the time to designate those as well. 4. Next, a list of software categories to install is presented, followed by a chance to customize which software packages from each category are to be installed. If you have not installed Red Hat or other distributions of Linux before, simply choose the category of software to install and let the setup program install the defaults for each category. If you need a package that wasnt installed originally, you can always install it later. While the software is installing, you will see a progress indicator and you should get a cup or two of coffee. Installation can take thirty minutes to an hour or more, depending on software choices and hardware conguration. 5. After the software installation is done, you will be asked to congure your mouse. A discussion mouse protocols and devices starts on page 40. 6. Next is the X Window System conguration. It is recommend you wait until after you boot your system for the rst time to congure X. If something goes wrong with the X conguration, you may need to start the installation procedure from the beginning if the Installation Program isnt able to recover. 7. If you do not have an Ethernet card, do not congure your network at this time. If you have a network card and didnt congure it earlier, you should congure it now. Conguration for a dialup network should be done after the installation is complete. 8. Next, you need to congure the system clock. UTC is a good choice if you are on a network and want daylight savings time handled properly. Local Time is okay if the computer is a stand-alone machine. 9. If you do not have a US keyboard, you will need specify the conguration for your keyboard.
84
TOC
10. You are prompted for the root system password. Dont forget it. Recovering the password is not a trivial matter. You will need the password to access the system when you rst reboot. 11. Finally, you will be asked to congure LILO.
If you have not installed a root partition that begins and ends between cylinder 0-1023, Do not install LILO. When you reboot the system for the rst time, if LILO does not allow you to boot your system correctly, use the Emergency MS-DOS and Windows 95 boot diskette and, at A:\> enter FDISK /mbr. This allows your system to boot into an existing MS-DOS or Windows 95 system as it did before LILO was installed. You can then use the Red Hat Boot diskette with the following parameters at the boot: prompt to boot your system on the hard drive:
boot: rescue root=/dev/xxxx ro load ramdisk=0
Where xxxx is the root partition. After the installation procedure is complet, you are ready to reboot your system and use Linux.
85
TOC
This tells us that dos is the default operating system, which will boot if nothing is typed; to boot Linux, type linux. However, LILO lets you pass parameters to the Linux kernel which override the default behavior. For example, you may have been experimenting with start-up conguration les and did something to prevent the system from coming up properly. If so, you want to boot the system up to the point where it reads the conguration les and no further . The override for this is single:
boot: linux single
boots the system in single user mode so you can take corrective action. This is also useful if your system doesnt boot all the way to the login: prompt for some reason. Logging in the rst time. Now that you are faced with the login: prompt for the rst time, you may be wondering how to get into the system. At this point on a newly installed system, there is only one account to log in tothe administrative account, root. This account is used to manage your system and do things like congure the system, add and remove users, software, and so on. To login into the account, enter root at the login: prompt and press Enter . You are aked for the password you entered during installation. Enter that password at the password: prompt. The system prompt root@locahost # appears after you have successfully negotiated the login. The system prompt tells you two things: you are logged in as root, and in this case, your machine is called localhost. If you named your machine during the installation process, your host name will appear instead of localhost.
86
TOC
and Metro-X, are not. In the list of packages included on the COL media starting on page 196 of the Guide, the commercial packages are noted by an asterisk. COL is available directly from Caldera, or through a network of Partners around the world who have committed to supporting Caldera products. These Partners can usually provide professional assistance, conguration and training for Caldera users. For a current list of Partners, check the Caldera web site.
2.6. Slackware
87
TOC
modules-2.0.25-XXX.img
The XXX is replaced by the version number of the disk images. At the time of writing, the current images are 034 and located in the 001 directory. After you have these images, transfer them onto two oppies as described for generic installations on page 50, using the MS-DOS program RAWRITE.EXE from the Caldera CD-ROM or dd from a Linux system. Calderas CD-ROM is bootable if your systems BIOS allows it, but use the downloaded oppies if possible. They are newer and will contain bug-xes that wont be in the CD versions.
2.6 Slackware
This section on Linux Slackware was written by Sean Dreilinger.
88
Jokes alluding to RFC 666, demonic daemons, and speculation that Pat Volkerding was actually L. Ron Hubbard in disguise were rampant in the threads that followed. The whole amusing incident probably helped Slackware gain some market share: I LOVE THIS!!
Linux Slackware
89
TOC
I was browsing here to figure which version of Linux to install, but after this, I think that I hve no choice but to install Slackware now. From: Date: [email protected] (David Devejian) 10 Jan 1994 04:57:41 GMT
All folklore and kidding aside, Slackware is a wise and powerful choice for your adventures in Linux, whether you are a hobbyist, student, hacker, or system-administrator-in-the-making.
One thing we dont hear too often with Slackware is the U-word. Slackwares setup program is designed to put a fresh operating system onto empty hard disks or empty disk partitions. Installing on top of a previous Slackware installation can erase your custom applications and cause compatibility problems between updated applications and older les
90
TOC
on the same system. When Slackware was rst put together, everyone was a rst-time Linux user, and the system was always experimentalreinstalling the entire operating system and applications was the norm in a developmental system. Today, many institutions and businesses run mission-critical applications on Slackware Linux. In such environment, a simple reboot is a planned activity and taking down the system and overwriting all the user les or custom applications is absolutely unacceptable. Teaching you how to nagle a Slackware upgrade is beyond the scope of this chapter, but it is workable if you are an experienced UNIX administrator and youve taken precautions to preserve your local modications and user les. There is an Internet resource that claims to analyze your distribution and bring it up to date across the Internet. you might want to have a look at this URL if youre facing an upgrade situation:
ftp://ftp.wsc.com/pub/freeware/linux/update.linux/
Or read, weep, and learn from the upgrade expertise of Greg Louis in his mini HOWTO document: Upgrading Your Linux Distribution available where ner LDP publications are mirrored:
http://sunsite.unc.edu/LDP/
Linux Slackware
91
TOC
FTP. Once you transfer Slackware from the closest possible FTP mirror, youll still need to put the Slackware disk sets onto installation media such as a hard drive partition or laboriously copy them onto 50-odd oppy diskettes. NFS. In a networked environment, it is possible to install Slackware on a shared le system and allow everyone on the Local net to attach to this shared location and install. If you have the technical know-how or a geeked out system administrator who is Linuxliterate, this is a great way to go. The initial distribution of Slackware can be added to the network via CD-ROM, FTP, Loading oppies, tape, or even via a remote NFS share across the Internet! For details on such a remote share, see these URLs:
http://sunsite.doc.ic.ac.uk/sunsite/access/nfs.html ftp://ftp.cdrom.com/pub/linux/slackware/MIRRORS.TXT http://www.cs.us.es/archive/nfs.html
Floppy. Its time consuming, but it worksyou can create the pile of oppies needed to install Slackware and then feed them into your box one-by-one when prompted. Slackware disk sets are actually designed and arranged to t oppy diskettes. If you happen to have a huge stack of recycled, high-density oppy diskettes at your disposal, this can be the most economical way to go. Hard disk. This is the way to do it if youve transferred the Slackware distribution across the Internet via FTPyoull escape the oppy trap by merely creating boot, root, and rescue diskettes. It requires you to have an extra disk or disk partition with extra space to hold the Slackware les during installation (you can erase them afterwards). Installation from the hard drive is also a workaround if you bought the CD but your CD-ROM drive is not supported by any of the Linux kernels that come with the Slackware CD. You can use your present operating system to transfer the Slackware les onto spare hard disk space, then boot into the Slackware installation. Tape. Still experimental as of this writing, tape offers a great compromise of speed and economy when installing Slackwareworth considering if a friend with compatible tape drive can dupe a CD or FTP archive for you. Get the latest details from the Tape section of the INSTALL.TXT le that accompanies your Slackware distribution.
92
Linux Slackware
93
TOC
Last chance to back out! When using the install from scratch option, you must install to a blank partition. If you have not already formatted it manually, then you must format it when prompted. Enter I to install from scratch, or a to add software to your existing system. i nstall or a dd (Re)format the main Linux partition. Would you like to format this partition? y es, n o, or c heck sectors, too ext2fs defaults to one inode per 4096 bytes of drive space. If youre going to have many small les on your drive, you may need more inodes (one is used for each le entry). You can change the density to one inode per 2048 bytes, or even per 1024 bytes. Enter 2048 or 1024, or just hit Enter to accept the default of 4096. 4096 (default). 2048, or 1024 4. Prepare Additional Linux Partitions: You can mount some other partitions for /usr or /usr/X11 or whatever (/tmpyou name it). Would you like to use some of the other Linux partitions to mount some of your directories? y es or n o These are your Linux partitions (partition list displayed). These partitions are already in use (partition list displayed). Enter the partition you would like to use, or type q to quit adding new partitions. Use a format such as: /dev/hda3 or whatever the device name is. Partition name or q uit Would you like to format this partition? y es, n o, or c heck sections, too Now this new partition must be mounted somewhere in your new directory tree. For example, if you want to put it under /usr/X11R6, then respond: /usr/X11R6 Where would you like to mount this new partition?
94
TOC
Mount point Would you like to mount some more additional partitions? y es or n o 5. DOS and OS/2 Partition Setup: The following DOS FAT or OS/2 HPFS partitions were found: (partition list displayed). Would you like to set up some of these partitions to be visible from Linux? y es or n o Please enter the partition you would like to access from Linux, or type q to quit adding new partitions. Use a format such as: /dev/hda3 or whatever the device name is. Partition name or q uit Now this new partition must be mounted somewhere in your directory tree. Please enter the directory under which you would like to put it. for instance, you might want to reply /dosc, /dosd, or something like that. Where would you like to mount this partition? Mount point 6. Source Media Selection:
(a) Install from a hard drive partition. (b) Install from floppy disks. (c) Install via NFS. (d) Install from a pre-mounted directory. (e) Install from CD-ROM.
1, 2, 3, 4, or 5
Linux Slackware
95
TOC
7. Install from a hard drive partition: To install directly from the hard disk, you must have a partition with a directory containing the Slackware distribution such that each disk other than the boot disk is contained in a subdirectory. For example, if the distribution is in /stuff/slack, then you need to have directories named /stuff/slack/a1, /stuff/slack/a2, and so on, each containing the les that would be on that disk. You may install from DOS, HPFS, or Linux partitions. Enter the partition where the Slackware sources can be found, or p to see a partition list. Partition name or p artition list What directory on this partition can the Slackware sources be found. In the example above, this would be: /stuff/slack. What directory are the Slackware sources in? Directory name What type of le system does your Slackware source partition contain?
(a) FAT (MS-DOS, DR-DOS, OS/2) (b) Linux Second Extended File System (c) Linux Xiafs (d) Linux MINIX (e) OS/2 HPFS
1, 2, 3, 4, or 5 8. Install from a pre-mounted directory: Okay, we will install from a directory that is currently mounted. This can be mounted normally or through NFS. You need to specify the name of the directory that contains the subdirectories for each source disk. Which directory would you like to install from? Directory name 9. Install from oppy disks: The base Slackware series (A) can be installed from 1.2M or 1.44M media. Most of the other disks will not t on 1.2M media, but can be downloaded to your hard drive and installed from there later. Which drive would you like to install from (1/2/3/4)?
96
TOC
/dev/fd0u1440 (1.44M drive a:) /dev/fd1u1440 (1.44M drive b:) /dev/fd0h1200 (1.2M drive a:) /dev/fd1h1200 (1.2M drive b:)
1, 2, 3, or 4 10. Install via NFS: Youre running off the hard drive le system. Is this machine currently running on the network you plan to install from? If so, we wont try to recongure your ethernet card. Are you up and running on the network? y es or n o You will need to enter the IP address you wish to assign to this machine. Example: 111.112.113.114. What is your IP address? IP address Now we need to know your netmask. Typically this will be 255.255.255.0. What is your netmask? IP address Do you have a gateway (y/n)? y es or n o What is your gateway address? IP address Good! Were all set on the local end, but now we need to know where to nd the software packages to install. First, we need the IP address of the machine where the Slackware sources are stored. Since youre already running on the network, you should be able to use the hostname instead of an IP address if you wish. What is the IP address of your NFS server?
Linux Slackware
97
TOC
IP address There must be a directory on the server with the Slackware sources for each disk in subdirectories beneath it. setup needs to know the name of the directory on your server that contains the disk subdirectories. For example, if your A3 disk is found at /slackware/a3, then you would respond: /slackware. What is the Slackware source directory? Directory name 11. Install from CD-ROM: What type of CD-ROM drive do you have?
(a) Works with most ATAPI/IDE CD drives (/dev/hd*) (b) SCSI (/dev/scd0 or /dev/scd1) (c) Sony CDU31A/CDU33A (/dev/sonycd) (d) Sony 531/535 (/dev/cdu535) (e) Mitsumi, proprietary interface---not IDE (/dev/mcd) (f) New Mitsumi, also not IDE (/dev/mcdx0) (g) Sound Blaster Pro/Panasonic (/dev/sbpcd) (h) Aztech/Orchid/Okano/Wearnes (/dev/aztcd) (i) Phillips and some ProAudioSpectrum16 (/dev/cm206cd) (j) Goldstar R420 (/dev/gscd) (k) Optics Storage 8000 (/dev/optcd) (l) Sanyo CDR-H94 + ISP16 soundcard (/dev/sjcd) (m) Try to scan for your CD drive
1, 2, 3, 4, 5, 6, 7 8, 9, 10, 11, 12, or 13 IDE CD-ROM: Enter the device name that represents your IDE CDROM drive. This will probably be one of these (in the order of most to least likely): /dev/hdb /dev/hdc /dev/hdd /dev/hde /dev/hdf /dev/hdg /dev/hdh /dev/hda Device name
98
TOC
SCSI CD-ROM: Which SCSI CD-ROM are you using? If youre not sure, select /dev/scd0. 1. /dev/scd0 2. /dev/scd1 installation method: With the Slackware CD, you can run most of the system from the CD if youre short of drive space or if you just want to test Linux without going through a complete installation. Which type of installation do you want (slakware or slaktest)? slakware Normal installation to hard drive slaktest Link /usr- /cdrom/live/usr to run mostly from CD-ROM slakware or slaktext 12. Series Selection: Identify which Packages you plan to install. You may specify any combination of disk sets at the prompt which follows. For example, to install the base system, the base X Window System, and the Tcl toolkit, you would enter: a x tcl. Which disk sets do you want to install?
A Base Linux system AP Various applications that do not need X D Program Development (C, C++, Kernel source, Lisp, Perl, etc.) E GNU Emacs F FAQ lists K Linux kernel source N Networking (TCP/IP, UUCP, Mail) Q Extra kernels with special drivers (needed for non-SCSI CD) T TeX TCL Tcl/Tk/TclX, Tcl language, and Tk toolkit for developing X apps X Xfree86 Base X Window System XAP X Window Applications XD Xfree86 X11 server development system
Linux Slackware
99
TOC
XV Xview (OpenLook virtual Window Manager, apps) Y Games (that do not require X)
Any combination of a ap d e f k n q t tcl x xap xd xv y and other disk sets offered, separated by spaces 13. Software Installation: Next, software packages are going to be transferred on to your hard drive. If this is your rst time installing Linux, you should probably use PROMPT mode. This will follow a defaults le on the rst disk of each series you install that will ensure that required packages are installed automatically. You will be prompted for the installation of other packages. If you dont use PROMPT mode, the install program will just go ahead and install everything from the disk sets you have selected. Do you want to use PROMPT mode (y/n)? y es or n o These defaults are user denableyou may set any package to be added or skipped automatically by editing your choices into a le called TAGFILE that will be found on the rst disk of each series. There will also be a copy of the original tagle called TAGFILE.ORG available in case you want to restore the default settings. The tagle contains all the instructions needed to completely automate your installation. Would you like to use a special tagle extension? You can specify an extension consisting of a . followed by any combination of 3 characters other than tgz. For instance, I specify .pat, and then whenever any tagles called tagle.pat are found during the installation they are used instead of the default tagle les. If the install program does not nd tagles with the custom extension, it will use the default tagles. Enter your custom tagle extension (including the leading .), or just press Enter to continue without a custom extension. Tagle extension Enter 14. Extra Conguration: If you wish, you may now go through the options to recongure your hardware, make a bootdisk, and install LILO. If youve installed a new kernel image, you should go through these steps again. Otherwise, its up to you. y es or n o
100
TOC
15. Boot Disk Creation: It is recommended that you make a boot disk. Would you like to do this? y es or n o Now put a formatted oppy in your boot drive. This will be made into your Linux boot disk. Use this to boot Linux until LILO has been congured to boot from the hard drive. Any data on the target disk will be destroyed. Insert the disk and press Return , or s if you want to skip this step.
Enter or s kip
16. Modem Setup: A link in /dev will be created from your callout device (cua0, cua1, cua2 , cua3) to /dev/modem. You can change this link later if you put your modem on a different port. Would you like to set up your modem? y es or n o These are the standard serial I/O devices, Which device is your modem attached to (0, 1, 2, 3)?
0 /dev/ttyS0 (or COM1: 1 /dev/ttyS1 (or COM2: 2 /dev/ttyS2 (or COM3: 3 /dev/ttyS3 (or COM4: under DOS) under DOS) under DOS) under DOS)
0, 1, 2, or 3 17. Mouse Setup: A link will be created in /dev from your mouse device to /dev/mouse. You can change this link later if you switch to a different type of mouse. Would you like to set up your mouse? y es or n o These types are supported. Which type of mouse do you have (1, 2, 3, 4, 5, 6, 7)?
Linux Slackware
101
TOC
(a) Microsoft compatible serial mouse (b) QuickPort or PS/2 style mouse (Auxiliary port) (c) Logitech Bus Mouse (d) ATI XL Bus Mouse (e) Microsoft Bus Mouse (f) Mouse Systems serial mouse (g) Logitech (MouseMan) serial mouse
1, 2, 3, 4, 5, 6, or 7 These are the standard serial I/O devices. Which device is your mouse attached to (0, 1, 2, 3)?
0 /dev/ttyS0 (or COM1: 1 /dev/ttyS1 (or COM2: 2 /dev/ttyS2 (or COM3: 3 /dev/ttyS3 (or COM4: under DOS) under DOS) under DOS) under DOS)
0, 1, 2, or 3 18. Network Conguration: Now we will attempt to congure your mail and TCP/IP. This process probably wont work on all possible network congurations, but should give you a good start. You will be able to recongure your system at any time by typing netconfig. First, well need the name youd like to give your host. Only the base host name is needed right now (not the domain). Enter the host name. Host name Now, we need the domain name. Do not supply a leading . Enter the domain name. Domain name If you only plan to use TCP/IP through loopback, then your IP address will be 127.0.0.1, and we can skip a lot of the following questions. Do you plan to only use loopback?
102
TOC
y es or n o Enter your IP address for the local machine. Example: 111.112.113.114. Enter the IP address for this machine (aaa.bbb.ccc.ddd). IP address Enter your gateway address, such as 111.112.113.1. If you dont have a gateway, you can edit /etc/rc.d/rc.inet1 later,or you can probably get away with entering your own IP address here. Enter the gateway address (aaa.bbb.ccc.ddd). IP address Enter your netmask. This will generally look something like this: 255.255.255.0. Enter the netmask (aaa.bbb.ccc.ddd). IP address Will you be accessing a name server? y es or n o Please give the IP address of the name server to use. You can add more Domain Name Servers by editing /etc/resolv.conf. Name server for your domain (aaa.bbb.ccc.ddd)? IP address You may now reboot your computer by pressing Ctrl - Alt - Delete . If you installed LILO, remove the boot disk from your computer before rebooting. Dont forget to create your /etc/fstab if you dont have one (see page 196)!
Linux Slackware
103
ftp://ftp.cdrom.com/pub/linux/slackware/bootdsks.144/README.TXT
104
TOC
dont know much about UNIX and would feel more comfortable with an attractive, clean interface to the same process, then by all means go for the beautiful setup.
============== Slackware96 Linux Setup (version HD-3.1.0) ============== Welcome to Slackware Linux Setup. Hint: If you have trouble using the arrow keys on your keyboard, you can use +, -, and TAB instead. Which option would you like? ==================================================================== HELP Read the Slackware Setup HELP file KEYMAP Remap your keyboard MAKE TAGS Tagfile customization program TARGET Select target directory [now: / ] SOURCE Select source media DISK SETS Decide which disk sets you wish to install INSTALL Install selected disk sets CONFIGURE Reconfigure your Linux system PKGTOOL Install or remove packages with Pkgtool EXIT Exit Slackware Linux Setup ==================================================================== ======================================================================== < OK > <Cancel> ========================================================================
Transferring Slackware onto your system from here should involve little more than selecting what you want from the menus. By lling out Section 3 of the worksheet in advance, you should be able progress quickly through each menu in order, until you reach the INSTALL option, at which point things may s l o w down: you are advised to select the PROMPT feature and read about each software package, deciding whether or not youd like it to end up on your Slackware system. The last part of a regular setup is the CONFIGURE section on the setup menu, and the questions you must answer bear a striking resemblance to the second half of the Section 3 worksheet.
Linux Slackware
105
TOC
and wondering What Next? Well, if youre plagued by problems, youll want to proceed directly to the next section on troubleshooting. If things appear to be in working order, youve still got some details to attend to. Its sort of like purchasing a new automobileafter you select and pay for a car, there are still some things that you need before you can drive it with condenceinsurance, a steering wheel club, and perhaps some luxuries that make the driving experience closer to Fahrvergn ugen than FAQ!
106
TOC
Mailing lists for Slackware. At this time, there are no electronic mail discussions devoted to Slackware per se. You can participate in some excellent Linux-related talk via e-mail, try http://www.linux.org, and ask in the Usenet newsgroups for a few good subscription lists. There is a general Linux mailing list server, [email protected]. See page 33 for a description of how to subscribe to mailing lists via this server. You get what you pay for (commercial support). Commercial support for Linux is available from some of the CD-ROM vendors and a long list of Linux Consultants, who can be contacted through the Linux Commercial and Consultants HOWTO documents:
http://sunsite.unc.edu/LDP/HOWTO/Consultants-HOWTO.html http://sunsite.unc.edu/LDP/HOWTO/Commercial-HOWTO.html
Linux Slackware
107
Give yourself an account. On large, shared systems, the super-user root account is not used as a working login account by any individual. If youre interested in system administration or are running a networked machine, this is a good precedent to follow. Use the /sbin/adduser program and make yourself a login account, rather than working out of the root login. I always smile when I see students and hobbyists posting proudly to the Usenet as [email protected]. Be humble and safe: create another login account for your daily work and use su (rather than login) to enter the root account sparingly. Read Chapter 4 for a discussion of what you should do with the root account (or shouldnt). Deny root logins. Not only is it uncommon to work as the root user, it is not considered secure to login as root across the network. Administrative users usually connect to a UNIX box as their regular, user-name login, then su to root as needed. To prevent crackers, hackers, and ignorant users from logging in directly as root, edit the le /etc/securetty and comment out (prepend a pound (#) sign before) all but the local terminals:
console tty1
108
TOC
tty2 # ttyS0 # ttyS1
After this x, users who attempt to login in as root across the network will be denied:
Linux 2.0.29 (durak.interactivate.com) (ttyp4) durak login: durak login: root
Apply the simple xes. Slackware installs itself with some very real security problems. Rather than master UNIX security and sleuth out these vulnerabilities yourself, you can jump start the hole-patching process by visiting a Web resource maintained for just this purpose, called Slackware SimpleFixes:
http://cesdis.gsfc.nasa.gov/linux-web/simplefixes/simplefixes.html
Check for patches on ftp.cdrom.com As an actively maintained Linux distribution, Slackware updates and patches are available from:
ftp://ftp.cdrom.com/pub/linux/slackware/patches/
Stay current. You might like to subscribe to one or more electronic mailing lists that alert users to issues in Linux administration, such as:
[email protected] [email protected]
2.6.16.1 Back up. Like how things are running? Save it for a rainy day by backing up. Amanda (the Advanced Maryland Automatic Network Disk Archiver) is one of several backup options for Linux installations. You can learn more about Amanda from:
http://www.cs.umd.edu/projects/amanda/index.html
2.7. S.u.S.E.
109
TOC
2.7 S.u.S.E.
This section on S.u.S.E. Linux was written by Larry Ayers. The SuSE distribution began a few years ago as an adaptation of Slackware. Patrick Volkerding of Slackware helped the SuSE developers at rst, but before too long, the distribution began to assume an identity of its own. Several new features intended to aid the rst-time user increase the probability an installation wont need to be immediately redone. Given the cross-pollination endemic in the free software world, I wouldnt be surprised to learn some of these features have shown up in newer Slackware releases.
110
TOC
that arent much different than in other distributions. They all use the same underlying tools; the procedure has become more or less standardized. Dependencies. The use of dependencies, which consist of information included in a software package concerning what other packages are necessary for it to run, has spread rapidly among Linux distributions. Unfortunately no universal format for dependencies has arisen. Each distribution uses a different format. Redhats RPM format, used in several distributions, is powerful and effective, but it has a few drawbacks. It works best on an all-RPM system, as the dependency checking done by the RPM program only knows about RPM packages. S.u.S.E. 5.1 uses srpm-format. The dependencies are only checked if a package is installed from within the YAST program, allowing the option (for a skilled user) of unarchiving a package in another location, then checking out the les and conguration before nal installation. Dependencies are most useful during the initial setup and while becoming familiar with a new installation. Once youve used the system for a while, youll have an idea of what libraries and programs are available. Most software packages for Linux also contain information as to what needs to be present on a system in order for the package to function. It is wise to read through the entire rc.config le before running SuSEconfig and committing any changes you may have made. Some of the default actions the script will take you may prefer to handle yourself, but they are easily disabled by editing the le. Users familiar with the Slackware layout of initialization les will need to make some adjustments; the les usually found in /etc/rc.d are instead in /sbin/init.d.
S.u.S.E. Linux
111
TOC
After you have S.u.S.E. Linux up and running, its a good idea to install the kernel source (available on the CD-ROM, its an optional package which can be installed during initial set-up). S.u.S.E. installs a generic kernel, and you probably need only a few of of the accompanying modules. This is an excellent opportunity to familiarize yourself with the mechanics of source code compilation, and youll end up with a smaller customized kernel with only the capabilities you need. The gcc compiler and accompanying tools must be installed in order to compile a kernel; these tools are a near-necessity on a Linux system even if youre not a programmer. The YAST dependency checking will help insure that all of the required compilation tools are installed. Kernel compilation can seem daunting to a beginner, but it is a fairly intuitive process. Three interfaces are available for the initial conguration step. The rst (and oldest) is a console-mode script invoked via the command make config. This script asks a series of questions and uses the results to write a le which guides the compiler in its work. You need to know some basic facts about your hardware such as what type of hard disk and CD-ROM drive you have. If you want sound support youll need to know the IRQ your card uses, as well as a few other parameters that can be gathered from the cards manual or the output of the MS-DOS msd utility. The other two interfaces are menuconfig and xconfig. The rst uses a modied version of the dialog program mentioned above, which runs on a virtual console or a xterm and resembles the YAST setup tool. xconfig is a Tk-based version, designed to run in a X window. All three accomplish the same task. The latter two let you make choices without typing much. The kernel sources are well-documented. The README le in the top-level directory contains enough information to nearly guarantee a successful build.
112
TOC
The S.u.S.E. developers have taken some pains in conguring the various window managers, for example, fvwm95. The rst time you start X, many of the applications you elected for installation will be available from the mouse activated root window menu. Another entry on the menu allows you to change the window background. Many well-designed icons are supplied with the S.u.S.E. distribution. This gives new users something of a reprieve. After getting Linux and X running nally, there is enough to do just learning the system without feeling compelled to customize the environment, in order to make it tolerable to view!
This cleanly reboots your system. The manual page for shutdown describes the other command-line arguments that are available. Use the command man shutdown to see the manual page for shutdown. Note, however, that many Linux distributions do not provide the shutdown command on the installation media. This means that the rst time you reboot your system after installation, you may need to use the Ctrl - Alt - Del combination. After you have a chance to explore and use the system, there are several conguration chores that you should undertake. The rst is to create a user account for yourself (and, optionally, any other users that might have access to the system). Creating user accounts
113
TOC
is described in Chapter 4. Usually, all that you have to do is login as root, and run the adduser (sometimes useradd) program. This leads you through several prompts to create new user accounts. If you create more than one lesystem for Linux, or if youre using a swap partition, you may need to edit the le /etc/fstab in order for those lesystems to be available automatically after rebooting. If youre using a separate lesystem for /usr, and none of the les that should be in /usr appear to be present, you may simply need to mount that lesystem. See page 196 for a description of the /etc/fstab le.
114
TOC
After the installation media boots, you will see a number of messages from the kernel itself, indicating which devices were detected and congured. After this, you will usually be presented with a login prompt, allowing you to proceed with installation (some distributions instead drop you right into an installation program of some kind). The system may appear to hang during several of these steps. Be patient: loading software from oppy is comparatively slow. In many cases, the system has not hung at all but is merely taking a long time. Verify that there is no drive or system activity for at least several minutes before assuming that the system is hung. 1. After booting from the LILO prompt, the system must load the kernel image from oppy. This may take several seconds; you will know that things are going well if the oppy drive light is still on. 2. While the kernel boots, SCSI devices must be probed for. If you do not have any SCSI devices installed, the system will hang for up to 15 seconds while the SCSI probe continues; this usually occurs after the line
lp init: lp1 exists (0), using polling driver
appears on your screen. 3. After the kernel is nished booting, control is transferred to the system boot-up les on the oppy. Finally, you will be presented with a login prompt, or be dropped into an installation program. If you are presented with a login prompt such as
Linux login:
you should then login (usually as root or installthis varies with each distribution). After entering the user name, the system may pause for 20 seconds or more while the installation program or shell is being loaded from oppy. Again, the oppy drive light should be on. Dont assume that the system is hung. Any of the above items may be the source of your problem. However, it is possible that the system actually may hang while booting, which can be due to several causes. First of all, you may not have enough available RAM to boot the installation media. (See the following item for information on disabling the ramdisk to free up memory.) The cause of many system hangs is hardware incompatibility. The last chapter presented an overview of supported hardware under Linux. Even if your hardware is supported, you may run into problems with incompatible hardware congurations
115
TOC
which are causing the system to hang. See page 116, below, for a discussion of hardware incompatibilities. System reports out-of-memory errors while attempting to boot or install the software. This item deals with the amount of RAM that you have available. On systems with 4 megabytes of RAM or less, you may run into trouble booting the installation media or installing the software itself. This is because many distributions use a RAM disk, a le system loaded directly into RAM, for operations while using the installation media. The entire image of the installation boot oppy, for example, may be loaded into a RAM disk, which may require more than a megabyte of RAM. You may not see an out of memory error when attempting to boot or install the software; instead, the system may unexpectedly hang, or fail to boot. If your system hangs, and none of the explanations in the previous section seem to be the cause, try disabling the ramdisk. See your distributions documentation for details. Keep in mind that Linux itself requires at least 2 megabytes of RAM to run at all; most modern distributions of Linux require 4 megabytes or more. The system reports an error like permission denied or file not found while booting. This is an indication that your installation bootup media is corrupt. If you try to boot from the installation media (and youre sure that youre doing everything correctly), you should not see any errors like this. Contact the distributor of your Linux software and nd out about the problem, and perhaps obtain another copy of the boot media if necessary. If you downloaded the boot disk yourself, try re-creating it and see if this solves the problem. The system reports the error VFS: Unable to mount root when booting. This error message means that the root le system (found on the boot media itself), could not be found. This means that either your boot media is corrupt in some way, or that you are not booting the system correctly. For example, many CD-ROM distributions require that you have the CD-ROM in the drive when booting. Be sure that the CD-ROM drive is on and check for any activity. Its also possible that the system is not locating your CD-ROM drive at boot time; see page 116 for more information.
116
117
TOC
tain IRQs for certain devices. For example, on some distributions of Linux, the kernel is precongured to use IRQ 5 for the TMC-950 SCSI controller, the Mitsumi CD-ROM controller, and the bus mouse driver. If you want to use two or more of these devices, youll need to rst install Linux with only one of these devices enabled, then recompile the kernel in order to change the default IRQ for one of them. (See Chapter 4 for information on recompiling the kernel.) Another area where hardware conicts can arise is with DMA (direct memory access) channels, I/O addresses, and shared memory addresses. All of these terms describe mechanisms through which the system interfaces with hardware devices. Some Ethernet boards, for example, use a shared memory address as well as an IRQ to interface with the system. If any of these are in conict with other devices, then the system may behave unexpectedly. You should be able to change the DMA channel, I/O or shared memory addresses for your various devices with jumper settings. (Unfortunately, some devices dont allow you to change these settings.) The documentation for various hardware devices should specify the IRQ, DMA channel, I/O address, or shared memory address that the devices use, and how to congure them. Again, the simple way to get around these problems is to temporarily disable the conicting devices until you have time to determine the cause of the problem. The table below is a list of IRQ and DMA channels used by various standard devices on most systems. Almost all systems have some of these devices, so you should avoid setting the IRQ or DMA of other devices in conict with these values. Problems recognizing hard drive or controller. When Linux boots, you should see a series of messages on your screen such as:
Console: colour EGA+ 80x25, 8 virtual consoles
Serial driver version 3.96 with no serial options enabled tty00 at 0x03f8 (irq = 4) is a 16450 tty03 at 0x02e8 (irq = 3) is a 16550A lp init: ... lp1 exists (0), using polling driver
Here, the kernel is detecting the various hardware devices present on your system. At some point, you should see the line
Partition check:
118
TOC
Partition check: hda: hdb: hda1 hda2 hdb1 hdb2 hdb3
If, for some reason, your drives or partitions are not recognized, then you will not be able to access them in any way. There are several things that can cause this to happen: Hard drive or controller not supported. If you have a hard drive controller (IDE, SCSI, or otherwise) that is not supported by Linux, the kernel will not recognize your partitions at boot time. Drive or controller improperly congured. Even if your controller is supported by Linux, it may not be congured correctly. (This is particularly a problem for SCSI controllers. Most non-SCSI controllers should work ne without any additional conguration). Refer to the documentation for your hard drive and/or controller. In particular, many hard drives need to have a jumper set to be used as a slave drive (the second device on either the primary or secondary IDE bus). The acid test of this kind of condition is to boot MS-DOS or some other operating system that is known to work with your drive and controller. If you can access the drive and controller from another operating system, then it is not a problem with your hardware conguration. See page ??, above, for information on resolving possible device conicts, and page ??, below, for information on conguring SCSI devices. Controller properly congured, but not detected. Some BIOS-less SCSI controllers require the user to specify information about the controller at boot time. A description of how to force hardware detection for these controllers begins on page ??. Hard drive geometry not recognized. Some systems, like the IBM PS/ValuePoint, do not store hard drive geometry information in the CMOS memory, where Linux expects to nd it. Also, certain SCSI controllers need to be told where to nd drive geometry in order for Linux to recognize the layout of your drive. Most distributions provide a bootup option to specify the drive geometry. In general, when booting the installation media, you can specify the drive geometry at the LILO boot prompt with a command such as:
119
TOC
boot: linux hd=cylinders,heads,sectors
where cylinders, heads, and sectors correspond to the number of cylinders, heads, and sectors per track for your hard drive. After installing Linux, you will be able to install LILO, allowing you to boot from the hard drive. At that time, you can specify the drive geometry to LILO, making it unnecessary to enter the drive geometry each time you boot. See Chapter 4 for more information about LILO.
Problems with SCSI controllers and devices. Presented here are some of the most common problems with SCSI controllers and devices like CD-ROMs, hard drives, and tape drives. If you have problems getting Linux to recognize your drive or controller, read on. The Linux SCSI HOWTO (see Appendix A) contains much useful information on SCSI devices in addition to that listed here. SCSI can be particularly tricky to congure at times. A SCSI device is detected at all possible IDs. This is caused by strapping the device to the same address as the controller. You need to change the jumper settings so that the drive uses a different address than the controller. Linux reports sense errors, even if the devices are known to be error-free. This can be caused by bad cables or bad termination. If your SCSI bus is not terminated at both ends, you may have errors accessing SCSI devices. When in doubt, always check your cables. SCSI devices report timeout errors. This is usually caused by a conict with IRQ, DMA, or device addresses. Also check that interrupts are enabled correctly on your controller. SCSI controllers that use BIOS are not detected. Detection of controllers that use BIOS will fail if the BIOS is disabled, or if your controllers signature is not recognized by the kernel. See the Linux SCSI HOWTO, available from the sources in Appendix A, for more information about this. Controllers using memory mapped I/O do not work. This is caused when the memory-mapped I/O ports are incorrectly cached. Either mark the boards address space as uncacheable in the XCMOS settings, or disable cache altogether. When partitioning, you get a warning that cylinders 1024, or you are unable to boot from a partition using cylinders numbered above 1023. BIOS limits the
120
TOC
number of cylinders to 1024, and any partition using cylinders numbered above this wont be accessible from the BIOS. As far as Linux is concerned, this affects only booting; once the system has booted you should be able to access the partition. Your options are to either boot Linux from a boot oppy, or boot from a partition using cylinders numbered below 1024. CD-ROM drive or other removeable media devices are not recognized at boot time. Try booting with a CD-ROM (or disk) in the drive. This is necessary for some devices. If your SCSI controller is not recognized, you may need to force hardware detection at boot time. This is particularly important for BIOS-less SCSI controllers. Most distributions allow you to specify the controller IRQ and shared memory address when booting the installation media. For example, if you are using a TMC-8xx controller, you may be able to enter
boot: linux tmx8xx=interrupt,memory-address
at the LILO boot prompt, where interrupt is the IRQ of controller, and memory-address is the shared memory address. Whether or not this is possible depends on the distribution of Linux; consult your documentation for details.
121
TOC
format. (The boot oppy is the exception; it is not in MS-DOS format in most cases.) If all else fails, either obtain a new set of oppies, or recreate the oppies (using new diskettes) if you downloaded the software yourself. System reports errors such as tar: read error or gzip: not in gzip format. This problem is usually caused by corrupt les on the installation media. In other words, your oppy may be error-free, but the data on the oppy is in some way corrupted. If you downloaded the Linux software using text mode, rather than binary mode, then your les will be corrupt, and unreadable by the installation software. System reports errors like device full while installing. This is a clear-cut sign that you have run out of space when installing the software. Not all Linux distributions can pick up the mess cleanly; you shouldnt be able to abort the installation and expect the system to work. The solution is usually to re-create your le systems (with mke2fs) which deletes the partially installed software. You can attempt to re-install the software, this time selecting a smaller amount of software to install. In other cases, you may need to start completely from scratch, and rethink your partition and lesystem sizes. System reports errors such as read intr: 0x10 while accessing the hard drive. This usually indicates bad blocks on your drive. However, if you receive these errors while using mkswap or mke2fs, the system may be having trouble accessing your drive. This can either be a hardware problem (see page 116), or it might be a case of poorly specied geometry. If you used the
hd=cylinders,heads,sectors
option at boot time to force detection of your drive geometry, and incorrectly specied the geometry, you could be prone to this problem. This can also happen if your drive geometry is incorrectly specied in the system CMOS. System reports errors like file not found or permission denied. This problem can occur if not all of the necessary les are present on the installation media (see the next paragraph) or if there is a permissions problem with the installation software. For example, some distributions of Linux have been known to have bugs in the installation software itself. These are usually xed very rapidly, and are quite infrequent. If you suspect that the distribution software contains bugs,
122
TOC
and youre sure that you have not done anything wrong, contact the maintainer of the distribution to report the bug. If you have other strange errors when installing Linux (especially if you downloaded the software yourself), be sure that you actually obtained all of the necessary les when downloading. For example, some people use the FTP command
mget *.*
when downloading the Linux software via FTP. This will download only those les that contain a . in their lenames; if there are any les without the ., you will miss them. The correct command to use in this case is
mget *
The best advice is to retrace your steps when something goes wrong. You may think that you have done everything correctly, when in fact you forgot a small but important step somewhere along the way. In many cases, re-downloading and re-installing the software can solve the problem. Dont beat your head against the wall any longer than you have to! Also, if Linux unexpectedly hangs during installation, there may be a hardware problem of some kind. See page 116 for hints.
123
TOC
boot: linux hd=partition
at the boot menu, where partition is the name of the Linux root partition, like /dev/hda2. Consult the documentation for your distribution for details. Problems booting Linux from the hard drive. If you opted to install LILO instead of creating a boot oppy, you should be able to boot Linux from the hard drive. However, the automated LILO installation procedure used by many distributions is not always perfect. It may make incorrect assumptions about your partition layout, and you will need to re-install LILO to get everything correct. LILO installation is covered in Chapter 4. System reports Drive not bootable---Please insert system disk. The hard drives master boot record is corrupt in some way. In most cases, its harmless, and everything else on your drive is still intact. There are several ways around this: 1. While partitioning your drive using fdisk, you may have deleted the partition that was marked as active. MS-DOS and other operating systems attempt to boot the active partition at boot time (Linux pays no attention to whether the partition is active or not). You may be able to boot MS-DOS from oppy and run FDISK.EXE to set the active ag on your MS-DOS paritition, and all will be well. Another command to try (with MS-DOS 5.0 and higher) is
FDISK /MBR
This command attempts to rebuild the hard drive master boot record for booting MS-DOS, by overwriting LILO. If you no longer have MS-DOS on your hard drive, you need to boot Linux from oppy and attempt to install LILO later. 2. If you created a MS-DOS partition using Linuxs version of fdisk, or vice versa, you may get this error. You should create MS-DOS partitions only using MS-DOSs version, FDISK.EXE. (This applies to operating systems other than MS-DOS.) The best solution is either to start from scratch and repartition the drive correctly, or to merely delete and re-create the offending partitions with the correct version of fdisk. 3. The LILO installation procedure may have failed. In this case, you should either boot from your Linux boot oppy (if you have one), or from the original installation media. Either of these should provide options for specifying the
124
TOC
Linux root partition to use when booting. Hold down Shift or Ctrl at boot time, and press Tab from the boot menu for a list of options. When booting the system from the hard drive, MS-DOS (or another operating system) starts instead of Linux. First of all, be sure that you actually installed LILO when installing the Linux software. If not, then the system still boots MS-DOS (or whatever other operating system you may have) when you attempt to boot from the hard drive. In order to boot Linux from the hard drive, you need to install LILO (see Chapter 4). On the other hand, if you did install LILO, and another operating system boots instead of Linux, then you have LILO congured to boot that other operating system by default. While the system is booting, hold down Shift or Ctrl , and press Tab at the boot prompt. This should present you with a list of possible operating systems to boot; select the appropriate option (usually linux) to boot Linux. If you wish to select Linux as the default operating system, you must re-install LILO. See Chapter 4. It may also be possible that you attempted to install LILO, but the installation procedure failed in some way. See the previous item. Problems logging in After booting Linux, you should be presented with a login prompt, like
linux login:
At this point, either the distributions documentation or the system itself will tell you what to do. For many distributions, you simply log in as root, with no password. Other possible user names to try are guest or test. Most newly installed Linux systems should not require a password for the initial log in. However, if you are asked to enter a password, there may be a problem. First, try using a password equivalent to the username; that is, if you are logging in as root, use root as the password. If you simply cant log in, there may be a problem. First, consult your distributions documentation; the user name and password to use may be buried in there somewhere. The user name and password may have been given to you during the installation procedure, or they may be printed on the login banner. One cause may be a problem with installing the Linux login program and initialization les. You may need to reinstall (at least parts of) the Linux software, or boot your
125
TOC
installation media and attempt to x the problem by handsee Chapter 4 for hints. Problems using the system. If logging in is successful, you should be presented with a shell prompt (like # or $) and can happily roam around your system. However, there are some initial problems with using the system that sometimes creep up. The most common initial conguration problem is incorrect le or directory permissions. This can cause the error message
Shell-init: permission denied
to be printed after logging in (in fact, any time you see the message permission denied you can be fairly certain that it is a problem with le permissions). In many cases, its a simple matter of using chmod to x the permissions of the appropriate les or directories. For example, some distributions of Linux once used the (incorrect) le mode 0644 for the root directory (/). The x was to issue the command
# chmod 755 /
as root. However, in order to issue this command, you needed to boot from the installation media and mount your Linux root lesystem by handa hairy task for most newcomers. As you use the system, you may run into places where le and directory permissions are incorrect, or software does not work as congured. Welcome to the world of Linux! While most distributions are quite trouble-free, very few of them are perfect. We dont want to cover all of those problems here. Instead, throughout the book we help you to solve many of these conguration problems by teaching you how to nd them and x them yourself. In Chapter 1 we discussed this philosophy in some detail. In Chapter 4, we give hints for xing many of these common conguration problems.
126
TOC
RPM Category BASE C Development Development Libs C++ Development Networked Workstation
Required? Yes Highly Recommend Highly Recommend Optional Recommend; Required for other network software Optional Optional
Network Management Workstation Dialup Workstation Game Machine Multimedia Machine X Window System X Multimedia Support TEX Document Formatting emacs emacs with X support MS-DOS and Microsoft Windows Connectivity Extra Documentation
Optional Recommended Optional Optional Optional Optional Optional Recommended Recommended Optional Required
Comments Should not be customized. Need the minimal system to compile a kernel. Need the minimal system to compile a kernel. C++ Development. Whether you are on an Ethernet or going to dialup networking, you need to install this package suite; You shouldnt customize this. If your Linux box is going to serve les via FTP or Gopher. Useful for Web Developers for local development, required if you serve Web pages. Has additional tools useful for dialup as well as Ethernet network. Required if you are going to dialup. Need I say more? Fortunes are required for humor. If you have supported hardware. If you want to run X. If you have supported hardware. Installation of the entire package is recommended. The One True Editing Environment. Requires X Huh? Manual pages should always be installed.
127
TOC
Size Comments If less than 16MB of RAM installed, 16MB of swapis a must. If space is tight, and 16MB RAM installed, 1 x Physical RAM is the minimum recommended. Depends on tools, like compilers, that are needed. Depends on tools like compilers, that are needed. Depends on being single or multiple users and needs. Depends on news feeds, number of users, etc. Used for programs not in RPM format or to be kept separate from the rest of Red Hat.
/usr
350+ MB
128
TOC
File aztech.i
bare.i cdu31a.i cdu535.i cm206.i goldstar.i mcd.i mcdx.i net.i optics.i sanyo.i sbpcd.i
xt.i
IDE Slackware bootdisks: CD-ROM drives: Aztech CDA268-01A, Orchid CD-3110, Okano/Wearnes CDD110, Conrad TXC, CyCDROM CR520, CR540. IDE support only. Sony CDU31/33a CD-ROM. Sony CDU531/535 CD-ROM. Philips/LMS cm206 CD-ROM with cm260 adapter card. Goldstar R420 CD-ROM (sometimes sold in a Reveal Multimedia Kit). NON-IDE Mitsumi CD-ROM support. Improved NON-IDE Mitsumi CD-ROM support. Ethernet support. Optics Storage 8000 AT CD-ROM (the DOLPHIN drive). Sanyo CDR-H94A CD-ROM support. Matsushita, Kotobuki, Panasonic, CreativeLabs (Sound Blaster), Longshine and Teac NON-IDE CD-ROM support. MFM hard drive support.
129
TOC
File 7000fast.s Advansys.s Aha152x.s Aha1542.s Aha1740.s Aha2x4x.s SCSI/IDE Slackware bootdisks: Western Digital 7000FASST SCSI support. AdvanSys SCSI support. Adaptec 152x SCSI support. Adaptec 1542 SCSI support. Adaptec 1740 SCSI support. Adaptec AIC7xxx SCSI support (For these cards: AHA-274x, AHA-2842, AHA-2940, AHA-2940W, AHA-2940U, AHA-2940UW, AHA-2944D, AHA-2944WD, AHA-3940, AHA-3940W, AHA-3985, AHA-3985W). AMD AM53/79C974 SCSI support. All supported SCSI controllers, plus CD-ROM support for Aztech CDA268-01A, Orchid CD-3110, Okano/Wearnes CDD110, Conrad TXC, CyCDROM CR520, CR540. Buslogic MultiMaster SCSI support. All supported SCSI controllers, plus CD-ROM support for Sony CDU31/33a. All supported SCSI controllers, plus CD-ROM support for Sony CDU531/535. All supported SCSI controllers, plus Philips/LMS cm206 CD-ROM with cm260 adapter card. DTC (Data Technology Corp) 3180/3280 SCSI support. DPT EATA-DMA SCSI support. (Boards like PM2011, PM2021, PM2041, PM3021, PM2012B, PM2022, PM2122, PM2322, PM2042, PM3122, PM3222, PM3332, PM2024, PM2124, PM2044, PM2144, PM3224, PM3334.) DPT EATA-ISA/EISA SCSI support. (Boards like PM2011B/9X, PM2021A/9X, PM2012A, PM2012B, PM2022A/9X, PM2122A/9X, PM2322A/9X). DPT EATA-PIO SCSI support (PM2001 and PM2012A). Future Domain TMC-16x0 SCSI support. All supported SCSI controllers, plus Goldstar R420 CD-ROM (sometimes sold in a Reveal Multimedia Kit). Always IN2000 SCSI support. IOMEGA PPA3 parallel port SCSI support (also supports the parallel port version of the ZIP drive). All supported SCSI controllers, plusstandard non-IDE Mitsumi CD-ROM support. All supported SCSI controllers, plus enhanced non-IDE Mitsumi CD-ROM support. NCR 53c406a SCSI support. NCR 5380 and 53c400 SCSI support. NCR 53c7xx, 53c8xx SCSI support (Most NCR PCI SCSI controllers use this driver). All supported SCSI controllers, plus support for the Optics Storage 8000 AT CDROM (the DOLPHIN drive). Pro Audio Spectrum/Studio 16 SCSI support. ISA/VLB/PCMCIA Qlogic FastSCSI! support (also supports the Control Concepts SCSI cards based on the Qlogic FASXXX chip). Supports all Qlogic PCI SCSI controllers, except the PCI-basic, which the AMD SCSI driver supports. All supported SCSI controllers, plus Sanyo CDR-H94A CD-ROM support. All supported SCSI controllers, plus Matsushita, Kotobuki, Panasonic, CreativeLabs (Sound Blaster), Longshine and Teac NON-IDE CDROM support. All supported SCSI controllers, plus full ethernet support.
Eata isa.s Eata pio.s Fdomain.s Goldstar.s In2000.s Iomega.s Mcd.s Mcdx.s N53c406a.s N 5380.s N 53c7xx.s Optics.s Pas16.s Qlog fas.s Qlog isp.s Sanyo.s Sbpcd.s Scsinet.s
130
TOC
Device ttyS0 (COM1) ttyS1 (COM2) ttyS2 (COM3) ttyS3 (COM4) lp0 (LPT1) lp1 (LPT2) fd0, fd1 (oppies 1 and 2) fd2, fd3 (oppies 3 and 4)
I/O address 3f8 2f8 3e8 2e8 378 - 37f 278 - 27f 3f0 - 3f7 370 - 377
IRQ 4 3 4 3 7 5 6 10
TOC
Chapter 3
Linux Tutorial
3.1 Introduction.
If youre new to UNIX and Linux, you may be a bit intimidated by the size and apparent complexity of the system before you. This chapter does not go into great detail or cover advanced topics. Instead, we want you to hit the ground running. We assume very little here about your background, except perhaps that you have some familiarity with personal computer systems, and MS-DOS. However, even if youre not an MS-DOS user, you should be able to understand everything here. At rst glance, Linux looks a lot like MS-DOSafter all, parts of MS-DOS were modeled on the CP/M operating system, which in turn was modeled on UNIX. However, only the most supercial features of Linux resemble MS-DOS. Even if youre completely new to the PC world, this tutorial should help. And, before we begin: Dont be afraid to experiment. The system wont bite you. You cant destroy anything by working on the system. Linux has built-in security features to prevent normal users from damaging les that are essential to the system. Even so, the worst thing that can happen is that you may delete some or all of your les and youll have to re-install the system. So, at this point, you have nothing to lose.
131
132
Linux Tutorial
TOC
DOS, where only one person can use the system at any one time. Under Linux, to identify yourself to the system, you must log in, which entails entering your login name (the name the system uses to identify you), and entering your password, which is your personal key for logging in to your account. Because only you know your password, no one else can log in to the system under your user name. On traditional UNIX systems, the system administrator assigns you a user name and an initial password when you are given an account on the system. However, because in Linux tt you are the system administrator, you must set up your own account before you can log in. For the following discussions, well use the imaginary user name, larry. In addition, each system has a host name assigned to it. It is this host name that gives your machine a name, gives it character and charm. The host name is used to identify individual machines on a network, but even if your machine isnt networked, it should have a host name. For our examples below, the systems host name is mousehouse.
Enter your user name and press the Enter key. Our hero, larry, would type:
mousehouse login: Password: larry
Next, enter your password. The characters you enter wont be echoed to the screen, so type carefully. If you mistype your password, youll see the message
Login incorrect
133
TOC
and youll have to try again. Once you have correctly entered the user name and password, you are ofcially logged in to the system, and are free to roam.
larrys password
134
Linux Tutorial
TOC
Welcome to Mousehouse! /home/larry#
The last line of this text is the shells prompt, indicating that its ready to take commands. (More on what the prompt itself means later.) Lets try telling the system to do something interesting:
/home/larry# make love make: *** No way to make target love. Stop. /home/larry#
Well, as it turns out, make is the name of an actual program on the system, and the shell executed this program when given the command. (Unfortunately, the system was being unfriendly.) This brings us to the burning question: What is a command? What happens when you type make love? The rst word on the command line, make, is the name of the command to be executed. Everything else on the command line is taken as arguments to this command. Example:
/home/larry# cp foo bar
The name of this command is cp, and the arguments are foo and bar. When you enter a command, the shell does several things. First, it checks the command to see if it is internal to the shell. (That is, a command which the shell knows how to execute itself. There are a number of these commands, and well go into them later.) The shell also checks to see if the command is an alias, or substitute name, for another command. If neither of these conditions apply, the shell looks for a program, on disk, having the specied name. If successful, the shell runs the program, sending the arguments specied on the command line. In our example, the shell looks for a program called make, and runs it with the argument love. Make is a program often used to compile large programs, and takes as arguments the name of a target to compile. In the case of make love, we instructed make to compile the target love. Because make cant nd a target by this name, it fails with a humorous error message, and returns us to the shell prompt. What happens if we type a command to a shell and the shell cant nd a program having the specied name? Well, we can try the following:
/home/larry# eat dirt
135
TOC
eat: command not found
/home/larry#
Quite simply, if the shell cant nd a program having the name given on the command line (here, eat), it prints an error message. Youll often see this error message if you mistype a command (for example, if you had typed mkae love instead of make love).
to log out. There are other ways of logging out, but this is the most foolproof one.
136
Linux Tutorial
TOC
given names, with which you can identify them. Furthermore, directories are maintained in a tree-like structure; that is, directories may contain other directories. Consequently, you can refer to a le by its path name, which is made up of the lename, preceded by the name of the directory containing the le. For example, lets say that Larry has a directory called papers, which contains three les: history-final, english-lit, and masters-thesis. Each of these three les contains information for three of Larrys ongoing projects. To refer to the english-lit le, Larry can specify the les pathname, as in:
papers/english-lit
As you can see, the directory and lename are separated by a single slash (/). For this reason, lenames themselves cannot contain the / character. MS-DOS users will nd this convention familiar, although in the MS-DOS world the backslash (\) is used instead. As mentioned, directories can be nested within each other as well. For example, lets say that there is another directory within papers, called notes. The notes directory contains the les math-notes and cheat-sheet. The pathname of the le cheat-sheet would be
papers/notes/cheat-sheet
Therefore, a path name is really like a path to the le. The directory that contains a given subdirectory is known as the parent directory. Here, the directory papers is the parent of the notes directory.
137
TOC
/ bin dev etc home lib proc tmp usr
larry sam
var
X11R6 bin emacs etc g++-include include lib bin local emacs etc lib man src linux spool tmp
The more command simply displays a le, one screen at a time. However, because Larrys current working directory is /home/larry, he can instead refer to the le relative to his
138
Linux Tutorial
TOC
current location by using the command
/home/larry# more papers/history-final
If you begin a lename (like papers/final) with a character other than /, youre referring to the le in terms relative to your current working directory. This is known as a relative path name. On the other hand, if you begin a le name with a /, the system interprets this as a full path namethat is, a path name that includes the entire path to the le, starting from the root directory, /. This is known as an absolute path name.
is equivalent to
/home/larry# more /home/larry/papers/history-final
The shell replaces the character with the name of your home directory. You can also specify other users home directories with the tilde character. The pathname karl/letters translates to /home/karl/letters by the shell (if /home/karl is karls home directory). Using a tilde is simply a shortcut; there is no directory named its just syntactic sugar provided by the shell.
executes them; most Linux systems enable either tcsh or bash for new user accounts.
139
where directory is the name of the directory which you wish to become the current working directory. As mentioned earlier, when you log in, you begin in your home directory. If Larry wanted to switch to the papers subdirectory, hed use the command
/home/larry# cd papers /home/larry/papers#
As you can see, Larrys prompt changes to reect his current working directory (so he knows where he is). Now that hes in the papers directory, he can look at his history nal with the command
/home/larry/papers# more history-final
Now, Larry is stuck in the papers subdirectory. To move back up to the next higher (or parent) directory, use the command
/home/larry/papers# cd /home/larry# ..
(Note the space between the cd and the ...) Every directory has an entry named .. which refers to the parent directory. Similarly, every directory has an entry named . which refers to itself. Therefore, the command
/home/larry/papers# cd .
gets us nowhere. You can also use absolute pathnames with the cd command. To cd into Karls home directory, we can use the command
/home/larry/papers# cd /home/karl /home/karl#
140
Linux Tutorial
TOC
Also, using cd with no argument will return you to your own home directory.
/home/karl# cd /home/larry#
Here we can see that Larry has three entries in his current directory: Mail, letters, and papers. This doesnt tell us muchare these directories or les? We can use the -F option of the ls command to get more detailed information.
/home/larry# ls --F Mail/ letters/ papers/ /home/larry#
From the / appended to each lename, we know that these three entries are in fact subdirectories. Using ls -F may also append * to the end of a lename in the resulting list which would indicate that the le is an executable, or a program which can be run. If nothing is appended to the lename using ls -F, the le is a plain old le, that is, its neither a directory nor an executable. In general, each UNIX command may take a number of options in addition to other arguments. These options usually begin with a -, as demonstrated above with the -F option. The -F option tells ls to give more information about the type of the les involved in this case, printing a / after each directory name. If you give ls a directory name, the system will print the contents of that directory.
141
TOC
/home/larry# ls --F papers english-lit history-final masters-thesis notes/ /home/larry#
Or, for a more interesting listing, lets see whats in the systems /etc directory.
/home/larry# ls /etc Images adm bcheckrc brc brc csh.cshrc csh.login default disktab fdprm fstab ftpaccess /home/larry# ftpusers getty gettydefs group inet init init.d initrunlvl inittab inittab.old issue lilo lpc magic motd mount mtab mtools pac passwd printcap profile psdatabase rc rc.new rc0.d rc1.d rc2.d rc3.d rc4.d rc5.d rmt rpc rpcinfo securetty services
shells startcon swapoff swapon syslog.c syslog.p syslogd. termcap umount update utmp wtmp
If youre a MS-DOS user, you may notice that the lenames can be longer than 8 characters, and can contain periods in any position. You can even use more than one period in a lename. Lets move to the top of the directory tree, and then down to another directory with the commands
/home/larry# cd .. /home# cd .. /# cd usr /usr# cd bin /usr/bin#
You can also move into directories in one step, as in cd /usr/bin. Try moving around various directories, using ls and cd. In some cases, you may run into the foreboding Permission denied error message. This is simply UNIX
142
Linux Tutorial
TOC
security kicking in: in order to use the ls or cd commands, you must have permission to do so. We talk more about this starting on page 161.
Congratulations! You made a new directory and moved into it. Since there arent any les in this new directory, lets learn how to copy les from one place to another.
The cp command copies the les listed on the command line to the le or directory given as the last argument. Notice that we use . to refer to the current directory.
143
Notice that the termcap le has been renamed sells. You can also use the mv command to move a le to a completely new directory. Note: mv and cp will overwrite a destination le having the same name without asking you. Be careful when you move a le into another directory. There may already be a le having the same name in that directory, which youll overwrite!
Were left with nothing but shells, but we wont complain. Note that rm by default wont prompt you before deleting a leso be careful. A related command to rm is rmdir. This command deletes a directory, but only if the directory is empty. If the directory contains any les or subdirectories, rmdir will complain.
144
Linux Tutorial
TOC
In case youre interested what shells contains, its a list of valid shell programs on your system. On most systems, this includes /bin/sh, /bin/bash, and /bin/csh. Well talk about these different types of shells later. While using more, press Space to display the next page of text, and b to display the previous page. There are other commands available in more as well, these are just the basics. Pressing q will quit more. Quit more and try cat /etc/termcap. The text will probably y by too quickly for you to read it all. The name cat actually stands for concatenate, which is the real use of the program. The cat command can be used to concatenate the contents of several les and save the result to another le. This will be again in section 3.14.1.
and the manual page for ls will be displayed. Unfortunately, most manual pages are written for those who already have some idea of what the command or resource does. For this reason, manual pages usually contain only the technical details of the command, without much explanation. However, manual pages can be an invaluable resource for jogging your memory if you forget the syntax of a command. Manual pages will also tell you about commands that we dont cover in this book. I suggest that you try man for the commands that weve already gone over and whenever I introduce a new command. Some of these commands wont have manual pages, for several reasons. First, the manual pages may not have been written yet. (The Linux Documentation Project is responsible for manual pages under Linux as well. We are gradually accumulating most of the manual pages available for the system.) Second, the the command might be an internal shell command, or an alias (discussed on page 133), which would not have a manual page of its own. One example is cd, which is an internal shell command. The shell itself actually processes the cdthere is no separate program that implements this command.
145
TOC
will mount it under /mnt. See Section 4.8.4 for more information on mounting oppies. You can also mount an MS-DOS partition of your hard drive for access under Linux. If you have an MS-DOS partition on /dev/hda1, the command
# mount -t msdos /dev/hda1 /mnt
mounts it. Be sure to umount the partition when youre done using it. You can have a MS-DOS partition automatically mounted at boot time if you include the entry in /etc/fstab. See Section 4.4 for details. The following line in /etc/fstab will mount an MS-DOS partition on /dev/hda1 on the directory /dos.
/dev/hda1 /dos msdos defaults
You can also mount the VFAT le systems that are used by Windows 95:
# mount -t vfat /dev/hda1 /mnt
This allows access to the long lenames of Windows 95. This only applies to partitions that actually have the long lenames stored. You cant mount a normal FAT16 le system and use this to get long lenames. The Mtools software may also be used to access MS-DOS les. The commands mcd, mdir, and mcopy all behave like their MS-DOS counterparts. If you install Mtools, there should be manual pages available for these commands. Accessing MS-DOS les is one thing; running MS-DOS programs is another. There is an MS-DOS Emulator under development for Linux; it is widely available, and included in most distributions. It can also be retrieved from a number of locations, including the various Linux FTP sites listed in Appendix B. The MS-DOS Emulator is reportedly powerful enough to run a number of applications, including WordPerfect, from Linux. However, Linux and MS-DOS are vastly different operating systems. The power of any MS-DOS emulator under UNIX is limited. In addition, a Microsoft Windows emulator that runs under X Windows is under development.
146
Linux Tutorial
TOC
ls
cp
147
TOC
directory joe. mv Moves one or more le to another le or directory. This command does the equivalent of a copy followed by the deletion of the original le. You can use this to rename les, like in the MS-DOS command RENAME. Syntax: mv les destination Where les lists the les to move, and destination is the destination le or directory. Example: mv ../frog joe moves the le ../frog to the le or directory joe. Deletes les. Note that when you delete a le under UNIX, they are unrecoverable (unlike MS-DOS, where you can usually undelete the le). Syntax: rm les Where les describes the lenames to delete. The -i option prompts for conrmation before deleting the le. Example: rm -i /home/larry/joe /home/larry/frog deletes the les joe and frog in /home/larry. Creates new directories. Syntax: mkdir dirs Where dirs are the directories to create. Example: mkdir /home/larry/test creates the directory test in /home/larry. Deletes empty directories. When using rmdir, the current working directory must not be within the directory to be deleted. Syntax: rmdir dirs Where dirs denes the directories to delete. Example: rmdir /home/larry/papers deletes the directory /home/larry/papers, if empty. Displays the manual page for the given command or resource (that is, any system utility that isnt a command, such as a library function.) Syntax: man command Where command is the name of the command or resource to get help on. Example: man ls gives help on the ls command.
rm
mkdir
rmdir
man
148
Linux Tutorial
TOC
more Displays the contents of the named les, one screenful at a time. Syntax: more les Where les lists the les to display. Example: more papers/history-final displays the le papers/history-final. Ofcially used to concatenate les, cat is also used to display the contents of a le on screen. Syntax: cat les Where les lists the les to display. Example: cat letters/from-mdw displays the le letters/from-mdw. Displays the given arguments on the screen. Syntax: echo args Where args lists arguments to echo. Example: echo "Hello world" displays the string Hello world. Display every line in one or more les that match the given pattern. Syntax: grep pattern les Where pattern is a regular expression pattern, and les lists the les to search. Example: grep loomer /etc/hosts displays every line in the le /etc/hosts that contains the pattern loomer.
cat
echo
grep
149
TOC
Now, lets take a look at each of these directories. /bin /bin is short for binaries, or executables, where many essential system programs reside. Use ls -F /bin to list the les here. If you look down the list you may see a few commands that you recognize, such as cp, ls, and mv. These are the actual programs for these commands. When you use the cp command, for example, youre running the program /bin/cp. Using ls -F, youll see that most (if not all) of the les in /bin have an asterisk (*) appended to their lenames. This indicates that the les are executables, as described on page 140. /dev The les in /dev are device lesthey access system devices and resources like disk drives, modems, and memory. Just as your system can read data from a le, it can also read input from the mouse by accessing /dev/mouse. Filenames that begin with fd are oppy disk devices. fd0 is the rst oppy disk drive, and fd1 is the second. You may have noticed that there are more oppy disk devices than the two listed above: these represent specic types of oppy disks. For example, fd1H1440 accesses highdensity, 3.5 diskettes in drive 1. The following is a list of some of the most commonly used device les. Even though you may not have some of the physical devices listed below, chances are that youll have drivers in /dev for them anyway. /dev/console refers to the systems consolethat is, the monitor connected directly to your system. The various /dev/ttyS and /dev/cua devices are used for accessing serial ports. /dev/ttyS0 refers to COM1 under MSDOS. The /dev/cua devices are callout devices, and used with a modem. Device names beginning with hd access hard drives. /dev/hda refers to the whole rst hard disk, while /dev/hda1 refers to the rst partition on /dev/hda. Device names that begin with sd are SCSI drives. If you have a SCSI hard drive, instead of accessing it through /dev/hda, you
150
Linux Tutorial
TOC
would access /dev/sda. SCSI tapes are accessed via st devices, and SCSI CD-ROM via sr devices. Device names that begin with lp access parallel ports. /dev/lp0 is the same as LPT1 in the MS-DOS world. /dev/null is used as a black holedata sent to this device is gone forever. Why is this useful? Well, if you wanted to suppress the output of a command appearing on your screen, you could send that output to /dev/null. Well talk more about this later. Devices whose names are /dev/tty followed by a number refer to the virtual consoles on your system (accessed by pressing Alt-F1 , Alt-F2 , and so on). /dev/tty1 refers to the rst VC, /dev/tty2 refers to the second, and so on. Device names beginning with /dev/pty are pseudo-terminals, which are used to provide a terminal to remote login sessions. For example, if your machine is on a network, incoming telnet logins would use one of the /dev/pty devices. /etc /etc contains a number of miscellaneous system conguration les. These include /etc/passwd (the user database), /etc/rc (the system initialization script), and so on. /sbin contains essential system binaries that are used for system administration. /home contains users home directories. For example, /home/larry is the home directory for the user larry. On a newly installed system, there may not be any users in this directory. /lib contains shared library images, which are les that contain code which many programs share in common. Rather than each program using its own copy of these shared routines, they are all stored in one common place, in /lib. This makes executable les smaller, and saves space on your system. /proc supports a virtual le system, where the les are stored in memory, not on disk. These les refer to the various processes running on the system, and let you get information about the programs and
/sbin
/home
/lib
/proc
151
TOC
processes that are running at any given time. This is discussed in more detail starting on page 166. /tmp Many programs store temporary information and in a le that is deleted when the program has nished executing. The standard location for these les is in /tmp. /usr is a very important directory which contains subdirectories that contain some of the most important and useful programs and conguration les used on the system. The various directories described above are essential for the system to operate, but most of the items found in /usr are optional. However, it is these optional items that make the system useful and interesting. Without /usr, youd have a boring system that supports only programs like cp and ls. /usr contains most of the larger software packages and the conguration les that accompany them. /usr/X11R6 /usr/X11R6 contains The X Window System, if you installed it. The X Window System is a large, powerful graphical environment that provides a large number of graphical utilities and programs, displayed in windows on your screen. If youre at all familiar with the Microsoft Windows or Macintosh environments, X Windows will look familiar. The /usr/X11R6 directory contains all of the X Windows executables, conguration les, and support les. This is covered in more detail in Chapter ??. /usr/bin is the real warehouse for software on any Linux system, containing most of the executables for programs not found in other places, like /bin. Just as /etc contains essential miscellaneous system programs and conguration les, /usr/etc contains miscellaneous utilities and les, that in general, are not essential to the system.
/usr
/usr/bin
/usr/etc
/usr/include /usr/include contains include les for the C compiler. These les (most of which end in .h, for header) declare data structure names, subroutines, and constants used when writing programs in C. Files in
152
Linux Tutorial
TOC
/usr/include/sys are generally used when programming on the UNIX system level. If you are familiar with the C programming language, here youll nd header les like stdio.h, which declare functions like printf(). /usr/g++-include /usr/g++-include contains include les for the C++ compiler (much like /usr/include). /usr/lib /usr/lib contains the stub and static library equivalents for the les found in /lib. When compiling a program, the program is linked with the libraries found in /usr/lib, which then directs the program to look in /lib when it needs the actual code in the library. In addition, various other programs store conguration les in /usr/lib. /usr/local is much like /usrit contains various programs and les not essential to the system, but which make the system fun and exciting. In general, programs in /usr/local are specialized for your systemconsequently, /usr/local differs greatly between Linux systems. This directory contains manual pages. There are two subdirectories in it for every manual page section (use the command man man for details). For example, /usr/man/man1 contains the source (that is, the unformatted original) for manual pages in section 1, and /usr/man/cat1 contains the formatted manual pages for section 1. /usr/src contains the source code (the uncompiled instructions) for various programs on your system. The most important directory here is /usr/src/linux, which contains the source code for the Linux kernel. /var holds directories that often change in size or tend to grow. Many of those directories used to reside in /usr, but since those who support Linux are trying to keep it relatively unchangeable, the directories that change often have been moved to /var. Some Linux distributions maintain their software package databases in directories under /var. /var/log contains various les of interest to the system administra-
/usr/local
/usr/man
/usr/src
/var
/var/log
153
TOC
tor, specically system logs, which record errors or problems with the system. Other les record logins to the system as well as failed login attempts. This will be covered in Chapter 4. /var/spool /var/spool contains les which are spooled to another program. For example, if your machine is connected to a network, incoming mail is stored in /var/spool/mail until you read or delete it. Outgoing or incoming news articles are in /var/spool/news, and so on.
154
Linux Tutorial
TOC
The type of shell you decide to use is mostly a religious issue. Some folks prefer the Bourne shell syntax with the advanced features of bash, and some prefer the more structured C shell syntax. As far as normal commands such as cp and ls are concerned, the shell you use doesnt matterthe syntax is the same. Only when you start to write shell scripts or use advanced features of a shell do the differences between shell types begin to matter. As we discuss the features of the various shells, well note differences between Bourne and C shells. However, for the purposes of this manual most of those differences are minimal. (If youre really curious at this point, read the man pages for bash and tcsh).
3.8 Wildcards.
A key feature of most Linux shells is the ability to refer to more than one le by name using special characters. These wildcards let you refer to, say, all le names that contain the character n. The wildcard * species any character or string of characters in a le name. When you use the character * in a le name, the shell replaces it with all possible substitutions from le names in the directory youre referencing. Heres a quick example. Suppose that Larry has the les frog, joe, and stuff in his current directory.
/home/larry# ls frog joe stuff /home/larry#
To specify all les containing the letter o in the lename, use the command
/home/larry# ls *o* frog joe /home/larry#
As you can see, each instance of * is replaced with all substitutions that match the wildcard from lenames in the current directory. The use of * by itself simply matches all lenames, because all characters match the wildcard.
/home/larry# ls * frog joe stuff /home/larry#
Wildcards
155
TOC
Here are a few more examples:
/home/larry# ls f* frog /home/larry# ls *ff stuff /home/larry# ls *f* frog stuff /home/larry# stuff /home/larry# ls s*f
The process of changing a * into a series of lenames is called wildcard expansion and is done by the shell. This is important: an individual command, such as ls, never sees the * in its list of parameters. The shell expands the wildcard to include all lenames that match. So, the command
/home/larry# ls *o*
One important note about the * wildcard: it does not match le names that begin with a single period (.). These les are treated as hidden leswhile they are not really hidden, they dont show up on normal ls listings and arent touched by the use of the * wildcard. Heres an example. We mentioned earlier that each directory contains two special entries: . refers to the current directory, and .. refers to the parent directory. However, when you use ls, these two entries dont show up.
/home/larry# ls frog joe stuff /home/larry#
If you use the -a switch with ls, however, you can display lenames that begin with .. Observe:
/home/larry# ls -a . stuff /home/larry# .. .bash profile .bashrc frog joe
156
Linux Tutorial
TOC
The listing contains the two special entries, . and .., as well as two other hidden les.bash profile and .bashrc. These two les are startup les used by bash when larry logs in. They are described starting on page 185. Note that when you use the * wildcard, none of the lenames beginning with . are displayed.
/home/larry# ls * frog joe stuff /home/larry#
This is a safety feature: if the * wildcard matched lenames beginning with ., it would also match the directory names . and ... This can be dangerous when using certain commands. Another wildcard is ?. The ? wildcard expands to only a single character. Thus, ls ? displays all one-character lenames. And ls termca? would display termcap but not termcap.backup. Heres another example:
/home/larry# ls j?e joe /home/larry# ls f??g frog /home/larry# ls ????f stuff /home/larry#
As you can see, wildcards lets you specify many les at one time. In the command summary that starts on page 146, we said that the cp and mv commands actually can copy or move more than one le at a time. For example,
/home/larry# cp /etc/s* /home/larry
copies all lenames in /etc beginning with s to the directory /home/larry. The format of the cp command is really
cp les destination
where les lists the lenames to copy, and destination is the destination le or directory. mv has an identical syntax. If you are copying or moving more than one le, the destination must be a directory. You can only copy or move a single le to another le.
157
TOC
displays the contents of the le history-final followed by masters-thesis. However, if you dont specify a lename, cat reads data from stdin and sends it back to stdout. Heres an example:
/home/larry/papers# cat Hello there. Hello there. Bye. Bye. Ctrl-D /home/larry/papers#
Each line that you type is immediately echoed back by cat. When reading from standard input, you indicate the input is nished by sending an EOT (end-of-text) signal, in general, generated by pressing Ctrl-D . Heres another example. The sort command reads lines of text (again, from stdin, unless you specify one or more lenames) and sends the sorted output to stdout. Try the following.
/home/larry/papers# sort bananas carrots apples Ctrl-D apples bananas
158
Linux Tutorial
TOC
carrots /home/larry/papers#
As you can see, the result of the sort command isnt displayed, but is saved to the le named shopping-list. Lets look at this le:
/home/larry/papers# cat shopping-list apples bananas carrots /home/larry/papers#
Now you can sort your shopping list, and save it, too! But lets suppose that you are storing the unsorted, original shopping list in the le items. One way of sorting the information and saving it to a le would be to give sort the name of the le to read, in lieu of standard input, and redirect standard output as we did above, as follows:
/home/larry/papers# sort items apples bananas carrots /home/larry/papers# shopping-list
However, theres another way to do this. Not only can you redirect standard output, you can redirect standard input as well, using the < symbol.
Linux Plumbing
159
TOC
/home/larry/papers# sort apples bananas carrots /home/larry/papers# items
Technically, sort < items is equivalent to sort items, but lets you demonstrate the following point: sort < items behaves as if the data in the le items was typed to standard input. The shell handles the redirection. sort wasnt given the name of the le (items) to read; as far as sort is concerned, it still reads from standard input as if you had typed the data from your keyboard. This introduces the concept of a lter. A lter is a program that reads data from standard input, processes it in some way, and sends the processed data to standard output. Using redirection, standard input and standard output can be referenced from les. As mentioned above, stdin and stdout default to the keyboard and screen respectively. sort is a simple lter. It sorts the incoming data and sends the result to standard output. cat is even simpler. It doesnt do anything with the incoming data, it simply outputs whatever is given to it.
160
Linux Tutorial
TOC
notes masters-thesis history-final english-list /home/larry/papers#
Here, you save the output of ls in a le, and then run sort -r on that le. But this is unwieldy and uses a temporary le to save the data from ls. The solution is pipelining. This is a shell feature that connects a string of commands via a pipe. The stdout of the rst command is sent to the stdin of the second command. In this case, we want to send the stdout of ls to the stdin of sort. Use the | symbol to create a pipe, as follows:
/home/larry/papers# ls j sort -r notes masters-thesis history-final english-list /home/larry/papers#
This command is shorter and easier to type. Heres another useful example, the command
/home/larry/papers# ls /usr/bin
displays a long list of les, most of which y past the screen too quickly for you to read. So, lets use more to display the list of les in /usr/bin.
/home/larry/papers# ls /usr/bin j more
Now you can page down the list of les at your leisure. But the fun doesnt stop here! You can pipe more than two commands together. The command head is a lter that displays the rst lines from an input stream (in this case, input from a pipe). If you want to display the last lename in alphabetical order in the current directory, use commands like the following:
/home/larry/papers# ls j sort -r j head -1 notes /home/larry/papers#
where head -1 displays the rst line of input that it receives (in this case, the stream of reverse-sorted data from ls).
161
overwrites the contents of the le file-list. If instead, you redirect with the symbol >>, the output is appended to (added to the end of) the named le instead of overwriting it. For example,
/home/larry/papers# ls file-list
appends the output of the ls command to file-list. Keep in mind that redirection and pipes are features of the shellwhich supports the use of >, >> and |. It has nothing to do with the commands themselves.
162
Linux Tutorial
TOC
Permissions fall into three main divisions: read, write, and execute. These permissions may be granted to three classes of users: the owner of the le, the group to which the le belongs, and to all users, regardless of group. Read permission lets a user read the contents of the le, or in the case of directories, list the contents of the directory (using ls). Write permission lets the user write to and modify the le. For directories, write permission lets the user create new les or delete les within that directory. Finally, execute permission lets the user run the le as a program or shell script (if the le is a program or shell script). For directories, having execute permission lets the user cd into the directory in question.
/home/larry/foo#
The rst eld in the listing represents the le permissions. The third eld is the owner of the le (larry) and the fourth eld is the group to which the le belongs (users). Obviously, the last eld is the name of the le ( stuff). Well cover the other elds later. This le is owned by larry, and belongs to the group users. The string -rw-r--r-- lists, in order, the permissions granted to the les owner, the les group, and everybody else. The rst character of the permissions string (-) represents the type of le. A - means that this is a regular le (as opposed to a directory or device driver). The next three characters (rw-) represent the permissions granted to the les owner, larry. The r stands for read and the w stands for write. Thus, larry has read and write permission to the le stuff. As mentioned, besides read and write permission, there is also execute permission represented by an x. However, a - is listed here in place of an x, so Larry doesnt have execute permission on this le. This is ne, as the le stuff isnt a program of any kind. Of course, because Larry owns the le, he may grant himself execute permission for the le if he so desires. (This will be covered shortly.)
File Permissions
163
TOC
The next three characters, (r--), represent the groups permissions on the le. The group that owns this le is users. Because only an r appears here, any user who belongs to the group users may read this le. The last three characters, also (r--), represent the permissions granted to every other user on the system (other than the owner of the le and those in the group users). Again, because only an r is present, other users may read the le, but not write to it or execute it. Here are some other examples of permissions: -rwxr-xr-x The owner of the le may read, write, and execute the le. Users in the les group, and all other users, may read and execute the le. The owner of the le may read and write the le. No other user can access the le. All users may read, write, and execute the le.
-rw-------
-rwxrwxrwx
164
Linux Tutorial
Briey, you supply one or more of all, user, group, or other. Then you specify whether you are adding rights (+) or taking them away (-). Finally, you specify one or more of read, write, and execute. Some examples of legal commands are: chmod a+r stuff Gives all users read access to the le. chmod +r stuff Same as aboveif none of a, u, g, or o is specied, a is assumed. chmod og-x stuff Remove execute permission from users other than the owner. chmod u+rwx stuff Let the owner of the le read, write, and execute the le. chmod o-rwx stuff Remove read, write, and execute permission from users other than the owner and users in the les group.
165
TOC
/home/larry# ls -i foo 22192 foo /home/larry#
Here, foo has an inode number of 22192 in the le system. You can create another link to foo, named bar, as follows:
/home/larry# ln foo bar
With ls -i, you see that the two les have the same inode.
/home/larry# ls -i foo bar 22192 bar 22192 foo /home/larry#
Now, specifying either foo or bar will access the same le. If you make changes to foo, those changes appear in bar as well. For all purposes, foo and bar are the same le. These links are known as hard links because they create a direct link to an inode. Note that you can hard-link les only when theyre on the same le system; symbolic links (see below) dont have this restriction. When you delete a le with rm, you are actually only deleting one link to a le. If you use the command
/home/larry# rm foo
then only the link named foo is deleted, bar will still exist. A le is only truly deleted on the system when it has no links to it. Usually, les have only one link, so using the rm command deletes the le. However, if a le has multiple links to it, using rm will delete only a single link; in order to delete the le, you must delete all links to the le. The command ls -l displays the number of links to a le (among other information).
/home/larry# ls -l foo bar -rw-r--r--rw-r--r-/home/larry# 2 root 2 root root root 12 Aug 12 Aug 5 16:51 bar 5 16:50 foo
The second column in the listing, 2, species the number of links to the le. As it turns out, a directory is actually just a le containing information about link-toinode associations. Also, every directory contains at least two hard links: . (a link pointing to itself), and .. (a link pointing to the parent directory). The root directory (/) .. link just points back to /. (In other words, the parent of the root directory is the root directory itself.)
166
Linux Tutorial
you will create a symbolic link named bar that points to the le foo. If you use ls -i, youll see that the two les have different inodes, indeed.
/home/larry# ls -i foo bar 22195 bar 22192 foo /home/larry#
However, using ls -l, we see that the le bar is a symlink pointing to foo.
/home/larry# ls -l foo bar lrwxrwxrwx -rw-r--r-/home/larry# 1 root 1 root root root 3 Aug 12 Aug 5 16:51 bar -> foo 5 16:50 foo
The le permissions on a symbolic link are not used (they always appear as rwxrwxrwx). Instead, the permissions on the symbolic link are determined by the permissions on the target of the symbolic link (in our example, the le foo). Functionally, hard links and symbolic links are similar, but there are differences. For one thing, you can create a symbolic link to a le that doesnt exist; the same is not true for hard links. Symbolic links are processed by the kernel differently than are hard links, which is just a technical difference but sometimes an important one. Symbolic links are helpful because they identify the le they point to; with hard links, there is no easy way to determine which les are linked to the same inode. Links are used in many places on the Linux system. Symbolic links are especially important to the shared library images in /lib. See page 223 for more information.
Job Control
167
TOC
let you control multiple running commands, or jobs, at once. Before we can delve much further, we need to talk about processes. Every time you run a program, you start what is called a process. The command ps displays a list of currently running processes, as shown here:
/home/larry# ps PID TT STAT 24 3 S 161 3 R /home/larry# TIME COMMAND 0:03 (bash) 0:00 ps
The PID listed in the rst column is the process ID, a unique number given to every running process. The last column, COMMAND, is the name of the running command. Here, were looking only at the processes which Larry himself is currently running. (There are many other processes running on the system as wellps -aux lists them all.) These are bash (Larrys shell), and the ps command itself. As you can see, bash is running concurrently with the ps command. bash executed ps when Larry typed the command. After ps has nished running (after the table of processes is displayed), control is returned to the bash process, which displays the prompt, ready for another command. A running process is also called a job. The terms process and job are interchangeable. However, a process is usually referred to as a job when used in conjunction with job controla feature of the shell that lets you switch between several independent jobs. In most cases users run only a single job at a timewhatever command they last typed to the shell. However, using job control, you can run several jobs at once, and switch between them as needed. How might this be useful? Lets say you are editing a text le and want to interrupt your editing and do something else. With job control, you can temporarily suspend the editor, go back to the shell prompt and start to work on something else. When youre done, you can switch back to the editor and be back where you started, as if you didnt leave the editor. There are many other practical uses of job control.
168
Linux Tutorial
TOC
have redirected input or output, as described starting on page 157). On the other hand, jobs in the background do not receive input from the terminalin general, they run along quietly without the need for interaction. Some jobs take a long time to nish and dont do anything interesting while they are running. Compiling programs is one such job, as is compressing a large le. Theres no reason why you should sit around being bored while these jobs complete their tasks; just run them in the background. While jobs run in the background, you are free to run other programs. Jobs may also be suspended. A suspended job is a job that is temporarily stopped. After you suspend a job, you can tell the job to continue in the foreground or the background as needed. Resuming a suspended job does not change the state of the job in any waythe job continues to run where it left off. Suspending a job is not equal to interrupting a job. When you interrupt a running process (by pressing the interrupt key, which is usually Ctrl-C )3 , the process is killed, for good. Once the job is killed, theres no hope of resuming it. Youll must run the command again. Also, some programs trap the interrupt, so that pressing Ctrl-C wont immediately kill the job. This is to let the program perform any necessary cleanup operations before exiting. In fact, some programs dont let you kill them with an interrupt at all.
The ys will continue ad innitum. You can kill the process by pressing the interrupt key, which is usually Ctrl-C . So that we dont have to put up with the annoying stream of
3 You can set the interrupt key with the stty command.
Job Control
169
TOC
ys, lets redirect the standard output of yes to /dev/null. As you may remember, /dev/null acts as a black hole for data. Any data sent to it disappears. This is a very effective method of quieting an otherwise verbose program.
/home/larry# yes /dev/null
Ah, much better. Nothing is printed, but the shell prompt doesnt come back. This is because yes is still running, and is sending those inane ys to /dev/null. Again, to kill the job, press the interrupt key. Lets suppose that you want the yes command to continue to run but wanted to get the shell prompt back so that you can work on other things. You can put yes into the background, allowing it to run, without need for interaction. One way to put a process in the background is to append an & character to the end of the command.
/home/larry# yes [1] 164 /home/larry# /dev/null &
As you can see, the shell prompt has returned. But what is this [1] 164? And is the yes command really running? The [1] represents the job number for the yes process. The shell assigns a job number to every running job. Because yes is the one and only job were running, it is assigned job number 1. The 164 is the process ID, or PID, number given by the system to the job. You can use either number to refer to the job, as youll see later. You now have the yes process running in the background, continuously sending a stream of ys to /dev/null. To check on the status of this process, use the internal shell command jobs.
/home/larry# jobs [1]+ Running yes >/dev/null & /home/larry#
Sure enough, there it is. You could also use the ps command as demonstrated above to check on the status of the job. To terminate the job, use the kill command. This command takes either a job number or a process ID number as an argument. This was job number 1, so using the command
/home/larry# kill %1
170
Linux Tutorial
TOC
kills the job. When identifying the job with the job number, you must prex the number with a percent (%) character. Now that youve killed the job, use jobs again to check on it:
/home/larry# jobs [1]+ Terminated yes >/dev/null
/home/larry#
The job is in fact dead, and if you use the jobs command again nothing should be printed. You can also kill the job using the process ID (PID) number, displayed along with the job ID when you start the job. In our example, the process ID is 164, so the command
/home/larry# kill 164
is equivalent to
/home/larry# kill %1
You dont need to use the % when referring to a job by its process ID.
Again, because yes is running in the foreground, you shouldnt get the shell prompt back. Now, rather than interrupt the job with Ctrl-C , suspend the job. Suspending a job doesnt kill it: it only temporarily stops the job until you restart it. To do this, press the suspend key, which is usually Ctrl-Z .
/home/larry# yes ctrl-Z [1]+ Stopped yes >/dev/null /home/larry# /dev/null
While the job is suspended, its simply not running. No CPU time is used for the job. However, you can restart the job, which causes the job to run again as if nothing ever happened. It will continue to run where it left off. To restart the job in the foreground, use the fg command (for foreground).
Job Control
171
TOC
/home/larry# fg yes >/dev/null
The shell displays the name of the command again so youre aware of which job you just put into the foreground. Stop the job again with Ctrl-Z . This time, use the bg command to put the job into the background. This causes the command to run just as if you started the command with & as in the last section.
/home/larry# bg [1]+ yes >/dev/null & /home/larry#
And you have your prompt back. Jobs should report that yes is indeed running, and you can kill the job with kill as we did before. How can you stop the job again? Using Ctrl-Z wont work, because the job is in the background. The answer is to put the job in the foreground with fg, and then stop it. As it turns out, you can use fg on either stopped jobs or jobs in the background. There is a big difference between a job in the background and a job that is stopped. A stopped job is not runningits not using any CPU time, and its not doing any work (the job still occupies system memory, although it may have been swapped out to disk). A job in the background is running and using memory, as well as completing some task while you do other work. However, a job in the background may try to display text on your terminal, which can be annoying if youre trying to work on something else. For example, if you used the command
/home/larry# yes &
without redirecting stdout to /dev/null, a stream of ys would be displayed on your screen, without any way for you to interrupt it. (You cant use Ctrl-C to interrupt jobs in the background.) In order to stop the endless ys, use the fg command to bring the job to the foreground, and then use Ctrl-C to kill it. Another note. The fg and bg commands normally affect the job that was last stopped (indicated by a + next to the job number when you use the jobs command). If you are running multiple jobs at once, you can put jobs in the foreground or background by giving the job ID as an argument to fg or bg, as in
/home/larry# fg %2
172
Linux Tutorial
TOC
/home/larry# bg %3
(to put job number 3 into the background). You cant use process ID numbers with fg or bg. Furthermore, using the job number alone, as in
/home/larry# %2
is equivalent to
/home/larry# fg %2
Just remember that using job control is a feature of the shell. The fg, bg and jobs commands are internal to the shell. If for some reason you use a shell that doesnt support job control, dont expect to nd these commands available. In addition, there are some aspects of job control that differ between bash and tcsh. In fact, some shells dont provide job control at allhowever, most shells available for Linux do.
173
TOC
Learning the vi Editor from OReilly and Associates, or the VI Tutorial from Specialized Systems Consultants (SSC) Inc. See Appendix A for information.
3.13.1 Concepts.
While using vi, at any one time you are in one of three modes of operation. These modes are called command mode, insert mode, and last line mode. When you start up vi, you are in command mode. This mode lets you use commands to edit les or change to other modes. For example, typing x while in command mode deletes the character underneath the cursor. The arrow keys move the cursor around the le youre editing. Generally, the commands used in command mode are one or two characters long. You actually insert or edit text within insert mode. When using vi, youll probably spend most of your time in this mode. You start insert mode by using a command such as i (for insert) from command mode. While in insert mode, you can insert text into the document at the current cursor location. To end insert mode and return to command mode, press Esc . Last line mode is a special mode used to give certain extended commands to vi. While typing these commands, they appear on the last line of the screen (hence the name). For example, when you type : in command mode, you jump into last line mode and can use commands like wq (to write the le and quit vi), or q! (to quit vi without saving changes). Last line mode is generally used for vi commands that are longer than one character. In last line mode, you enter a single-line command and press Enter to execute it.
174
Linux Tutorial
TOC
to edit the le test. You should see something like
"test" [New file]
The column of characters indicates you are at the end of the le. The represents the cursor.
Type as many lines as you want (pressing Enter after each). You may correct mistakes with the Backspace key. To end insert mode and return to command mode, press Esc . In command mode you can use the arrow keys to move around in the le. (If you have only one line of text, trying to use the up- or down-arrow keys will probably cause vi to beep at you.) There are several ways to insert text other than the i command. The a command inserts text beginning after the current cursor position, instead of at the current cursor position. For example, use the left arrow key to move the cursor between the words good and men.
175
TOC
Now is the time for all good men to come to the aid of the party.
Press a to start insert mode, type wo, and then press Esc to return to command mode.
Now is the time for all good women to come to the aid of the party.
To begin inserting text at the next line, use the o command. Press o and enter another line or two:
Now is the time for all good humans to come to the aid of the party. Afterwards, well go out for pizza and beer.
176
Linux Tutorial
TOC
Now press a and insert some text, followed by esc :
Now is the time for all good humans to come to the aid of the party. Afterwards, well go out for pizza and Diet Coke.
You can delete entire lines using the command dd (that is, press d twice in a row). If the cursor is on the second line and you type dd, youll see:
Now is the time for all good humans to come to the aid of the party.
To delete the word that the cursor is on, use the dw command. Place the cursor on the word good, and type dw.
Now is the time for all humans to come to the aid of the party.
177
TOC
Now is the time for all humans to come to the aid of the hungry.
Using R to edit text is like the i and a commands, but R overwrites, rather than inserts, text. The r command replaces the single character under the cursor. For example, move the cursor to the beginning of the word Now, and press r followed by C, youll see:
Cow is the time for all humans to come to the aid of the hungry.
The command changes the case of the letter under the cursor from upper- to lowercase, and back. For example, if you place the cursor on the o in Cow above and repeatedly press , youll end up with:
COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY.
178
Linux Tutorial
TOC
The 0 command (thats the zero key) moves the cursor to the beginning of the current line, and the $ command moves it to the end of the line. When editing large les, youll want to move forwards or backwards through the le a screenful at a time. Pressing Ctrl-F moves the cursor one screenful forward, and Ctrl-B moves it a screenful back. To move the cursor to the end of the le, press G. You can also move to an arbitrary line; for example, typing the command 10G would move the cursor to line 10 in the le. To move to the beginning of the le, use 1G. You can couple moving commands with other commands, such as those for deleting text. For example, the d$ command deletes everything from the cursor to the end of the line; dG deletes everything from the cursor to the end of the le, and so on.
In last line mode, certain extended commands are available. One of them is q!, which quits vi without saving. The command :wq saves the le and then exits vi. The command ZZ (from command mode, without the :) is equivalent to :wq. If the le has not been changed since the last save, it merely exits, preserving the modication time of the last change. Remember that you must press Enter after a command entered in last line mode. To save the le without quitting vi, use :w.
179
TOC
COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY. :e foo
If you use :e without saving the le rst, youll get the error message
No write since last change (":edit!" overrides)
which means that vi doesnt want to edit another le until you save the rst one. At this point, you can use :w to save the original le, and then use :e, or you can use the command
COW IS THE TIME FOR ALL WOMEN TO COME TO THE AID OF THE HUNGRY. :e! foo
The ! tells vi that you really mean itedit the new le without saving changes to the rst.
inserts the contents of the le foo.txt in the text at the location of the cursor.
180
Linux Tutorial
TOC
:r! ls -F
You can also shell out of vi, in other words, run a command from within vi, and return to the editor when youre done. For example, if you use the command
:! ls -F
the ls -F command will be executed and the results displayed on the screen, but not inserted into the le youre editing. If you use the command
:shell
vi starts an instance of the shell, letting you temporarily put vi on hold while you execute other commands. Just log out of the shell (using the exit command) to return to vi.
181
TOC
of syntax. In this section, we wont be encountering many differences between the two, but we will assume that shell scripts are executed using the Bourne shell syntax.
concatenates the les chapter1, chapter2, and chapter3 and places the result in the le book. The second command displays a count of the number of lines in book, and the third command lp book prints book. Rather than type all these commands, you can group them into a shell script. The shell script used to run all these commands might look like this:
#!/bin/sh # A shell script to create and print the book cat chapter1 chapter2 chapter3 > book wc -l book lp book
Shell scripts are just plain text les; you can create them with an editor such as emacs or vi, which is described starting on page 172. Lets look at this shell script. The rst line, #!/bin/sh, identies the le as a shell script and tells the shell how to execute the script. It instructs the shell to pass the script to /bin/sh for execution, where /bin/sh is the shell program itself. Why is this important? On most Linux systems, /bin/sh is a Bourne-type shell, like bash. By forcing the shell script to run using /bin/sh, you ensure that the script will run under a Bourne-syntax shell (rather than a C shell). This will cause your script to run using the Bourne syntax even if you use tcsh (or another C shell) as your login shell. The second line is a comment. Comments begin with the character # and continue to the end of the line. Comments are ignored by the shellthey are commonly used to identify the shell script to the programmer and make the script easier to understand. The rest of the lines in the script are just commands, as you would type them to the shell directly. In effect, the shell reads each line of the script and runs that line as if you had typed it at the shell prompt.
182
Linux Tutorial
TOC
Permissions are important for shell scripts. If you create a shell script, make sure that you have execute permission on the script in order to run it. When you create text les, the default permissions usually dont include execute permission, and you must set them explicitly. See the discussion of le permissions on page 161 for details. Briey, if this script were saved in the le called makebook, you could use the command
/home/larry# chmod u+x makebook
to give yourself execute permission for the shell script makebook. You can use the command
/home/larry# makebook
A shell lets you dene variables, as do most programming languages. A variable is just a piece of data that is given a name. tcsh, as well as other C-type shells, use a different mechanism for setting variables than is described here. This discussion assumes the use of a Bourne shell like bash. See the tcsh manual page for details. When you assign a value to a variable (using the = operator), you can access the variable by prepending a $ to the variable name, as demonstrated below.
/home/larry# foo=hello there
The variable foo is given the value hello there. You can then refer to this value by the variable name prexed with a $ character. For example, the command
/home/larry# echo $foo hello there /home/larry#
These variables are internal to the shell, which means that only the shell can access them. This can be useful in shell scripts; if you need to keep track of a lename, for
183
TOC
example, you can store it in a variable, as above. Using the set command displays a list of all dened shell variables. However, the shell lets you export variables to the environment. The environment is the set of variables that are accessible by all commands that you execute. Once you dene a variable inside the shell, exporting it makes the variable part of the environment as well. Use the export command to export a variable to the environment. Again, here we differ between bash and tcsh. If you use tcsh, another syntax is used for setting environment variables (the setenv command is used). See the tcsh manual page for more information. The environment is very important to the UNIX system. It lets you congure certain commands just by setting variables which the commands know about. Heres a quick example. The environment variable PAGER is used by the man command and it species the command to use to display manual pages one screenful at a time. If you set PAGER to the name of a command, it uses that command to display the man pages, instead of more (which is the default). Set PAGER to cat. This causes output from man to be displayed to the screen all at once, without pausing between pages.
/home/larry# PAGER=cat
Try the command man ls. The man page should y past your screen without pausing for you. Now, if we set PAGER to more, the more command is used to display the man page.
/home/larry# PAGER=more
Note that we dont have to use the export command after we change the value of PAGER. We only need to export a variable once; any changes made to it thereafter will automatically be propagated to the environment. It is often necessary to quote strings in order to prevent the shell from treating various characters as special. For example, you need to quote a string in order to prevent the shell from interpreting the special meaning of characters such as *, ? or a space. There are many other characters that may need to be protected from interpretation. A detailed explanation and desription of quoting is described in SSCs Bourne Shell Tutorial. The manual pages for a particular command tell you if the command uses any environment variables. For example, the man man page explains that PAGER is used to specify the
184
Linux Tutorial
TOC
pager command. Some commands share environment variables. For example, many commands use the EDITOR environment variable to specify the default editor to use when one is needed. The environment is also used to keep track of important information about your login session. An example is the HOME environment variable, which contains the name of your home directory.
/home/larry/papers# echo $HOME /home/larry
Another interesting environment variable is PS1, which denes the main shell prompt. For example,
/home/larry# PS1=Your command, please: Your command, please:
To set the prompt back (which contains the current working directory followed by a # symbol),
Your command, please: /home/larry# PS1=\w#
The bash manual page describes the syntax used for setting the prompt. The PATH environment variable. When you use the ls command, how does the shell nd the ls executable itself? In fact, ls is in /bin on most systems. The shell uses the environment variable PATH to locate executable les for commands you type. For example, your PATH variable may be set to
/bin:/usr/bin:/usr/local/bin:.
This is a list of directories for the shell to search, each directory separated by a :. When you use the command ls, the shell rst looks for /bin/ls, then /usr/bin/ls, and so on. Note that the PATH has nothing to do with nding regular les. For example, if you use the command
/home/larry# cp foo bar
the shell does not use PATH to locate the les foo and barthose lenames are assumed to be complete. The shell only uses PATH to locate the cp executable.
185
TOC
This saves you time, and means that you dont have to remember where all the command executables are stored. On many systems, executables are scattered about in many places, such as /usr/bin, /bin, or /usr/local/bin. Rather than give the commands full pathname (such as /usr/bin/cp), you can set PATH to the list of directories that you want the shell to automatically search. Notice that PATH contains ., which is the current working directory. This lets you create a shell script or program and run it as a command from your current directory without having to specify it directly (as in ./makebook). If a directory isnt in your PATH, then the shell will not search it for commands to run; this also includes the current directory.
186
Linux Tutorial
TOC
TOC
Chapter 4
System Administration
This chapter covers the most important things that you need to know about system administration under Linux in sufcient detail to start using the system comfortably. In order to keep the chapter manageable, it covers just the basics and omits many important details. The Linux System Administrators Guide, by Lars Wirzenius (see Appendix A) provides considerably more detail on system administration topics. It will help you understand better how things work and hang together. At least, skim through the SAG so that you know what it contains and what kind of help you can expect from it.
187
188
System Administration
TOC
cares for the system logs in as root to perform tasks that cannot be executed as a normal user. Because root can do anything, it is easy to make mistakes that have catastrophic consequences. If a normal user tries inadvertently to delete all of the les in /etc, the system will not permit him or her to do so. However, if root tries to do the same thing, the system doesnt complain at all. It is very easy to trash a Linux system when using root. The best way to prevent accidents is: Sit on your hands before you press Enter for any command that is non-reversible. If youre about to clean out a directory, re-read the entire command to make sure that it is correct. Use a different prompt for the root account. roots .bashrc or .login le should set the shell prompt to something different than the standard user prompt. Many people reserve the character # in prompts for root and use the prompt character $ for everyone else. Log in as root only when absolutely necessary. When you have nished your work as root, log out. The less you use the root account, the less likely you are to damage the system. You are less likely to confuse the privileges of root with those of a normal user. Picture the root account as a special, magic hat that gives you lots of power, with which you can, by waving your hands, destroy entire cities. It is a good idea to be a bit careful about what you do with your hands. Because it is easy to wave your hands in a destructive manner, it is not a good idea to wear the magic hat when it is not needed, despite the wonderful feeling. Well talk in greater detail about the system administrators responsibilities starting on page 201.
189
TOC
Once you know where the kernel is, set the root device of the kernel image to the name of your Linux root partition with the rdev command. The format of the command is
rdev kernel-name root-device
where kernel-name is the name of the kernel image, and root-device is the name of the Linux root partition. For example, to set the root device in the kernel /vmlinuz to /dev/hda2, use the command
# rdev /vmlinuz /dev/hda2
rdev can set other options in the kernel, like the default SVGA mode to use at boot time. The command
# rdev -h
prints a help message on the screen. After setting the root device, simply copy the kernel image to the oppy. Before copying data to any oppy, however, its a good idea to use the MS-DOS FORMAT.COM or the Linux fdformat program to format the diskette. This lays down the sector and track information that is appropriate to the oppys capacity. Floppy diskette formats and their device driver les are discussed further starting on page 211. Device driver les, as mentioned earlier, reside in the /dev directory. To copy the kernel in the le /etc/Image to the oppy in /dev/fd0, use the command
# cp /vmlinuz /dev/fd0
190
System Administration
TOC
The easy way to install LILO is to edit the conguration le, /etc/lilo.conf. The command
# /sbin/lilo
rewrites the modied lilo.conf conguration to the boot sector of the hard disk, and must be run every time you modify lilo.conf. The LILO conguration le contains a stanza for each operating system that you want to boot. The best way to demonstrate this is with an example. The lilo.conf le below is for a system which has a Linux root partition on /dev/hda1 and a MS-DOS partition on /dev/hda2.
# Tell LILO to modify the boot record on /dev/hda (the first # non-SCSI hard drive). If you boot from a drive other than # /dev/hda, change the following line. boot = /dev/hda # Set a sane videomode vga = normal # Set the delay in milli-seconds. This is the time you have to # press the SHIFT key to bring up the LILO: prompt if you # havent specified the prompt directive. delay = 60 # Name of the boot loader. No reason to modify this unless youre # doing some serious hacking on LILO. install = /boot/boot.b # This forces LILO to prompt you for the OS you want to boot. # A TAB key at the LILO: prompt will display a list of the OSs # available to boot according to the names given in the label= # directives below. prompt # Have LILO perform some optimization. compact # Stanza for Linux root partition on /dev/hda1. image = /vmlinuz # Location of kernel
191
TOC
label = linux root = /dev/hda1 read-only # Name of OS (for the LILO boot menu) # Location of root partition # Mount read only
# Stanza for MSDOS partition on /dev/hda2. other = /dev/hda2 # Location of partition table = /dev/hda # Location of partition table for /dev/hda2 label = msdos # Name of OS (for boot menu)
The rst operating system stanza is the default operating system for LILO to boot. Also note that if you use the root = line, above, theres no reason to use rdev to set the root partition in the kernel image. LILO sets it at boot time. The Microsoft Windows 95 installer will overwrite the LILO boot manager. If you are going to install Windows 95 on your system after installing LILO, make sure to create a boot disk rst (see Section 4.2). With the boot disk, you can boot Linux and re-install LILO after the Windows 95 installation is completed. This is done simply by typing, as root, the command /sbin/lilo, as in the step above. Partitions with Windows 95 can be congured to boot with LILO using the same lilo.conf entries that are used to boot the MS-DOS partition. The Linux FAQ (see Appendix A) provides more information on LILO, including how to use LILO to boot with the OS/2 Boot Manager.
The time argument is the time to shut down the system (in the format hh:mm:ss), and
192
System Administration
TOC
warning-message is a message displayed on all users terminals before shutdown. Alternately, you can specify the time as now, to shut down immediately. The -r option may be given to shutdown to reboot the system after shutting down. For example, to shut down and reboot the system at 8:00 pm, use the command
# shutdown -r 20:00
The command halt may be used to force an immediate shutdown without any warning messages or grace period. halt is useful if youre the only one using the system and want to shut down and turn off the machine. Dont turn off the power or reboot the system until you see the message:
The system is halted
It is very important that you shut down the system, cleanly, using the shutdown or halt command. On some systems, pressing Ctrl - Alt - Del will be trapped and cause a shutdown. On other systems, using the Vulcan nerve pinch will reboot the system immediately and cause disaster.
193
TOC
# # Version: @(#)inittab 2.04 17/05/93 MvS # 2.10 02/10/95 # # Author: Miquel van Smoorenburg, <[email protected]> # Modified by: Patrick J. Volkerding, <[email protected]> # Minor modifications by: # Robert Kiesling, <[email protected]> # # Default runlevel. id:3:initdefault: # System initialization (runs when system boots). si:S:sysinit:/etc/rc.d/rc.S # Script to run when going single user (runlevel 1). su:1S:wait:/etc/rc.d/rc.K # Script to run when going multi user. rc:23456:wait:/etc/rc.d/rc.M # What to do at Ctrl-Alt-Del ca::ctrlaltdel:/sbin/shutdown -t5 -rfn now # Runlevel 0 halts the system. l0:0:wait:/etc/rc.d/rc.0 # Runlevel 6 reboots the system. l6:6:wait:/etc/rc.d/rc.6 # What to do when power fails (shutdown to single user). pf::powerfail:/sbin/shutdown -f +5 "THE POWER IS FAILING" # If power is back before shutdown, cancel the running shutdown. pg:0123456:powerokwait:/sbin/shutdown -c "THE POWER IS BACK" # If power comes back in single user mode, return to multi user mode. ps:S:powerokwait:/sbin/init 5
PV
194
System Administration
TOC
# The getties in multi user mode on consoles an serial lines. # # NOTE NOTE NOTE adjust this to your getty or you will not be # able to login !! # # Note: for agetty you use linespeed, line. # for getty_ps you use line, linespeed and also use gettydefs c1:1235:respawn:/sbin/agetty 38400 tty1 linux c2:1235:respawn:/sbin/agetty 38400 tty2 linux c3:1235:respawn:/sbin/agetty 38400 tty3 linux c4:1235:respawn:/sbin/agetty 38400 tty4 linux c5:1235:respawn:/sbin/agetty 38400 tty5 linux c6:12345:respawn:/sbin/agetty 38400 tty6 linux # Serial lines # s1:12345:respawn:/sbin/agetty -L 9600 ttyS0 vt100 s2:12345:respawn:/sbin/agetty -L 9600 ttyS1 vt100 # Dialup lines d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100 #d2:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS1 vt100 # Runlevel 4 used to be for an X-window only system, until we discovered # that it throws init into a loop that keeps your load avg at least 1 all # the time. Thus, there is now one getty opened on tty6. Hopefully no one # will notice. ;) # It might not be bad to have one text console anyway, in case something # happens to X. x1:4:wait:/etc/rc.d/rc.4 # End of /etc/inittab
At startup, this /etc/inittab starts six virtual consoles, a login: prompt on the modem attached to /dev/ttyS0, and a login: prompt on a character terminal connected via a RS-232 serial line to /dev/ttyS1. Briey, init steps through a series of run levels, which correspond to various operationing states of the system. Run level 1 is entered immediately after the system boots,
195
TOC
run levels 2 and 3 are the normal, multiuser operation modes of the system, run level 4 starts the X Window System via the X display manager xdm, and run level 6 reboots the system. The run level(s) associated with each command are the second item in each line of the /etc/inittab le. For example, the line
s2:12345:respawn:/sbin/agetty -L 9600 ttyS1 vt100
will maintain a login prompt on a serial terminal for runlevels 15. The s2 before the rst colon is a symbolic identier used internally by init. respawn is an init keyword that is often used in conjunction with serial terminals. If, after a certain period of time, the agetty program, which spawns the terminals login: prompt, does not receive input at the terminal, the program times out and terminates execution. respawn tells init to re-execute agetty, ensuring that there is always a login: prompt at the terminal, regardless of whether someone has logged in. The remaining parameters are passed directly to agetty and instruct it to spawn the login shell, the data rate of the serial line, the serial device, and the terminal type, as dened in /etc/termcap or /etc/terminfo. The /sbin/agetty program handles many details related to terminal I/O on the system. There are several different versions that are commonly in use on Linux systems. They include mgetty, psgetty, or simply, getty. In the case of the /etc/inittab line
d1:12345:respawn:/sbin/agetty -mt60 38400,19200,9600,2400,1200 ttyS0 vt100
which allows users to log in via a modem connected to serial line /dev/ttyS0, the /sbin/agetty parameters -mt60 allow the system to step through all of the modem speeds that a caller dialing into the system might use, and to shut down /sbin/agetty if there is no connection after 60 seconds. This is called negotiating a connection. The supported modem speeds are enumerated on the command line also, as well as the serial line to use, and the terminal type. Of course, both of the modems must support the data rate which is nally negotiated by both machines. Many important details have been glossed over in this section. The tasks that /etc/inittab maintains would comprise a book of their own. For further information, the manual pages of the init and agetty programs, and the Linux Documentation Projects Serial HOWTO, available from the sources listed in Appendix A, are starting points.
196
System Administration
TOC
is executed automatically by the le /etc/rc at boot time, or by the le /etc/rc.d/boot (see page 225) on some Linux systems. The le /etc/fstab provides information on le systems and mount points. An example /etc/fstab le is
# device /dev/hda2 /dev/hda3 /dev/hda4 /proc directory / /usr none /proc type ext2 ext2 swap proc options defaults defaults sw none
The rst eld, device, is the name of the partition to mount. The second eld is the mount point. The third eld is the le system type, like ext2 (for ext2fs) or minix (for Minix le systems). Table 4.1 lists the various le system types that are mountable under Linux.1 Not all of these le system types may be available on your system, because the kernel must have support for them compiled in. See page 216 for information on building the kernel.
1 This table is current as of kernel version 2.0.33.
197
TOC
File system Second Extended File system Extended File system Minix File system Xia File system UMSDOS File system MS-DOS File system /proc File system ISO 9660 File system Xenix File system System V File system Coherent File system HPFS File system Type name ext2 ext minix xia umsdos msdos proc iso9660 xenix sysv coherent hpfs Comment Most common Linux le system. Superseded by ext2. Original Minix le system; rarely used. Like ext2, but rarely used. Used to install Linux on an MS-DOS partition. Used to access MS-DOS les. Provides process information for ps, etc. Format used by most CD-ROMs. Used to access les from Xenix. Used to access les from System V variants for the x86. Used to access les from Coherent. Read-only access for HPFS partitions (DoubleSpace).
The last eld of the fstab le are the mount options. This is normally set to defaults. Swap partitions are included in the /etc/fstab le. They have a mount directory of none, and type swap. The swapon -a command, which is executed from /etc/rc or /etc/init.d/boot, is used to enable swapping on all of the swap devices that are listed in /etc/fstab. The /etc/fstab le contains one special entry for the /proc le system. As described on page 166, the /proc le system is used to store information about system processes, available memory, and so on. If /proc is not mounted, commands like ps will not work. The mount command may be used only by root. This ensures security on the system. You wouldnt want regular users mounting and unmounting le systems on a whim. Several software packages are available which allow non-root users to mount and unmount le systems, especially oppies, without compromising system security. The mount -av command actually mounts all of the le systems other than the root le system (in the table above, /dev/hda2). The root le system is automatically mounted at boot time by the kernel. Instead of using mount -av, you can mount a le system by hand. The command
# mount -t ext2 /dev/hda3 /usr
198
System Administration
TOC
is equivalent to mounting the le system with the entry for /dev/hda3 in the example /etc/fstab le, above.
Table 4.2: IDE device driver names. CD-ROM and tape drives which use the extended IDE/ATAPI drive interface also use these device names. Many machines, however, including high-end personal computer workstations, and machines based on Digital Equipment Corporations Alpha processor, use the Small Computer System Interface (SCSI). The naming conventions for SCSI devices are somewhat different than that given above, due the greater exibility of SCSI addressing. The rst SCSI hard drive on a system is /dev/sda, the second SCSI drive is /dev/sdb, and so on. A list of common SCSI devices is given in Table 4.3. Note that SCSI CD-ROM and tape drives are named differently than SCSI hard drives. Removable SCSI media, like the Iomega Zip drive, follow naming conventions for nonremovable SCSI drives. The use of a Zip drive for making backups is described starting on page 213 Streaming tape drives, like those which read and write QIC-02, QIC-40, and QIC80 format magnetic tapes, have their own set of device names, which are described on
199
TOC
Device driver /dev/sda /dev/sdb /dev/st0 /dev/st1 /dev/scd0 /dev/scd1 Drive First SCSI hard drive. Second SCSI hard drive. First SCSI tape drive. Second SCSI tape drive. First SCSI CD-ROM drive. Second SCSI CD-ROM drive.
page 214. Floppy disk drives use still another naming scheme, which is described on page 211.
checks the ext2fs le system on /dev/hda2 and automatically corrects any errors. It is usually a good idea to unmount a le system before checking it, and necessary, if e2fsck is to perform any repairs on the le system. The command
# umount /dev/hda2
unmounts the le system on /dev/hda2. The one exception is that you cannot unmount the root le system. In order to check the root le system when its unmounted, you should use a maintenance boot/root diskette (see page 227). You also cannot unmount a le system if any of the les which it contains are busythat is, in use by a running process. For example, you cannot unmount a le system if any users current working directory is on that le system. You will instead receive a Device busy error message. Other le system types use different forms of the e2fsck command, like efsck and xfsck. On some systems, you can simply use the command fsck, which automatically determines the le system type and executes the appropriate command.
200
System Administration
TOC
If e2fsck reports that it performed repairs on a mounted le system, you must reboot the system immediately. You should give the command shutdown -r to perform the reboot. This allows the system to re-synchronize the information about the le system after e2fsck modies it. The /proc le system never needs to be checked in this manner. /proc is a memory le system and is managed directly by the kernel.
This command creates the swap le, /swap. The count= parameter is the size of the swap le in blocks.
# mkswap /swap 8208
This command initializes the swap le. Again, replace the name and size of the swaple with the appropriate values.
# sync # swapon /swap
Now the system is swapping on the le /swap. The sync command ensures that the le has been written to disk. One major drawback to using a swap le is that all access to the swap le is done through the le system. This means the blocks which make up the swap le may not be contiguous. Performance may not be as good as a swap partition, where the blocks are always contiguous and I/O requests are made directly to the device. Another drawback of large swap les is the greater chance that the le system will be corrupted if something goes wrong. Keeping the regular le systems and swap partitions separate prevents this from happening. Swap les can be useful if you need to use more swap space temporarily. If youre compiling a large program and would like to speed things up somewhat, you can create a temporary swap le and use it in addition to the regular swap space. To remove a swap le, rst use swapoff, as in
201
TOC
# swapoff /swap
Each swap le or partition may be as large as 16 megabytes, but you may use up to 8 swap les or partitions on your system.
user ID
group ID
password
full name
202
System Administration
TOC
home directory This is the directory the user is initially placed in at login, and where his or her personal les are stored. Every user is given a home directory, which is commonly located under /home. login shell The shell that is started for the user at login. Examples are /bin/bash and /bin/tcsh.
This information is stored in the le /etc/passwd. Each line in the le has the format
user name:encrypted password:UID:GID:full name:home directory:login shell
An example might be
kiwi:Xv8Q981g71oKK:102:100:Laura Poole:/home/kiwi:/bin/bash
In this example, the rst eld, kiwi, is the user name. The next eld, Xv8Q981g71oKK, is the encrypted password. Passwords are not stored on the system in human-readable format. The password is encrypted using itself as the secret key. In other words, one must know the password in order to decrypt it. This form of encryption is reasonably secure. Some systems use shadow passwords, in which password information is stored in the le /etc/shadow. Because /etc/passwd is world-readable, /etc/shadow provides some degree of extra security because its access permissions are much more restricted. Shadow passwords also provide other features, like password expiration. The third eld, 102, is the UID. This must be unique for each user. The fourth eld, 100, is the GID. This user belongs to the group numbered 100. Group information is stored in the le /etc/group. See Section 4.6.5 for more information. The fth eld is the users full name, Laura Poole. The last two elds are the users home directory (/home/kiwi), and login shell (/bin/bash), respectively. It is not required that the users home directory be given the same name as the user name. It simply helps identify the directory.
Managing Users
203
TOC
mation must be specied. The users home directory must be created, and the permissions on the directory set so that the user owns the directory. Shell initialization les must be installed in the home directory, and other les must be congured system-wide (for example, a spool for the users incoming e-mail). It is not difcult to add users by hand, but when you are running a system with many users, it is easy to forget something. The easiest way to add users is to use an interactive program which updates all of the system les automatically. The name of this program is useradd or adduser, depending on what software is installed. The adduser command takes its information from the le /etc/adduser.conf, which denes a standard, default conguration for all new users. A typical /etc/adduser.conf le is shown below.
# /etc/adduser.conf: adduser configuration. # See adduser(8) and adduser.conf(5) for full documentation. # The DSHELL variable specifies the default login shell on your # system. DSHELL=/bin/bash # The DHOME variable specifies the directory containing users home # directories. DHOME=/home # If GROUPHOMES is "yes", then the home directories will be created as # /home/groupname/user. GROUPHOMES=no # If LETTERHOMES is "yes", then the created home directories will have # an extra directory - the first letter of the user name. For example: # /home/u/user. LETTERHOMES=no # The SKEL variable specifies the directory containing "skeletal" user # files; in other words, files such as a sample .profile that will be # copied to the new users home directory when it is created. SKEL=/etc/skel # FIRST_SYSTEM_UID to LAST_SYSTEM_UID inclusive is the range for UIDs # for dynamically allocated administrative and system accounts.
204
System Administration
TOC
FIRST_SYSTEM_UID=100 LAST_SYSTEM_UID=999 # FIRST_UID to LAST_UID inclusive is the range of UIDs of dynamically # allocated user accounts. FIRST_UID=1000 LAST_UID=29999 # The USERGROUPS variable can be either "yes" or "no". If "yes" each # created user will be given their own group to use as a default, and # their home directories will be g+s. If "no", each created user will # be placed in the group whose gid is USERS_GID (see below). USERGROUPS=yes # If USERGROUPS is "no", then USERS_GID should be the GID of the group # users (or the equivalent group) on your system. USERS_GID=100 # If QUOTAUSER is set, a default quota will be set from that user with # edquota -p QUOTAUSER newuser QUOTAUSER=""
In addition to dening preset variables that the adduser command uses, /etc/adduser.conf also species where default system conguration les for each user are located. In this example, they are located in the directory /etc/skel, as dened by the SKEL= line, above. Files which are placed in this directory, like a system-wide, default .profile, .tcshrc, or .bashrc le, will be automatically installed in a new users home directory by the adduser command.
Managing Users
205
TOC
prevents kiwi from logging in.
will change larrys password. Only root may change other users passwords in this manner. Users can change their own passwords, however. On some systems, the commands chfn and chsh allow users to set their own full name and login shell attributes. If not, the system administrator must change these attributes for them.
4.6.5 Groups.
As mentioned above, each user belongs to one or more groups. The only real importance of group relationships pertains to le permissions. As youll recall from Section 3.10, each le has a group ownership and a set of group permissions which denes how users in that group may access the le. There are several system-dened groups, like bin, mail, and sys. Users should not belong to any of these groups; they are used for system le permissions. Instead, users should belong to an individual group like users. You can also maintain several groups for users, like student, staff, and faculty. The le /etc/group contains information about groups. The format of each line is
group name:password:GID:other members
The rst group, root, is a special system group reserved for the root account. The next group, users, is for regular users. It has a GID of 100. The users mdw and larry are given access to this group. Remember that in /etc/passwd each user was given
206
System Administration
TOC
a default GID. However, users may belong to more than one group, by adding their user names to other group lines in /etc/group. The groups command lists what groups you are given access to. The third group, guest, is for guest users, and other is for other users. The user kiwi is given access to this group as well. The password eld of /etc/group is sometimes used to set a password on group access. This is seldom necessary. To protect users from changing into privileged groups (with the newgroup command), set the password eld to *. The commands addgroup or groupadd may be used to add groups to your system. Usually, its easier just to add entries in /etc/group yourself, as no other conguration needs to be done to add a group. To delete a group, simply delete its entry in /etc/group.
Managing Users
207
TOC
causing trouble on the system (for instance, by lling up the user partition with large les, or running multiple instances of a large program), the user is simply unaware that he or she is creation a problem. I have come down on users who were causing a great deal of trouble, but they were simply acting out of ignorancenot malice. When you deal with users who cause potential trouble, dont be accusatory. The burden of proof is on you; that is, the rule of innocent until proven guilty still holds. It is best to simply talk to the user and question him or her about the trouble instead of being confrontational. The last thing you want is to be on the users bad side. This will raise a lot of suspicion about youthe system administratorrunning the system correctly. If a user believes that you distrust or dislike them, they might accuse you of deleting les or breaching privacy on the system. This is certainly not the kind of position you want to be in. If you nd that a user is attempting to crack, or otherwise intentionally do harm to the system, dont return the malicious behavior with malice of your own. Instead, provide a warning, but be exible. In many cases, you may catch a user in the act of doing harm to the system. Give them a warning. Tell them not to let it happen again. However, if you do catch them causing harm again, be absolutely sure that it is intentional. I cant even begin to describe the number of cases where it appeared as though a user was causing trouble, when in fact it was either an accident or a fault of my own.
208
System Administration
TOC
only a few users, or if youre the only user on the system. However, its always a good ideain any situationto understand what being the system administrator really means. Being the system administrator doesnt make a Linux wizard. There are many administrators who know very little about Linux. Likewise, many normal users know more about Linux than any system administrator. Also, being the system administrator does not allow one to use malice against users. Just because the system gives administrators the ability to mess with user les does not mean that he or she has a right to do so. Being the system administrator is not a big deal. It doesnt matter if your system is a tiny 386 or a Cray supercomputer. Running the system is the same, regardless. Knowing the root password isnt going to earn you money or fame. It will allow you to maintain the system and keep it running. Thats it.
where options is the list of commands and options for tar, and les is the list of les to add or extract from the archive. For example, the command
# tar cvf backup.tar /etc
packs all of the les in /etc into the tar archive backup.tar. The rst argument to tar, cvf, is the tar command. c tells tar to create a new archive le. v forces tar to use verbose mode, printing each le name as it is archived. The f option tells tar that the next argument, backup.tar, is the name of the archive to create. The rest of the arguments to tar are the le and directory names to add to the archive. The command
# tar xvf backup.tar
209
TOC
will extract the tar le backup.tar in the current directory. Old les with the same name are overwritten when extracting les into an existing directory. Before extracting tar les it is important to know where the les should be unpacked. Lets say that you archive the following les: /etc/hosts, /etc/group, and /etc/passwd. If you use the command
# tar cvf backup.tar /etc/hosts /etc/group /etc/passwd
the directory name /etc/ is added to the beginning of each le name. In order to extract the les to the correct location, use
# cd / # tar xvf backup.tar
because les are extracted with the path name saved in the archive le. However, if you archive the les with the command
# cd /etc # tar cvf hosts group passwd
the directory name is not saved in the archive le. Therefore, you need to cd /etc before extracting the les. As you can see, how the tar le is created makes a large difference in where you extract it. The command
# tar tvf backup.tar
can be used to display a listing of the archives les without extracting them. You can see what directory the les in the archive are stored relative to, and extract the archive in the correct location.
compresses backup.tar and leaves you with backup.tar.gz, a compressed version of the le. The -9 switch tells gzip to use the highest compression factor.
210
System Administration
TOC
The gunzip command may be used to uncompress a gzipped le. Equivalently, you may use gzip -d. gzip is a relatively new tool in the UNIX community. For many years, the compress command was used instead. However, because of several factors, including a software patent dispute against the compress data compression algorithm, and the fact that gzip is much more efcient, compress is being phased out. Files that are output by compress end in .Z. backup.tar.Z is the compressed version of backup.tar, while backup.tar.gz is the gzipped version2 . The uncompress command is used to expand a compressed le. It is equivalent to compress -d. gunzip knows how to handle compressed les as well.
The result is backup.tar.gz. To unpack this le, use the reverse commands:
# gunzip backup.tar.gz # tar xvf backup.tar
Always make sure that you are in the correct directory before unpacking a tar le. You can use some Linux cleverness to do this on one command line.
# tar cvf - /etc j gzip -9c backup.tar.gz
Here, we send the tar le to -, which stands for tars standard output. This is piped to gzip, which compresses the incoming tar le. The result is saved in backup.tar.gz. The -c option tells gzip to send its output to standard output, which is redirected to backup.tar.gz. A single command to unpack this archive would be:
# gunzip -c backup.tar.gz j tar xvf -
Again, gunzip uncompresses the contents of backup.tar.gz and sends the resulting tar le to standard output. This is piped to tar, which reads -, this time referring to tars standard input.
2 For some time, the extension .z (lowercase z) was used for gzipped les. The conventional gzip extension is now .gz.
211
TOC
Happily, the tar command also includes the z option to automatically compress/uncompress les on the y, using the gzip compression algorithm. The command
# tar cvfz backup.tar.gz /etc
is equivalent to
# tar cvf backup.tar /etc # gzip backup.tar
Refer to the tar and gzip manual pages for more information.
212
System Administration
TOC
Floppy device driver /dev/fd0d360 /dev/fd0h1200 /dev/fd0h1440 Format Double density, 360 Kb, 5.25 inch. High density, 1.2 MB, 5.25 inch. High density, 1.44 MB, 3.5 inch.
You can also use oppies to hold individual le systems and mount the oppy to access the data on it. See section 4.8.4.
will make a complete backup of your system using the oppy drive /dev/fd0. The M option to tar allows the backup to span multiple volumes; that is, when one oppy is full, tar will prompt for the next. The command
# tar xvfzM /dev/fd0
restores the complete backup. This method can also be used with a tape drive connected to your system. See section 4.8.3. Several other programs exist for making multiple-volume backups; the backflops program found on tsx-11.mit.edu may come in handy. Making a complete backup of the system with oppies can be time- and resourceconsuming. Many system administrators use an incremental backup policy. Every month, a complete backup is made, and every week only those les which have been modied in the last week are backed up. In this case, if you trash your system in the middle of the month, you can simply restore the last full monthly backup, and then restore the last weekly backups as needed. The find command is useful for locating les which were modied after a certain date. Several scripts for managing incremental backups can be found on sunsite.unc.edu.
213
It is often convenient to provide a separate mount point for Zip le systems; for example, /zip. The following steps, which must be executed as root, would create the mount point:
# mkdir /zip # chmod 0755 /zip
Then you can use /zip for mounting the Zip le system. Writing archives to Zip disks is similar to archiving to oppies. To archive and compress the /etc directory to a mounted Zip drive, the command used would be
# tar zcvf /zip/etc.tgz /etc
This command could be executed from any directory because it species absolute path names. The archive name etc.tgz is necessary if the Zip drive contains a MS-DOS le system, because any les written to the disk must have names which conform to MS-DOSs 8+3 naming conventions; otherwise, the le names will be truncated. Similarly, extracting this archive requires the commands
# cd / # tar zxvf /zip/etc.tgz
To create, for example, an ext2 le system on a Zip drive, you would give the command (for an unmounted Zip disk)
214
System Administration
TOC
# mke2fs /dev/sda4
With a Zip drive mounted in this manner, with an ext2 le system, it is possible to back up entire le systems with a single command.
# tar zcvf /zip/local.tar.gz /usr/local
Note that backing up with tar is still preferable in many cases to simply making an archival copy with the cp -a command, because tar preserves the original les modication times.
Floppy tape drives use the oppy drive controller interface and are controlled by the ftape device driver, which is covered below. Installation of the ftape device driver module is described on page 221. SCSI tape devices are listed in Table 4.3. To archive the /etc directory a tape device with tar, use the command
# tar cvf /dev/qft0 /etc
Similarly, to extract the les from the tape, use the commands
# cd / # tar xvf /dev/qft0
215
TOC
These tapes, like diskettes, must be formatted before they can be used. The ftape driver can format tapes under Linux. To format a QIC-40 format tape, use the command
# ftformat --format-parameter qic40-205ft --mode-auto --omit-erase --discard-header
Other tape drives have their own formatting software. Check the hardware documentation for the tape drive or the documentation of the Linux device driver associated with it. Before tapes can be removed from the drive, they must be rewound and the I/O buffers written to the tape. This is analogous to unmounting a oppy before ejecting it, because the tape driver also caches data in memory. The standard UNIX command to control tape drive operations is mt. Your system may not provide this command, depending on whether it has tape drive facilities. The ftape driver has a similar command, ftmt, which is used to control tape operations. To rewind a tape before removing it, use the command
# ftmt -f /dev/qft0 rewoffl
Of course, substitute the correct tape device driver for your system. It is also a good idea to retension a tape after writing to it, because magnetic tapes are susceptible to stretch. The command
# ftmt -f /dev/qft0 retension
To obtain the status of the tape device, with a formatted tape in the drive, give the command
# ftmt -f /dev/qft0 status
creates a le system on the oppy in /dev/fd0. The size of the le system must correspond to the size of the oppy. High-density 3.5 disks are 1.44 megabytes, or 1440 blocks, in size. High-density 5.25 disks are 1200 blocks. It is necessary to specify the size of the le system in blocks if the system cannot automatically detect the oppys capacity. In order to access the oppy, you must mount the le system contained on it. The command
216
System Administration
TOC
# mount /dev/fd0 /mnt
will mount the oppy in /dev/fd0 on the directory /mnt. Now, all of the les on the oppy will appear under /mnt on your drive. The mount point, the directory where youre mounting the le system, must exist when you use the mount command. If it doesnt exist, create it with mkdir as described on page 213. See page 196 for more information on le systems, mounting, and mount points. Note that any I/O to the oppy is buffered the same as hard disk I/O is. If you change data on the oppy, you may not see the drive light come on until the kernel ushes its I/O buffers. Its important that you not remove a oppy before you unmount it with the command
# umount /dev/fd0
Do not simply switch oppies as you would on a MS-DOS system. Whenever you change oppies, umount the rst oppy and mount the next.
217
TOC
newest version of all of the software. If you nd that you would like or need features that a new version offers, then upgrade. If not, dont upgrade. In other words, upgrade only what you must, when you must. Dont upgrade for the sake of upgrading. This wastes a lot of time and effort.
When upgrading to a newer patchlevel of the same kernel version, kernel patch les can save le transfer time because the kernel source is around 7MB after being compressed by gzip. To upgrade from kernel 2.0.31 to kernel 2.0.33, you would download the patch les patch-2.0.32.gz and patch-2.0.33.gz, which can be found at the same FTP site as the kernel sources. After you have placed the patches in the /usr/src directory,
218
System Administration
TOC
apply the patches to the kernel in sequence to update the source. One way to do this would be
# cd /usr/src # gzip -cd patch-2.0.32.gz j patch -p0 # gzip -cd patch-2.0.33.gz j patch -p0
After the sources are unpacked and any patches have been applied, you need to make sure that three symbolic links in /usr/include are correct for your kernel distribution. To create these links use the commands
# cd /usr/include # rm -rf asm linux scsi # ln -s /usr/src/linux/include/asm-i386 asm # ln -s /usr/src/linux/include/linux linux # ln -s /usr/src/linux/include/scsi scsi
After you create the links, there is no reason to create them again when you install the next kernel patch or a newer kernel version. (See Section 3.11 for more about symbolic links.) In order to compile the kernel, you must have the gcc C compiler installed on your system. gcc version 2.6.3 or a more recent version is required to compile the 2.0 kernel. First cd to /usr/src/linux. The command make config prompts you for a number of conguration options. This is the step where you select the hardware that your kernel will support. The biggest mistake to avoid is not including support for your hard disk controller. Without the correct hard disk support in the kernel, the system wont even boot. If you are unsure about what a kernel option means, a short description is available by pressing ? and Enter . Next, run the command make dep to update all of the source dependencies. This is an important step. make clean removes old binary les from the kernel source tree. The command make zImage compiles the kernel and writes it to /usr/src/linux/arch/i386/boot/zImage. Linux kernels on Intel systems are always compressed. Sometimes the kernel you want to compile is too large to be compressed with the compression system that make zImage uses. A kernel which is too large will exit the kernel compile with the error message: Kernel Image Too Large. If this happens, try the command make bzImage, which uses a compression system that supports larger kernels. The kernel is written to /usr/src/linux/arch/i386/boot/bzImage. Once you have the kernel compiled, you need to either copy it to a boot oppy (with a
219
TOC
command like cp zImage /dev/fd0) or install the image so LILO will boot from your hard drive. See page 189 for more information.
After you have sucessfully run make config with all of the support options you want included in the kernel, then run make dep, make clean, and make zImage to build the kernel, you must tell the kernel how to install the driver. This is done via a command line to the LILO boot loader. As described in section 4.2.1, the LILO conguration le, /etc/lilo.conf has stanzas for each operating system that it knows about, and also directives for presenting these options to the user at boot time. Another directive that LILO recognizes is append=, which allows you to add boottime information required by various device drivers to the command line. In this case, the Iomega Zip ppa driver requires an unused interrupt and I/O port address. This is exactly analogous to specifying separate printer devices like LPT1: and LPT2: under MS-DOS. For example, if your printer uses the hexadecimal (base 16) port address 0x378 (see the installation manual for your parallel port card if you dont know what the address is) and is polled (that is, it doesnt require an IRQ line, a common Linux conguration), you would place the following line in your systems /etc/lilo.conf le:
append="lp=0x378,0"
220
System Administration
TOC
It is worth noting that Linux automatically recognizes one /dev/lp port at boot time, but when specifying a custom port congurations, the boot-time instructions are needed. The 0 after the port address tells the kernel not to use a IRQ (interrupt request) line for the printer. This is generally acceptable because printers are much slower than CPUs, so a slower method of accessing I/O devices, known as polling, where the kernel periodically checks the printer status on its own, still allows the computer to keep up with the printer. However, devices that operate at higher speeds, like serial lines and disks, each require an IRQ, or interrupt request, line. This is a hardware signal sent by the device to the processor whenever the device requires the processors attention; for example, if the device has data waiting to be input to the processor. The processor stops whatever it is doing and handles the interrupt request of the device. The Zip drive ppa device requires a free interrupt, which must correspond to the interrupt that is set on the printer card that you connect the Zip drive to. At the time of this writing, the Linux ppa device driver does not support chaining of parallel port devices, and separate parallel ports must be used for the Zip ppa device and each printer. To determine which interrupts are already in use on your system, the command
# cat /proc/interrupt
displays a list of devices and the IRQ lines they use. However, you also need to be careful not to use any automatically congured serial port interrupts as well, which may not be listed in the /proc/interrupt le. The Linux Documentation Projects Serial HOWTO, available from the sources listed in Appendix A, describes in detail the conguration of serial ports. You should also check the hardware settings of various interface cards on your machine by opening the machines case and visually checking the jumper settings if necessary, to ensure that you are not co-opting an IRQ line that is already in use by another device. Multiple devices ghting for an interrupt line is perhaps the single most common cause of non-functioning Linux systems. A typical /proc/interrupt le looks like
0: 1: 2: 4: 13: 14: 6091646 timer 40691 keyboard 0 cascade 284686 + serial 1 math error 192560 + ide0
221
TOC
The rst column is of interest here. These are the numbers of the IRQ lines that are in use on the system. For the ppa driver, we want to choose a line which is not listed. IRQ 7 is often a good choice, becuase it is seldom used in default system congurations. We also need to specify the port address which the ppa device will use. This address needs to be physically congured on the interface card. Parallel I/O ports are assigned specic addresses, so you will need to read the documentation for your parallel port card. In this example, we will use the I/O port address 0x278, which corresponds to the LPT2: printer port under MS-DOS. Adding both the IRQ line and port address to our boot-time command line, above, yields the following statement as it would appear in the appropriate stanza of the /etc/lilo.conf le:
append="lp=0x378,0 ppa=0x278,7"
These statements are appended to the kernels start-up parameters at boot time. They ensure that any printer attached to the system does not interfere with the Zip drives operation. Of course, if your system does not have a printer installed, the lp= directive can, and should, be omitted. After you have installed the custom kernel itself, as described in section 4.2.1, and before you reboot the system, be sure to run the command
# /sbin/lilo
to install the new LILO conguration on the hard drives boot sector.
222
System Administration
TOC
make clean and make install will ensure that the modules are compiled on your system. To use this version of the ftape driver, you must have module support compiled into the kernel, as well as support for the kerneld kernel daemon. However, you must not include the kernels built-in ftape code as a kernel option, as the more recent ftape module completely replaces this code. make install also installs the device driver modules in the correct directories. On standard Linux systems, modules are located in the directory
/lib/modules/kernel-version
If your kernel version is 2.0.30, the modules on your system are located in /lib/modules/2.0.30. The make install step also insures that these modules are locatable by adding the appropriate statements to the modules.dep le, located in the top-level directory of the module les, in this case /lib/modules/2.0.30. The ftape installation adds the following modules to your system (using kernel version 2.0.30 in this example):
/lib/modules/2.0.30/misc/ftape.o /lib/modules/2.0.30/misc/zft-compressor.o /lib/modules/2.0.30/misc/zftape.o
The instructions to load the modules also need to be added to the system-wide module conguration le. This is the le /etc/conf.modules on many systems. To automatically load the ftape modules on demand, add the following lines to the /etc/conf.modules le:
alias char-major-27 zftape pre-install ftape /sbin/swapout 5
The rst statement loads all of the ftape related modules if necessary when a device with the major number 27 (the ftape device) is accessed by the kernel. Because support for the zftape module (which provides automatic data compression for tape devices) requires the support of the other ftape modules, all of them are loaded on demand by the kernel. The second line species load-time parameters for the modules. In this case, the utility /sbin/swapout, which is provided with the ftape package, ensures that sufcient DMA memory is available for the ftape driver to function. To access the ftape device, you must rst place a formatted tape in the drive. Instructions for formatting tapes and operation of the tape drive are given in section 4.8.3.
223
when attempting to run a program, then you need to upgrade to the version of the libraries which the program requires. Libraries are backwardly compatible. A program compiled to use an older version of the libraries should work with the new version of the libraries installed. However, the reverse is not true. The newest version of the libraries can be found on Linux FTP sites. On sunsite.unc.edu, they are located in /pub/Linux/GCC. The release les there should explain what les you need to download and how to install them. Briey, you should get the les image-version.tar.gz and inc-version.tar.gz where version is the version of the libraries to install, such as 4.4.1. These are tar les compressed with gzip. The image le contains the library images to install in /lib and /usr/lib. The inc le contains include les to install in /usr/include The release-version.tar.gz should explain the installation procedure in detail (the exact instructions vary with each release). In general, you need to install the librarys .a and .sa les in /usr/lib. These are the libraries used at compilation time. In addition, the shared library image les, libc.so.version are installed in /lib. These are the shared library images loaded at run time by programs using the libraries. Each library has a symbolic link using the major version number of the library in /lib. The libc library version 4.4.1 has a major version number of 4. The le containing the library is libc.so.4.4.1. A symbolic link of the name libc.so.4 is also placed in /lib pointing to the library. You must change this symbolic link when upgrading the libraries. For example, when upgrading from libc.so.4.4 to libc.so.4.4.1, you need to change the symbolic link to point to the new version. You must change the symbolic link in one step, as described below. If you delete the symbolic link libc.so.4, then programs which depend on the link (including basic utilities like ls and cat) will stop working. Use the following command to update the symbolic link libc.so.4 to point to the le libc.so.4.4.1:
# ln -sf /lib/libc.so.4.4.1 /lib/libc.so.4
You also need to change the symbolic link libm.so.version in the same manner. If you are upgrading to a different version of the libraries, substitute the appropriate le names,
224
System Administration
TOC
above. The library release notes should explain the details. (See page 164 for more information about symbolic links.)
Miscellaneous Tasks
225
226
System Administration
TOC
This assigns your host name, floof.org, to the loopback address 127.0.0.1. The loopback interface is present whether the machine is connected to a network or not. The localhost alias is always assigned to this address. If you are on a TCP/IP network, your actual IP address and host name should appear in /etc/hosts. For example, if your host name is goober.norelco.com, and your IP address is 128.253.154.32, add the following line to /etc/hosts:
128.253.154.32 goober.norelco.com
To set your host name, simply use the hostname command. For example, the command
# hostname -S goober.norelco.com
sets the host name to goober.norelco.com. In most cases, the hostname command is executed from one of the system startup les, like /etc/rc or /etc/rc.local. Edit these two les and change the hostname command found there to set your own host name. Upon rebooting, the system will use the new name.
What To Do in an Emergency
227
will mount an ext2fs le system on /dev/hda2 under /mnt. Remember that / is now on the boot/root disk itself; you need to mount your hard drive le systems under some directory in order to access the les. Therefore, /etc/passwd on your hard drive is now /mnt/etc/passwd if you mount your root le system on /mnt.
Now root has no password. When you reboot from the hard drive you should be able to login as root and reset the password using passwd. Arent you glad that you learned how to use vi? On your boot/root disk, editors like Emacs probably arent available, but vi should be.
228
System Administration
where partition is the partition on which the le system resides. The -b 8193 option tells e2fsck to use the copy of the superblock stored at block 8193 in the le system.
The -a option tells cp to preserve the permissions on the le(s) being copied. Of course, if the les you deleted arent essential system les that have counterparts on the boot/root oppy, youre out of luck. If you make backups however, you can always restore them.
TOC
Chapter 5
229
230
Advanced Features
TOC
under Linux. You still need to ll in some of the details by reading the XFree86 documentation, which is discussed below. The Linux XFree86 HOW TO is another good information source.
231
TOC
before you take the plunge and purchase expensive hardware. Benchmark comparisons of video cards under XFree86 are posted routinely to the Usenet news groups comp.windows.x.i386unix and comp.os.linux.misc. It is important to note that the average accelerated video card is signicantly faster than the standard graphics card of most workstations. An 80486DX2, 66-MHz Linux System with 20 megabytes of RAM, equipped with a VESA Local Bus (VLB) S3-864 chip set card with 2 megabytes of DRAM, will consistently be about 7 times as fast a Sun Sparc IPX workstation on X benchmarks with the XFree86 server version 3.1. Version 3.3 is even faster. In general, a Linux system with an accelerated SVGA card will give you much greater performance than commercial UNIX workstations, which usually employ simple frame buffers for graphics.
232
Advanced Features
TOC
File X338514.tgz X33AGX.tgz X33I128.tgz X33Ma64.tgz X33Ma32.tgz X33Ma8.tgz X33Mono.tgz X33P9K.tgz X33S3.tgz X33S3V.tgz X33SVGA.tgz X33VGA16.tgz X33W32.tgz Description Server for 8514-based boards. Server for AGX-based boards. Server for the Imagine I128 boards. Server for Mach64-based boards. Server for Mach32-based boards. Server for Mach8-based boards. Server for monochrome video modes. Server for P9000-based boards. Server for S3-based boards. Server for S3/Virge-based boards. Server for Super VGA-based boards. Server for VGA/EGA-based boards. Server for ET4000/W32-based boards.
The following is required for new installations, and optional for existing installations:
File X33cfg.tgz Description sample cong les for xinit, xdm
3 3
Do not install X33cfg.tgz over an existing XFree86 installation without rst backing up the conguration les. Unpacking X33cfg.tgz overwrites these and other les. If you do have customized conguration les, there is no need to install this package anyway. The bit mapped fonts distributed with release 3.3.1 are compressed with the gzip program rather than compress. You will probably want to remove the old fonts after you back them up. The X servers and font servers in previous releases cannot read fonts compressed by gzip, so keep a copy of the old fonts if you want to use older servers. The following les are optional:
233
TOC
File X33f100.tgz X33fcyr.tgz X33fnon.tgz X33fscl.tgz X33fsrv.tgz X33prog.tgz X33nest.tgz X33vfb.tgz X33prt.tgz X33ps.tgz X33html.tgz X33jdoc.tgz X33jhtm.tgz X33lkit.tgz Description 100dpi fonts Cyrillic fonts Other fonts (Chinese, Japanese, Korean, Hebrew) Scalable fonts (Speedo and Type1) Font server and cong les X header les, cong les and compile-time libs Nested X server Virtual framebuffer X server X Print server PostScript version of the documentation HTML version of the documentation Documentation in Japanese (for version 3.2) HTML version of the documentation in Japanese (3.2) X server LinkKit
The XFree86 directory should contain README les and installation notes for the current version. Next, as root, create the directory /usr/X11R6 if it doesnt already exist. Then run the pre-installation script, preinst.sh. You should copy the script, and all of the archive les for your system to the /var/tmp directory before you run preinst.sh. /usr/X11R6 must be your current directory when you run the pre-installation script and unpack the archives.
# cd /usr/X11R6 # sh /var/tmp/preinst.sh
You should then unpack the les from /var/tmp to /usr/X11R6 with a command like:
# gzip -d < /var/tmp/X33prog.tgz j tar vxf -
These tar les are packed relative to /usr/X11R6. You must unpack the les there. On some Linux distributions, the parent directory is /var/X11R6 instead. After you have upacked the required les and any optional les you selected, run the post-installation script postinst.sh.
# cd /usr/X11R6 # sh /var/tmp/postinst.sh
234
Advanced Features
TOC
Now link the le /usr/X11R6/bin/X to the server that supports your video card. For example, the SVGA color server, /usr/bin/X11/X should be linked to /usr/X11R6/bin/XF86 SVGA. To use the monochrome server instead, relink X to XF86 MONO with the command
# ln --sf /usr/X11R6/bin/XF86 MONO /usr/X11R6/bin/X
The same holds true for the other servers. You also need to ensure that the directory, /usr/X11R6/bin, is on your path. This can be done by editing your system default /etc/profile or /etc/csh.login (based on the shell that you, or other users on your system, use). Or you can simply add the directory to your personal path by modifying /etc/.bashrc or /etc/.cshrc, based on your shell. Finally, ensure that /usr/X11R6/lib can be located by ld.so, the run time linker. To do this, add the line
/usr/X11R6/lib
It is possible that SuperProbe will confuse hardware that uses I/O port addresses that might be used by video cards. To prevent SuperProbe from checking these addresses, use the excl argument, followed by a list of addresses that SuperProbe should not examine. For example:
# SuperProbe -excl 0x200-0x230,0x240
The addresses are given as hexadecimal numbers that are prexed by 0x. To display a list of video devices that SuperProbe knows about, use the command
# SuperProbe -info
235
TOC
SuperProbe can print lots of information if you provide it with the -verbose argument. You can redirect the output to a le:
# SuperProbe -verbose >superprobe.out
Running SuperProbe can cause the system to hang. Make certain that any non-essential applications are not running, or at least have all of their data safely saved to disk, and ensure that any users are logged off. Also, a loaded system (one that is printing in the background, for example), can skew the output of software like SuperProbe or an X server that is trying to measure the video cards timing specications.
236
Advanced Features
TOC
Several video chip sets have separate README les in the above directory (like README.Cirrus and README.S3). Read the le that applies to your video card. The manual page for XFree86. The manual page for XF86Config. The manual page for the server that you are using, like XF86 SVGA or XF86 S3. The main XFree86 conguration le is /usr/X11R6/lib/X11/XF86Config. This le contains information for your mouse, video card parameters, and so on. The le XF86Config.eg is provided with the XFree86 distribution as an example. Copy this le to XF86Config and edit it as a starting point. The XF86Config manual page explains the format of the XF86Config le. Read the manual page if you have not done so already. We are going to describe a sample XF86Config le, a section at a time. This le may not look exactly like the sample le included in the XFree86 distribution, but the structure is the same. Note that the XF86Config le format may change with each version of XFree86. See your distributions release notes for errata. Do not copy the conguration le listed here to your system and try to use it. A conguration le that does not correspond to your hardware can drive the monitor at a frequency which is too high. There have been reports of damage to monitors, especially xed-frequency monitors, that has been caused by incorrectly congured XF86Config les. Make absolutely sure that your XF86Config le corresponds to your hardware before you use it. Each section of the XF86Config le is surrounded by a pair of lines with the syntax, Section "section-name". . . EndSection. The rst section of the XF86Config le is Files, which looks like this:
Section "Files" RgbPath "/usr/X11R6/lib/X11/rgb" FontPath "/usr/X11R6/lib/X11/fonts/misc/" FontPath "/usr/X11R6/lib/X11/fonts/75dpi/" EndSection
3 3
The RgbPath line sets the path to the X11R6 RGB color database, and each FontPath line sets the path to a directory containing X11 fonts. You shouldnt have to modify these lines. Simply ensure that a FontPath entry exists for each font type that you have installed; that is, for each directory in /usr/X11R6/lib/X11/fonts.
237
TOC
The next section is ServerFlags, which species several global ags for the server. In general this section is empty.
Section "ServerFlags" # Uncomment this to cause a core dump at the spot where a signal is # received. This may leave the console in an unusable state, but may # provide a better stack trace in the core dump to aid in debugging # NoTrapSignals # Uncomment this to disable the <Crtl><Alt><BS> server abort sequence # DontZap EndSection
In this ServerFlags section, all of the lines are commented out. The next section is Keyboard. This example shows a basic conguration that should work on most systems. The XF86Config le describes how to modify the conguration.
Section "Keyboard" Protocol "Standard" AutoRepeat 500 5 ServerNumLock EndSection
The next section is Pointer, which species parameters for the mouse device:
Section "Pointer" Protocol Device "MouseSystems" "/dev/mouse"
# Baudrate and SampleRate are only for some Logitech mice # BaudRate 9600 # SampleRate 150 # Emulate3Buttons is an option for 2-button Microsoft mice # Emulate3Buttons # ChordMiddle is an option for some 3-button Logitech mice # ChordMiddle EndSection
238
Advanced Features
TOC
For the moment, the only options that should concern you are Protocol and Device. Protocol species the mouse protocol, which is not necessarily the same as the manufacturer. XFree86 under Linux recognizes these mouse protocols: BusMouse Logitech Microsoft MMSeries Mouseman MouseSystems PS/2 MMHitTab BusMouse should be used for the Logitech bus mice. Older Logitech mice use Logitech, and newer Logitech serial mice use either Microsoft or Mouseman protocols. Device species the device le by which the mouse can be accessed. On most Linux systems, this is /dev/mouse, which is usually a link to the appropriate serial port, like /dev/cua0 for serial mice and the appropriate bus mouse device for bus mice. At any rate, be sure that the device le exists. The next section is Monitor, which species the characteristics of your monitor. As with other sections in the XF86Config le, there may be more than one Monitor section. This is useful if you have multiple monitors connected to a system, or use the same XF86Config le for multiple hardware congurations.
Section "Monitor" Identifier "CTX 5468 NI"
# These values are for a CTX 5468NI only! Dont attempt to use # them with your monitor (unless you have this model) Bandwidth HorizSync 60 30-38,47-50
239
TOC
VertRefresh 50-90 dotclock horiz 640 664 760 800 800 824 896 1024 1024 1088 1200 1328 vert 480 491 493 525 600 601 603 625 768 783 789 818
# Modes: Name
Identifier is an arbitrary name for the Monitor entry. This can be any string and is used to refer to the Monitor entry later in the XF86Config le. HorizSync species the valid horizontal sync frequencies for your monitor, in kHz. Multisync monitors may have a range of values, or several, comma separated ranges. Fixedfrequency monitors require a list of discrete values; for example:
HorizSync 31.5, 35.2, 37.9, 35.5, 48.95
The monitor manual should list these values in the technical specications section. If it does not, contact the manufacturer or vendor of your monitor to obtain it. VertRefresh species the valid vertical refresh rates (or vertical synchronization frequencies) for your monitor, in kHz. Like HorizSync, this can be a range or a list of discrete values. Your monitor manual should list them. HorizSync and VertRefresh are used only to double-check that the monitor resolutions are in valid ranges. This reduces the chance that you will damage your monitor by driving it at a frequency which it was not designed for. The ModeLine directive is used to specify resolution modes for your monitor. The format is
ModeLine name clock horiz-values vert-values
name is an arbitrary string which you will use to refer to the resolution mode later in the le. dot-clock is the driving clock frequency, or dot clock associated with the resolution mode. A dot clock is usually specied in MHz. It is the rate at which the video card must send pixels to the monitor at this resolution. horiz-values and vert-values are four numbers each that specify when the electron gun of the monitor should re, and when the horizontal and vertical sync pulses re during a sweep. The le VideoModes.doc, included with the XFree86 distribution, describes in detail how to determine the ModeLine values for each resolution mode that your monitor
240
Advanced Features
TOC
supports. clock must correspond to one of the dot clock values that your video card supports. Later in the XF86Config le, you will specify these clocks. Two les, modeDB.txt and Monitors, may have ModeLine information for your monitor. They are located in /usr/X11R6/lib/X11/doc. Start with ModeLine values for VESA-standard monitor timings, because most monitors support them. ModeDB.txt includes the timing values for VESA-standard resolutions. For example, this entry,
# # # # # 640x480@60Hz Non-Interlaced mode Horizontal Sync = 31.5kHz Timing: H=(0.95us, 3.81us, 1.59us), V=(0.35ms, 0.064ms, 1.02ms) name "640x480" clock horizontal timing 25.175 640 664 760 800 vertical timing 480 491 493 525 flags
is the VESA-standard timing for a 640x480 video mode. It has a dot clock of 25.175, which your video card must support. This is described below. To include this entry in the XF86Config le, use the line
ModeLine "640x480" 25.175 525 640 664 760 800 480 491 493
The name argument to ModeLine ("640x480") is an arbitrary string. By convention modes are named by their resolutions, but name can, technically, be any descriptive label. For each ModeLine, the server checks the mode specications and ensures that they fall in the range of values specied for Bandwidth, HorizSync, and VertRefresh. If they do not, the server complains when you attempt to start X. For one thing, the dot clock used by the mode should not be greater than the value used for Bandwidth. However, in many cases, it is safe to use a mode that has a slightly higher bandwidth than your monitor can support. If the VESA standard timings do not work, (youll know after you try to use them), then look in the les modeDB.txt and Monitors, which include specic mode values for many monitor types. You can create ModeLine entries from these values as well. Be sure only to use values for your specic monitor. Many 14 and 15-inch monitors do not support higher resolution modes, and often resolutions of 1024x768 at low dot clocks. If you cant nd high-resolution modes for your monitor in these les, then your monitor probably does not support them. If you are completely at a loss and cant nd ModeLine values for your monitor, follow the instructions in the VideoModes.doc le, which is included in the XFree86
241
TOC
distribution, and generate values from the specications in your monitors manual. Your mileage will certainly vary when you attempt to generate ModeLine values by hand. But this is a good place to look if you cant nd the values that you need. VideoModes.doc also describes the format of the ModeLine directive, and other aspects of the XFree86 server in gory detail. Lastly, if you do obtain ModeLine values that are almost but not exactly right, you may possibly be able to modify the values a little to obtain the desired result. For example, if the XFree86 display image is shifted slightly, or the image seems to roll, then follow the instructions in the VideoModes.doc le and x the values. Be sure to check the controls on the monitor itself. In many cases, you must change the horizontal or vertical size of the display after XFree86 starts, to center and size the image. Dont use monitor timing values or ModeLine values for monitors other than your model. If you try to drive a monitor at a frequency for which it was not designed, you can damage or even destroy it. The next section of the XF86Config le is Device, which species parameters for your video card. Here is an example.
Section "Device" Identifier "#9 GXE 64" # Nothing yet; we fill in these values later. EndSection
This section denes properties for a particular video card. Identifier is an arbitrary, descriptive string. You will use this string to refer to the card later. Initially, you dont need to include anything in the Device section except the Identifier. We will use the X server itself to probe for the properties of the video card and enter them into the Device section later. The XFree86 server is capable of probing for the video chip set, clocks, RAMDAC, and amount of video RAM on the board. This is described in Section 5.6. Before we do this, however, we need to nish writing the XF86Config le. The next section is Screen, which species the monitor/video card combination to use for a particular server.
Section "Screen" Driver "Accel" Device "#9 GXE 64" Monitor "CTX 5468 NI"
242
Advanced Features
TOC
Subsection "Display" Depth 16 Modes "1024x768" "800x600" "640x480" ViewPort 0 0 Virtual 1024 768 EndSubsection EndSection
The Driver line species the X server that you will be using. Valid Driver values are: Accel: For the XF86 S3, XF86 Mach32, XF86 Mach8, XF86 8514, XF86 P9000, XF86 AGX, and XF86 W32 servers; SVGA: For the XF86 SVGA server; VGA16: For the XF86 VGA16 server; VGA2: For the XF86 Mono server; Mono: For the non-VGA monochrome drivers in the XF86 Mono and XF86 VGA16 servers. Be sure that /usr/X11R6/bin/X is a symbolic link to this server. The Device line species the Identifier of the Device section that corresponds to the video card to use for this server. Above, we created a Device section with the line
Identifier "#9 GXE 64"
Therefore, we use "#9 GXE 64" on the Device line here. Similarly, the Monitor line species the name of the Monitor section to be used with this server. Here, "CTX 5468 NI" is the Identifier used in the Monitor section described above. Subsection "Display" denes several properties of the XFree86 server corresponding to your monitor/video card combination. The XF86Config le describes all of these options in detail. Most of them are not necessary to get the system working. The options that you should know about are: Depth. Denes the number of color planes; that is, the number of bits per pixel. Usually, Depth is set to 16. For the VGA16 server, you would use a depth of 4, and for the monochrome server a depth of 1. If you use an accelerated video card with
243
TOC
enough memory to support more bits per pixel, you can set Depth to 24, or 32. If you have problems with depths higher than 16, set it back to 16 and attempt to debug the problem later. Modes. This is the list of mode names which have been dened using the ModeLine directive(s) in the Monitor section. In the above section, we used ModeLines named "1024x768", "800x600", and "640x48"0. Therefore, we use a Modes line of
Modes "1024x768" "800x600" "640x480"
The rst mode listed on this line is the default when XFree86 starts. After XFree86 is running, you can switch between the modes listed here using the keys Ctrl - Alt Numeric + and Ctrl - Alt - Numeric - . It might be best, when you initially congure XFree86, to use lower resolution video modes like 640x480, which tend to work with most systems. Once you have the basic conguration working, you can modify XF86Config to support higher resolutions. Virtual. Set the virtual desktop size. XFree86 can use additional memory on your video card to extend the size of the desktop. When you move the mouse pointer to the edge of the display, the desktop scrolls, bringing the additional space into view. Even if you run the server at a lower video resolution like 800x600, you can set Virtual to the total resolution that your video card can support. A 1-megabyte video card can support 1024x768 at a depth of 8 bits per pixel; a 2-megabyte card 1280x1024 at depth 8, or 1024x768 at depth 16. Of course, the entire area will not be visible at once, but it can still be used. The Virtual feature is rather limited. If you want to use a true virtual desktop, fvwm and similar window managers allow you to have large, virtual desktops by hiding windows and using other techniques, instead of storing the entire desktop in video memory. See the manual pages for fvwm for more details about this. Many Linux systems use fvwm by default. ViewPort. If you are using the Virtual option which is described above, ViewPort sets the coordinates of the upper-left-hand corner of the virtual desktop when XFree86 starts up. Virtual 0 0 is often used. If this is unspecied, then the desktop is centered on the virtual desktop display, which may be undesirable to you.
244
Advanced Features
TOC
Many other options for this section exist; see the XF86Config manual page for a complete description. In practice, these options are not necessary to get XFree86 working initially.
This gives the chip set names known to the X server. (The manual pages for each X server list these, too.) For example, with the accelerated XF86 S3 server, we get:
XFree86 Version 3.1 / X Window System (protocol Version 11, revision 0, vendor release 6000) Operating System: Linux Configured drivers: S3: accelerated server for S3 graphics adaptors (Patchlevel 0) mmio_928, s3_generic
The valid chip set names for this server are mmio 928 and s3 generic. The XF86 S3 man page describes these chip sets and video cards that use them. In the case of the #9 GXE 64 video card, mmio 928 is appropriate. If you dont know which chip set is in use, the X server can probe it for you. To do this, run the command
245
TOC
X -probeonly > /tmp/x.out 2>&1
You should run this command while the system is unloaded; that is, while no other activity occurs on the system. This command also probes for your video card dot clocks (as seen below), and system load can throw off this calculation. The output from the above, in /tmp/x.out, should contain lines like:
XFree86 Version 3.1 / X Window System (protocol Version 11, revision 0, vendor release 6000) Operating System: Linux Configured drivers: S3: accelerated server for S3 graphics adaptors (Patchlevel 0) mmio_928, s3_generic Several lines deleted. . . (--) S3: card type: 386/486 localbus (--) S3: chipset: 864 rev. 0 (--) S3: chipset driver: mmio_928
Here, we see that the two valid chip sets for this server (in this case, XF86 S3) are mmio 928 and s3 generic. The server probed for and found a video card that has the mmio 928 chipset. In the Device section of the XF86Config le, add a Chipset line that has the name of the chip set as determined above. For example,
Section "Device" # We already had Identifier here... Identifier "#9 GXE 64" # Add this line: Chipset "mmio_928" EndSection
Now, we need to determine the driving clock frequencies used by the video card. A driving clock frequency, or dot clock, is simply a rate at which the video card can send pixels to the monitor. As described above, each monitor resolution has a dot clock associated with it. We need to determine which dot clocks are made available by the video card. First, you should look at the documentation mentioned above and see if the cards clocks are listed there. The dot clocks are usually a list of 8 or 16 values, all of which are
246
Advanced Features
TOC
in MHz. For example, when looking at modeDB.txt, we see an entry for the Cardinal ET4000 video card, which looks like:
# chip ET4000 ram 1024 virtual 1024 768 clocks 25 28 38 36 40 45 32 0 default-mode "1024x768" flags
The dot clocks for this card are 25, 28, 38, 36, 40, 45, 32, and 0 MHz. In the Devices section of the XF86Config le, add a Clocks line containing the list of dot clocks for your card. For example, for the clocks above, add the line
Clocks 25 28 38 36 40 45 32 0
to the Devices section of the le, after Chipset. The order of the dot clocks is important. Dont re-sort the list or remove duplicates. If you cannot nd the dot clocks associated with your card, the X server can probe for these, too. Use X -probeonly as described above. The output should contain lines which look like the following:
(--) S3: clocks: 25.18 28.32 38.02 36.15 40.33 45.32 32.00 00.00
We can then add a Clocks line which contains all of these values, as printed. You can use more than one Clocks line in XF86Config if all of the values (sometimes there are more than 8 clock values printed) do not t onto one line. Again, be sure to keep the list of clocks in the order that they are displayed. Be sure that there is no Clocks line (or that it is commented out) in the Devices section of the le when using X -probeonly. If there is a Clocks line present, the server does not probe for the clocksit uses the values given in XF86Config. Some video boards use a programmable clock chip. See the manual page for your X server or the XFree86 README le that describes your video card. The chip essentially allows the X server to tell the card the dot clocks to use. For video cards that have clock chips, you may not nd a list of dot clocks for the card in any of the above les. Or, the list of dot clocks printed when using X -probeonly will only contain one or two discrete clock values, with the rest being duplicates or zero. Or, the X server may provide an explicit warning that the video card has a programmable clock chip, like:
(--) SVGA: cldg5434: Specifying a Clocks line makes no sense for this driver
This example is taken from a XF86 SVGA server running a Cirrus Logic PCI card. For boards which use programmable clock chips, you use a ClockChip line instead of a Clocks line in the XF86Config le. ClockChip is the name of the clock chip as used by the video card; the manual pages for each server describe them. For example,
247
TOC
in the le README.S3, we see that several S3-864 video cards use an ICD2061A clock chip, and that we should use the line
ClockChip "icd2061a"
instead of Clocks in the XF86Config le. As with Clocks, this line goes in the Devices section, after Chipset. Similarly, some video cards require that you specify the RAMDAC chip type in the XF86Config le. This is done with a Ramdac line. The XF86 Accel man page describes this option. Often the X server will correctly probe for the RAMDAC. Some video card types require that you specify several options in the Devices section of XF86Config. These options are described in the manual page for your server, as well as in the various les like README.cirrus and README.S3. These options are enabled using an Option line. For example, the #9 GXE 64 card requires two options:
Option "number_nine" Option "dac_8_bit"
An X server may work without the Option lines, but they are necessary to get the best performance out of the card. There are too many options to list here. They are different for each card. If you must use one, the X server manual pages and various les in /usr/X11R6/lib/X11/doc will tell you what they are. When you nish, you should have a Devices section that looks something like:
Section "Device" # Device section for the #9 GXE 64 only ! Identifier "#9 GXE 64" Chipset "mmio_928" ClockChip "icd2061a" Option "number_nine" Option "dac_8_bit" EndSection
There are other options which you can include in the Devices entry. The X server manual pages provide the gritty details.
248
Advanced Features
TOC
The command to start XFree86 is
startx
This is a front end to xinit. It starts the X server and executes the commands in the le .xinitrc in your home directory. .xinitrc is a shell script that contains the command lines of the X clients to run when the X server starts. If this le does not exist, the system default /usr/X11R6/lib/X11/xinit/xinitrc is used. A simple .xinitrc le looks like this:
#!/bin/sh xterm -fn 7x13bold -geometry 80x32+10+50 & xterm -fn 9x15bold -geometry 80x34+30-10 & oclock -geometry 70x70-7+7 & xsetroot -solid midnightblue & exec twm
This script starts two xterm clients and an oclock, and sets the root window (background) color to midnightblue. It starts twm, the window manager. twm is executed with the shells exec statement. This causes the xinit process to be replaced by twm. After the twm process exits, the X server shuts down. You can cause twm to exit by using the root menu. Depress mouse button 1 on the desktop background. This displays a pop-up menu that allows you to Exit Twm. Be sure that the last command in .xinitrc is started with exec, and that it is not placed into the background (no ampersand at the end of the line). Otherwise the X server will shut down immediately after it starts the clients in the .xinitrc le. Alternately, you can exit X by pressing Ctrl - Alt - Backspace in combination. This kills the X server directly, exiting the window system. The above is a only a simple desktop conguration. Again, we suggest that you read a book like The X Window System: A Users Guide (see Appendix A). The possible variations of X usage and conguration are too many to describe here. The xterm, oclock, and twm manual pages will provide you clues on how to begin.
249
TOC
or the video card dot clocks are set incorrectly. If the display seems to roll, or the edges are fuzzy, this indicates that the monitor timing values or dot clocks are wrong. Also, be sure that you correctly specied the video card chip set and options in the Device section of XF86Config. Be absolutely sure that you are using the correct X server and that /usr/X11R6/bin/X is a symbolic link to it. If all else fails, try to start X bare; that is, with a command like:
X > /tmp/x.out 2>&1
You can then kill the X server (using Ctrl - Alt - Backspace ) and examine the contents of /tmp/x.out. The X server reports any warnings or errorsfor example, if your video card doesnt have a dot clock corresponding to a mode supported by your monitor. The le VideoModes.doc, which is included in the XFree86 distribution, contains many hints for adjusting the values in your XF86Config le. Remember that you can use Ctrl - Alt - Numeric + and Ctrl - Alt Numeric - to switch between the video modes listed on the Modes line of the Screen section of XF86Config. If the highest resolution mode doesnt look right, try switching to a lower resolution. This lets you know, at least, that those parts of your X conguration are working correctly. Also, adjust the vertical and horizontal size/hold knobs on your monitor. In many cases, it is necessary to adjust these when starting up X. For example, if the display seems to be shifted slightly to one side, you can usually correct this using the monitor controls. Again, the USENET newsgroup comp.windows.x.i386unix is devoted to discussions about XFree86. It might be a good idea to read the newsgroups for postings related to video conguration. You might run across someone with the same problem. There are also sample XF86Config les which have been contributed by users. Some of these are available on the sunsite.unc.edu archive in the /pub/Linux/X11 directory, and elsewhere. You might nd a conguration le that somebody has already written for your hardware.
TOC
Chapter 6
Networking
In this chapter we discuss Networkinghow to congure a connection, using TCP/IP, SLIP, PPP or UUCP, and electronic mail and news.
250
TCP/IP Networking
251
TOC
Linux machine also has Ethernet access to the Internet, you can set up your Linux box as a SLIP or PPP server. For complete information on setting up TCP/IP under Linux, we encourage you to read the Linux NET-3 HOWTO, available via anonymous FTP from sunsite.unc.edu. The NET-3 HOWTO is a complete guide to conguring TCP/IP, including Ethernet and SLIP or PPP connections, under Linux. The Linux Ethernet HOWTO is a related document that describes conguration of various Ethernet card drivers for Linux. The Linux Network Administrators Guide, from the Linux Documentation Project, is also available. See Appendix A for more information on these documents. Also of interest is the book TCP/IP Network Administration, by Craig Hunt. It contains complete information on using and conguring TCP/IP on UNIX systems.
252
Advanced Features
TOC
This discussion should be enough to get you on the right path to conguring the network parameters of your machine, but there are numerous caveats and ne details not mentioned here. We direct you to the Linux Network Administrators Guide and the NET-3-HOWTO for more information.1 First, we assume that you have a Linux system that has the TCP/IP software installed. This includes basic clients such as telnet and ftp, system administration commands such as ifconfig and route (usually found in /etc), and networking conguration les (such as /etc/hosts). The other Linux-related networking documents described above explain how to go about installing the Linux networking software if you do not have it already. We also assume that your kernel has been congured and compiled with TCP/IP support enabled. See Section 4.9 for information on compiling your kernel. To enable networking, you must answer yes to the appropriate questions during the make config step, and rebuild the kernel. Once this has been done, you must modify a number of conguration les used by NET-3. For the most part this is a simple procedure. Unfortunately, however, there is wide disagreement between Linux distributions as to where the various TCP/IP conguration les and support programs should go. Much of the time, they can be found in /etc, but in other cases may be found in /usr/etc, /usr/etc/inet, or other bizarre locations. In the worst case youll have to use the find command to locate the les on your system. Also note that not all distributions keep the NET-3 conguration les and software in the same locationthey may be spread across several directories. The following information applies primarily to Ethernet connections. If youre planning to use SLIP or PPP, read this section to understand the concepts, and follow the more specic instructions in the following sections. Your network conguration. Before you can congure TCP/IP, you need to determine the following information about your network setup. In most cases, your local network administrator can provide you with this information. IP address. This is the unique machine address in dotted-decimal format. An example is 128.253.153.54. Your network admins will provide you with this number. If youre only conguring loopback mode (i.e. no SLIP, no Ethernet card, just TCP/IP connections to your own machine) then your IP address is 127.0.0.1. Your network mask (netmask). This is a dotted quad, similar to the IP address,
1 Some of this information is adapted from the NET-3-HOWTO by Terry Dawson and Matt Welsh.
TCP/IP Networking
253
TOC
which determines which portion of the IP address species the subnetwork number, and which portion species the host on that subnet. (If youre shaky on these TCP/IP networking terms, we suggest reading some introductory material on network administration.) The network mask is a pattern of bits, which when overlayed onto an address on your network, will tell you which subnet that address lives on. This is very important for routing, and if you nd, for example, that you can happily talk to people outside your network, but not to some people within your network, there is a good chance that you have an incorrect mask specied. Your network administrators will have chosen the netmask when the network was designed, and therefore they should be able to supply you with the correct mask to use. Most networks are class C subnetworks which use 255.255.255.0 as their netmask. Class B networks use 255.255.0.0. The NET-3 code will automatically select a mask that assumes no subnetting as a default if you do not specify one. This applies as well to the loopback port. Since the loopback ports address is always 127.0.0.1, the netmask for this port is always 255.0.0.0. You can either specify this explicitly or rely on the default mask. Your network address. This is your IP address masked bitwise-ANDed the netmask. For example, if your netmask is 255.255.255.0, and your IP address is 128.253.154.32, your network address is 128.253.154.0. With a netmask of 255.255.0.0, this would be 128.253.0.0. If youre only using loopback, you dont have a network address. Your broadcast address. The broadcast address is used to broadcast packets to every machine on your subnet. Therefore, if the host number of machines on your subnet is given by the last byte of the IP address (netmask 255.255.255.0), your broadcast address will be your network address ORed with 0.0.0.255. For example, if your IP address is 128.253.154.32, and your netmask is 255.255.255.0, your broadcast address is 128.253.154.255. Note that for historical reasons, some networks are setup to use the network address as the broadcast address, if you have any doubt, check with your network administrators. (In many cases, it will sufce to duplicate the network conguration of other machines on your subnet, substituting your own IP address, of course.) If youre only using loopback, you dont have a broadcast address.
254
Advanced Features
TOC
Your gateway address. This is the address of the machine which is your gateway to the outside world (i.e. machines not on your subnet). In many cases the gateway machine has an IP address identical to yours but with a .1 as its host address; e.g., if your IP address is 128.253.154.32, your gateway might be 128.253.154.1. Your network admins will provide you with the IP address of your gateway. In fact, you may have multiple gateways. A gateway is simply a machine that lives on two different networks (has IP addresses on different subnets), and routes packets between them. Many networks have a single gateway to the outside world (the network directly adjacent to your own), but in some cases you will have multiple gatewaysone for each adjacent network. If youre only using loopback, you dont have a gateway address. The same is true if your network is isolated from all others. Your name server address. Most machines on the net have a name server which translates host names into IP addresses for them. Your network admins will tell you the address of your name server. You can also run a server on your own machine by running named, in which case the name server address is 127.0.0.1. Unless you absolutely must run your own name server, we suggest using the one provided to you on the network (if any). Conguration of named is another issue altogether; our priority at this point is to get you talking to the network. You can deal with name resolution issues later. If youre only using loopback, you dont have a name server address. SLIP/PPP users: You may or may not require any of the above information, except for a name server address. When using SLIP, your IP address is usually determined in one of two ways: Either (a) you have a static IP address, which is the same every time you connect to the network, or (b) you have a dynamic IP address, which is allocated from a pool available addresses when you connect to the server. In the following section on SLIP conguration this is covered in more detail. NET-3 supports full routing, multiple routes, subnetworking (at this stage on byte boundaries only), the whole nine yards. The above describes most basic TCP/IP congurations. Yours may be quite different: when in doubt, consult your local network gurus and check out the man pages for route and ifconfig. Conguring TCP/IP networks is very much beyond the scope of this book; the above should be enough to get most people started.
TCP/IP Networking
255
TOC
The networking rc les. rc les are systemwide conguration scripts executed at boot time by init, which start up all of the basic system daemons (such as sendmail, cron, etc.) and congure things such as the network parameters, system host name, and so on. rc les are usually found in the directory /etc/rc.d but on other systems may be in /etc. In general Slackware distributions use the les rc.inet1, etc. in /etc/rc.d whereas the RedHat distributions use a series of directories Here, were going to describe the rc les used to congure TCP/IP. There are two of them: rc.inet1 and rc.inet2. rc.inet1 is used to congure the basic network parameters (such as IP addresses and routing information) and rc.inet2 res up the TCP/IP daemons (telnetd, ftpd, and so forth). Many systems combine these two les into one, usually called rc.inet or rc.net. The names given to your rc les doesnt matter, as long as they perform the correct functions and are executed at boot time by init. To ensure this, you may need to edit /etc/inittab and uncomment lines to execute the appropriate rc le(s). In the worst case you will have to create the rc.inet1 and rc.inet2 les from scratch and add entries for them to /etc/inittab. As we said, rc.inet1 congures the basic network interface. This includes your IP and network address, and the routing table information for your network. The routing tables are used to route outgoing (and incoming) network datagrams to other machines. On most simple congurations, you have three routes: One for sending packets to your own machine, another for sending packets to other machines on your network, and another for sending packets to machines outside of your network (through the gateway machine). Two programs are used to congure these parameters: ifconfig and route. Both of these are usually found in /etc. ifconfig is used for conguring the network device interface with the parameters that it requires to function, such as the IP address, network mask, broadcast address and the like. Route is used to create and modify entries in the routing table. For most congurations, an rc.inet1 le that looks like the following should work. You will, of course, have to edit this for your own system. Do not use the sample IP and network addresses listed here for your own system; they correspond to an actual machine on the Internet.
#!/bin/sh # This is /etc/rc.d/rc.inet1 -- Configure the TCP/IP interfaces # First, configure the loopback device
256
Advanced Features
TOC
HOSTNAME=host name /etc/ifconfig lo 127.0.0.1 /etc/route add 127.0.0.1 # uses default netmask 255.0.0.0 # a route to point to the loopback device
# Next, configure the ethernet device. If youre only using loopback or # SLIP, comment out the rest of these lines. # Edit for your setup. IPADDR="128.253.154.32" NETMASK="255.255.255.0" NETWORK="128.253.154.0" BROADCAST="128.253.154.255" GATEWAY="128.253.154.1"
# # # # # #
REPLACE with REPLACE with REPLACE with REPLACE with have one. If REPLACE with
IP address netmask network address broadcast address, if you leave blank and edit below. gateway address!
/etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK} broadcast ${BROADCAST} # If you dont have a broadcast address, change the above line to just: # /etc/ifconfig eth0 ${IPADDR} netmask ${NETMASK} /etc/route add ${NETWORK} # The following is only necessary if you have a gateway; that is, your # network is connected to the outside world. /etc/route add default gw ${GATEWAY} metric 1 # End of Ethernet Configuration
Again, you may have to tweak this le somewhat to get it to work. The above should be sufcient for the majority of simple network congurations, but certainly not all. rc.inet2 starts up various servers used by the TCP/IP suite. The most important of these is inetd. Inetd sits in the background and listens to various network ports. When a machine tries to make a connection to a certain port (for example, the incoming telnet port), inetd forks off a copy of the appropriate daemon for that port (in the case of the telnet port, inetd starts in.telnetd). This is simpler than running many separate, standalone daemons (e.g., individual copies of telnetd, ftpd, and so forth)inetd starts up the daemons only when they are needed. Syslogd is the system logging daemonit accumulates log messages from vari-
TCP/IP Networking
257
TOC
ous applications and stores them into log les based on the conguration information in /etc/syslogd.conf. routed is a server used to maintain dynamic routing information. When your system attempts to send packets to another network, it may require additional routing table entries in order to do so. routed takes care of manipulating the routing table without the need for user intervention. Our example rc.inet2, below, only starts up the bare minimum of servers. There are many other servers as wellmany of which have to do with NFS conguration. When attempting to setup TCP/IP on your system, its usually best to start with a minimal conguration and add more complex pieces (such as NFS) when you have things working. Note that in the below le, we assume that all of the network daemons are held in /etc. As usual, edit this for your own conguration.
#! /bin/sh # Sample /etc/rc.d/rc.inet2 # Start syslogd if [ -f /etc/syslogd ] then /etc/syslogd fi # Start inetd if [ -f /etc/inetd ] then /etc/inetd fi # Start routed if [ -f /etc/routed ] then /etc/routed -q fi # Done!
Among the various additional servers that you may want to start in rc.inet2 is named. Named is a name serverit is responsible for translating (local) IP addresses to names, and vice versa. If you dont have a name server elsewhere on the network, or want to provide local machine names to other machines in your domain, it may be necessary to
258
Advanced Features
TOC
run named. (For most congurations it is not necessary, however.) Named conguration is somewhat complex and requires planning; we refer interested readers to a good book on TCP/IP network administration. The /etc/hosts le. /etc/hosts contains a list of IP addresses and the host names that they correspond to. In general, /etc/hosts only contains entries for your local machine, and perhaps other important machines (such as your name server or gateway). Your local name server will provide address-to-name mappings for other machines on the network, transparently. For example, if your machine is loomer.vpizza.com with the IP address 128.253.154.32, your /etc/hosts would look like:
127.0.0.1 128.253.154.32 localhost loomer.vpizza.com loomer
If youre only using loopback, the only line in /etc/hosts should be for 127.0.0.1, with both localhost and your host name after it. The /etc/networks le. The /etc/networks le lists the names and addresses of your own, and other, networks. It is used by the route command, and allows you to specify a network by name, should you so desire. Every network you wish to add a route to using the route command (generally called from rc.inet1see above) must have an entry in /etc/networks. As an example,
default 0.0.0.0 # default route - mandatory loopnet 127.0.0.0 # loopback network - mandatory mynet 128.253.154.0 # Modify for your own network address
The /etc/host.conf le. This le is used to specify how your system will resolve host names. It should contain the two lines:
order hosts,bind multi on
These lines tell the resolve libraries to rst check the /etc/hosts le for any names to lookup, and then to ask the name server (if one is present). The multi entry allows you to have multiple IP addresses for a given machine name in /etc/hosts.
TCP/IP Networking
259
TOC
The /etc/resolv.conf le. This le congures the name resolver, specifying the address of your name server (if any) and your domain name. Your domain name is your fully-qualied host name (if youre a registered machine on the Internet, for example), with the host name chopped off. That is, if your full host name is loomer.vpizza.com, your domain name is just vpizza.com. For example, if your machine is goober.norelco.com, and has a name server at the address 128.253.154.5, your /etc/resolv.conf would look like:
domain nameserver norelco.com 127.253.154.5
You can specify more than one name servereach must have a nameserver line of its own in resolv.conf. Setting your host name. You should set your system host name with the hostname command. This is usually called from /etc/rc or /etc/rc.local; simply search your system rc les to determine where it is invoked. For example, if your (full) host name is loomer.vpizza.com, edit the appropriate rc le to execute the command:
/bin/hostname loomer.vpizza.com
Note that the hostname executable may not be found in /bin on your system. Trying it out. Once you have all of these les set up, you should be able to reboot your new kernel and attempt to use the network. There are many places where things can go wrong, so its a good idea to test individual aspects of the network conguration (e.g., its probably not a good idea to test your network conguration by ring up Mosaic over a network-based X connection). You can use the netstat command to display your routing tables; this is usually the source of the most trouble. The netstat man page describes the exact syntax of this command in detail. In order to test network connectivity, we suggest using a client such as telnet to connect to machines both on your local subnetwork and external networks. This will help to narrow down the source of the problem. (For example, if youre unable to connect to local machines, but can connect to machines on other networks, more than likely there is a problem with your netmask and routing table conguration). You can also invoke the route command directly (as root) to play with the entries in your routing table. You should also test network connectivity by specifying IP addresses directly, instead of host names. For example, if you have problems with the command
260
Advanced Features
TOC
$ telnet shoop.vpizza.com
the cause may be incorrect name server conguration. Try using the actual IP address of the machine in question; if that works, then you know your basic network setup is (more than likely) correct, and the problem lies in your specication of the name server address. Debugging network congurations can be a difcult task, and we cant begin to cover it here. If you are unable to get help from a local guru we strongly suggest reading the Linux Network Administrators Guide from the LDP.
TCP/IP Networking
261
TOC
addressesin which case your IP address will be the same every time you connect to the server. However, many SLIP servers allocate IP addresses dynamicallyin which case you receive a different IP address each time you connect. In general, the SLIP server will print the values of your IP and gateway addresses when you connect. dip is capable of reading these values from the output of the SLIP server login session and using them to congure the SLIP device. Essentially, conguring a SLIP connection is just like conguring for loopback or ethernet. The main differences are discussed below. Read the previous section on conguring the basic TCP/IP les, and apply the changes described below. Static IP address SLIP connections using dip. If you are using a static-allocation SLIP server, you may want to include entries for your IP address and host name in /etc/hosts. Also, congure these les listed in the above section: rc.inet2, host.conf, and resolv.conf. Also, congure rc.inet1, as described above. However, you only want to execute ifconfig and route commands for the loopback device. If you use dip to connect to the SLIP server, it will execute the appropriate ifconfig and route commands for the SLIP device for you. (If youre using slattach, on the other hand, you will need to include ifconfig/route commands in rc.inet1 for the SLIP devicesee below.) dip should congure your routing tables appropriately for the SLIP connection when you connect. In some cases, however, dips behavior may not be correct for your conguration, and youll have to run ifconfig or route commands by hand after connecting to the server with dip (this is most easily done from within a shell script that runs dip and immediately executes the appropriate conguration commands). Your gateway is, in most cases, the address of the SLIP server. You may know this address before hand, or the gateway address will be printed by the SLIP server when you connect. Your dip chat script (described below) can obtain this information from the SLIP server. ifconfig may require use of the pointopoint argument, if dip doesnt congure the interface correctly. For example, if your SLIP server address is 128.253.154.2, and your IP address is 128.253.154.32, you may need to run the command
ifconfig sl0 128.253.154.32 pointopoint 128.253.154.2
as root, after connecting with dip. The man pages for ifconfig will come in handy. Note that SLIP device names used with the ifconfig and route commands are sl0, sl1 and so on (as opposed to eth0, eth1, etc. for Ethernet devices). In Section 6.1.2, below, we explain how to congure dip to connect to the SLIP server.
262
Advanced Features
TOC
Static IP address SLIP connections using slattach. If you have a leased line or cable running directly to your SLIP server, then there is no need to use dip to initiate a connection. slattach can be used to congure the SLIP device instead. In this case, your /etc/rc.inet1 le should look something like the following:
#!/bin/sh IPADDR="128.253.154.32" # Replace with your IP address REMADDR="128.253.154.2" # Replace with your SLIP server address # Modify the following for the appropriate serial device for the SLIP # connection: slattach -p cslip -s 19200 /dev/ttyS0 /etc/ifconfig sl0 $IPADDR pointopoint $REMADDR up /etc/route add default gw $REMADDR
slattach allocates the rst unallocated SLIP device (sl0, sl1, etc.) to the serial line specied. Note that the rst parameter to slattach is the SLIP protocol to use. At present the only valid values are slip and cslip. Slip is regular SLIP, as you would expect, and cslip is SLIP with datagram header compression. In most cases you should use cslip; however, if you seem to be having problems with this, try slip. If you have more than one SLIP interface then you will have routing considerations to make. You will have to decide what routes to add, and those decisions can only be made on the basis of the actual layout of your network connections. A book on TCP/IP network conguration, as well as the man pages to route, will be of use. Dynamic IP address SLIP connections using dip. If your SLIP server allocates an IP address dynamically, then you certainly dont know your address in advancetherefore, you cant include an entry for it in /etc/hosts. (You should, however, include an entry for your host with the loopback address, 127.0.0.1.) Many SLIP servers print your IP address (as well as the servers address) when you connect. For example, one type of SLIP server prints a string such as,
Your IP address is 128.253.154.44. Server address is 128.253.154.2.
dip can capture these numbers from the output of the server and use them to congure the SLIP device.
TCP/IP Networking
263
TOC
See page 261, above, for information on conguring your various TCP/IP les for use with SLIP. Below, we explain how to congure dip to connect to the SLIP server.
Using dip.
dip can simplify the process of connecting to a SLIP server, logging in, and conguring the SLIP device. Unless you have a leased line running to your SLIP server, dip is the way to go. To use dip, youll need to write a chat script which contains a list of commands used to communicate with the SLIP server at login time. These commands can automatically send your user name/password to the server, as well as get information on your IP address from the server. Here is an example dip chat script, for use with a dynamic IP address server. For static servers, you will need to set the variables $local and $remote to the values of your local IP address and server IP address, respectively, at the top of the script. See the dip man page for details.
main: # Set Maximum Transfer Unit. This is the maximum size of packets # transmitted on the SLIP device. Many SLIP servers use either 1500 or # 1006; check with your network admins when in doubt. get $mtu 1500 # Make the SLIP route the default route on your system. default # Set the desired serial port and speed. port cua03 speed 38400 # Reset the modem and terminal line. If this causes trouble for you, # comment it out. reset # Prepare for dialing. Replace the following with your # modem initialization string. send ATT&C1&D2\\N3&Q5%M3%C1N1W1L1S48=7\r wait OK 2 if $errlvl != 0 goto error
264
Advanced Features
TOC
# Dial the SLIP server dial 2546000 if $errlvl != 0 goto error wait CONNECT 60 if $errlvl != 0 goto error # We are connected. Login to the system. login: sleep 3 send \r\n\r\n # Wait for the login prompt wait login: 10 if $errlvl != 0 goto error # Send your username send USERNAME\n # Wait for password prompt wait ord: 5 if $errlvl != 0 goto error # Send password. send PASSWORD\n # Wait for SLIP server ready prompt wait annex: 30 if $errlvl != 0 goto error # Send commands to SLIP server to initiate connection. send slip\n wait Annex 30 # Get the remote IP address from the SLIP server. The get...remote # command reads text in the form xxx.xxx.xxx.xxx, and assigns it # to the variable given as the second argument (here, $remote). get $remote remote if $errlvl != 0 goto error wait Your 30
TCP/IP Networking
265
TOC
# Get local IP address from SLIP server, assign to variable $local. get $local remote if $errlvl != 0 goto error # Fire up the SLIP connection done: print CONNECTED to $remote at $rmtip print GATEWAY address $rmtip print LOCAL address $local mode SLIP goto exit error: print SLIP to $remote failed. exit:
dip automatically executes ifconfig and route commands based on the values of the variables $local and $remote. Here, those variables are assigned using the get...remote command, which obtains text from the SLIP server and assigns it to the named variable. If the ifconfig and route commands that dip runs for you dont work, you can either run the correct commands in a shell script after executing dip, or modify the source for dip itself. Running dip with the -v option will print debugging information while the connection is being set up, which should help you to determine where things might be going awry. Now, in order to run dip and open the SLIP connection, you can use a command such as:
/etc/dip/dip -v /etc/dip/mychat 2>&1
Where the various dip les, and the chat script (mychat.dip), are stored in /etc/dip. The above discussion should be enough to get you well on your way to talking to the network, either via Ethernet or SLIP. Again, we strongly suggest looking into a book on TCP/IP network conguration, especially if your network has any special routing considerations, other than those mentioned here.
266
Advanced Features
TOC
267
TOC
The modem setup information pagesee (http://www.in.net/info/modems/index.html) Modem Setup Information
The excellent Unix/Linux books published by OReilly and Associates. See (OReilly and Associates On-Line catalog (http://www.ora.com/). If you are new to Unix/Linux, run (dont walk) to your nearest computer book shop and invest in a number of these immediately! The PPP-FAQ maintained by Al Longyear, available from (ftp://sunsite.unc.edu/pub/Linux/docs/faqs; see Appendix B). This contains a great deal of useful information in question/answer format that is very useful when working out why PPP is not working (properly).
268
Advanced Features
TOC
Make sure that the kernel has TCP/IP support. Linux PPP operations come in two parts: 1) the PPP daemon and kernel support for PPP. Most distributions seem to provide PPP kernel support in their default installation kernels, but others do not. You should make sure that TCP/IP is compiled into your kernel. You can do this by issuing the following command:
grep -i TCP/IP /var/adm/messages
then you have TCP/IP support compiled in. You can also look for the above information on the console while Linux is booting. On many fast machines, this scrolls by too quickly. You can use Shift - PageUp to scroll the screen up and see this. Make sure that the kernel has PPP support. like
PPP Dynamic channel allocation code copyright 1995 Caldera, Inc. PPP line discipline registered.
then your kernel has PPP support. You can also issue the command
# grep -i PPP /var/adm/messages
that means PPP support is present. Make sure that you have a modem congured. You should make sure that your modem is correctly set up and that you know which serial port it is connected to. DOS com1: = Linux /dev/cua0 (and /dev/ttyS0) DOS com2: = Linux /dev/cua1 (and /dev/ttyS1), et cetera
269
TOC
Historically, Linux used cuax devices for dial out and ttySx devices for dial in. The kernel code that required this was changed in kernel version 2.0.x and you should now use ttySx for both dial in and dial out. The cuax device names may well disappear in future kernel versions. If you are using a high speed (external) modem (14,400 Baud or above), your serial port needs to be capable of handling the throughput that such a modem is capable of producing, particularly when the modems are compressing the data. This requires your serial port to use a modern UART (Universal Asynchronous Receiver Transmitter) such as a 16550A. If you are using an old machine (or old serial card), it is quite possible that your serial port has only an 8250 UART, which will cause you considerable problems when used with a high speed modem. Use the command
# setserial -a /dev/ttySx
to get Linux to report to you the type of UART you have. If you do not have a 16550A type UART, invest in a new serial card (available for under $50). You will need to congure your modem correctly for PPPto do this READ YOUR MODEM MANUAL! Most modems come with a factory default setting that selects the options required for PPP. Recommended conguration species (in standard Hayes commands): Hardware ow control (RTS/CTS) (&K3 on many modems) E1 Command/usr/src/linux-2.0.27/include/linux/serial.h Echo ON (required for chat to operate) Q0 Report result codes (required for chat to operate) S0=0 Auto Answer OFF (unless you want your modem to answer the phone) &C1 Carrier Detect ON only after connect &S0 Data Set Ready (DSR) always ON (depends) Data Terminal Ready There is a site offering sample congurations for a growing variety of modem makes and models at Modem setup information (http://www.in.net/info/modems/index.html) which may assist you in this.
270
Advanced Features
TOC
Use your communications software (e.g. minicom or seyon) to nd out about your modem conguration and set it to what is required for PPP. Many modems report their current settings in response to AT&V, but you should consult your modem manual. If you completely mess up the settings, you can return to sanity (usually) by issuing an AT&Freturn to factory settings. (For most modem modems I have encountered, the factory settings include all you need for PPPbut you should check). Once you have worked out the modem setup string required write it down. You now have a decision: you can store these settings in your modem non-volatile memory so they can be recalled by issuing the appropriate AT command. Alternatively you can pass the correct settings to your modem as part of the PPP dialing process. If you only use your modem from Linux to call into your ISP or corporate server, the simplest set up will have you save your modem conguration in non-volatile RAM. If on the other hand, your modem is used by other applications and operating systems, it is safest to pass this information to the modem as each call is made so that the modem is guaranteed to be in the correct state for the call. (This has the added advantage also of recording the modem setup string in case the modem looses the contents of its NV-RAM, which can indeed happen). ISP information. Before you can establish your PPP connection with a remote server, you need to obtain the following information from the system administrator or technical support people of the ISP. The telephone number(s) to dial for the service If you are behind a PABX, you also need the PABX number that gives you an outside dial tonethis is frequently digit zero (0) or nine (9). Does the server use DYNAMIC or STATIC IP numbers? If the server uses STATIC IP numbers, then you may need to know what IP number to use for your end of the PPP connection. If your ISP is providing you with a subnet of valid IP numbers, you will need to know the IP numbers you can use and the network mask (netmask). Most Internet Service Providers use DYNAMIC IP numbers. As mentioned above, this has some implications in terms of the services you can use. However, even if you are using STATIC IP numbers, most PPP servers will never (for security reasons) allow the client to specify an IP number as this is a security risk. You do still need to know this information!
271
TOC
What are the IP numbers of the ISPs Domain Name Servers? There should be at least two although only one is needed. There could be a problem here. The MS Windows 95 PPP setup allows the DNS address to be passed to the client as part of its connection process. So your ISP (or corporate help desk) may well tell you you dont need the IP address of the DNS server(s). For Linux, you DO need the address of at least one DNS. The linux implementation of PPP does not allow the setting of the DNS IP number dynamically at connection timeand quite possibly will never do so. Does the server require the use of PAP/CHAP? If this is the case you need to know the id and secret you are to use in connecting. (These are probably your user name and password at your ISP). Does the server automatically start PPP or do you need to issue any commands to start PPP on the server once you are logged in? If you must issue a command to start PPP, what is it? Is the server a Microsoft Windows NT system and, if so, is it using the MS PAP/CHAP system? Many corporate LANs seem to use MS Windows NT this way for increased security. Every device that connects to the Internet must have its own, unique IP number. These are assigned centrally by a designated authority for each country. Therefore to use a PPP connection must have an IP assigned to you. Due to the increased number of machines on the Internet (partly do the large number of PPP users), a dynamic scheme has been developed for PPP that provides an IP on the y to your machine when it rst establishes the PPP connection. This means that you will have a different IP address every time you connect to the remote PPP dialup service. This is the most common method for most ISPs. The other method is to use a static IP. You cannot just choose an IP to us. It must be assigned by the centralized agency in charge of issuing IP numbers. This prevents two computers from having the same IP address and causing problems on the Internet. The remote PPP dialup service provider will be able to tell you if you are using a static or dynamic IP and also provide you with the actual IP number if you are using the static method. It is important to note that if you are using dynamic IP assignment, it will be very very difcult to provide any permanent Internet services such as World Wide Web servers, gopher services, or Internet Relay Chat servers. You can still use such services that are on
272
Advanced Features
TOC
other machines but cannot offer such services on your machine without going through an extreme amount of effort. Doing this beyond the scope of this document. PAP and CHAP are different commonly-used authentication methods. Linux supports both of them. Testing your modem and remote service. Now that you have sorted out the serial port and modem settings it is a good idea to make sure that these setting do indeed work by dialing you ISP and seeing if you can connect. Using you terminal communications package (such as minicom or seyon), set up the modem initialization required for PPP and dial into the PPP server you want to connect to with a PPP session. (Note: at this stage we are NOT trying to make a PPP connectionjust establishing that we have the right phone number and also to nd out exactly what the server sends to us in order to get logged in and start PPP). During this process, either capture (log to a le) the entire login process or carefully (very carefully) write down exactly what prompts the server gives to let you know it is time to enter your user name and password (and any other commands needed to establish the PPP connection). If your server uses PAP, you should not see a login prompt, but should instead see the (text representation) of the link control protocol (which looks like garbage) starting on your screen. A few words of warning: some servers are quite intelligent: you can log in using text based user name/passwords OR using PAP. So if your ISP or corporate site uses PAP but you do not see the garbage start up immediately, this may not mean you have done something wrong. some servers require you to enter some text initially and then start a standard PAP sequence. Some PPP servers are passivethat is they simply sit there sending nothing until the client that is dialing in sends them a valid lcp packet. If the PPP server you are connecting to operates in passive mode, you will never see the garbage! Some servers do not start PPP until you press ENTERso it is worth trying this if you correctly log in and do not see the garbage!
273
TOC
It is worth dialing in at least twicesome servers change their prompts (e.g. with the time!) every time you log in. The two critical prompts your Linux box needs to be able to identify every time you dial in are: the prompt that requests you to enter your user name; the prompt that requests you to enter your password; If you have to issue a command to start PPP on the server, you will also need to nd out the prompt the server gives you once you are logged in to tell you that you can now enter the command to start PPP. If your server automatically starts PPP, once you have logged in, you will start to see garbage on your screenthis is the PPP server sending your machine information to start up and congure the PPP connection. This should look something like this : y}#.!}!}!} }8}!}}U}"}\&} } } } }}\& ...}}"}(}"} .y} On some systems PPP must be explicitly started on the server. This is usually because the server has been set up to allow PPP logins and shell logins using the same user name/password pair. If this is the case, issue this command once you have logged in. Again, you will see the garbage as the server end of the PPP connection starts up. If you do not see this immediately after connecting (and logging in and starting the PPP server if required), press Enter to see if this starts the PPP server. At this point, you can hang up your modem (usually, type +++ quickly and then issue the ATH0 command once your modem responds with OK). If you cant get your modem to work, read your modem manual, the man pages for your communications software and the Serial HOWTO. Once you have this sorted out, carry on as above. Using Internet servers with dynamic IP numbers. If you are using dynamic IP numbers (and many service providers will only give you a dynamic IP number unless you pay signicantly more for your connection), then you have to recognise the limitations this imposes. First of all, outbound service requests will work just ne. That is, you can send email using sendmail (provided you have correctly set up sendmail), ftp les from remote sites, nger users on other machines, browse the web etc. In particular, you can answer email that you have brought down to your machine whilst you are off line. Mail will simply sit in your mail queue until you dial back into your ISP.
274
Advanced Features
TOC
However, your machine is not connected to the Internet 24 hours a day, nor does it have the same IP number every time it is connected. So it is impossible for you to receive email directed to your machine, and very difcult to set up a web or ftp server that your friends can access! As far as the Internet is concerned your machine does not exist as a unique, permanently contactable machine as it does not have a unique IP number (rememberother machines will be using the IP number when they are allocated it on dial in). If you set up a WWW (or any other server), it is totally unknown by any user on the Internet UNLESS they know that your machine is connected AND its actual (current) IP number. There are a number of ways they can get this info, ranging from you ringing them, sending them email to tell them or cunning use of .plan les on a shell account at your service provider (assuming that your provider allows shell and nger access). For most users, this is not a problemall that most people want is to send and receive email (using your account on your service provider) and make outbound connections to WWW, ftp and other servers on the Internet. If you must have inbound connections to your server, you should really get a static IP number. PPP connection les. You now need to be logged in as root to create the directories and edit the les needed to set up PPP. PPP uses a number of les to connect and set up a PPP connection. These differ in name and location between PPP 2.1.2 and 2.2. For PPP 2.1.2 the les are:
/usr/sbin/pppd /usr/sbin/ppp-on /usr/sbin/ppp-off /etc/ppp/options /etc/ppp/options.ttyXX # the PPP binary # the dialer/connection script # the disconnection script # the options pppd uses for all connections # the options specic to a connection on this port
Red Hat Linux users should note that the standard Red Hat 4.X installation places these scripts in /usr/doc/ppp-2.2.0f-2/scripts. In your /etc directory there should be a ppp directory: drwxrwxr-x 2 root root 1024 Oct 9 11:01 ppp
275
TOC
If it does not existcreate it with these ownerships and permissions. If the directory already existed, it should contain a template options le called options.tpl. This le is included below in case it does not. Print it out as it contains an explanation of nearly all the PPP options (these are useful to read in conjunction with the pppd man pages). Whilst you can use this le as the basis of your /etc/ppp/options le, it is probably better to create your own options le that does not include all the comments in the template - it will be much shorter and easier to read/maintain. Some distributions of PPP seem to have lost the options.tpl le. You should examine the PPP-HOWTO document for the complete version. What options should I use? Well, as in all things that depends (sigh). The options specied here should work with most servers. However, if it does NOT work, READ THE TEMPLATE FILE (/etc/ppp/options.tpl) and the pppd man pages and speak to the sysadmin/user support people who run the server to which you are connecting. You should also note that the connect scripts presented here also use some command line options to pppd to make things a bit easier to change.
# /etc/ppp/options (no PAP/CHAP support) # # Prevent pppd from forking into the background -detach # # use the modem control lines modem # use uucp style locks to ensure exclusive access to the serial device lock # use hardware flow control crtscts # create a default route for this connection in the routing table defaultroute # do NOT set up any "escaped" control sequences asyncmap 0 # use a maximum transmission packet size of 552 bytes mtu 552 # use a maximum receive packet size of 552 bytes mru 552 # #-------END OF SAMPLE /etc/ppp/options (no PAP/CHAP support)
276
Advanced Features
TOC
Setting up the PPP connection manually. Now that you have created your /etc/ppp/options and /etc/resolv.conf les (and, if necessary, the /etc/ppp/papchap-secrets le), you can test the settings by manually establishing a PPP connection. (Once we have the manual connection working, we will automate the process). To do this, your communications software must be capable of quitting WITHOUT resetting the modem. Minicom can do this with the sequence Control - A Q Make sure you are logged in as root. Fire up you communications software (such as minicom), dial into the PPP server and log in as normal. If you need to issue a command to start up PPP on the server, do so. You will now see the garbage you saw before. If you are using PAP or CHAP, then merely connecting to the remote system should start PPP on the remote and you will see the garbage without logging in (although this may not happen for some servers - try pressing Enter and see if the garbage starts up). Now quit the communications software without resetting the modem and at the Linux prompt (as root) type
# pppd -d /dev/ttyS0 38400 &
Substituting the name of the device your modem is connected to, of course. The -d option enables debuggingthe PPP connection start-up conversation will be logged to your system logwhich is useful for tracing problems later. Your modem lights should now ash as the PPP connection is established. It will take a short while for the PPP connection to be made. At this point you can look at the PPP interface, by issuing the command
# ifconfig
In addition to any Ethernet and loop back devices you have, you should see something like : ppp0
Link encap:Point-Point Protocol inet addr:10.144.153.104 P-t-P:10.144.153.51 Mask:255.255.255.0 UP POINTOPOINT RUNNING MTU:552 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 TX packets:0 errors:0 dropped:0 overruns:0
277
TOC
Where inet addr:10.144.153.10 is the IP number of your end of the link. P-t-P:10.144.153.5 is the SERVERs IP number. (Ifcong will not report these IP numbers, but the ones used by your PPP server.) Note: ifcong also tells you that the link is UP and RUNNING! You should also be able to see a route to the the remote host (and beyond). To do this, issue the command
# route -n
Window Us 0 0 1 0 3 0
Of particular importance here, notice we have TWO entries pointing to our PPP interface. The rst is a HOST route (indicated by the H ag) and that allows us to see the host to which we are connected tobut no further. The second is the default route (established by giving pppd the option defaultroute. This is the route that tells our Linux PC to send any packets NOT destined for the local Ethernet(s)to which we have specic network routesto the PPP server itself. The PPP server then is responsible for routing our packets out onto the Internet and routing the return packets back to us. If you do not see a routing table with two entries, something is wrong. In particular if your syslog shows a message telling you pppd is not replacing an existing default route, then you have a default route pointing at your Ethernet interfacewhich MUST be replaced by a specic network route: YOU CAN ONLY HAVE ONE DEFAULT ROUTE!!! You will need to explore your system initialization les to nd out where this default route is being set up (it will use a route add default... command). Change this command to something like route add net.... Now test the link by pinging the server at its IP number as reported by the ifcong output, i.e.
278
Advanced Features
TOC
# ping 10.144.153.51
ms ms ms ms
This listing will go on for everto stop it press Control - C , at which point you will receive some more information:
--- 10.144.153.51 ping statistics --4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 170.7/219.2/328.3 ms
Now try pinging a host by name (not the name of the PPP server itself) but a host at another site that you KNOW is probably going to be up and running. For example
# ping sunsite.unc.edu
This time there will be a bit of a pause as Linux obtains the IP number for the fully qualied host name you have pinged from the DNS you specied in /etc/resolv.confso dont worry (but you will see your modem lights ash). Shortly you will receive output like
PING sunsite.unc.edu (152.2.254.81): 56 data bytes 64 bytes from 152.2.254.81: icmp_seq=0 ttl=254 time=190.1 64 bytes from 152.2.254.81: icmp_seq=1 ttl=254 time=180.6 64 bytes from 152.2.254.81: icmp_seq=2 ttl=254 time=169.8 64 bytes from 152.2.254.81: icmp_seq=3 ttl=254 time=170.6 64 bytes from 152.2.254.81: icmp_seq=4 ttl=254 time=170.6
ms ms ms ms ms
Again, stop the output by pressing Control - C and get the statistics...
--- sunsite.unc.edu ping statistics --5 packets transmitted, 5 packets received, 0% packet loss round-trip min/avg/max = 169.8/176.3/190.1 ms
279
TOC
If you dont get any response, try pinging the IP address of the DNS server at your ISPs site. If you get a result from this, then it looks like you have a problem with /etc/resolv.conf. If this doesnt work, you have a routing problem, or your ISP has a problem routing packets back to you. Check your routing table as shown above and if that is OK, contact your ISP. A good test of the ISP is to use another operating system to connect. If you can get beyond your ISP with that, then the problem is at your end. If everything works, shut down the connection by typing
# ppp-off
After a short pause, the modem should hang itself up. If that does not work, either turn off your modem or re up your communications software and interrupt the modem with +++ and then hang up with ATH0 when you receive the modems OK prompt. You may also need to clean up the lock le created by pppd by typing
# rm -f /var/lock/LCK..ttySx
280
Advanced Features
TOC
For the benet of PPP 2.1.2 users, here are BETTER template versions, taken from the PPP 2.2 distribution. I suggest you copy and use these scripts instead of the old PPP-2.1.2 scripts. 15.2. The ppp-on script This is the rst of a PAIR of scripts that actually re up the connection.
#!/bin/sh # # Script to initiate a PPP connection. This is the first part of the # pair of scripts. This is not a secure pair of scripts as the codes # are visible with the ps command. However, it is simple. # # These are the parameters. Change as needed. TELEPHONE=555-1212 # The telephone number for the connection ACCOUNT=george # The account name for logon (as in George Burns) PASSWORD=gracie # The password for this account (and Gracie Allen) LOCAL_IP=0.0.0.0 # Local IP address if known. Dynamic = 0.0.0.0 REMOTE_IP=0.0.0.0 # Remote IP address if desired. Normally 0.0.0.0 NETMASK=255.255.255.0 # The proper netmask if needed # # Export them so that they will be available to ppp-on-dialer export TELEPHONE ACCOUNT PASSWORD # # This is the location of the script which dials the phone and logs # in. Please use the absolute file name as the $PATH variable is not # used on the connect option. (To do so on a root account would be # a security hole so dont ask.) # DIALER_SCRIPT=/etc/ppp/ppp-on-dialer # # Initiate the connection # # exec /usr/sbin/pppd debug /dev/ttySx 38400 \ $LOCAL_IP:$REMOTE_IP \ connect $DIALER_SCRIPT
281
TOC
# This is part 2 of the ppp-on script. It will perform the connection # protocol for the desired connection. # /usr/sbin/chat -v \ TIMEOUT 3 \ ABORT \nBUSY\r \ ABORT \nNO ANSWER\r \ ABORT \nRINGING\r\n\r\nRINGING\r \ \rAT \ OK-+++\c-OK ATH0 \ TIMEOUT 30 \ OK ATDT$TELEPHONE \ CONNECT \ ogin:--ogin: $ACCOUNT \ assword: $PASSWORD
#!/bin/sh ###################################################################### # # Determine the device to be terminated. # if [ "$1" = "" ]; then DEVICE=ppp0 else DEVICE=$1 fi
###################################################################### # # If the ppp0 pid file is present then the program is running. Stop it if [ -r /var/run/$DEVICE.pid ]; then kill -INT cat /var/run/$DEVICE.pid # # If the kill did not work then there is no process running for this # pid. It may also mean that the lock file will be left. You may wish # to delete the lock file at the same time. if [ ! "$?" = "0" ]; then rm -f /var/run/$DEVICE.pid echo "ERROR: Removed stale pid file"
282
Advanced Features
TOC
exit 1 fi # # Success. Let pppd clean up its own junk. echo "PPP link to $DEVICE terminated." exit 0 fi # # The ppp process is not running for ppp0 echo "ERROR: PPP link is not active on $DEVICE" exit 1
283
TOC
A chat script is a sequence of expect string send string pairs. In particular, note that we ALWAYS expect something before we send something. If we are to send something WITHOUT receiving anything rst, we must use an empty expect string (indicated by ) and similarly for expecting something without sending anything! Also, if a string consists of several words, (e.g. NO CARRIER), you must quote the string so that it is seen as a single entity by chat. The chat line in our template is:
exec /usr/sbin/chat -v
Invoke chat, the -v tells chat to copy ALL its I/O into the system log (usually /var/log/messages). Once you are happy that the chat script is working reliably, edit this line to remove the -v to save unnecessary clutter in your syslog.
TIMEOUT 3
This sets the timeout for the receipt of expected input to three seconds. You may need to increase this to say 5 or 10 seconds if you are using a really slow modem!
ABORT \nBUSY\r
Expect nothing from the modem and send the string AT.
OK-+++\c-OK ATH0
284
Advanced Features
TOC
This one is a bit more complicated as it uses some of chats error recovery capabilities. What is says is...Expect OK, if it is NOT received (because the modem is not in command mode) then send +++ (the standard Hayes-compatible modem string that returns the modem to command mode) and expect OK. Then send ATH0 (the modem hang up string). This allows your script to cope with the situation of your modem being stuck on-line!
TIMEOUT 30
Set the timeout to 30 seconds for the remainder of the script. If you experience trouble with the chat script aborting due to timeouts, increase this to 45 seconds or more.
OK ATDT$TELEPHONE
Expect OK (the modems response to the ATH0 command) and dial the number we want to call.
CONNECT
Expect CONNECT (which our modem sends when the remote modem answers) and send nothing in reply.
ogin:--ogin: $ACCOUNT
Again, we have some error recovery built in here. Expect the login prompt (...ogin:) but if we dont receive it by the timeout, send a return and then look for the login prompt again. When the prompt is received, send the username (stored in the shell variable $ACCOUNT).
assword: $PASSWORD
Expect the password prompt and send our password (again, stored in a shell variable). This chat script has reasonable error recovery capability. Chat has considerably more features than demonstrated here. For more information consult the chat manual page (man 8 chat).
285
TOC
At the END of the script (after the password line) add an additional expect send pair this one would look for your login prompt (beware of characters that have a special meaning in the Bourne shell, like
$[]
Once chat has found the shell prompt, chat must issue the ppp start up command required for your ISPs PPP server. In one authors case, the PPP server uses the standard Linux Bash prompt
[hartr@kepler hartr]$
to start up PPP on the server. It is a good idea to allow for a bit of error recovery here, so use
hartr--hartr ppp
This says, if we dont receive the prompt within the timeout, send a carriage return and looks for the prompt again. Once the prompt is received, then send the string ppp. Note: dont forget to add a to the end of the previous line so chat still thinks the entire chat script is on one line! Unfortunately, some servers produce a very variable set of prompts! You may need to log in several times using minicom to understand what is going on and pick the stable expect strings.
286
Advanced Features
TOC
# # If you are running a PPP *server* and need to force PAP or CHAP # uncomment the appropriate one of the following lines. Do NOT use # these is you are a client connecting to a PPP server (even if it uses PAP # or CHAP) as this tells the SERVER to authenticate itself to your # machine (which almost certainly cant do---and the link will fail). #+chap #+pap # # If you are using ENCRYPTED secrets in the /etc/ppp/pap-secrets # file, then uncomment the following line. # Note: this is NOT the same as using MS encrypted passwords as can be # set up in MS RAS on Windows NT. #+papcrypt
The critical information here is auth chap 80. In order to use MS CHAP, you will need to recompile pppd to support this. Please see the instructions in the README.MSCHAP80 le in the PPP source le for instructions on how to compile and use this variation. If you are using pap or chap authentication, then you also need to create the secrets le. These are 1)/etc/ppp/pap-secrets and 2)/etc/ppp/chap-secrets. They must be owned by user root, group root and have le permissions 740 for security. The rst point to note about PAP and CHAP is that they are designed to authenticate computer systems not users. In other words, once your computer has made its PPP connection to the server, ANY user on your system can use that connectionnot just you. PAP can (and for CHAP DOES) require bidirectional authenticationthat is a valid name and secret is required on each computer for the other computer involved. However, this is NOT the way most PPP servers offering dial up PPP PAP-authenticated connections operate.
287
TOC
That being said, your ISP will probably have given you a user name and password to allow you to connect to their system and thence the Internet. Your ISP is not interested in your computers name at all, so you will probably need to use the user name at your ISP as the name for your computer. This is done using the name user name option to pppd. So, if you are to use the user name given you by your ISP, add the line name your_user name_at_your_ISP to your /etc/ppp/options le. Technically, you should really use user our user name at your ISP for PAP, but pppd is sufciently intelligent to interpret name as user if it is required to use PAP. The advantage of using the name option is that this is also valid for CHAP. As PAP is for authenticating computers, technically you need also to specify a remote computer name. However, as most people only have one ISP, you can use a wild card (*) for the remote host name in the secrets le. The /etc/ppp/pap-secrets le looks like # Secrets for authentication using PAP # client server secret
acceptable_local_IP_address
The four elds are white space delimited and the last one can be blank (which is what you want for a dynamic and probably static IP allocation from your ISP). Suppose your ISP gave you a user name of fred and a password of intstone you would set the name fred option in /etc/ppp/options and set up your /etc/ppp/pap-secrets le as follows # Secrets for authentication using PAP # client server secret fred * flintstone
This says for the local machine name fred (which we have told pppd to use even though it is not our local machine name) and for ANY server, use the password (secret) of intstone. Note that we do not need to specify a local IP address, unless we are required to FORCE a particular local, static IP address. Even if you try this, it is unlikely to work as most PPP servers (for security reasons) do not allow the remote system to set the IP number they are to be given. This requires that you have mutual authentication methodsthat is you must allow for both your machine to authenticate the remote server AND the remote server to authenticate your machine.
288
Advanced Features
TOC
So, if your machine is fred and the remote is barney, your machine would set name fred remotename barney and the remote machine would set name barney remotename fred in their respective /etc/ppp/options.ttySx les. The /etc/chap-secrets le for fred would look like # Secrets for authentication using CHAP # client server secret fred barney flintstone barney fred wilma and for barney # Secrets for authentication using CHAP # client server secret barney fred flintstone fred barney wilma
Note in particular that both machines must have entries for bidirectional authentication. This allows the local machine to authenticate itself to the remote AND the remote machine to authenticate itself to the local machine. A chat script for PAP/CHAP authenticated connections. If your ISP is using PAP/CHAP, then your chat script is much simpler. All your chat script needs to do is dial the telephone, wait for a connect and then let pppd handle the logging in!
#!/bin/sh # # This is part 2 of the ppp-on script. It will perform the connection # protocol for the desired connection. # exec /usr/sbin/chat -v \ TIMEOUT 3 \ ABORT \nBUSY\r \ ABORT \nNO ANSWER\r \ ABORT \nRINGING\r\n\r\nRINGING\r \ \rAT \ OK-+++\c-OK ATH0 \ TIMEOUT 30 \ OK ATDT$TELEPHONE \ CONNECT \
289
TOC
As we have already seen, you can turn on debug information logging with the -d option to pppd. The debug option is equivalent to this. As we are establishing a new connection with a new script, leave in the debug option for now. (Warning: if your disk space is tight, logging pppd exchanges can rapidly extend your syslog le and run you into troublebut to do this you must fail to connect and keep on trying for quite a few minutes). Once you are happy that all is working properly, then you can remove this option.
exec /usr/sbin/pppd debug file options.myserver /dev/ttyS0 38400 \
Testing the connection script. Open a new root Xterm (if you are in X) or open a new virtual console and log in as root. In this new session, issue the command
# tail -f /var/log/messages
Many systems log output to /var/log/messages. If it has a different name on your system, substitute the name of your system log le in the command above. In the rst window (or virtual console) issue the command
# ppp-on &
(or whatever name you have called your edited version of /usr/sbin/ppp-on). If you do not put the script into the background by specifying & at the end of the command, you will not get your terminal prompt back until ppp exits (when the link terminates). Now switch back to the window that is tracking your system log.
290
Advanced Features
TOC
You could of course do the individual a favour and educate then about Linux (any ISP help desk person should be reasonably with it in Internet terms and that means they should have a home Linux boxof course it does)! Address resolution problems. OKyour PPP connection is up and running and you can ping the PPP server by IP number (the second or remote IP number shown by ifcong ppp0), but you cant reach anything beyond this. First of all, try pinging the IP numbers you have specied in /etc/resolv.conf as name servers. If this works, you can see beyond your PPP server (unless this has the same IP number as the remote IP number of your connection). So now try pinging the full Internet name of your service provider
ping my.isp.net
Substituting, of course, the name of your actual ISP. If this does not work, you have a problem with name resolution. This is probably because of a typo in your /etc/resolv.conf le. Check this le carefully against the information in the sample /etc/resolve.conf le in section 6.1.1. If it still doesnt work (and your service provider conrms that his name servers are up and running), you have a problem somewhere elseand check carefully through your Linux installation (looking particularly at le permissions). If you still cant ping your service providers IP name servers by IP number, either they are down (give them a voice call and check) or there is a routing problem at your service providers end. One possibility is that the remote end is a Linux PPP server where the IP forwarding option has not been specied in the kernel! Debugging a failed attempt. There are any number of reasons that your connection does not work chat has failed to complete correctly, you have a dirty line, etc. So check your syslog for indications. A very common problem is that people compile PPP support into the kernel and yet when they try to run pppd, the kernel complains that it does not support ppp! There are a variety of reasons this can occur. You failed to boot the new kernel that you compiled with PPP support. You failed to install the PPP module that you compiled. You expected modules to be loaded automatically and they arent.
291
TOC
You are using the incorrect version of PPP for your kernel. You are not running pppd as root. You mistyped something in your startup scripts. You are not correctly logging into the server. You are not starting PPP on the server. The remote PPP process is slow to start. Default route not set. And a host of others. Look in the PPP FAQ (which is really a series of questions and answers). This is a very comprehensive document and the answers are there! If the answer to your problems is not there, the problem is not ppps fault! Getting help when totally stuck. If you cant get your PPP link to work, go back through this document and check everythingin conjunction with the output created by chat-v... and pppd -d in you system log. Also consult the PPP documentation and FAQ plus the other documents mention herein! If you are still stuck, try the comp.os.linux.misc and comp.os.linux.networking newsgroups are reasonably regularly scanned by people that can help you with PPP as is comp.protocols.ppp If you do choose to seek help in the USENET newsgroups, please dont post a very long message consisting of debugging output. This wastes huge amounts of network bandwidth. It is much better to describe the problem and perhaps include a few lines of debugging output (denitely no more than one screenful).
292
Advanced Features
TOC
The Linux Network Administrators Guide contains complete information on conguring and using UUCP under Linux. Also, the Linux UUCP HOWTO, available via anonymous FTP from sunsite.unc.edu, should be of help. Another source of information on UUCP is the book Managing UUCP and USENET, by Tim OReilly and Grace Todino. See Appendix A for more information.
293
TOC
Linux and how to congure it on your system. If you plan to send mail remotely, youll need to understand either TCP/IP or UUCP, depending on how your machine is networked (see Sections 6.1 and 6.3). The UUCP and TCP/IP documents listed in Appendix A should be of help there. Most of the Linux mail software can be retrieved via anonymous FTP from sunsite.unc.edu in the directory /pub/Linux/system/Mail.
294
Advanced Features
TOC
news articles on disk. Here are some possible scenarios for news conguration. You run news locally. That is, you have no network connection, or no desire to run news over the network. In this case, you need to run C News or INN on your machine, and install a news reader to read the news locally. You have access to a TCP/IP network and an NNTP server. If your organization has an NNTP news server set up, you can read and post news from your Linux machine by simply installing an NNTP-based news reader. (Most news readers available can be congured to run locally or use NNTP). In this case, you do not need to install a news server or store news articles on your system. The news reader will take care of reading and posting news over the network. Of course, you will need to have TCP/IP congured and have access to the network (see Section 6.1). You have access to a TCP/IP network but have no NNTP server. In this case, you can run an NNTP news server on your Linux system. You can install either a local or an NNTP-based news reader, and the server will store news articles on your system. In addition, you can congure the server to communicate with other NNTP news servers to transfer news articles. You want to transfer news using UUCP. If you have UUCP access (see Section 6.3), you can participate in Usenet as well. You will need to install a (local) news server and a news reader. In addition, you will need to congure your UUCP software to periodically transfer news articles to another nearby UUCP machine (known as your news feed). UUCP does not use NNTP to transfer news; simply, UUCP provides its own mechanism for transferring news articles. Most of the standard news software (available via anonymous FTP from ftp.uu.net in the directory /news) will compile out-of-the box on Linux. Necessary patches can be found on sunsite.unc.edu in /pub/Linux/system/Mail (which is, incidentally, also where mail software for Linux is found). Other news binaries for Linux may be found in this directory as well. For more information, refer to the Linux News HOWTO from sunsite.unc.edu in /pub/Linux/docs/HOWTO. Also, the LDPs Linux Network Administrators Guide contains complete information on conguring news software for Linux. The book Managing UUCP and Usenet, by Tim OReilly and Grace Todino, is an excellent guide to setting up UUCP and news software. Also of interest is the Usenet docu-
295
TOC
ment How to become a Usenet site, available from ftp.uu.net, in the directory /usenet/news.announce.newusers.
TOC
Appendix A
Online documents.
These documents should be available on any of the Linux FTP archive sites (see Appendix B for a list). If you do not have direct access to FTP, you may be able to locate these documents on other online services (such as CompuServe, local BBSs, and so on). If you have access to Internet mail, you can use the ftpmail service to receive these documents. See Appendix B for more information. In particular, the following documents may be found on sunsite.unc.edu in the directory /pub/Linux/docs. Many sites mirror this directory; however, if youre unable to locate a mirror site near you, this is a good one to fall back on. The Linux Frequently Asked Questions with Answers The Linux Frequently Asked Questions list, or FAQ, is a list of common questions (and answers!) about Linux. This document is meant to provide a general source of information about Linux, common problems and solutions, and a list of other sources of information. Every new Linux user should read this document. It is available in a number of for296
297
TOC
mats, including plain ASCII, PostScript, and HTML. The Linux FAQ is maintained by Roert Kiesling, [email protected]. The Linux META-FAQ The META-FAQ is a collection of metaquestions about Linux; that is, sources of information about the Linux system, and other general topics. It is a good starting place for the Internet user wishing to nd more information about the system. It is maintained by Michael K. Johnson, [email protected]. The Linux INFO-SHEET The Linux INFO-SHEET is a technical introduction to the Linux system. It gives an overview of the systems features and available software, and also provides a list of other sources of Linux information. The format and content is similar in nature to the META-FAQ; incidentally, it is also maintained by Michael K. Johnson. Linux Journal Linux Journal makes selected articles from the magazine (published monthly) available in electronic form from their web site, http://www.linuxjournal.com/. Articles cover topics for beginning to advanced users, include features about Linux being used in the real world, and the frequently referenced Linux distribution comparison articles and tables. A free on-line publication found at http://www.linuxgazette.com/, Linux Gazette offers answers and entertainment, making Linux just a little more fun. The Gazette is produced by SSC, the publishers of Linux Journal. Contact [email protected] for more information.
Linux Gazette
Linux Resources The Linux Resources (http://www.linuxresources.com/) cover What it is, where to get it, how to nd all the information you need to get it running and much more. What it is, where to get it, how to nd all the information you need to get it running and much more. The Linux Software Map The Linux Software Map is a list of many applications available for
298
Appendix
TOC
Linux, where to get them, who maintains them, and so forth. It is far from completeto compile a complete list of Linux software would be nearly impossible. However, it does include many of the most popular Linux software packages. If you cant nd a particular application to suit your needs, the LSM is a good place to start. It is maintained by Lars Wirzenius, [email protected]. The Linux HOWTO Index The Linux HOWTOs are a collection of how to documents, each describing in detail a certain aspect of the Linux system. They are maintained by Matt Welsh, [email protected]. The HOWTO-Index lists the HOWTO documents which are available. Other online documents If you browse the docs subdirectory of any Linux FTP site, youll see many other documents which are not listed here: A slew of FAQs, interesting tidbits, and other important information. This miscellany is difcult to categorize here; if you dont see what youre looking for on the list above, just take a look at one of the Linux archive sites listed in Appendix B.
299
TOC
The Linux Kernel Hackers Guide, an interactive, edited forum where Linux kernel developers talk about kernel development issues. Special HOWTOs, HOWTO documents that rely on things that cannot be supported in plain text versions. In addition to the LDP web pages, there are four basic types of documentation produced by the LDP: Guides, HOWTOs and mini-HOWTOs, man pages, and FAQs. Guides Entire books on complex topics. HOWTOs and mini-HOWTOs Documents with full coverage of a fairly well-dened topic or simple coverage, usually of a single task. man pages Documentation for single programs, le formats, and library functions in standard UNIX reference format. FAQs Frequently Asked Questions on verious topics, including the Linux FAQ. If you have comments about any particular document in this set, feel free to send it to the author. All documents have the authors email address to send comments to, and while the authors may not always have time to respond, they do read and consider thoughtful comments on their work. Your comments help make the next versions of these documents better. If you have comments or questions about the LDP in general, please contact Greg Hankins via email at [email protected] .
300
Appendix
TOC
call +1 206 782-7733, or toll free 1-888-66-Linux in North America. Their FAX number is +1 206 782-7191, and e-mail address is [email protected]. You can also nd a Linux Journal FAQ and sample articles via anonymous FTP on sunsite.unc.edu in /pub/Linux/docs/linux-journal. As we have said, not many books have been published dealing with Linux specically. However, if you are new to the world of UNIX, or want more information than is presented here, we suggest that you take a look at the following books which are available.
Linux Titles.
Title: Author: Publisher: ISBN: The Complete Linux Kit Stefan Strobel, Rainer Maurer, Stefan Middendorf, Volker Elling Springer Verlag, 1997 0387142371, $59.95
Publisher desription: This two-volume, four-CD-ROM bundle consists of Linux Universe: Installation and Conguration and Linux: Unleashing the Workstation in Your PC. The former is a book/CD-ROM package which includes a full installable version of Linux 2.0 and a detailed installation guide for that version. The latter is a highly detailed guide to installing and administering any Linux system along with a host of Linux tools and applications. Title: Author: Publisher: ISBN: Linux: Installation, Conguration, and Use Michael Koer Addison-Wesley, 1997 0201178095, $34.95
Publisher Description: A comprehensive and practical guide, this book covers the installation, conguration and use of Linux. Michael Koer walks readers through installation to simple administration and the use of Emacs editor, LaTeX typesetting, and the Tcl/Tk programming language. The CDROM contains RedHat Linux 4.1 and complete kernel sources for versions 2.0.29 and 2.1.28.
301
TOC
Title: Author: Publisher: ISBN: Linux: Conguration and Installation (3rd Edition) Patrick Volkerding IDG Books, 1997 1558285660, $39.95
Summary: Our 2-CD-ROM pack offers one of the most popular Linux distributions, Slackware 96, and comes directly from Patrick Volkerding, the creator of Salckware. Provides you with undocumented tips and techniques for setting up, using, and optimizing your Linux system. Title: Author: Publisher: ISBN: Linux in Plain English Patrick Volkerding, Kevin Reichard IDG Books, 1997 1558285423 , $19.95
Includes detailed listings of all Linux commands, covering the GNU command set and the Linux Bash Shell, le manipulation, text processing, printing, the Internet, and FTP and system administration. Title: Author: Publisher: ISBN: Linux for Dummies (1st Ed) Craig Witherspoon, Coletta Witherspoon IDG Books, 1998 0764502751 , $24.99 A beginners book on Linux Title: Author: Publisher: ISBN: Linux for Dummies Quick Reference Phil Hughes IDG Books, 1998 0764503022, $14.99
302
Appendix
TOC
Publisher Description: This Quick Reference is a handy guide to the most commonly used Linux commands and tasks, emphasizing the most popular text editors, Windows interfaces, and Linux avors. The book covers the shell commands, basic shell scripting commands, and common networking and administration commands. Title: Author: Publisher: ISBN: Discover Linux (1st Ed) Steve Oualline IDG Books, 1997 0764531050 , $24.99
Publisher Description: Users who know UNIX and want to learn and use Linux will nd what they need to know in this title. Different types of audiences include programmers, network administrators, people who need an easy Internet/Web connection, users who need a secure rewall machine, and game players. The CD-ROM includes the popular and easy-to-install RedHat Linux 4.1 distribution. Title: Author: Publisher: ISBN: Complete Red Hat Linux Resource Kit C/Dos/Us Collective Work Macmillan Digital, 1997 0672310570 , $64.99
Publisher Description: Turn your PC into a powerful UNIX workstation! Red Hat Linux is the hottest implementation of the Linux operating system. This collection includes the softwares latest version, plus everything else you need to run the popular 32-bit UNIX operating system. Features the easiest installation of any Linux system, more than 180 Linux programs, and an RPM manager allowing new version updates without system reinstallation. Also comes with Apache web server, games and 250-page user guide. Title: Author: Running Linux (2nd Edition) Matt Welsh, Lar Kaufman
303
TOC
Publisher: ISBN: OReilly and Associates, 1996 1565921518 , $29.95
Publisher Description: This second edition of Running Linux covers everything you need to understand, install, and start using the Linux operating system. It includes a comprehensive installation tutorial, complete information on system maintenance, tools for document development and programming. Title: Author: Publisher: ISBN: Linux: Installation, Conguration, and Use Michael Koer Addison-Wesley Pub Co, 1997 0201178095 , $34.95
Publisher Description: A comprehensive and practical guide, this book covers the installation, conguration and use of Linux. Michael Koer walks readers through installation to simple administration and the use of Emacs editor, LaTeX typesetting, and the Tcl/Tk programming language. The CDROM contains RedHat Linux 4.1 and complete kernel sources for versions 2.0.29 and 2.1.28. Title: Author: Publisher: ISBN: The No B.S. Guide to Linux Bob Rankin No Starch Press, 1997 1886411042 , $34.95
Publisher Description: This guide provides all the information new users need without burying them in history lessons and technical details. The question-and-answer format of this guide lets readers troubleshoot problems, discover taskbar tricks and shortcuts, and make the transition to a new system as smooth as possible. Title: Linux Start-Up Guide : A Self-Contained Introduction
304
Appendix
TOC
Author: Publisher: ISBN: Fred Hantelmann, A. Faber (Translator) Springer Verlag, 1997 354062676X , $28.00
Publisher Description: This systematic overview for beginners, system administrators, and new users of Linux gives the full details of operating system architecture, basic Linux commands, and typical development and application packages.
Using UNIX.
Title: Author: Publisher: ISBN: Learning the UNIX Operating System Grace Todino & John Strang OReilly and Associates, 1987 0-937175-16-1, $9.00
A good introductory book on learning the UNIX operating system. Most of the information should be applicable to Linux as well. I suggest reading this book if youre new to UNIX and really want to get started with using your new system. Title: Author: Publisher: ISBN: Learning the vi Editor Linda Lamb OReilly and Associates, 1990 0-937175-67-6, $21.95
This is a book about the vi editor, a powerful text editor found on every UNIX system in the world. Its often important to know and be able to use vi, because you wont always have access to a real editor such as Emacs. Title: Author: VI Tutorial Belinda Frazier
305
TOC
Publisher: ISBN: Specialized Systems Consultants 0-916151-54-9, $6.00
This tutorial provides explanations of examples of vi commands. While some long-time vi users have reported they learned something new the rst time they read the VI Tutorial, it is geared towards beginning and intermediate vi users. Title: Author: Publisher: ISBN: Bourne Shell Tutorial Phil Hughes Specialized Systems Consultants 0-916151-39-5, $6.00
This tutorial explains many of the capabilities of the standard UNIX System V shell, commonly called the Bourne Shell. Included is a 4-page reference guide of the commands built into the shell and a 3-page summary of some of the commonly used UNIX commands.
System Administration.
Title: Author: Publisher: ISBN: Essential System Administration leen Frisch OReilly and Associates, 1991 0-937175-80-3, $29.95
From the OReilly and Associates Catalog, Like any other multi-user system, UNIX requires some care and feeding. Essential System Administration tells you how. This book strips away the myth and confusion surrounding this important topic and provides a compact, manageable introduction to the tasks faced by anyone responsible for a UNIX system. I couldnt have said it better myself. Title: Samba: Integrating UNIX and Windows
306
Appendix
TOC
Author: Publisher: ISBN: John D. Blair Specialized Systems Consultants 1-57831-006-7, $29.95
Samba is the tool of choice for providing Windows le sharing and printer services from UNIX and UNIX-like systems. Freely available under the GNU Public License, Samba allows UNIX machines to be seamlessly integrated into a Windows network without installing any additional software on the Windows machines. Used in tandem with Linux or FreeBSD, Samba provides a low-cost alternative to the Windows NT Server. Title: Author: Publisher: ISBN: TCP/IP Network Administration Craig Hunt OReilly and Associates, 1990 0-937175-82-X, $24.95
A complete guide to setting up and running a TCP/IP network. While this book is not Linux-specic, roughly 90% of it is applicable to Linux. Coupled with the Linux NET-2-HOWTO and Linux Network Administrators Guide, this is a great book discussing the concepts and technical details of managing TCP/IP. Title: Author: Publisher: ISBN: Managing UUCP and Usenet Tim OReilly and Grace Todino OReilly and Associates, 1991 0-937175-93-5, $24.95
This book covers how to install and congure UUCP networking software, including conguration for USENET news. If youre at all interested in using UUCP or accessing USENET news on your system, this book is a must-read.
307
A complete tutorial and reference guide to using the X Window System. If you installed X windows on your Linux system, and want to know how to get the most out of it, you should read this book. Unlike some windowing systems, a lot of the power provided by X is not obvious at rst sight.
Programming.
Title: Author: Publisher: ISBN: The C Programming Language Brian Kernighan and Dennis Ritchie Prentice-Hall, 1988 0-13-110362-8, $25.00
This book is a must-have for anyone wishing to do C programming on a UNIX system. (Or any system, for that matter.) While this book is not obstensibly UNIX-specic, it is quite applicable to programming C under UNIX. Title: Author: Publisher: ISBN: The Unix Programming Environment Brian Kernighan and Bob Pike Prentice-Hall, 1984 0-13-937681-X, $40.00
An overview to programming under the UNIX system. Covers all of the tools of the trade; a good read to get acquainted with the somewhat amorphous UNIX programming world. Title: Advanced Programming in the UNIX Environment
308
Appendix
TOC
Author: Publisher: ISBN: W. Richard Stevens Addison-Wesley 0-201-56317-7, $50.00
This mighty tome contains everything that you need to know to program UNIX at the system levelle I/O, process control, interprocess communication, signals, terminal I/O, the works. This book focuses on various UNI standards, including POSIX.1, which Linux mostly adheres to.
Kernel hacking.
Title: Author: Publisher: ISBN: Inside Linux: A Look at Operating System Development Randolph Bentson Specialized Systems Consultants 0-916151-89-1, $22.00
This book provides an informal introduction to a number of operating system issues by looking at the history of operating systems, by looking at how they are used, and by looking at the details of one operating system. The contents are a conscious effort to braid discussion of history, theory and practice so that the reader can see what goes on inside the system. Title: Author: Publisher: ISBN: The Design of the UNIX Operating System Maurice J. Bach Prentice-Hall, 1986 0-13-201799-7, $70.00
This book covers the algorithms and internals of the UNIX kernel. It is not specic to any particular kernel, although it does lean towards System V-isms. This is the best place to start if you want to understand the inner tickings of the Linux system. Title: The Magic Garden Explained
309
TOC
Author: Publisher: ISBN: Berny Goodheart and James Cox Prentice-Hall, 1994 0-13-098138-9, $53.00
This book describes the System V R4 kernel in detail. Unlike Bachs book, which concentrates heavily on the algorithms which make the kernel tick, this book presents the SVR4 implementation on a more technical level. Although Linux and SVR4 are distant cousins, this book can give you much insight into the workings of an actual UNIX kernel implementation. This is also a very modern book on the UNIX kernelpublished in 1994. Title: Author: Publisher: ISBN: Linux Kernel Internals Michael Beck Addison-Wesley, 1997 0201331438, $41.95 A look at the code and technical details of the Linux Kernel
TOC
Appendix B
311
TOC
Starting ftp
Note that in the example screens printed below Im only showing the most important information, and what you see may differ. Also, commands in italics represent commands that you type; everything else is screen output. To start ftp and connect to a site, simply use the command
ftp hostname
where hostname is the name of the site you are connecting to. For example, to connect to the mythical site shoop.vpizza.com we can use the command
ftp shoop.vpizza.com
Logging In
When ftp starts up we should see something like
Connected to shoop.vpizza.com. 220 Shoop.vpizza.com FTPD ready at 15 Dec 1992 08:20:42 EDT Name (shoop.vpizza.com:mdw):
Here, ftp is asking us to give the username that we want to login as on shoop.vpizza.com. The default here is mdw, which is my username on the system Im using FTP from. Since I dont have an account on shoop.vpizza.com I cant login as myself. Instead, to access publicly-available software on an FTP site you login as anonymous, and give your Internet e-mail address (if you have one) as the password. So, we would type
Name (shoop.vpizza.com:mdw): Password: [email protected] Download pizza in 30 anonymous
331-Guest login ok, send e-mail address as password. 230- Welcome to shoop.vpizza.com. 230- Virtual Pizza Delivery[tm]: cycles or less 230- or you get it FREE! ftp>
312
Appendix
TOC
Of course, you should give your e-mail address, instead of mine, and it wont echo to the screen as youre typing it (since its technically a password). ftp should allow us to login and well be ready to download software.
Poking Around
Okay, were in. ftp> is our prompt, and the ftp program is waiting for commands. There are a few basic commands you need to know about. First, the commands
ls le
and
dir le
both give le listings (where le is an optional argument specifying a particular le name to list). The difference is that ls usually gives a short listing and dir gives a longer listing (that is, with more information on the sizes of the les, dates of modication, and so on). The command
cd directory
will move to the given directory (just like the cd command on Unix or MS-DOS systems). You can use the command
cdup
will give help on the given ftp command (such as ls or cd). If no command is specied, ftp will list all of the available commands. If we type dir at this point well see an initial directory listing of where we are.
ftp> dir 200 PORT command successful. 150 Opening ASCII mode data connection for /bin/ls. total 1337
1 The directory above the current one.
313
TOC
dr-xr-xr-x 2 root drwxr-xr-x 2 root drwxr-xr-x 2 root drwxr-xr-x 19 root drwxrwx-wx 4 root drwxr-xr-x 3 root 226 Transfer complete. 921 bytes received in 0.24 seconds (3.7 Kbytes/s) ftp> wheel wheel wheel wheel ftp-admi wheel 512 512 512 1024 1024 512 Aug Aug Jan Jan Feb Mar 13 13 25 27 6 11 13:55 13:58 17:35 21:39 22:10 1992 bin dev etc pub uploads usr
Each of these entries is a directory, not an individual le which we can download (specied by the d in the rst column of the listing). On most FTP archive sites, the publicly available software is under the directory /pub, so lets go there.
ftp> cd pub ftp> dir 200 PORT command successful. 150 ASCII data connection for /bin/ls (128.84.181.1,4525) (0 bytes). total 846
-rw-r--r--r--r--r--rw-r--r--r--r--r--rw-r--r--rw-r--r--rw-rw-rw-r--r--r--rw-r--r-drwxr-xr-x -rw-r--r--
1 1 1 1 1 1 1 1 1 2 1
root 3807 539 65534 root 432 615 root root 2195 root
staff staff staff 65534 other staff staff wheel staff staff staff
1433 15586 52664 56456 2013041 41831 50315 12168 7035 512 5593
Jul May Feb Dec Jul Jan Apr Dec Aug Mar Jul
12 1988 README 13 1991 US-DOMAIN.TXT.2 20 1991 altenergy.avail 17 1990 ataxx.tar.Z 3 1991 gesyps.tar.Z 30 1989 gnexe.arc 16 1992 linpack.tar.Z 25 1990 localtime.o 27 1986 manualslist.tblms 10 00:48 mdw 19 1988 t.out.h
226 ASCII Transfer complete. 2443 bytes received in 0.35 seconds (6.8 Kbytes/s) ftp>
Here we can see a number of (interesting?) les, one of which is called README, which we should download (most FTP sites have a README le in the /pub directory).
314
Appendix
TOC
Downloading les
Before downloading les, there are a few things that you need to take care of. Turn on hash mark printing. Hash marks are printed to the screen as les are being transferred; they let you know how far along the transfer is, and that your connection hasnt hung up (so you dont sit for 20 minutes, thinking that youre still downloading a le). In general, a hash mark appears as a pound sign (#), and one is printed for every 1024 or 8192 bytes transferred, depending on your system. To turn on hash mark printing, give the command hash.
ftp> hash Hash mark printing on (8192 bytes/hash mark). ftp>
Determine the type of le which you are downloading. As far as FTP is concerned, les come in two avors: binary and text. Most of the les which youll be downloading are binary les: that is, programs, compressed les, archive les, and so on. However, many les (such as READMEs and so on) are text les. Why does the le type matter? Only because on some systems (such as MS-DOS systems), certain characters in a text le, such as carriage returns, need to be converted so that the le will be readable. While transferring in binary mode, no conversion is donethe le is simply transferred byte after byte. The commands bin and ascii set the transfer mode to binary and text, respectively. When in doubt, always use binary mode to transfer les. If you try to transfer a binary le in text mode, youll corrupt the le and it will be unusable. (This is one of the most common mistakes made when using FTP.) However, you can use text mode for plain text les (whose le names often end in .txt). For our example, were downloading the le README, which is most likely a text le, so we use the command
ftp> ascii 200 Type set to A. ftp>
Set your local directory. Your local directory is the directory on your system where you want the downloaded les to end up. Whereas the cd command changes the re-
315
TOC
mote directory (on the remote machine which youre FTPing to), the lcd command changes the local directory. For example, to set the local directory to /home/db/mdw/tmp, use the command
ftp> lcd /home/db/mdw/tmp Local directory now /home/db/mdw/tmp ftp>
is used for this, where remote-name is the name of the le on the remote machine, and local-name is the name that you wish to give the le on your local machine. The localname argument is optional; by default, the local le name is the same as the remote one. However, if for example youre downloading the le README, and you already have a README in your local directory, youll want to give a different local-lename so that the rst one isnt overwritten. For our example, to download the le README, we simply use
ftp> get README 200 PORT command successful. 150 ASCII data connection for README (128.84.181.1,4527) (1433 bytes). # 226 ASCII Transfer complete. local: ftp> README remote: README 1493 bytes received in 0.03 seconds (49 Kbytes/s)
Quitting FTP
To end your FTP session, simply use the command
quit
The command
close
316
Appendix
TOC
can be used to close the connection with the current remote FTP site; the open command can then be used to start a session with another site (without quitting the FTP program altogether).
ftp> close 221 Goodbye. ftp> quit
Using ftpmail
ftpmail is a service which allows you to obtain les from FTP archive sites via Internet electronic mail. If you dont have direct Internet access, but are able to send mail to the Internet (from a service such as CompuServe, for example), ftpmail is a good way to get les from FTP archive sites. Unfortunately, ftpmail can be slow, especially when sending large jobs. Before attempting to download large amounts of software using ftpmail, be sure that your mail spool will be able to handle the incoming trafc. Many systems keep quotas on incoming electronic mail, and may delete your account if your mail exceeds this quota. Just use common sense. sunsite.unc.edu, one of the major Linux FTP archive sites, is home to an ftpmail server. To use this service, send electronic mail to
[email protected]
This will send you back a list of ftpmail commands and a brief tutorial on using the system. For example, to get a listing of Linux les found on sunsite.unc.edu, send mail to the above address containing the text
open sunsite.unc.edu cd /pub/Linux dir quit
You may use the ftpmail service to connect to any FTP archive site; you are not limited to sunsite.unc.edu. The next section lists a number of Linux FTP archives.
317
TOC
Site Name tsx-11.mit.edu sunsite.unc.edu nic.funet. ftp.mcc.ac.uk fgb1.fgb.mw.tu-muenchen.de ftp.informatik.tu-muenchen.de ftp.dfv.rwth-aachen.de ftp.informatik.rwth-aachen.de ftp.ibp.fr kirk.bu.oz.au ftp.uu.net wuarchive.wustl.edu ftp.win.tue.nl ftp.ibr.cs.tu-bs.de ftp.denet.dk IP Address 18.172.1.2 152.2.22.81 128.214.6.100 130.88.200.7 129.187.200.1 131.159.0.110 137.226.4.105 137.226.112.172 132.227.60.2 131.244.1.1 137.39.1.9 128.252.135.4 131.155.70.100 134.169.34.15 129.142.6.74 Directory /pub/linux /pub/Linux /pub/OS/Linux /pub/linux /pub/linux /pub/Linux /pub/linux /pub/Linux /pub/linux /pub/OS/Linux /systems/unix/linux /systems/linux /pub/linux /pub/os/linux /pub/OS/linux
TOC
Appendix C
319
TOC
can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each authors protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modied by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reect on the original authors reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyones free use or not licensed at all. The precise terms and conditions for copying, distribution and modication follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The Program, below, refers to any such program or work, and a work based on the Program means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modications and/or translated into another language. (Hereinafter, translation is included without limitation in the term modication.) Each licensee is addressed as you. Activities other than copying, distribution and modication are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does.
320
Appendix
TOC
1. You may copy and distribute verbatim copies of the Programs source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a. You must cause the modied les to carry prominent notices stating that you changed the les and the date of any change. b. You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c. If the modied program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modied work as a whole. If identiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to
321
TOC
work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a. Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b. Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c. Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface denition les, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code.
322
Appendix
TOC
4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contri-
323
TOC
butions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program species a version number of this License which applies to it and any later version, you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
324
Appendix
TOC
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS A PPENDIX : H OW TO A PPLY T HESE T ERMS TO YOUR N EW P ROGRAMS If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source le to most effectively convey the exclusion of warranty; and each le should have at least the copyright line and a pointer to where the full notice is found.
one line to give the programs name and a brief idea of what it does. Copyright c 19yy name of author
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
325
TOC
You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type show w. This is free software, and you are welcome to redistribute it under certain conditions; type show c for details.
The hypothetical commands show w and show c should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than show w and show c; they could even be mouse-clicks or menu items whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a copyright disclaimer for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program Gnomovision (which makes passes at compilers) written by James Hacker.