Thư viện tri thức trực tuyến
Kho tài liệu với 50,000+ tài liệu học thuật
© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

Tài liệu UNIX IN A NUTSHELL ppt
Nội dung xem thử
Mô tả chi tiết
UNIX
IN A NUTSHELL
,TITLE.12845 Page i Tuesday, August 22, 2006 4:51 PM
Other resources from O’Reilly
Related titles Classic Shell Scripting
Effective awk
Programming
Essential CVS
Essential System
Administration
GDB Pocket Reference
Learning GNU Emacs
Learning the bash Shell
Learning the Korn Shell
Learning the vi Editor
Linux in a Nutshell
Mac OS X Tiger for Unix
Geeks
Managing Projects with
GNU Make
Running Linux
sed and awk Pocket
Reference
TCP/IP Network
Administration
The Complete FreeBSD
Unix Power Tools
Using csh & tcsh
Version Control with
Subversion
oreilly.com oreilly.com is more than a complete catalog of O’Reilly
books. You'll also find links to news, events, articles,
weblogs, sample chapters, and code examples.
Conferences O’Reilly brings diverse innovators together to nurture the
ideas that spark revolutionary industries. We specialize in
documenting the latest tools and systems, translating the
innovator’s knowledge into useful skills for those in the
trenches. Visit conferences.oreilly.com for our upcoming
events.
Safari Bookshelf (safari.oreilly.com) is the premier online
reference library for programmers and IT professionals.
Conduct searches across more than 1,000 books. Subscribers can zero in on answers to time-critical questions
in a matter of seconds. Read the books on your Bookshelf from cover to cover or simply flip to the page you
need. Try it today for free.
,TITLE.12845 Page ii Tuesday, August 22, 2006 4:51 PM
Fourth Edition
UNIX
IN A NUTSHELL
Arnold Robbins
Beijing • Cambridge • Farnham • Köln • Paris • Sebastopol • Taipei • Tokyo
,TITLE.12845 Page iii Tuesday, August 22, 2006 4:51 PM
Unix in a Nutshell, Fourth Edition
by Arnold Robbins
Copyright © 2006, 1999, 1992, 1989 O’Reilly Media, Inc. All rights reserved.
Printed in the United States of America.
Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472.
O’Reilly books may be purchased for educational, business, or sales promotional use. Online
editions are also available for most titles (safari.oreilly.com). For more information, contact
our corporate/institutional sales department: (800) 998-9938 or [email protected].
Editor: Mike Loukides
Production Editor: Colleen Gorman
Cover Designer: Edie Freedman
Interior Designer: David Futato
Back Cover Illustration: J.D. “Illiad” Frazer
Printing History:
May 1989: First Edition.
June 1992: Second Edition.
August 1999: Third Edition.
October 2005: Fourth Edition.
Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered
trademarks of O’Reilly Media, Inc. The In a Nutshell series designations, Unix in a Nutshell,
the image of a tarsier, and related trade dress are trademarks of O’Reilly Media, Inc.
Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in this book, and O’Reilly Media,
Inc. was aware of a trademark claim, the designations have been printed in caps or initial
caps. UNIX is a registered trademark of The Open Group.
While every precaution has been taken in the preparation of this book, the publisher and
author assume no responsibility for errors or omissions, or for damages resulting from the use
of the information contained herein.
ISBN: 0-596-10029-9
[M] [8/06]
,COPYRIGHT.12974 Page iv Tuesday, August 22, 2006 4:52 PM
To my wife, Miriam. May our dreams continue to come true.
To my children, Chana, Rivka, Nachum, and Malka.
To the memory of Frank Willison.
vii
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Chapter 1
Table of Contents
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Part I. Commands and Shells
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
Unix in the 21st Century 3
Obtaining Compilers 5
Building Software 6
What’s in the Quick Reference 7
Beginner’s Guide 8
Solaris: Standard Compliant Programs 11
2. Unix Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
Introduction 13
Alphabetical Summary of Common Commands 15
Alphabetical Summary of Solaris Commands 241
Alphabetical Summary of GNU/Linux Commands 260
Alphabetical Summary of Mac OS X Commands 304
Alphabetical Summary of Java Commands 321
3. The Unix Shell: An Overview . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341
Introduction to the Shell 341
Purpose of the Shell 342
Shell Flavors 343
viii | Table of Contents
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Shell Source Code URLs 344
Common Features 344
Differing Features 345
4. The Bash and Korn Shells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 347
Overview of Features 348
Invoking the Shell 349
Syntax 350
Functions 357
Variables 358
Arithmetic Expressions 366
Command History 368
Job Control 372
Command Execution 372
Restricted Shells 373
Built-in Commands (Bash and Korn Shells) 374
5. tcsh: An Extended C Shell . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417
Overview of Features 417
Invoking the Shell 418
Syntax 419
Variables 423
Expressions 435
Command History 438
Command-Line Manipulation 442
Job Control 445
Built-in Commands 446
6. Package Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 467
Linux Package Management 467
The Red Hat Package Manager 470
Yum: Yellowdog Updater Modified 484
up2date: Red Hat Update Agent 489
The Debian Package Manager 492
Mac OS X Package Management 520
Solaris Package Management 521
Table of Contents | ix
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Part II. Text Editing and Processing
7. Pattern Matching . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 535
Filenames Versus Patterns 535
Metacharacters 536
Metacharacters, Listed by Unix Program 538
Examples of Searching 539
8. The Emacs Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 543
Conceptual Overview 543
Command-Line Syntax 545
Summary of Commands by Group 546
Summary of Commands by Key 552
Summary of Commands by Name 555
9. The vi, ex, and vim Editors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 561
Conceptual Overview 561
Command-Line Syntax 562
Review of vi Operations 565
vi Commands 567
vi Configuration 574
ex Basics 579
Alphabetical Summary of ex Commands 580
10. The sed Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 595
Conceptual Overview 595
Command-Line Syntax 596
Syntax of sed Commands 598
Group Summary of sed Commands 600
Alphabetical Summary of sed Commands 601
11. The awk Programming Language . . . . . . . . . . . . . . . . . . . . . . . . . . . 611
Conceptual Overview 611
Command-Line Syntax 613
Patterns and Procedures 614
Built-in Variables 616
Operators 617
Variable and Array Assignment 618
User-Defined Functions 619
Gawk-Specific Features 620
x | Table of Contents
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Implementation Limits 622
Group Listing of awk Functions and Commands 623
Alphabetical Summary of awk Functions and Commands 623
Output Redirections 632
Source Code 634
Part III. Software Development
12. Source Code Management: An Overview . . . . . . . . . . . . . . . . . . . . . 637
Introduction and Terminology 637
Usage Models 639
Unix Source Code Management Systems 640
Other Source Code Management Systems 641
13. The Revision Control System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 643
Overview of Commands 643
Basic Operation 644
General RCS Specifications 645
Alphabetical Summary of Commands 649
14. The Concurrent Versions System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 659
Conceptual Overview 659
Command-Line Syntax and Options 661
Dot Files 664
Environment Variables 665
Keywords and Keyword Modes 667
Dates 669
CVSROOT Variables 672
Alphabetical Summary of Commands 674
15. The Subversion Version Control System . . . . . . . . . . . . . . . . . . . . . . . 697
Conceptual Overview 697
Obtaining Subversion 702
Using Subversion: A Quick Tour 704
The Subversion Command Line Client: svn 706
Repository Administration: svnadmin 733
Examining the Repository: svnlook 737
Providing Remote Access: svnserve 742
Other Subversion Components 743
Table of Contents | xi
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
16. The GNU make Utility . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 745
Conceptual Overview 745
Command-Line Syntax 746
Makefile Lines 749
Macros 754
Special Target Names 761
Writing Command Lines 762
17. The GDB Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 765
Conceptual Overview 765
Command-Line Syntax 768
Initialization Files 770
GDB Expressions 771
The GDB Text User Interface 773
Group Listing of GDB Commands 773
Summary of set and show Commands 777
Summary of the info Command 788
Alphabetical Summary of GDB Commands 790
18. Writing Manual Pages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 813
Introduction 813
Overview of nroff/troff 814
Alphabetical Summary of man Macros 819
Predefined Strings 823
Internal Names 823
Sample Document 823
Part IV. References
ISO 8859-1 (Latin-1) Character Set . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 829
Bibliography . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 837
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 849
xiii
This is the Title of the Book, eMatter Edition
Copyright © 2006 O’Reilly & Associates, Inc. All rights reserved.
Chapter 2
Preface
The fourth edition of Unix in a Nutshell brings the book into the 21st century.
The term “UNIX” is a registered trademark of The Open Group. It is used for
branding systems as compliant with the various standards that collectively define
the behavior of a modern Unix system. More informally though, many systems in
use today are Unix work-alikes, even though their source code base was developed independently from the original Unix systems.
Thus, the goal of this edition to present the broader state of Unix in today’s world.
In particular, it’s important to cover both the commercial variants, and those where
source code for the system and the utilities are freely available. To this end, we have
chosen to cover these systems, which are representative of “Unix” today:
Solaris 10
Solaris is the most popular commercial system based on the original Unix
System V code base.
GNU/Linux
GNU/Linux systems have gained a huge foothold in the commercial marketplace. While currently used most heavily for back-end servers, GNU/Linux is
also starting to gain ground in the desktop market.
Mac OS X
Apple’s rewrite of their operating system has a core based on Mach and
various BSD technologies. The command set is derived from FreeBSD. Thus,
besides having an exciting user interface, Mac OS X is representative of the
BSD strain of free Unix-like systems.
The commands covered by the current POSIX standard form the core of our presentation. Each specific system has commands that are unique to it; these are covered
too. Finally, many important and useful utilities are distributed as Free or Open
Source software on the Internet. We have done our best to cover those as well,
including presenting the Internet URL from which you can download the source
code, in case your particular system doesn’t include that utility in its distribution.