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

Prentice hall linux for programmers and users feb 2006 ISBN 0131857487

1,3K 275 0

Đ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 1.268
Dung lượng 5,22 MB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Pages : 700 Offering full coverage of Linux in one source, this book documents the most commonly needed topics for new and experienced Linux users and programmers... Utilities and Shell

Trang 1

Pages : 700

Offering full coverage of Linux in one source, this book documents the most commonly needed topics for new and experienced Linux users and programmers.

Trang 4

Section 3.10 Poetry in Motion: Exploring the File System 50 Section 3.11 Printing Your Shell's Current Working Directory: pwd 52 Section 3.12 Absolute and Relative Pathnames 52 Section 3.13 Creating a File 54 Section 3.14 Listing the Contents of a Directory: ls 55 Section 3.15 Listing the Contents of a File: cat/more/head/tail 56 Section 3.16 Renaming a File: mv 58 Section 3.17 Creating a Directory: mkdir 58 Section 3.18 Moving to a Directory: cd 59 Section 3.19 Copying a File: cp 60 Section 3.20 Editing a File: vim 61 Section 3.21 Deleting a Directory: rmdir 62 Section 3.22 Deleting a File: rm 62 Section 3.23 Printing a File: lp/lpstat/cancel 64 Section 3.24 Printing a File: lpr/lpq/lprm 65 Section 3.25 Counting Words in a File: wc 67 Section 3.26 File Attributes 68

Section 3.28 Listing Your Groups: groups 73 Section 3.29 Changing a File's Group: chgrp 73 Section 3.30 Changing a File's Permissions: chmod 74 Section 3.31 Changing a File's Owner: chown 76 Section 3.32 Changing Groups: newgrp 76 Section 3.33 Poetry in Motion: Epilogue 77 Section 3.34 Determining Your Terminal's Type: tset 77 Section 3.35 Changing a Terminal's Characteristics: stty 80 Section 3.36 Editing a File: vim 82 Section 3.37 Editing a File: emacs 93 Section 3.38 Electronic Mail: mail 99

Trang 5

Section 4.4 Comparing Files: cmp and diff 116 Section 4.5 Finding Files: find 119 Section 4.6 Archiving Files: cpio, tar, and dump/restore 121 Section 4.7 Scheduling Commands: crontab and at 128 Section 4.8 Programmable Text Processing: gawk 132 Section 4.9 Hard and Soft Links: ln 137 Section 4.10 Identifying Shells: whoami 139 Section 4.11 Substituting a User: su 139 Section 4.12 Transforming Files 140 Section 4.13 Looking at Raw File Contents: od 148 Section 4.14 Mounting File Systems: mount and umount 149 Section 4.15 Identifying Terminals: tty 150 Section 4.16 Timing Execution: time 151 Section 4.17 Rolling Your Own Programs: Perl 152

Section 5.7 Filename Substitution (Wildcards) 174 Section 5.8 Command Substitution 178

Section 5.10 Grouping Commands 179 Section 5.11 Background Processing 180 Section 5.12 Redirecting Background Processes 181 Section 5.13 Shell Programs (Scripts) 182 Section 5.14 Subshells or Child Shells 183

Section 5.17 Here Documents 187

Trang 6

Section 5.18 Job Control 188 Section 5.19 Finding a Command: $PATH 194 Section 5.20 Superseding Standard Utilities 195 Section 5.21 Termination and Exit Codes 196 Section 5.22 Common Core Built-Ins 197

Section 6.7 Command Substitution 222

Section 6.9 Conditional Expressions 223 Section 6.10 Control Structures 226

Section 6.12 Menus: select 236 Section 6.13 Directory Access and the Directory Stack 237

Trang 7

Section 7.6 Editing Commands 262

Section 7.8 Tilde Substitution 267 Section 7.9 Menus: select 267

Section 7.12 Enhancements 276 Section 7.13 Sample Project: junk 290 Section 7.14 Command-Line Options 293

Section 8.9 Control Structures 314 Section 8.10 Sample Project: junk 321 Section 8.11 Enhancements 323

Section 8.13 The Directory Stack 330 Section 8.14 Command-Line Options 332

Trang 8

Section 9.3 Internetworking 338 Section 9.4 Identifying Network Users 344 Section 9.5 Communicating with Network Users 347 Section 9.6 Distributing Data 350 Section 9.7 Distributed Processing 354 Section 9.8 Evolution of the Internet 360 Section 9.9 Using Today's Internet 371

Section 10.6 Desktop Operation 387 Section 10.7 Client Applications 389 Section 10.8 Standard X Client Arguments 391 Section 10.9 Advanced Topics 392

Trang 9

Chapter Review 429 Chapter 12 Systems Programming 431

Trang 10

Section 14.6 Maintaining User Accounts 584 Section 14.7 Installing New Software 587 Section 14.8 Peripheral Devices 587 Section 14.9 The Network Interface 588 Section 14.10 Automating Tasks 589 Section 14.11 Tunable Kernel Parameters 590 Section 14.12 Security Issues 591

Section A.1 Regular Expressions 595 Section A.2 Extended Regular Expressions 597 Section A.3 Modified Backus-Naur Notation 597 Section A.4 Utilities and Shell Built-In Commands 598 Section A.5 System Calls and Library Functions 605

Index

Trang 12

The author and publisher of this book have used their bestefforts in preparing this book These efforts include the

development, research, and testing of the theories and

programs to determine their effectiveness The author andpublisher make no warranty of any kind, expressed or implied,

Trang 13

in this book The author and publisher shall not be liable in anyevent for incidental or consequential damages in connection

with, or arising out of, the furnishing, performance, or use ofthese programs

Trang 14

[Page ii]

Trang 15

GNOME is a trademark of the GNOME Foundation, Inc

GNU is a trademark of the Free Software Foundation

Intel®, Itanium™, and Pentium® are registered trademarks ofIntel Corporation

IRIX® is a registered trademark of Silicon Graphics, Inc

Java™ is a trademark of Sun Microsystems, Inc

KDE and K Desktop Environment are trademarks of KDE e.V.Linux is a registered trademark of Linus Torvalds

Macintosh® and MacOS are registered trademarks of Apple

Computer, Inc

Trang 16

Microsystems, Inc All SPARC trademarks are used under

license and are trademarks or registered trademarks of SPARCInternational, Inc

Trang 17

UNIX and X Window System are registered trademarks of TheOpen Group

VMware is a trademark of VMware, Inc

HP VUE is a registered trademark of Hewlett-Packard Company

Windows, Windows 95, Windows 98, Windows ME, Windows NT,Windows 2000, and Windows XP are trademarks of MicrosoftCorporation

XFree86 is a registered trademark of The XFree86 Project, Inc.XFS® is a registered trademark of Silicon Graphics, Inc

All other trademarks and copyrights appearing in this book arethe properties of their respective owners

Trang 18

[Page xxv]

Trang 20

About the Authors

Graham Glass graduated from the University of Southampton,England, with a Bachelor's degree in Computer Science and

Mathematics He immigrated to the United States and obtainedhis Master's degree in Computer Science from the University ofTexas at Dallas He then worked as a UNIX/C systems analystand became heavily involved with research in neural networksand parallel distributed processing He later taught at the

University of Texas at Dallas, covering a wide variety of coursesincluding UNIX, C, assembly language, programming languages,C++, and Smalltalk He co-founded ObjectSpace, which

specialized in object-oriented training, consulting, and products

He then founded The Mind Electric, which produced a Java webservices platform called Glue and a platform for shared SOAinfrastructure called Fabric The Mind Electric was acquired bywebMethods, where Graham is now the Chief Technology

Officer In his spare time, he reads, runs, swims, cycles, dives,skis, travels, and maintains a blog

King Ables earned his Bachelor's degree in Computer Sciencefrom the University of Texas at Austin in 1982 He has been aUNIX user, developer, systems administrator, or consultant since

1979 and a Linux user since late in the last century He has

worked in academia, at small startup companies, and in largecorporations, and is currently an independent consultant

specializing in IT services and network security He has

developed UNIX and Linux product software and systems tools,delivered support and training services, and written productdocumentation and training materials He has authored or co-authored two books on UNIX, written many magazine articles

on various UNIX topics, and is a co-inventor of an e-commerceprivacy mechanism that was awarded a software patent Hisprofessional interests include networking, security, and privacy,

Trang 22

platform of choice for computer science students

Graham wrote the original version in response to the need forcourse material for university students as well as professionalprogrammers, taking great care to include many different types

of users in his target audience He created a book that was

helpful to everyone from a complete beginner to an experiencedprogrammer and allowed instructors to teach a variety of

courses The widespread use of Linux has led to the same needfor Linux users and instructors

When my editors at Prentice-Hall first approached me aboutcreating a Linux version of the book, my flippant response was

"Fine, change 'UNIX' to 'Linux' on the cover and ship it!" Thatresponse was made in jest, of course, but I also thought it wasrooted in some amount of truth I had used many versions ofboth UNIX and Linux in the past several years, and they

seemed all the same to me (which is a strength of both Linuxand UNIX) But this similarity is only skin deep

Experienced UNIX users will feel very comfortable with Linuxbecause it adheres to a specified standard for portable

operating systems, which means that it provides a specific set

of commands, applications, library functions, and system calls.Most of the commands and system calls behave similarly to, ifnot exactly the same as, those in most versions of UNIX Some

Trang 23

equivalent

While, on the surface, Linux looks just like UNIX (which is thewhole idea behind having a standard), the implementation isanother story With the benefit of thousands of volunteer

programers unencumbered by marketing departments and

product release schedules (i.e., "business issues") but armedwith years of advances in operating-systems understanding,Linux is actually a significant improvement of an already goodidea When you look "under the hood," you will find that Linux

is a much cleaner implementation because it doesn't suffer fromthe long evolution and tangled code base that plagues manyversions of UNIX today

And so this Linux-specific book is actually very different from itsUNIX counterpart Even where the substance is similar to UNIX,the details and examples may vary greatly Substantive

differences include a new chapter on installing Linux and largelyrevised chapters on the internal workings of Linux and systemadministration

While we could not possibly cover every detail of every

command or application that comes with Linux (without

creating a multivolume set!), we try to cover the basics and themost often used utilities to provide a solid foundation upon

which you can continue to build your understanding of Linuxand the GNU utilities

Trang 24

Organization of the Book

Linux is a big thing To describe it fully requires an explanation

of many topics from different angles, which is exactly what I'veprovided This book is split into several sections, each designedfor a particular kind of user I recommend that the various

Trang 27

A list of the system calls that are covered in the chapter (whenappropriate)

[Page xxviii]

Shell Commands

A list of the shell commands that are covered in the chapter(when appropriate)

In addition, every chapter ends with a review section, whichcontains the following:

Trang 28

One or more related projects, rated easy, medium, or hard.

Trang 29

A Guide for Teachers

As I mentioned earlier, this book was originally written for anaudience of undergraduate and graduate students I suggestthat a lecture series based on this book could be designed asfollows

paced course could begin with:

If the students don't know the C language, then a medium-a Chapter 1, "What Is Linux?"

If the students already know the C language, then a medium-a Chapter 1, "What Is Linux?"

Trang 30

g Chapter 13, "Linux Internals"

Projects focusing on parallel processing and interprocess

communication will ensure that the students end up with a goodknowledge of Linux fundamentals

Trang 31

Nomenclature

There are references throughout this book to Linux utilities, shell commands (that is, commands that are part of a command shell itself), and system calls (Linux library

functions) It's quite easy to confuse these three things, so I adopted a consistent way to differentiate them:

Formal descriptions of utilities, shell commands, and system calls are supplied in a box, using a modified-for-Linux Backus-Naur notation The conventions of this notation are fairly simple and are described fully in the Appendix As an example, here's a description

Sample Linux command sessions are presented in a Courierfont Keyboard input from the user is always displayed in italics,and annotations are always preceded by ellipses ( .) Here's

Trang 32

$ ls generate a directory listing.myfile.txt yourfile.txt

$ whoami

ables

$ _ a new prompt is displayed

Trang 33

References to Other Books

For the same reason that it's good to reuse existing code, it'salso good to use other people's reference material when it

The information in brackets is usually the name of the primaryauthor and the year of publication; in this case this book is

entitled Linux Internals Where we reference specific pages, it

is, of course, possible that future editions of these books willhave different page numbers The reference will hopefully stillremain reasonably close to the quoted page number

Trang 34

Source Code Availability Online

Source code examples of any "significant" length used in thisedition can be found on the web at:

http://www.prenhall.com/glass

(You can type this string into a web browser or see Chapter 9,

"Networking and the Internet," for more information on FTP.)

Trang 35

Acknowledgments

First of all, thanks go to Graham Glass for his original work andhis assistance and support for my work to keep it up-to-dateand to develop this Linux version Also thanks to all those whofound the UNIX edition useful and expressed a desire for a

Linux edition

I must also thank thousands of people, most of whom I've

never met, but without whom this Linux edition would have noneed to fill Linus Torvalds and his legion of contributors to

Linux, as well as Richard Stallman and his Free Software

Foundation members and followers, have changed the business

of software development

Those who have been of great help to me personally throughoutthis process include reviewers Dean Mellas of Cerritos College,Ramon Mata-Toledo and Josh Blake of James Madison

University, William D Leahy Jr of The Georgia Institute of

Technology, Bob Kramer of Youngstown State University, Shawn

M Crowley of The University of Buffalo, and Sydney Shewchuk

of Heald College Other colleagues and friends to whom I owe adebt are David Carver and Judy Ashworth, who provided

excellent feedback that helped make this edition much better,and Chris and Dana Dodge and Dan and Denise Downs, whodonated equipment to my home computer "lab."

As always, the folks at Prentice Hall have been nothing but

helpful, encouraging, and supportive, especially Petra Recter,Kate Hargett, Camille Trentacoste, Marcia Horton, Michael

Giacobbe, Tracy Dunkelberger, Donna Crilly, Sarah Parker,

Christianna Lee, and John Keegan

Special thanks to Paul Becker and Alan Apt for starting me onthis road and for their continued friendship and encouragement

Trang 36

Without them, you would not be holding this book

King Ables

Trang 37

[Page 1]

Trang 39

Chapter Review

Trang 40

Motivation

Linux is a popular operating system in the engineering and

information technology world and has lately been growing inpopularity in the business world Knowledge of its functions andpurpose will help you to understand why so many people

choose to use it, and will make your own use of Linux moreeffective

Ngày đăng: 26/03/2019, 16:33