LINUX: Rute User's Tutorial and Exposition
Total Page:16
File Type:pdf, Size:1020Kb
LINUX: Rute User’s Tutorial and Exposition Paul Sheer August 14, 2001 Pages up to and including this page are not included by Prentice Hall. 2 “The reason we don’t sell billions and billions of Guides,” continued Harl, after wiping his mouth, “is the expense. What we do is we sell one Guide billions and billions of times. We exploit the multidimensional nature of the Universe to cut down on manufacturing costs. And we don’t sell to penniless hitchhikers. What a stupid notion that was! Find the one section of the market that, more or less by definition, doesn’t have any money, and try to sell to it. No. We sell to the affluent business traveler and his vacationing wife in a billion, billion different futures. This is the most radical, dynamic and thrusting business venture in the entire multidimensional infinity of space-time-probability ever.” ... Ford was completely at a loss for what to do next. “Look,” he said in a stern voice. But he wasn’t certain how far saying things like “Look” in a stern voice was necessarily going to get him, and time was not on his side. What the hell, he thought, you’re only young once, and threw himself out of the window. That would at least keep the element of surprise on his side. ... In a spirit of scientific inquiry he hurled himself out of the window again. Douglas Adams Mostly Harmless Strangely, the thing that least intrigued me was how they’d managed to get it all done. I suppose I sort of knew. If I’d learned one thing from traveling, it was that the way to get things done was to go ahead and do them. Don’t talk about going to Borneo. Book a ticket, get a visa, pack a bag, and it just happens. Alex Garland The Beach vi Chapter Summary 1 Introduction .................................. 1 2 Computing Sub-basics ............................ 5 3 PC Hardware .................................. 15 4 Basic Commands ................................ 25 5 Regular Expressions .............................. 49 6 Editing Text Files ................................ 53 7 Shell Scripting ................................. 61 8 Streams and sed — The Stream Editor ................... 73 9 Processes, Environment Variables ...................... 81 10 Mail ....................................... 97 11 User Accounts and Ownerships ....................... 101 12 Using Internet Services ............................ 111 13 LINUX Resources ................................ 117 14 Permission and Modification Times ..................... 123 15 Symbolic and Hard Links ........................... 127 16 Pre-installed Documentation ......................... 131 17 Overview of the UNIX Directory Layout .................. 135 18 UNIX Devices .................................. 141 19 Partitions, File Systems, Formatting, Mounting .............. 153 20 Advanced Shell Scripting ........................... 171 21 System Services and lpd ........................... 193 22 Trivial Introduction to C ........................... 207 23 Shared Libraries ................................ 233 24 Source and Binary Packages ......................... 237 25 Introduction to IP ............................... 247 26 TCP and UDP .................................. 263 vii Chapter Summary 27 DNS and Name Resolution .......................... 273 28 Network File System, NFS .......................... 285 29 Services Running Under inetd ....................... 291 30 exim and sendmail .............................. 299 31 lilo, initrd, and Booting ......................... 317 32 init, ?getty, and UNIX Run Levels .................... 325 33 Sending Faxes ................................. 333 34 uucp and uux .................................. 337 35 The LINUX File System Standard ...................... 347 36 httpd — Apache Web Server ........................ 389 37 crond and atd ................................. 409 38 postgres SQL Server ............................ 413 39 smbd — Samba NT Server .......................... 425 40 named — Domain Name Server ....................... 437 41 Point-to-Point Protocol — Dialup Networking .............. 453 42 The LINUX Kernel Source, Modules, and Hardware Support ...... 463 43 The X Window System ............................ 485 44 UNIX Security ................................. 511 A Lecture Schedule ................................ 525 B LPI Certification Cross-Reference ...................... 531 C RHCE Certification Cross-Reference .................... 543 D LINUX Advocacy FAQ ............................. 551 E The GNU General Public License Version 2 ................ 573 Index 581 viii Contents Acknowledgments xxxi 1 Introduction 1 1.1 What This Book Covers . 1 1.2 Read This Next. 1 1.3 What Do I Need to Get Started? . 1 1.4 More About This Book . 2 1.5 I Get Frustrated with UNIX Documentation That I Don’t Understand . 2 1.6 LPI and RHCE Requirements . 2 1.7 Not RedHat: RedHat-like ........................... 3 1.8 Updates and Errata . 3 2 Computing Sub-basics 5 2.1 Binary, Octal, Decimal, and Hexadecimal . 5 2.2 Files . 7 2.3 Commands . 8 2.4 Login and Password Change . 9 2.5 Listing Files . 10 2.6 Command-Line Editing Keys . 10 2.7 Console Keys . 11 2.8 Creating Files . 12 2.9 Allowable Characters for File Names . 12 2.10 Directories . 12 3 PC Hardware 15 3.1 Motherboard . 15 3.2 Master/Slave IDE . 19 ix Contents 3.3 CMOS . 20 3.4 Serial Devices . 20 3.5 Modems . 23 4 Basic Commands 25 4.1 The ls Command, Hidden Files, Command-Line Options . 25 4.2 Error Messages . 26 4.3 Wildcards, Names, Extensions, and glob Expressions . 29 4.3.1 File naming . 29 4.3.2 Glob expressions . 32 4.4 Usage Summaries and the Copy Command . 33 4.5 Directory Manipulation . 34 4.6 Relative vs. Absolute Pathnames . 34 4.7 System Manual Pages . 35 4.8 System info Pages . 36 4.9 Some Basic Commands . 36 4.10 The mc File Manager . 40 4.11 Multimedia Commands for Fun . 40 4.12 Terminating Commands . 41 4.13 Compressed Files . 41 4.14 Searching for Files . 42 4.15 Searching Within Files . 43 4.16 Copying to MS-DOS and Windows Formatted Floppy Disks . 44 4.17 Archives and Backups . 45 4.18 The PATH Where Commands Are Searched For . 46 4.19 The -- Option . 47 5 Regular Expressions 49 5.1 Overview . 49 5.2 The fgrep Command . 51 5.3 Regular Expression \{ \} Notation . 51 5.4 + ? \< \> ( ) | Notation . 52 5.5 Regular Expression Subexpressions . 52 x Contents 6 Editing Text Files 53 6.1 vi ......................................... 53 6.2 Syntax Highlighting . 57 6.3 Editors . 57 6.3.1 Cooledit . 58 6.3.2 vi and vim ............................... 58 6.3.3 Emacs . 59 6.3.4 Other editors . 59 7 Shell Scripting 61 7.1 Introduction . 61 7.2 Looping: the while and until Statements . 62 7.3 Looping: the for Statement . 63 7.4 breaking Out of Loops and continueing . 65 7.5 Looping Over Glob Expressions . 66 7.6 The case Statement . 66 7.7 Using Functions: the function Keyword . 67 7.8 Properly Processing Command-Line Args: shift ............. 68 7.9 More on Command-Line Arguments: $@ and $0 .............. 70 7.10 Single Forward Quote Notation . 70 7.11 Double-Quote Notation . 70 7.12 Backward-Quote Substitution . 71 8 Streams and sed — The Stream Editor 73 8.1 Introduction . 73 8.2 Tutorial . 74 8.3 Piping Using | Notation . 74 8.4 A Complex Piping Example . 75 8.5 Redirecting Streams with >& ......................... 75 8.6 Using sed to Edit Streams . 77 8.7 Regular Expression Subexpressions . 77 8.8 Inserting and Deleting Lines . 79 9 Processes, Environment Variables 81 9.1 Introduction . 81 9.2 ps — List Running Processes . 82 9.3 Controlling Jobs . 82 xi Contents 9.4 Creating Background Processes . 83 9.5 killing a Process, Sending Signals . 84 9.6 List of Common Signals . 86 9.7 Niceness of Processes, Scheduling Priority . 87 9.8 Process CPU/Memory Consumption, top ................. 88 9.9 Environments of Processes . 90 10 Mail 97 10.1 Sending and Reading Mail . 99 10.2 The SMTP Protocol — Sending Mail Raw to Port 25 ............ 99 11 User Accounts and Ownerships 101 11.1 File Ownerships . 101 11.2 The Password File /etc/passwd ...................... 102 11.3 Shadow Password File: /etc/shadow ................... 103 11.4 The groups Command and /etc/group ................. 104 11.5 Manually Creating a User Account . 105 11.6 Automatically: useradd and groupadd .................. 106 11.7 User Logins . 106 11.7.1 The login command . 106 11.7.2 The set user, su command . 107 11.7.3 The who, w, and users commands to see who is logged in . 108 11.7.4 The id command and effective UID . 109 11.7.5 User limits . 109 12 Using Internet Services 111 12.1.