Think Unix Associate Publisher Tracy Dunkelberger Jon Lasser Acquisitions Editor Copyright © 2000 by Que Corporation Katie Purdum All Rights Reserved
Total Page:16
File Type:pdf, Size:1020Kb
00 2376 FM 11.30.00 9:21 AM Page i PERMISSIONS AND OWNERSHIP • USERS AND GROUPS HARD LINKS • SOFT LINKS • REDIRECTION AND PIPES REDIRECTING STDERR • NAME LOOKUP • ROUTING READING MAIL VIA POP3 • VI AND REGULAR EXPRESSIONS FILENAME GLOBBING VERSUS REGEXPS • INTERACTIVE COMMAND-LINE EDITING • HISTORY SUBSTITUTION • JOB CONTROL • VARIABLES AND QUOTING • CONDITIONAL EXECUTION • WHILE AND UNTIL LOOPS • ALIASES AND FUNCTIONS • THE X WINDOW CLIENT/SERVER MODEL WIDGETS AND TOOLKITS • CONFIGURING X • PERMISSIONS AND OWNERSHIP • USERS AND GROUPS • HARD LINKS • SOFT LINKS • REDIRECTION AND PIPES • REDIRECTING STDERR NAME LOOKUP • ROUTING READING MAIL VIA POP3 • VI AND REGULAR EXPRESSIONS FILENAME GLOBBING VERSUS REGEXPS • INTERACTIVE COMMAND-LINE EDITING • HISTORY SUBSTITUTION • JOB CONTROL • VARIABLES AND QUOTING CONDITIONAL EXECUTION • WHILE AND UNTIL LOOPS • ALIASES AND FUNCTIONS • THE X WINDOW CLIENT/SERVER MODEL WIDGETS AND TOOLKITS • CONFIGURING X • PERMISSIONS AND OWNERSHIP • USERS AND GROUPS HARD LINKS • SOFT LINKS • REDIRECTION AND PIPES • REDIRECTING STDERR • NAME LOOKUP • ROUTING READING MAIL VIA POP3 • VI AND REGULAR EXPRESSIONS • FILENAME GLOBBING VERSUS REGEXPS • INTERACTIVE COMMAND-LINE EDITING • HISTORY THINKSUBSTITUTION • JOB CONTROL • VARIABLES AND QUOTINGUnix READING MAN PAGES • ABSOLUTE AND RELATIVE P PERMISSIONS AND OWNERSHIP • USERS AND GRO HARD LINKS • SOFT LINKS • REDIRECTION AND PIPE JON LASSER REDIRECTING STDERR • NAME LOOKUP • ROUTING READING MAIL VIA POP3 • VI AND REGULAR EXPRE FILENAME GLOBBING VERSUS REGEXPS • INTERACT COMMAND-LINE EDITING • HISTORY SUBSTITUTION CONTROL • VARIABLES AND QUOTING • CONDITIO EXECUTION • WHILE AND UNTIL LOOPS • ALIASES A FUNCTIONS • THE X WINDOW CLIENT/SERVER MO WIDGETS AND TOOLKITS • CONFIGURING X • PERM OWNERSHIP • USERS AND GROUPS • HARD LINKS REDIRECTION AND PIPES • REDIRECTING STDERR NA ROUTING READING MAIL VIA POP3 • VI AND REGU EXPRESSIONS FILENAME GLOBBING VERSUS REGEXP INTERACTIVE COMMAND-LINE EDITING • HISTORY S JOB CONTROL • VARIABLES AND QUOTING CONDIT EXECUTION • WHILE AND UNTIL LOOPS • ALIASES A FUNCTIONS • THE X WINDOW CLIENT/SERVER MO AND TOOLKITS • CONFIGURING X • PERMISSIONS OWNERSHIP • USERS AND GROUPS HARD LINKS • REDIRECTION AND PIPES • REDIRECTING STDERR • N • ROUTING READING MAIL VIA POP3 • VI AND REG EXPRESSIONS • FILENAME GLOBBING VERSUS REGE INTERACTIVE COMMAND-LINE EDITING • HISTORY S JOB CONTROL • VARIABLES AND QUOTING • CON EXECUTION • WHILE AND UNTIL LOOPS • ALIASES A FUNCTIONS • THE X WINDOW CLIENT/SERVER MO WIDGETS AND TOOLKITS • CONFIGURING X • READ PAGES • ABSOLUTE AND RELATIVE PATHS PERMISSIONS AND OWNERSHIP • USERS AND GRO HARD LINKS • SOFT LINKS • REDIRECTION AND PIPE 00 2376 FM 11.30.00 9:21 AM Page ii ii Think Unix Associate Publisher Tracy Dunkelberger Jon Lasser Acquisitions Editor Copyright © 2000 by Que Corporation Katie Purdum All rights reserved. No part of this book shall be reproduced, Development Editor stored in a retrieval system, or transmitted by any means, elec- Hugh Vandivier tronic, mechanical, photocopying, recording, or otherwise, Managing Editor without written permission from the publisher. No patent lia- Thomas F.Hayes bility is assumed with respect to the use of the information contained herein.Although every precaution has been taken Project Editor in the preparation of this book, the publisher and author Tonya Simpson assume no responsibility for errors or omissions. Nor is any Copy Editors liability assumed for damages resulting from the use of the Kay Hoskin information contained herein. Mike Dietsch International Standard Book Number: 0-7897-2376-x Indexer Library of Congress Catalog Card Number: 00-100690 Kelly Castell Printed in the United States of America Proofreader First Printing: July, 2000 Benjamin Berg 02 01 00 4 3 2 Technical Editors Andy Johnston Trademarks Scott Orr All terms mentioned in this book that are known to be trade- Team Coordinator marks or service marks have been appropriately capitalized. Vicki Harding Que Corporation cannot attest to the accuracy of this infor- mation. Use of a term in this book should not be regarded as Interior Designer affecting the validity of any trademark or service mark. Maureen McCarty Cover Designer Warning and Disclaimer Anne Jones Production Every effort has been made to make this book as complete Darin Crone and as accurate as possible, but no warranty or fitness is implied.The information provided is on an “as is” basis.The author and the publisher shall have neither liability nor responsibility to any person or entity with respect to any loss or damages arising from the information contained in this book. 00 2376 FM 11.30.00 9:21 AM Page iii iii Contents Introduction 1 About This Book 1 1Unix Concepts 7 1 Unix Documentation 9 Words of Warning 10 Reading Man Pages 10 Documentation Hide-and-Go-Seek 20 Suggested Exercises 27 2 Files and Processes 29 Files 30 Processes 53 3 Redirection and Pipes 63 Redirection 64 Pipes 69 4 Networking 79 A Broad Overview of Networking 80 Talking with Other Machines 90 Using Machines Remotely 102 5 vi, Dotfiles, and Regular Expressions 107 Surviving vi 109 Thriving in vi 114 Regular Expressions 122 II Shell Concepts 131 6 Muddling Through Shells 133 Shell Wars 134 Fixing Mistakes 136 Job Control 140 00 2376 FM 11.30.00 9:21 AM Page iv iv 7 Variables and Quoting 147 Variables 148 Practice Problems 158 Quoting 158 Practice Problems 165 8 Conditional Execution and Loops 167 Sequential Execution 168 Conditional Execution 169 Practice Problems 178 Loops 179 Practice Problems 183 9 Shell Scripts and More 185 Grouping Commands 186 Aliases and Functions 187 Practice Problems 190 Shell Scripts 190 Practice Problems 196 III X Window System Concepts 197 10 Thinking Like X 199 What X Does Differently 200 Nuts and Bolts 203 Desktop Environments 214 Something Useful: xterm 218 Suggested Exercises 220 11 Configuring X 221 Starting X 222 Command-Line Options 225 Suggested Exercises 228 X Resources 228 Suggested Exercises 235 Color Names and Numbers 235 Fonts 237 Listing Fonts 238 A Few Final Words 240 00 2376 FM 11.30.00 9:21 AM Page v v IV Appendixes 243 A Answers to Practice Problems 245 B Glossary and References 255 Index 267 00 2376 FM 11.30.00 9:21 AM Page vi vi About the Author Jon Lasser lives in Baltimore, Maryland, with his wife, Kathleen, and their three cats. Professionally, Jon juggles Unix systems administration along with both writ- ing and speaking about Unix systems administration. He is also lead coordinator for the Bastille Linux Project, which aims to simplify security on Linux systems. Dedication For Kathleen, who knows it’s for her anyway. Acknowledgments As much as authors might wish otherwise, writing a book is not a solitary endeavor.Above all, I have to thank Kathleen, who washed more than her share of dishes and supported me in countless other ways while I wrote this book.Thanks also to the rest of my family for encouragement, for support, and for maintaining a certain level of excitement about the project. Thanks go to everyone at Macmillan, especially Katie and Hugh.Thanks, Katie, for pushing me to finish up the book proposal.Thanks to my technical reviewers, Scott and Andy.Thanks,Andy, for long discussions about how one might write a good intro to Unix book. Many friends contributed to the process in their own special ways. Special thanks go to Karen, for her perspective on design, and to Steve, Shawn, and Jay for asking the right questions. Thanks to all of my co-workers at UMBC, for tolerating week-long absences throughout this book, for general support, and for always pushing me to deepen my own Unix knowledge. Finally, thanks to the Tuesday night crew at The Brewer’s Art and the Thursday Night Bolton Hill Walkers’ Patrol, for helping to keep me sane. 00 2376 FM 11.30.00 9:21 AM Page vii vii Tell Us What You Think! As the reader of this book, you are our most important critic and commentator.We value your opinion and want to know what we’re doing right, what we could do better, what areas you’d like to see us publish in, and any other words of wisdom you’re willing to pass our way. As an associate publisher for Que, I welcome your comments.You can fax, email, or write me directly to let me know what you did or didn’t like about this book—as well as what we can do to make our books stronger. Please note that I cannot help you with technical problems related to the topic of this book, and that due to the high volume of mail I receive, I might not be able to reply to every mes- sage. When you write, please be sure to include this book’s title and author as well as your name and phone or fax number. I will carefully review your comments and share them with the author and editors who worked on the book. Fax: 317-581-4666 Email: [email protected] Mail: Associate Publisher Que 201 West 103rd Street Indianapolis, IN 46290 USA 00 2376 FM 11.30.00 9:21 AM Page viii viii 01 2376 Intro 6/12/00 12:41 PM Page 1 Introduction Think Unix 1 Introduction About This Book So here you are, standing in the bookstore, flipping through this book, trying to decide whether Think Unix is for you. Fortunately, you decided to read this part of the book, so I can answer your question directly. Is This Book For You? First of all, this book is intended for people with some computer experience. If you’ve never used a PC or Macintosh, there are probably better places for you to start than this book. I don’t start at the beginning. I assume you have an idea of what a file is; what a folder or subdirectory is; where to find the keyboard, moni- tor, and mouse; and how to turn your computer on.