1. Trang chủ
  2. » Công Nghệ Thông Tin

Tài liệu Teach yourself Unix in 24 hours pdf

572 469 1

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 572
Dung lượng 4,03 MB

Nội dung

Dave Taylor James C. Armstrong, Jr. Teach Yourself UNIX in 24 Hours 201 West 103rd Street Indianapolis, Indiana 46290 Teach Yourself UNIX in 24 Hours iv President, Sams Publishng Richard K. Swadley Publishing Manager Dean Miller Director of Editorial Services Cindy Morrow Director of Marketing Kelli Spencer Product Marketing Manager Wendy Gilbride Assistant Marketing Managers Jen Pock, Rachel Wolfe Decimilli accipitrae Raptor Regina.—JA To the newest light of my life: Ashley Elizabeth.—DT Copyright  1997 by Sams Publishing FIRST EDITION All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, or transmitted by any means, electronic, mechanical, photo- copying, recording, or otherwise, without written permission from the publisher. No patent liability is assumed with respect to the use of the informa- tion contained herein. Although every precaution has been taken in the preparation of this book, the publisher and author assume no responsibility for errors or omissions. Neither is any liability assumed for damages resulting from the use of the information contained herein. For information, address Sams Publishing, 201 W. 103rd St., Indianapolis, IN 46290. International Standard Book Number: 0-672-31107-0 Library of Congress Catalog Card Number: 97-66198 2000 99 98 97 4 3 2 1 Interpretation of the printing code: the rightmost double-digit number is the year of the book’s printing; the rightmost single-digit, the number of the book’s printing. For example, a printing code of 97-1 shows that the first printing of the book occurred in 1997. Composed in AGaramond and MCPdigital by Macmillan Computer Publishing Printed in the United States of America All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized. Sams Publishing cannot attest to the accuracy of this information. Use of a term in this book should not be regarded as affecting the validity of any trademark or service mark. Acquisitions Editor Grace M. Buechlein Development Editor Brian-Kent Proffitt Production Editor Kristi Hart Indexer Greg Pearson Technical Reviewer Raj Mangal Editorial Coordinators Mandi Rouell Katie Wise Technical Edit Coordinator Lynette Quinn Resource Coordinator Deborah Frisby Editorial Assistants Carol Ackerman Andi Richter Rhonda Tinch-Mize Cover Designer Tim Amrhein Book Designer Gary Adair Copy Writer David Reichwein Production Team Supervisors Brad Chinn Charlotte Clapp Production Brad Lenser Chris Livengood Gene Redding Janet Seib Overview Introduction xvi Hour 1 What Is this UNIX Stuff? 1 2 Getting onto the System and Using the Command Line 21 3 Moving About the File System 43 4 Listing Files and Managing Disk Usage 63 5 Ownership and Permissions 87 6 Creating, Moving, Renaming, and Deleting Files and Directories 113 7 Looking into Files 127 8 Filters and Piping 145 9 Wildcards and Regular Expressions 161 10 Power Filters and File Redirection 187 11 An Introduction to the vi Editor 199 12 Advanced vi Tricks, Tools, and Techniques 245 13 An Overview of the emacs Editor 281 14 Introduction to Command Shells 305 15 Getting the Most Out of the C Shell 323 16 Basic Shell Programming 347 17 Job Control 361 18 Printing in the UNIX Environment 379 19 Searching for Information and Files 397 20 Communicating with Others 407 21 Using Netscape To See the World Wide Web 425 22 Internet E-Mail, Netnews, and IRC 443 23 Using telnet and ftp 479 24 Programming in C for UNIX 509 Glossary 531 Index 541 Teach Yourself UNIX in 24 Hours vi Contents Hour 1 What Is This UNIX Stuff? 1 Goals for This Hour 1 What Is UNIX? 2 A Brief History of UNIX 3 The C Programming Language 4 UNIX Becomes Popular 5 What’s All This About Multiuser Systems? 5 Cracking Open the Shell 6 Getting Help 7 Task 1.1: Man Pages, UNIX Online Reference 7 Task 1.2: Other Ways to Find Help in UNIX 14 Summary 17 Workshop 17 Key Terms 17 Questions 18 Preview of the Next Hour 19 2 Getting onto the System and Using the Command Line 21 Goals for This Hour 21 Task 2.1: Logging In and Out of the System 22 Task 2.2: Changing Passwords with passwd 25 Task 2.3: Picking a Secure Password 26 Task 2.4: Who Are You? 28 Task 2.5: Finding Out What Other Users Are Logged in to the System 30 Task 2.6: What Is Everyone Doing on the Computer? 31 Task 2.7: Checking the Current Date and Time 33 Task 2.8: Looking at a Calendar 33 Simple Math with UNIX 36 Task 2.9: Using the bc Infix Calculator 36 Task 2.10: Using the dc Postfix Calculator 38 Summary 40 Workshop 40 Key Terms 40 Questions 41 Preview of the Next Hour 41 3 Moving About the File System 43 Goals for This Hour 43 What a Hierarchical File System Is All About 44 Task 3.1: The UNIX File System Organization 45 The bin Directory 46 The dev Directory 47 The etc Directory 47 The lib Directory 47 The lost+found Directory 48 The mnt and sys Directories 48 The tmp Directory 48 The usr Directory 48 Other Miscellaneous Stuff at the Top Level 49 How Mac and PC File Systems Differ from the UNIX File System 50 Directory Separator Characters 50 The Difference Between Relative and Absolute Filenames 51 Task 3.2: Hidden Files in UNIX 52 Task 3.3: The Special Directories “.” and “ ” 55 Task 3.4: The env Command 56 Task 3.5: PATH and HOME 57 Task 3.6: Find Where You Are with pwd 58 Task 3.7: Move to Another Location with cd 58 Summary 60 Workshop 60 Key Terms 60 Questions 62 Preview of the Next Hour 62 4 Listing Files and Managing Disk Usage 63 Goals for This Hour 63 The ls Command 64 Task 4.1: All About the ls Command 64 Task 4.2: Having ls Tell You More 65 Task 4.3: Combining Flags 68 Task 4.4: Listing Directories Without Changing Location 69 Special ls Command Flags 71 Task 4.5: Changing the Sort Order in ls 71 Task 4.6: Listing Directory Trees Recursively in ls 73 Task 4.7: Long Listing Format in ls 74 Permissions Strings 74 Task 4.8: Long Listing Format for Directories in ls 75 Task 4.9: Creating Files with the touch Command 78 Task 4.10: Check Disk-Space Usage with du 79 Task 4.11: Check Available Disk Space with df 82 Task 4.12: Shrink Big Files with the compress Program 83 Summary 84 Workshop 84 Key Terms 84 Questions 85 Preview of the Next Hour 85 Teach Yourself UNIX in 24 Hours viii 5 Ownership and Permissions 87 Goals for This Hour 87 Task 5.1: Understand File Permissions Settings 88 Task 5.2: Directory Permissions Settings 93 Task 5.3: Modify File and Directory Permissions with chmod 96 Task 5.4: Set New File Permissions with chmod 98 Task 5.5: Calculating Numeric Permissions Strings 102 Task 5.6: Establish Default File and Directory Permissions with the umask Command 104 Task 5.7: Identify Owner and Group for Any File or Directory 107 Task 5.8: Change the Owner of a File or Directory 108 Task 5.9: Change the Group of a File or Directory 109 Summary 110 Workshop 110 Key Terms 110 Questions 111 Preview of the Next Hour 111 6 Creating, Moving, Renaming, and Deleting Files and Directories 113 Goals for This Hour 113 Task 6.1: Creating New Directories Using mkdir 114 Task 6.2: Copying Files to New Locations Using cp 116 Task 6.3: Moving Files to New Locations Using mv 118 Task 6.4: Renaming Files with mv 119 Task 6.5: Removing Directories with rmdir 120 Task 6.6: Removing Files Using rm 121 Task 6.7: Minimizing the Danger of the rm Command 123 Summary 125 Workshop 125 Key Terms 125 Questions 126 Preview of the Next Hour 126 7 Looking into Files 127 Goals for This Hour 127 Task 7.1: Using file to Identify File Types 128 Task 7.2: Exploring UNIX Directories with file 130 Task 7.3: Peeking at the First Few Lines with head 133 Task 7.4: Viewing the Last Few Lines with tail 135 Task 7.5: Viewing the Contents of Files with cat 136 Task 7.6: Viewing Larger Files with more 139 Summary 143 Workshop 143 Key Terms 143 Questions 144 Preview of the Next Hour 144 8 Filters and Piping 145 Goals for This Hour 145 Task 8.1: The Secrets of File Redirection 146 Task 8.2: Counting Words and Lines Using wc 147 Task 8.3: Removing Extraneous Lines Using uniq 149 Task 8.4: Sorting Information in a File Using sort 150 Task 8.5: Number Lines in Files Using cat -n and nl 153 Task 8.6: Cool nl Tricks and Capabilities 154 Summary 157 Workshop 158 Key Terms 158 Questions 158 Preview of the Next Hour 159 9 Wildcards and Regular Expressions 161 Goals for This Hour 161 Task 9.1: Filename Wildcards 162 Task 9.2: Advanced Filename Wildcards 164 Task 9.3: Creating Sophisticated Regular Expressions 167 Task 9.4: Searching Files Using grep 172 Task 9.5: For Complex Expressions, Try egrep 175 Task 9.6: Searching for Multiple Patterns at Once with fgrep 176 Task 9.7: Changing Things En Route with sed 179 Summary 185 Workshop 185 Key Terms 185 Questions 185 Preview of the Next Hour 186 10 Power Filters and File Redirection 187 Goals for This Hour 187 Task 10.1: The Wild and Weird awk Command 188 Task 10.2: Re-routing the Pipeline with tee 196 Summary 197 Workshop 197 Questions 197 Preview of the Next Hour 198 11 An Introduction to the vi Editor 199 Goals for This Hour 200 Task 11.1: How To Start and Quit vi 200 Task 11.2: Simple Cursor Motion in vi 205 Task 11.3: Moving by Words and Pages 208 Task 11.4: Inserting Text into the File Using i, a, o, and O 212 Task 11.5: Deleting Text 220 Task 11.6: Searching Within a File 229 Task 11.7: How To Start vi Correctly 234 Task 11.8: The Colon Commands in vi 236 ixContents Teach Yourself UNIX in 24 Hours x Summary 242 Workshop 243 Key Terms 243 Questions 244 Preview of the Next Hour 244 12 Advanced vi Tricks, Tools, and Techniques 245 Goals for This Hour 245 Task 12.1: The Change and Replace Commands 246 Task 12.2: Numeric Repeat Prefixes 253 Task 12.3: Numbering Lines in the File 255 Task 12.4: Search and Replace 257 Task 12.5: Mapping Keys with the :map Command 260 Task 12.6: Moving Sentences and Paragraphs 266 Task 12.7: Access UNIX with ! 270 Summary of vi Commands 278 Summary 279 Workshop 279 Key Terms 279 Questions 279 Preview of the Next Hour 280 13 An Overview of the emacs Editor 281 Goals for This Hour 281 Task 13.1: Launching emacs and Inserting Text 282 Task 13.2: How To Move Around in a File 285 Task 13.3: How To Delete Characters and Words 289 Task 13.4: Search and Replace in emacs 294 Task 13.5: Using the emacs Tutorial and Help System 297 Task 13.6: Working with Other Files 299 Summary 303 Workshop 303 Key Terms 303 Questions 303 Preview of the Next Hour 304 14 Introduction to Command Shells 305 Goals for This Hour 305 Task 14.1: What Shells Are Available? 306 Task 14.2: Identifying Your Shell 309 Task 14.3: How To Choose a New Shell 310 Task 14.4: Learning the Shell Environment 313 Task 14.5: Exploring csh Configuration Files 317 Summary 321 Workshop 321 Key Terms 321 Questions 321 Preview of the Next Hour 322 15 Getting the Most Out of the C Shell 323 Goals for This Hour 323 Task 15.1: The C Shell and Korn Shell History Mechanisms 324 Task 15.2: Using History to Cut Down on Typing 327 Task 15.3: Command Aliases 333 Task 15.4: Some Power Aliases 335 Task 15.5: Setting Custom Prompts 338 Task 15.6: Creating Simple Shell Scripts 340 Summary 344 Workshop 344 Key Terms 344 Questions 344 Preview of the Next Hour 345 16 Basic Shell Programming 347 Goals for This Hour 347 Task 16.1: Shell Variables 348 Task 16.2: Shell Arithmetic 350 Task 16.3: Comparison Functions 351 Task 16.4: Conditional Expressions 355 Task 16.5: Looping expressions 357 Summary 359 Workshop 359 Key Terms 360 Questions 360 Preview of the Next Hour 360 17 Job Control 361 Goals for This Hour 361 Task 17.1: Job Control in the Shell: Stopping Jobs 362 Task 17.2: Foreground/Background and UNIX Programs 365 Task 17.3: Finding Out What Tasks Are Running 368 Task 17.4: Terminating Processes with kill 374 Summary 377 Workshop 377 Key Terms 377 Questions 378 Preview of the Next Hour 378 18 Printing in the UNIX Environment 379 Goals for This Hour 379 Task 18.1: Find Local Printers with printers 380 Task 18.2: Printing Files with lpr or lp 384 Task 18.3: Formatting Print Jobs with pr 387 Task 18.4: Working with the Print Queue 391 xiContents Teach Yourself UNIX in 24 Hours xii Summary 394 Workshop 394 Key Terms 395 Questions 395 Preview of the Next Hour 395 19 Searching for Information and Files 397 Goals for This Hour 397 Task 19.1: The find Command and Its Weird Options 398 Task 19.2: Using find with xargs 403 Summary 405 Workshop 405 Questions 405 Preview of the Next Hour 406 20 Communicating with Others 407 Goals for This Hour 407 Task 20.1: Enabling Messages Using mesg 408 Task 20.2: Writing to Other Users with write 409 Task 20.3: Reading Electronic Mail with mailx 411 Task 20.4: Sending Mail with mailx 417 Task 20.5: The Smarter Electronic Mail Alternative, elm 420 Summary 423 Workshop 423 Key Terms 424 Questions 424 Preview of the Next Hour 424 21 Using Netscape To See the World Wide Web 425 Goals for This Hour 425 Introduction to the Internet 426 Task 21.1: Starting Your Browser 427 Task 21.2: Finding Some Sites 432 Task 21.3: Customizing Your Browser 437 Summary 440 Workshop 440 Key Terms 440 Questions 441 Preview of the Next Hour 441 22 Internet E-Mail, Netnews, and IRC 443 Goals for This Hour 443 Task 22.1: Sending E-Mail to Internet Users 444 Task 22.2: Talking with Remote Internet Users 446 Task 22.3: Searching Databases with WAIS 449 Task 22.4: Having the Whole World with gopher 454 [...]... our books stronger Here’s the information: Fax: 317-581-4669 E-mail: opsys_mgr@sams.mcp.com Mail: Dean Miller Comments Department Sams Publishing 201 W 103rd Street Indianapolis, IN 46290 Teach Yourself UNIX in 24 Hours xvi Introduction Welcome to Teach Yourself UNIX in 24 Hours ! This book has been designed so it is helpful for both beginning users and those with previous UNIX experience This text is... Yourself UNIX in 24 Hours! This hour starts you toward becoming a UNIX expert Our goal for the first hour is to introduce you to some UNIX history and to teach you where to go for help online Goals for This Hour In the first hour, you learn s s s s s s s The history of UNIX Why it’s called UNIX What multiuser systems are all about The difference between UNIX and other operating systems About command-line interpreters... The Internet Mall, Inc., (http:// www.internetmall.com), the largest online shopping site in the world He has been involved with UNIX and the Internet since 1980, having created the popular Elm Mail System and Embot mail autoresponder A prolific author, he has been published over 1,000 times, and his most recent books include the best-selling Creating Cool HTML 3.2 Web Pages and The Internet Business... 1997 login: The first line indicates what variant of UNIX the system is running (DYNIX is UNIX on Sequent computers), the actual name of the computer system, and the current date and time The second line is asking for your login, your account name 1 Connect your terminal or PC to the UNIX system until the point where you see a login prompt (login:) on your screen similar to that in the preceding example... Statements 517 Task 24. 4: Looping Statements 520 Task 24. 5: Functions 521 Task 24. 6: Arrays 523 Task 24. 7: Pointers 524 Task 24. 8: Structures 526 Summary 528 Where To Go Next 528 Workshop 529 Key Terms 529 Questions 530 Glossary 531 Index 541 Contents Teach Yourself UNIX in 24 Hours xiv About the... take long for others inside Bell Labs to begin clamoring for their own UNIX computer systems The C Programming Language That’s where UNIX came from What about C, the programming language that is integral to the system? 1 What Is This UNIX Stuff? In 1969, the original UNIX had a very-low-level assembly language compiler available for writing programs; all the PDP-7 work was done in this primitive language... Getting onto the System and Using the Command Line This is the second hour of UNIX lessons, so it’s time you logged in to the system and tried some commands This hour focuses on teaching you the basics of interacting with your UNIX machine Goals for This Hour In this hour, you learn how to s s s s s Log in and log out of the system Change passwords with passwd Choose a memorable and secure password Find... weekly intranet column in InfoWorld and a Web/CGI programming column in LOGIN Previous positions include being a Research Scientist at HP Laboratories and Senior Reviews Editor of SunWorld magazine He also has contributed software to the official 4.4 release of Berkeley UNIX (BSD), and his programs are found in all versions of Linux and other popular UNIX variants Dave has a Bachelor’s degree in Computer... relevant to your needs Main Section Each lesson has a main section that discusses the lesson topic in a clear, concise manner by breaking the topic down into logical component parts and explaining each component clearly Interspersed in each lesson are special elements, called Just a Minutes, Time Savers, and Cautions, that provide additional information JUST A MINUTE Just a Minutes are designed to clarify... pathname shell To interact with UNIX, you type in commands to the command-line interpreter, which is known in UNIX as the shell, or command shell It’s the underlying environment in which you work with the UNIX system Questions Each hour concludes with a set of questions for you to contemplate Here’s a warning up front: Not all of the questions have a definitive answer After all, you are learning about a . Taylor James C. Armstrong, Jr. Teach Yourself UNIX in 24 Hours 201 West 103rd Street Indianapolis, Indiana 46290 Teach Yourself UNIX in 24 Hours iv President, Sams. Street Indianapolis, IN 46290 JUST A MINUTE Teach Yourself UNIX in 24 Hours xvi Introduction Welcome to Teach Yourself UNIX in 24 Hours! This book has been designed

Ngày đăng: 17/01/2014, 08:20

TỪ KHÓA LIÊN QUAN