search for books and compare prices
Tables of Contents for Unix Power Tools
Chapter/Section Title
Page #
Page Count
How to Use This Book
xxvii
 
Preface
xxix
 
Part I Basic Unix Environment
Introduction
3
29
What's Special About Unix?
3
1
Power Grows on You
4
2
The Core of Unix
6
1
Communication with Unix
6
2
Programs Are Designed to Work Together
8
1
There Are Many Shells
9
2
Which Shell Am I Running?
11
1
Anyone Can Program the Shell
11
2
Internal and External Commands
13
1
The Kernel and Daemons
14
2
Filenames
16
1
Filename Extensions
17
1
Wildcards
18
2
The Tree Structure of the Filesystem
20
2
Your Home Directory
22
1
Making Pathnames
23
2
File Access Permissions
25
1
The Superuser (Root)
26
1
When Is a File Not a File?
27
1
Scripting
27
1
Unix Networking and Communications
28
2
The X Window System
30
2
Getting Help
32
11
The man Command
32
1
whatis: One-Line Command Summaries
33
1
whereis: Finding Where a Command Is Located
33
1
Searching Online Manual Pages
34
2
How Unix Systems Remember Their Names
36
1
Which Version Am I Using?
36
1
What tty Am I On?
37
1
Who's On?
38
1
The info Command
38
5
Part II Customizing Your Environment
Setting Up Your Unix Shell
43
27
What Happens When You Log In
43
1
The Mac OS X Terminal Application
44
1
Shell Setup Files---Which, Where, and Why
44
4
Login Shells, Interactive Shells
48
1
What Goes in Shell Setup Files?
49
1
Tip for Changing Account Setup: Keep a Shell Ready
50
1
Use Absolute Pathnames in Shell Setup Files
51
1
Setup Files Aren't Read When You Want?
51
2
Gotchas in set prompt Test
53
1
Automatic Setups for Different Terminals
54
1
Terminal Setup: Testing TERM
55
1
Terminal Setup: Testing Remote Hostname and X Display
56
1
Terminal Setup: Testing Port
57
1
Terminal Setup: Testing Environment Variables
57
1
Terminal Setup: Searching Terminal Table
58
1
Terminal Setup: Testing Window Size
58
1
Terminal Setup: Setting and Testing Window Name
59
1
A .cshrc.$HOST File for Per Host Setup
60
1
Making a ``Login'' Shell
61
1
RC Files
62
3
Make Your Own Manpages Without Learning troff
65
2
Writing a Simple Manpage with the --man Macros
67
3
Interacting with Your Environment
70
22
Basics of Setting the Prompt
70
1
Static Prompts
70
1
Dynamic Prompts
71
1
Simulating Dynamic Prompts
72
1
C-Shell Prompt Causes Problems in vi, rsh, etc.
73
1
Faster Prompt Setting with Built-ins
74
2
Multiline Shell Prompts
76
1
Session Info in Window Title or Status Line
77
2
A ``Menu Prompt'' for Naive Users
79
1
Highlighting and Color in Shell Prompts
79
2
Right-Side Prompts
81
1
Show Subshell Level with $SHLVL
82
1
What Good Is a Blank Shell Prompt?
83
1
dirs in Your Prompt: Better Than $cwd
84
2
External Commands Send Signals to Set Variables
86
1
Preprompt, Pre-execution, and Periodic Commands
87
2
Running Commands When You Log Out
89
1
Running Commands at Bourne/Korn Shell Logout
90
1
Stop Accidental Bourne-Shell Logouts
90
2
Getting the Most out of Terminals, xterm, and X Windows
92
32
There's a Lot to Know About Terminals
92
1
The Idea of a Terminal Database
93
2
Setting the Terminal Type When You Log In
95
2
Querying Your Terminal Type: qterm
97
2
Querying Your xterm Size: resize
99
1
Checklist: Terminal Hangs When I Log In
100
4
Find Out Terminal Settings with stty
104
1
Setting Your Erase, Kill, and Interrupt Characters
104
2
Working with xterm and Friends
106
1
Login xterms and rxvts
107
1
Working with Scrollbars
108
1
How Many Lines to Save?
109
1
Simple Copy and Paste in xterm
109
1
Defining What Makes Up a Word for Selection Purposes
110
1
Setting the Titlebar and Icon Text
111
1
The Simple Way to Pick a Font
112
1
The xterm Menus
113
2
Changing Fonts Dynamically
115
2
Working with xclipboard
117
2
Problems with Large Selections
119
1
Tips for Copy and Paste Between Windows
120
2
Running a Single Command with xterm --e
122
1
Don't Quote Arguments to xterm --e
123
1
Your X Environment
124
23
Defining Keys and Button Presses with xmodmap
124
3
Using xev to Learn Keysym Mappings
127
1
X Resource Syntax
128
2
X Event Translations
130
3
Setting X Resources: Overview
133
2
Setting Resources with the --xrm Option
135
1
How --name Affects Resources
135
1
Setting Resources with xrdb
136
3
Listing the Current Resources for a Client: appres
139
1
Starting Remote X Clients
140
7
Part III Working with Files and Directories
Directory Organization
147
7
What? Me, Organized?
147
1
Many Homes
148
1
Access to Directories
148
1
A bin Directory for Your Programs and Scripts
149
1
Private (Personal) Directories
150
1
Naming Files
150
1
Make More Directories!
151
1
Making Directories Made Easier
152
2
Directories and Files
154
17
Everything but the find Command
154
1
The Three Unix File Times
154
1
Finding Oldest or Newest Files with ls --t and ls --u
155
2
List All Subdirectories with ls --R
157
1
The ls --d Option
157
1
Color Is
158
3
Some GNU Is Features
161
1
A csh Alias to List Recently Changed Files
162
1
Showing Hidden Files with ls --A and --a
163
1
Useful Is Aliases
163
2
Can't Access a File? Look for Spaces in the Name
165
1
Showing Nonprintable Characters in Filenames
166
1
Counting Files by Types
167
1
Listing Files by Age and Size
168
1
newer: Print the Name of the Newest File
169
1
oldlinks: Find Unconnected Symbolic Links
169
1
Picking a Unique Filename Automatically
170
1
Finding Files with find
171
30
How to Use find
171
2
Delving Through a Deep Directory Tree
173
2
Don't Forget --print
175
1
Looking for Files with Particular Names
175
1
Searching for Old Files
175
1
Be an Expert on find Search Operators
176
2
The Times That find Finds
178
1
Exact File-Time Comparisons
179
1
Running Commands on What You Find
179
2
Using --exec to Create Custom Tests
181
1
Custom --exec Tests Applied
182
1
Finding Many Things with One Command
182
2
Searching for Files by Type
184
1
Searching for Files by Size
185
1
Searching for Files by Permission
185
1
Searching by Owner and Group
186
1
Duplicating a Directory Tree
187
1
Using ``Fast find'' Databases
187
2
Wildcards with ``Fast find'' Database
189
1
Finding Files (Much) Faster with a find Database
190
2
grepping a Directory Tree
192
1
lookfor: Which File Has That Word?
193
1
Using Shell Arrays to Browse Directories
194
3
Finding the (Hard) Links to a File
197
1
Finding Files with --prune
198
1
Quick finds in the Current Directory
199
1
Skipping Parts of a Tree in find
199
1
Keeping find from Searching Networked Filesystem
200
1
Linking, Renaming, and Copying Files
201
17
What's So Complicated About Copying Files
201
1
What's Really in a Directory?
201
2
Files with Two or More Names
203
2
More About Links
205
3
Creating and Removing Links
208
1
Stale Symbolic Links
209
1
Linking Directories
210
2
Showing the Actual Filenames for Symbolic Links
212
1
Renaming, Copying, or Comparing a Set of Files
212
1
Renaming a List of Files Interactively
213
1
One More Way to Do It
213
1
Copying Directory Trees with cp --r
214
2
Copying Directory Trees with tar and Pipes
216
2
Comparing Files
218
16
Checking Differences with diff
218
2
Comparing Three Different Versions with diff3
220
1
Context diffs
221
3
Side-by-Side diffs: sdiff
224
1
Choosing Sides with sdiff
225
1
Problems with diff and Tabstops
225
1
cmp and diff
226
1
Comparing Two Files with comm
227
2
More Friendly comm Output
229
1
make Isn't Just for Programmers!
230
2
Even More Uses for make
232
2
Showing What's in a File
234
13
Cracking the Nut
234
1
What Good Is a cat?
234
2
``less'' is More
236
1
Show Nonprinting Characters with cat --v or od --c
237
2
What's in That Whitespace?
239
1
Finding File Types
240
1
Squash Extra Blank Lines
241
1
How to Look at the End of a File: tail
242
1
Finer Control on tail
243
1
How to Look at Files as They Grow
243
2
GNU tail File Following
245
1
Printing the Top of a File
246
1
Numbering Lines
246
1
Searching Through Files
247
15
Different Versions of grep
247
1
Searching for Text with grep
248
1
Finding Text That Doesn't Match
249
1
Extended Searching for Text with egrep
250
1
grepping for a List of Patterns
251
1
Approximate grep: agrep
251
1
Search RCS Files with rcsgrep
252
2
GNU Context greps
254
1
A Multiline Context grep Using sed
255
1
Compound Searches
256
1
Narrowing a Search Quickly
257
1
Faking Case-Insensitive Searches
258
1
Finding a Character in a Column
258
1
Fast Searches and Spelling Checks with ``look''
259
1
Finding Words Inside Binary Files
259
1
A Highlighting grep
260
2
Removing Files
262
15
The Cycle of Creation and Destruction
262
1
How Unix Keeps Track of Files: Inodes
262
1
rm and Its Dangers
263
2
Tricks for Making rm Safer
265
1
Answer ``Yes'' or ``No'' Forever with yes
265
1
Remove Some, Leave Some
266
1
A Faster Way to Remove Files Interactively
266
1
Safer File Deletion in Some Directories
267
1
Safe Delete: Pros and Cons
268
1
Deletion with Prejudice: rm --f
269
1
Deleting Files with Odd Names
269
1
Using Wildcards to Delete Files with Strange Names
270
1
Handling a Filename Starting with a Dash (--)
271
1
Using unlink to Remove a File with a Strange Name
271
1
Removing a Strange File by its i-number
272
1
Problems Deleting Directories
272
2
Deleting Stale Files
274
1
Removing Every File but One
275
1
Using find to Clear Out Unneeded Files
276
1
Optimizing Disk Space
277
18
Disk Space Is Cheap
277
1
Instead of Removing a File, Empty It
277
2
Save Space with ``Bit Bucket'' Log Files and Mailboxes
279
1
Save Space with a Link
279
1
Limiting File Sizes
280
1
Compressing Files to Save Space
281
3
Save Space: tar and compress a Directory Tree
284
2
How Much Disk Space?
286
2
Compressing a Directory Tree: Fine-Tuning
288
1
Save Space in Executable Files with strip
289
1
Disk Quotas
290
5
Part IV Basic Editing
Spell Checking, Word Counting, and Textual Analysis
295
13
The Unix spell Command
295
1
Check Spelling Interactively with ispell
296
2
How Do I Spell That Word?
298
1
Inside spell
299
2
Adding Words to ispell's Dictionary
301
2
Counting Lines, Words, and Characters: wc
303
2
Find a a Doubled Word
305
1
Looking for Closure
305
1
Just the Words, Please
306
2
vi Tips and Tricks
308
28
The vi Editor: Why So Much Material?
308
1
What We Cover
309
1
Editing Multiple Files with vi
309
2
Edits Between Files
311
1
Local Settings for vi
312
1
Using Buffers to Move or Copy Text
313
1
Get Back What You Deleted with Numbered Buffers
313
1
Using Search Patterns and Global Commands
314
1
Confirming Substitutions in vi
315
1
Keep Your Original File, Write to a New File
316
1
Saving Part of a File
316
1
Appending to an Existing File
317
1
Moving Blocks of Text by Patterns
317
1
Useful Global Commands (with Pattern Matches)
318
2
Counting Occurrences; Stopping Search Wraps
320
1
Capitalizing Every Word on a Line
320
1
Per-File Setups in Separate Files
321
1
Filtering Text Through a Unix Command
322
2
vi File Recovery Versus Networked Filesystems
324
1
Be Careful with vi --r Recovered Buffers
325
1
Shell Escapes: Running One Unix Command While Using Another
326
1
vi Compound Searches
327
1
vi Word Abbreviation
328
2
Using vi Abbreviations as Commands (Cut and Paste Between vi's)
330
1
Fixing Typos with vi Abbreviations
330
1
vi Line Commands Versus Character Commands
331
1
Out of Temporary Space? Use Another Directory
332
1
Neatening Lines
333
1
Finding Your Place with Undo
334
1
Setting Up vi with the .exrc File
334
2
Creating Custom Commands in vi
336
17
Why Type More Than You Have To?
336
1
Save Time and Typing with the vi map Commands
336
3
What You Lose When You Use map!
339
1
vi @-Functions
340
3
Keymaps for Pasting into a Window Running vi
343
1
Protecting Keys from Interpretation by ex
343
2
Maps for Repeated Edits
345
2
More Examples of Mapping Keys in vi
347
1
Repeating a vi Keymap
348
1
Typing in Uppercase Without CAPS LOCK
348
1
Text-Input Mode Cursor Motion with No Arrow Keys
349
1
Don't Lose Important Functions with vi Maps: Use noremap
350
1
vi Macro for Splitting Long Lines
350
1
File-Backup Macros
351
2
GNU Emacs
353
14
Emacs: The Other Editor
353
1
Emacs Features: A Laundry List
354
4
Customizations and How to Avoid Them
358
1
Backup and Auto-Save Files
358
2
Putting Emacs in Overwrite Mode
360
1
Command Completion
360
1
Mike's Favorite Timesavers
361
1
Rational Searches
362
1
Unset PWD Before Using Emacs
363
1
Inserting Binary Characters into Files
363
1
Using Word-Abbreviation Mode
364
2
Directories for Emacs Hacks
366
1
An Absurd Amusement
366
1
Batch Editing
367
23
Why Line Editors Aren't Dinosaurs
367
1
Writing Editing Scripts
368
1
Line Addressing
369
1
Useful ex Commands
370
3
Running Editing Scripts Within vi
373
1
Change Many Files by Editing Just One
373
2
ed/ex Batch Edits: A Typical Example
375
1
Batch Editing Gotcha: Editors Fail on Big Files
376
1
patch: Generalized Updating of Files That Differ
377
1
Quick Reference: awk
378
10
Versions of awk
388
2
You Can't Quite Call This Editing
390
31
And Why Not?
390
1
Neatening Text with fmt
391
1
Alternatives to fmt
392
2
Clean Up Program Comment Blocks
394
1
Remove Mail/News Headers with behead
395
1
Low-Level File Butchery with dd
396
1
offset: Indent Text
396
1
Centering Lines in a File
397
1
Splitting Files at Fixed Points: split
398
3
Splitting Files by Context: csplit
401
3
Hacking on Characters with tr
404
2
Encoding ``Binary'' Files into ASCII
406
4
Text Conversion with dd
410
1
Cutting Columns or Fields
410
1
Making Text in Columns with pr
411
2
Make Columns Automatically with column
413
2
Straightening Jagged Columns
415
1
Pasting Things in Columns
416
1
Joining Lines with join
417
1
What Is (or Isn't) Unique?
418
1
Rotating Text
419
2
Sorting
421
14
Putting Things in Order
421
1
Sort Fields: How sort Sorts
422
2
Changing the sort Field Delimiter
424
1
Confusion with Whitespace Field Delimiters
424
2
Alphabetic and Numeric Sorting
426
1
Miscellaneous sort Hints
427
2
Iensort: Sort Lines by Length
429
1
Sorting a List of People by Last Name
430
5
Part V Processes and the Kernel
Job Control
435
16
Job Control in a Nutshell
435
2
Job Control Basics
437
1
Using jobs Effectively
438
2
Some Gotchas with Job Control
440
2
The ``Current Job'' Isn't Always What You Expect
442
1
Job Control and autowrite: Real Timesavers!
442
1
System Overloaded? Try Stopping Some Jobs
443
1
Notification When Jobs Change State
444
1
Stop Background Output with stty tostop
444
1
nohup
445
1
Disowning Processes
446
1
Linux Virtual Consoles
447
2
Stopping Remote Login Sessions
449
2
Starting, Stopping, and Killing Processes
451
37
What's in This Chapter
451
1
fork and exec
452
1
Managing Processes: Overall Concepts
453
2
Subshells
455
1
The ps Command
456
3
The Controlling Terminal
459
1
Tracking Down Processes
460
2
Why ps Prints Some Commands in Parentheses
462
1
The /proc Filesystem
463
5
What Are Signals?
468
1
Killing Foreground Jobs
469
1
Destroying Processes with kill
470
1
Printer Queue Watcher: A Restartable Daemon Shell Script
471
2
Killing All Your Processes
473
1
Killing Processes by Name?
474
2
Kill Processes Interactively
476
2
Processes Out of Control? Just STOP Them
478
1
Cleaning Up an Unkillable Process
479
1
Why You Can't Kill a Zombie
480
1
The Process Chain to Your Window
480
2
Terminal Windows Without Shells
482
2
Close a Window by Killing Its Process(es)
484
4
Delayed Execution
488
12
Building Software Robots the Easy Way
488
1
Periodic Program Execution: The cron Facility
489
5
Adding crontab Entries
494
1
Including Standard Input Within a cron Entry
495
1
The at Command
495
1
Making Your at Jobs Quiet
496
1
Checking and Removing Jobs
496
1
Avoiding Other at and cron Jobs
497
1
Waiting a Little While: sleep
498
2
System Performance and Profiling
500
13
Timing Is Everything
500
3
Timing Programs
503
1
What Commands Are Running and How Long Do They Take?
504
2
Checking System Load: uptime
506
1
Know When to Be ``nice'' to Other Users...and When Not To
506
4
A nice Gotcha
510
1
Changing a Running Job's Niceness
510
3
Part VI Scripting
Shell Interpretation
513
29
What the Shell Does
513
1
How the Shell Executes Other Commands
514
1
What's a Shell, Anyway?
515
2
Command Evaluation and Accidentally Overwriting Files
517
1
Output Command-Line Arguments One by One
518
1
Controlling Shell Command Searches
518
2
Wildcards Inside Aliases
520
1
eval: When You Need Another Chance
521
2
Which One Will bash Use?
523
1
Which One Will the C Shell Use?
524
2
Is It ``2>&1 file'' or ``>file2>&1''? Why?
526
1
Bourne Shell Quoting
526
5
Differences Between Bourne and C Shell Quoting
531
2
Quoting Special Characters in Filenames
533
1
Verbose and Echo Settings Show Quoting
533
1
Here Documents
534
1
``Special'' Characters and Operators
535
5
How Many Backslashes?
540
2
Saving Time on the Command Line
542
29
What's Special About the Unix Command Line
542
1
Reprinting Your Command Line with CTRL-r
543
1
Use Wildcards to Create Files?
544
1
Build Strings with { }
545
2
String Editing (Colon) Operators
547
2
Automatic Completion
549
4
Don't Match Useless Files in Filename Completion
553
1
Repeating Commands
554
1
Repeating and Varying Commands
554
3
Repeating a Command with Copy-and-Paste
557
1
Repeating a Time-Varying Command
558
1
Multiline Commands, Secondary Prompts
559
1
Here Document Example #1: Unformatted Form Letters
560
1
Command Substitution
561
2
Handling Lots of Text with Temporary Files
563
1
Separating Commands with Semicolons
563
2
Dealing with Too Many Arguments
565
2
Expect
567
4
Custom Commands
571
22
Creating Custom Commands
571
1
Introduction to Shell Aliases
571
1
C-Shell Aliases with Command-Line Arguments
572
2
Setting and Unsetting Bourne-Type Aliases
574
1
Korn-Shell Aliases
575
1
zsh Aliases
576
1
Sourceable Scripts
576
2
Avoiding C-Shell Alias Loops
578
1
How to Put if-then-else in a C-Shell Alias
579
1
Fix Quoting in csh Aliases with makealias and quote
580
1
Shell Function Basics
581
4
Shell Function Specifics
585
1
Propagating Shell Functions
586
5
Simulated Bourne Shell Functions and Aliases
591
2
The Use of History
593
24
The Lessons of History
593
1
History in a Nutshell
594
1
My Favorite Is !$
595
1
My Favorite Is !:n*
595
1
My Favorite Is ^^
596
1
Using !$ for Safety with Wildcards
597
1
History by Number
597
2
History Substitutions
599
5
Repeating a Cycle of Commands
604
1
Running a Series of Commands on a File
604
1
Check Your History First with :p
605
1
Picking Up Where You Left Off
606
2
Pass History to Another Shell
608
1
Shell Command-Line Editing
609
6
Changing History Characters with histchars
615
1
Instead of Changing History Characters
616
1
Moving Around in a Hurry
617
16
Getting Around the Filesystem
617
1
Using Relative and Absolute Pathnames
618
2
What Good Is a Current Directory?
620
1
How Does Unix Find Your Current Directory?
621
1
Saving Time When You Change Directories: cdpath
622
1
Loop Control: break and Continue
623
1
The Shells' pushd and popd Commands
624
2
Nice Aliases for pushd
626
1
Quick cds with Aliases
627
1
cd by Directory Initials
627
2
Finding (Anyone's) Home Directory, Quickly
629
1
Marking Your Place with a Shell Variable
630
1
Automatic Setup When You Enter/Exit a Directory
630
3
Regular Expressions (Pattern Matching)
633
24
That's an Expression
633
1
Don't Confuse Regular Expressions with Wildcards
634
1
Understanding Expressions
635
2
Using Metacharacters in Regular Expressions
637
1
Regular Expressions: The Anchor Characters ^ and $
638
1
Regular Expressions: Matching a Character with a Character Set
639
1
Regular Expressions: Match Any Character with . (Dot)
640
1
Regular Expressions: Specifying a Range of Characters with [...]
640
1
Regular Expressions: Exceptions in a Character Set
641
1
Regular Expressions: Repeating Character Sets with *
641
1
Regular Expressions: Matching a Specific Number of Sets with \ { and \ }
642
1
Regular Expressions: Matching Words with \ < and \ >
643
1
Regular Expressions: Remembering Patterns with \ (, \), and \1
644
1
Regular Expressions: Potential Problems
644
1
Extended Regular Expressions
645
1
Getting Regular Expressions Right
646
2
Just What Does a Regular Expression Match?
648
1
Limiting the Extent of a Match
649
1
I Never Meta Character I Didn't Like
650
1
Valid Metacharacters for Different Unix Programs
651
1
Pattern Matching Quick Reference with Examples
652
5
Wildcards
657
11
File-Naming Wildcards
657
1
Filename Wildcards in a Nutshell
658
2
Who Handles Wildcards?
660
2
What if a Wildcard Doesn't Match?
662
1
Maybe You Shouldn't Use Wildcards in Pathnames
663
1
Getting a List of Matching Files with grep --1
664
1
Getting a List of Nonmatching Files
664
2
nom: List Files That Don't Match a Wildcard
666
2
The sed Stream Editor
668
30
sed Sermon^H^H^H^H^H^HSummary
668
1
Two Things You Must Know About sed
669
1
Invoking sed
669
1
Testing and Using a sed Script: checksed, runsed
670
2
sed Addressing Basics
672
2
Order of Commands in a Script
674
1
One Thing at a Time
675
1
Delimiting a Regular Expression
675
1
Newlines in a sed Replacement
676
1
Referencing the Search String in a Replacement
677
1
Referencing Portions of a Search String
678
1
Search and Replacement: One Match Among Many
679
1
Transformations on Text
680
1
Hold Space: The Set-Aside Buffer
680
3
Transforming Part of a Line
683
2
Making Edits Across Line Boundaries
685
3
The Deliberate Scrivener
688
2
Searching for Patterns Split Across Lines
690
2
Multiline Delete
692
1
Making Edits Everywhere Except...
693
2
The sed Test Command
695
1
Uses of the sed Quit Command
696
1
Dangers of the sed Quit Command
696
1
sed Newlines, Quoting, and Backslashes in a Shell Script
697
1
Shell Programming for the Uninitiated
698
43
Writing a Simple Shell Program
698
2
Everyone Should Learn Some Shell Programming
700
2
What Environment Variables Are Good For
702
3
Parent-Child Relationships
705
1
Predefined Environment Variables
705
3
The PATH Environment Variable
708
1
PATH and path
709
1
The DISPLAY Environment Variable
710
1
Shell Variables
711
2
Test String Values with Bourne-Shell case
713
1
Pattern Matching in case Statements
714
1
Exit Status of Unix Processes
715
1
Test Exit Status with the if Statement
716
2
Testing Your Success
718
1
Loops That Test Exit Status
719
1
Set Exit Status of a Shell (Script)
720
1
Trapping Exits Caused by Interrupts
721
2
read: Reading from the Keyboard
723
1
Shell Script ``Wrappers'' for awk, sed, etc.
724
1
Handling Command-Line Arguments in Shell Scripts
725
2
Handling Command-Line Arguments with a for Loop
727
1
Handling Arguments with while and shift
728
2
Loop Control: break and continue
730
1
Standard Command-Line Parsing
730
2
The Bourne Shell set Command
732
3
test: Testing Files and Strings
735
1
Picking a Name for a New Command
736
1
Finding a Program Name and Giving Your Program Multiple Names
736
1
Reading Files with the . and source Commands
737
1
Using Shell Functions in Shell Scripts
738
3
Shell Programming for the Initiated
741
34
Beyond the Basics
741
1
The Story of : # #!
742
1
Don't Need a Shell for Your Script? Don't Use One
743
1
Making #! Search the PATH
744
1
The exec Command
745
1
The Unappreciated Bourne Shell ``:'' Operator
746
1
Parameter Substitution
747
1
Save Disk Space and Programming: Multiple Names for a Program
748
1
Finding the Last Command-Line Argument
749
1
How to Unset All Command-Line Parameters
749
1
Standard Input to a for Loop
750
1
Making a for Loop with Multiple Variables
750
1
Using basename and dirname
751
2
A while Loop with Several Loop Control Commands
753
1
Overview: Open Files and File Descriptors
753
3
n>&m: Swap Standard Output and Standard Error
756
3
A Shell Can Read a Script from Its Standard Input, but...
759
1
Shell Scripts On-the-Fly from Standard Input
760
1
Quoted hereis Document Terminators: sh Versus csh
761
1
Turn Off echo for ``Secret'' Answers
761
1
Quick Reference: expr
762
2
Testing Characters in a String with expr
764
1
Grabbing Parts of a String
764
4
Nested Command Substitution
768
2
Testing Two Strings with One case Statement
770
1
Outputting Text to an X Window
770
2
Shell Lockfile
772
3
Shell Script Debugging and Gotchas
775
12
Tips for Debugging Shell Scripts
775
2
Bourne Shell Debugger Shows a Shell Variable
777
1
Stop Syntax Errors in Numeric Tests
777
1
Stop Syntax Errors in String Tests
778
1
Quoting and Command-Line Parameters
779
2
How Unix Keeps Time
781
1
Copy What You Do with script
782
1
Cleaning script Files
783
1
Making an Arbitrary-Size File for Testing
784
3
Part VII Extending and Managing Your Environment
Backing Up Files
787
21
What Is This ``Backup'' Thing?
787
1
tar in a Nutshell
788
1
Make Your Own Backups
788
2
More Ways to Back Up
790
1
How to Make Backups to a Local Device
790
5
Restoring Files from Tape with tar
795
2
Using tar to a Remote Tape Drive
797
1
Using GNU tar with a Remote Tape Drive
798
1
On-Demand Incremental Backups of a Project
798
2
Using Wildcards with tar
800
3
Avoid Absolute Paths with tar
803
1
Getting tar's Arguments in the Right Order
804
1
The cpio Tape Archiver
805
1
Industrial Strength Backups
806
2
Creating and Reading Archives
808
14
Packing Up and Moving
808
1
Using tar to Create and Unpack Archives
809
4
GNU tar Sampler
813
1
Managing and Sharing Files with RCS and CVS
814
1
RCS Basics
815
2
List RCS Revision Numbers with rcsrevs
817
1
CVS Basics
818
1
More CVS
819
3
Software Installation
822
17
/usr/bin and Other Software Directories
822
2
The Challenges of Software Installation on Unix
824
1
Which make?
824
1
Simplifying the make Process
824
1
Using Debian's dselect
825
7
Installing Software with Debian's Apt-Get
832
2
Interruptable gets with wget
834
2
The curl Application and One-Step GNU-Darwin Auto-Installer for OS X
836
1
Installation with FreeBSD Ports
837
1
Installing with FreeBSD Packages
837
1
Finding and Installing RPM Packaged Software
838
1
Perl
839
30
High-Octane Shell Scripting
839
1
Checking your Perl Installation
839
2
Compiling Perl from Scratch
841
1
Perl Boot Camp, Part 1: Typical Script Anatomy
842
3
Perl Boot Camp, Part 2: Variables and Data Types
845
7
Perl Boot Camp, Part 3: Branching and Looping
852
2
Perl Boot Camp, Part 4: Pattern Matching
854
2
Perl Boot Camp, Part 5: Perl Knows Unix
856
3
Perl Boot Camp, Part 6: Modules
859
2
Perl Boot Camp, Part 7: perldoc
861
1
CPAN
862
3
Make Custom grep Commands (etc.) with Perl
865
1
Perl and the Internet
866
3
Python
869
16
What Is Python?
869
1
Installation and Distutils
869
2
Python Basics
871
5
Python and the Web
876
1
urllib
876
1
urllib2
877
1
htmllib and HTMLParser
878
1
cgi
878
1
mod_Python
879
1
What About Perl?
880
5
Part VIII Communication and Connectivity
Redirecting Input and Output
885
15
Using Standard Input and Output
885
3
One Argument with a cat Isn't Enough
888
1
Send (Only) Standard Error Down a Pipe
888
1
Problems Piping to a Pager
889
2
Redirection in C Shell: Capture Errors, Too?
891
1
Safe I/O Redirection with noclobber
892
1
The () Subshell Operators
893
1
Send Output Two or More Places
894
1
How to tee Several Commands into One Place
895
1
Redirecting Output to More Than One Place
895
2
Named Pipes: FIFOs
897
1
What Can You Do with an Empty File?
898
2
Devices
900
14
Quick Introduction to Hardware
900
1
Reading Kernel Boot Output
900
2
Basic Kernel Configuration
902
1
Disk Partitioning
903
1
Filesystem Types and /etc/fstab
904
2
Mounting and Unmounting Removable Filesystems
906
1
Loopback Mounts
907
1
Network Devices---ifconfig
908
1
Mounting Network Filesystems---NFS, SMBFS
908
1
Win Is a Modem Not a Modem?
909
1
Setting Up a Dialup PPP Session
910
1
USB Configuration
911
1
Dealing with Sound Cards and Other Annoying Hardware
911
1
Decapitating Your Machine---Serial Consoles
912
2
Printing
914
22
Introduction to Printing
914
1
Introduction to Printing on Unix
915
2
Printer Control with lpc
917
1
Using Different Printers
918
1
Using Symbolic Links for Spooling
919
1
Formatting Plain Text: pr
920
2
Formatting Plain Text: enscript
922
1
Printing Over a Network
923
1
Printing Over Samba
923
2
Introduction to Typesetting
925
1
A Bit of Unix Typesetting History
926
1
Typesetting Manpages: nroff
927
1
Formatting Markup Languages---troff, LATEX, HTML, and So On
928
1
Printing Languages---PostScript, PCL, DVI, PDF
929
1
Converting Text Files into a Printing Language
930
1
Converting Typeset Files into a Printing Language
931
1
Converting Source Files Automagically Within the Spooler
932
1
The Common Unix Printing System (CUPS)
933
1
The Portable Bitmap Package
933
3
Connectivity
936
15
TCP/IP---IP Addresses and Ports
936
2
/etc/services Is Your Friend
938
1
Status and Troubleshooting
939
2
Where, Oh Where Did That Packet Go?
941
1
The Director of Operations: inetd
942
1
Secure Shell (SSH)
943
1
Configuring an Anonymous FTP Server
944
1
Mail---SMTP, POP, and IMAP
944
1
Domain Name Service (DNS)
945
2
Dynamic Host Configuration Protocol (DHCP)
947
1
Gateways and NAT
948
1
Firewalls
949
1
Gatewaying from a Personal LAN over a Modem
950
1
Connecting to MS Windows
951
18
Building Bridges
951
1
Installing and Configuring Samba
951
4
Securing Samba
955
1
SWAT and GUI SMB Browsers
956
2
Printing with Samba
958
1
Connecting to SMB Shares from Unix
959
1
Sharing Desktops with VNC
959
3
Of Emulators and APIs
962
1
Citrix: Making Windows Multiuser
963
6
Part IX Security
Security Basics
969
13
Understanding Points of Vulnerability
969
1
CERT Security Checklists
970
1
Keeping Up with Security Alerts
971
1
What We Mean by Buffer Overflow
972
1
What We Mean by DoS
973
1
Beware of Sluggish Performance
974
3
Intruder Detection
977
1
Importance of MOTD
978
1
The Linux proc Filesystem
979
1
Disabling inetd
979
1
Disallow rlogin and rsh
980
1
TCP Wrappers
980
2
Root, Group, and User Management
982
12
Unix User/Group Infrastructure
982
1
When Does a User Become a User
982
2
Forgetting the root Password
984
1
Setting an Exact umask
985
1
Group Permissions in a Directory with the setgid Bit
985
1
Groups and Group Ownership
986
2
Add Users to a Group to Deny Permissions
988
1
Care and Feeding of SUID and SGID Scripts
989
1
Substitute Identity with su
990
1
Never Log In as root
990
1
Providing Superpowers with sudo
991
1
Enabling Root in Darwin
992
1
Disable logins
993
1
File Security, Ownership, and Sharing
994
17
Introduction to File Ownership and Security
994
1
Tutorial on File and Directory Permissions
994
4
Who Will Own a New File?
998
1
Protecting Files with the Sticky Bit
999
1
Using chmod to Change File Permission
1000
1
The Handy chmod = Operator
1001
1
Protect Important Files: Make Them Unwritable
1002
1
cx, cw, c--w: Quick File Permission Changes
1003
1
A Loophole: Modifying Files Without Write Access
1003
1
A Directory That People Can Access but Can't List
1004
2
Juggling Permissions
1006
1
File Verification with md5sum
1007
2
Shell Scripts Must Be Readable and (Usually) Executable
1009
1
Why Can't You Change File Ownership?
1009
1
How to Change File Ownership Without chown
1010
1
SSH
1011
19
Enabling Remote Access on Mac OS X
1011
1
Protecting Access Through SSH
1011
1
Free SSH with OpenSSH
1012
1
SSH Problems and Solutions
1013
1
General and Authentication Problems
1013
6
Key and Agent Problems
1019
2
Server and Client Problems
1021
9
Glossary
1030
7
Index
1037