Chapter 1 Overview of Operating Systems 1
1.1 Introduction 2
1.2 What Is an Operating System? 2
1.3 Operating System Services 4
1.4 Character Versus Graphical User Interfaces 4
1.5 Types of Operating Systems 5
1.6 The UNIX Family 6
Summary 6
Problems 7
Chapter 2 Brief History of the UNIX Operating System 9
2.2 Historical Development of the UNIX Operating System 10
2.1 Introduction 10
2.2.1 Beginnings 11
2.2.2 Research Operating System 12
2.2.3 AT&T System V 12
2.2.4 Berkely Software Distributions 12
2.2.5 The History of Shells 13
2.2.6 Current and Future Developments—LINUX 13
2.3 Variations in UNIX Systems 13
Summary 14
Problems 14
Chapter 3 Getting Started 15
3.2.1 Main/Primary Storage 16
3.1 Introduction 16
3.2 Computer System Hardware 16
3.2.2 Central Processing Unit(CPU) 17
3.2.3 Disk 18
3.2.4 Bus 18
3.2.5 I/O Devices 19
3.3 UNIX Software Architecture 19
3.3.1 Device Driver Layer 19
3.3.2 The UNIX Kernel 20
3.3.4 Language Libraries 22
3.3.5 UNIX Shell 22
3.3.3 The System Call Interface 22
3.3.6 Applications 23
3.4 Logging On and Logging Off 23
3.5 Correcting Mistakes 27
3.6 Some Important System Setups 28
3.7 Some Useful Commands for the Beginner 30
3.7.1 Changing Your Password 30
3.7.2 Getting Help 30
3.7.3 Finding Out Who You Are and What the Name of Your UNIX System Is 34
Summary 35
Problems 36
Chapter 4 UNIX Shells 39
4.1 Introduction 40
4.2 Various UNIX Shells 41
4.2.1 Shell Programs 42
4.2.2 Which Shell Suits Your Needs? 42
4.2.3 Ways to Change Your Shell 43
4.2.4 Shell Start-up Files and Environment Variables 45
4.3 Some Other Useful General-Purpose Commands 46
4.3.1 Creating and Displaying Directories 46
4.3.2 Displaying Files 48
4.3.3 Printing Files 48
4.3.5 One-Way Real-Time Messaging 49
4.3.4 Displaying a Calendar 49
4.3.6 Notification of and Permission for Electronic Communication 50
4.3.7 Creating Pseudonyms for Commands 51
4.3.8 Displaying System Up Time 53
4.4 Shell Metacharacters 54
Summary 56
Problems 56
Chapter 5 Editing Text Files 59
5.1 Introduction 60
5.2.1 Creating the Text of an e-mail Message with the pico Text Editor 61
5.2.2 How to Start,Save a File,and Exit 61
5.2 How to Do Short and Simple Edits by Using the pico Editor 61
5.2.3 General Keystroke Commands and Cursor Management 64
5.2.4 Cutting/Pasting and Searching 66
5.3 Obtaining More Control by Using the vi Editor 67
5.3.1 Shell Script File 68
5.3.2 How to Start,Save a File,and Exit 70
5.3.3 The Format of a vi Command and the Modes of Operation 71
5.3.4 Cursor Movement and Editing Commands 76
5.3.5 Yank and Put(Copy and Paste)and Substitute(Search and Replace) 78
5.3.6 Setting the vi Environment 81
5.4.1 DOS Aliases 82
5.4 Getting the Maximum Control by Using the emacs Editor 82
5.3.7 Executing Shell Commands from Within vi 82
5.4.2 How to Start,Save a File,and Exit 84
5.4.3 Cursor Movement and Editing Commands 85
5.4.4 Keyboard Macros 86
5.4.5 Cut or Copy and Paste and Search and Replace 89
5.5 Optional—How to Do Graphical Editing by Using emacs and the X Window System 93
5.5.1 Editing Data Files 93
5.5.2 How to Start,Save a File,and Exit 94
5.5.3 X Window emacs Menus 96
Summary 98
Problems 98
Chapter 6 Electronic Mail 101
6.1 Introduction 102
6.2 How to Use the UNIX mail Command Effectively 105
6.2.1 Sending and Reading e-mail with the UNIX mail Command 105
6.2.2 Sending e-mail with mail 106
6.2.3 Reading e-mail with mail 109
6.2.4 Saving Messages in Folders 111
6.2.5 Replying to and Forwarding Messages—and Including Attachments 112
6.2.6 mail Aliases 113
6.3 elm—A Full Screen Display e-mail System 114
6.3.1 Sending a Message in elm 115
6.3.2 Sending e-mail with elm 115
6.3.3 Reading e-mail in elm 119
6.3.4 Forwarding and Replying to an e-mail Message in elm 120
6.3.5 Saving Messages in Folders 123
6.3.6 elm Aliases 123
6.4 pine—Another Full-Screen Display e-mail System 125
6.4.1 Sending an e-mail Message by Using pine with an Attachment Created in vi 125
6.4.2 Sending e-mail with pine 128
6.4.3 Reading e-mail with pine 130
6.4.4 Disposing of e-mail in Folders in pine 131
6.4.5 Using the pine Address Book 133
6.4.6 A Summary of pine Commands 137
Summary 138
Problems 139
Chapter 7 Files and File System Structure 143
7.1 Introduction 144
7.2 The UNIX File Concept 144
7.3 Types of Files 144
7.3.1 Simple/Ordinary File 144
7.3.2 Directory 145
7.3.3 Link File 146
7.3.4 Special File(Device) 146
7.3.5 Named Pipe(FIFO) 147
7.4 File System Structure 147
7.4.1 File System Organization 147
7.4.3 Pathnames:Absolute and Relative 148
7.4.2 Home and Present Working Directories 148
7.4.4 Some Standard Directories and Files 149
7.5 Navigating the File Structure 152
7.5.1 Determining the Absolute Pathname for Your Home Directory 153
7.5.2 Browsing the File System 154
7.5.3 Creating Files 157
7.5.4 Creating and Removing Directories 157
7.5.5 Determing File Attributes 159
7.5.6 Determing the Type of a File's Contents 161
7.6 File Representation and Storage in UNIX 163
7.7 Standard Files and File Descriptions 165
Summary 167
7.8 End of File(eof)Marker 167
Problems 168
Chapter 8 File Security 171
8.1 Introduction 172
8.2 Password-Based Protection 172
8.3 Encryption-Based Protection 173
8.4 Protection Based on Access Permission 174
8.4.1 Types of Uses 174
8.4.2 Types of File Operations/Access Permissions 174
8.5 Determining and Changing File Access Privileges 175
8.5.1 Determing File Access Privileges 176
8.5.2 Changing File Access Privileges 178
8.5.3 Default File Access Privileges 183
8.6 Special Acces Bits 184
8.6.1 The Set-User-ID(SUID)Bit 184
8.6.2 The Set-Group-ID(SGID)Bit 186
8.6.3 The Sticky Bit 187
Summary 189
Problems 190
Chapter 9 Basic File Processing 193
9.1 Introduction 194
9.2 Viewing Contents of Text Files 194
9.2.1 Viewing Complete Files 194
9.2.2 Viewing Files One Page at a Time 197
9.2.3 Viewing the Head or Tail of a File 198
9.3 Copying,Moving,and Removing Files 202
9.3.1 Copying Files 202
9.3.2 Moving Files 205
9.3.3 Removing/Deleting Files 207
9.3.4 Determing File Size 209
9.4 Appending to Files 211
9.5 Combining Files 213
9.6 Comparing Files 215
9.7 Removing Repeated Lines 219
9.8.1 UNIX Mechanism for Printing Files 221
9.8 Printing Files and Controlling Print Jobs 221
9.8.2 Printing Files 222
9.8.3 Finding the Status of Your Print Requests 224
9.8.4 Canceling Your Print Jobs 226
Summary 228
Problems 229
Chapter 10 Advanced File Processing 231
10.1 Introduction 232
10.2 Regular Expressions 232
10.3 Compressing Files 234
10.4 Sorting Files 238
10.5 Searching for Commands and Files 241
10.6 Searching Files 245
10.7 Cutting and Pasting 250
10.8 Encoding and Decoding 255
10.9 File Encryption and Decryption 258
Summary 262
Problems 263
Chapter 11 File Sharing 265
11.1 Introduction 266
11.2 Duplicate Shared Files 266
11.3 Common Login for Memebers of a Team 266
11.6 File Sharmg Via Links 267
11.4 Setting Appropriate Access Permissions on Shared Files 267
11.5 Common Group for Members of a Team 267
11.6.1 Hard Links 268
11.6.2 Drawbacks of Hard Links 276
11.6.3 Soft/Symbolic Links 278
11.6.4 Pros and Cons of Symbolic Links 283
Summary 284
Problems 285
Chapter 12 Redirection and Piping 287
12.3 Input Redirection 288
12.2 Standard Files 288
12.1 Introduction 288
12.4 Output Redirection 290
12.5 Combining Input and Output Redirection 292
12.6 I/O Redirection with File Descriptors 293
12.7 Redirection Standard Error 294
12.8 Redirecting stdout and stderr in One Command 295
12.9 Redirecting stdin,stdout,and stderr in One Command 297
12.10 Redirecting Without Overwriting File Contents(Appending) 299
12.11 UNIX Pipes 301
12.12 Redirection and Piping Combined 305
12.13 Error Redirection in the C Shell 306
12.14 Recap of I/O and Error Redirection 310
Summary 312
Problems 313
Chapter 13 Processes 317
13.1 Introduction 318
13.2 Running Multiple Processes Simultaneously 318
13.3 UNIX Process States 319
13.4 Execution of Shell Commands 320
13.5 Process Attributes 324
13.6 Process and Job Control 328
13.6.1 Foreground and Background Processes and Related Commands 328
13.6.3 Sequential and Parallel Execution of Commands 335
13.6.2 UNIX Daemons 335
13.6.4 Abnormal Termination of Commands and Processes 340
13.7 Process Hierarchy in UNIX 344
Summary 345
Problems 346
Chapter 14 Networking and Internetworking 349
14.1 Introduction 350
14.2 Computer Networks and Internetworks 350
14.3 The Reasons for Computer Networks and Internetworks 351
14.4 Network Models 352
14.5.1 TCP and UDP 354
14.5 The TCP/IP Protocol Suite 354
14.5.2 Routing of Application Data—The Internet Protocol(IP) 355
14.5.3 IPv4 Addresses in Dotted Decimal Notation 357
14.5.4 Symbolic Names 358
14.5.5 Translating Names to IP Addresses—The Domain Name System 360
14.6 Internet Services and Protocols 362
14.7 The Client-Server Software Model 363
14.8 Application Software 364
14.8.1 Displaying the Host Name 364
14.8.2 Displaying List of Users Using Hosts on a Network 365
14.8.3 Displaying the Status of Hosts on a Network 367
14.8.4 Testing a Network Connection 368
14.8.5 Displaying Information about Users 369
14.8.6 Remote Login 373
14.8.7 Remote Command Execution 380
14.8.8 File Transfer 383
14.8.9 Remote Copy 387
14.8.10 Interactive Chat 389
14.8.11 Tracing the Route from One Site to Another Site 391
Summary 392
Problems 393
Chapter 15 Introductory Bourne Shell Programming 395
15.1 Introduction 396
15.2 Running a Bourne Shell Script 396
15.3 Shell Variables and Related Commands 397
15.3.1 Reading and Writing Shell Variables 401
15.3.2 Command Substitution 403
15.3.3 Exporting Environment 404
15.3.4 Resetting Variables 407
15.3.5 Creating Read-Only User-Defined Variables 408
15.3.6 Reading from Standard Input 409
15.4 Passing Arguments to Shell Scripts 411
15.5 Comments and Program Headers 415
15.6 Program Control Flow Commands 417
15.6.1 The if-then-elif-else-fi Statement 417
15.6.2 The for Statement 427
15.6.3 The while Statement 429
15.6.4 The until Statement 432
15.6.5 The break and continue Commands 433
15.6.6 The case Statement 434
Summary 439
Problems 440
Chapter 16 Advanced Bourne Shell Programming 443
16.1 Introduction 444
16.2 Numeric Data Processing 444
16.3 The Here Document 450
16.4 Interrupt(Signal)Processing 454
16.5.1 Execution of a Command Without Creating a New Process 459
16.5 The exec Command and File I/O 459
16.5.2 File I/O via the exec Command 461
16.6 Functions in the Bourne Shell 469
16.6.1 The Reasons for Functions 469
16.6.2 Function Definition 470
16.6.3 Function Invocation/Call 470
16.6.4 Examples of Functions 471
16.7 Debugging Shell Programs 473
Summary 475
Programs 476
Chapter 17 Introductory C Shell Programming 477
17.2 Running a C Shell Script 478
17.1 Introduction 478
17.3 Shell Variables and Related Commands 479
17.3.1 Reading and Writing Shell Variables 483
17.3.2 Command Substitution 486
17.3.3 Exporting Environment 487
17.3.4 Resetting Variables 489
17.3.5 Reading from Standard Input 491
17.4 Passing Arguments to Shell Scripts 492
17.5 Comments and Program Headers 496
17.6 Program Control Flow Commands 497
17.6.1 The if-the-else-endif Statement 498
17.6.2 The foreach Statement 506
17.6.3 The while Statement 508
17.6.4 The break,continue,and goto Commands 510
17.6.5 The switch Statement 512
Summary 515
Problems 516
Chapter 18 Advanced C Shell Programming 519
18.1 Introduction 520
18.2 Numeric Data Processing 520
18.3 Array Processing 522
18.4 The Here Document 528
18.5 Interrupt(Signal)Processing 530
18.6 Debugging Shell Programs 535
Summary 536
Problems 537
Chapter 19 File System Backup 539
19.1 Introduction 540
19.2 Archiving and Restoring Files Via tar 540
19.2.1 Archiving Files 542
19.2.2 Restoring Archived Files 546
19.2.3 Copying Directory Hierarchies 549
19.3 Software Distributions in the tar Format 550
Problems 551
Summary 551
Chapter 20 Unix Tools for Software Development 553
20.1 Introduction 554
20.2 Computer Programming Languages 554
20.3 The Compilation Process 556
20.4 The Software Engineering Life Cycle 557
20.5 Program Generation Tools 559
20.5.1 Generating C Source Files 559
20.5.2 Indenting C Source Code 559
20.5.3 Compiling C Programs 562
20.5.4 Handling Module-Based C Software 567
20.5.5 Building Object Files into a Library 578
20.5.6 Working with Libraries 582
20.5.7 Version Control 586
20.6 Stattic Analysis Tools 627
20.6.1 Verifying Code for Portability 628
20.6.2 Source Code Metrics 633
20.7 Dynamic Analysis Tools 634
20.7.1 Tracing Program Execution 634
20.7.2 Source Code Debugging 636
20.7.3 Run-Time Performance 651
Summary 653
Problems 654
Chapter 21 X Window System-The UNIX Graphical User Interface 657
21.2 User-Computer Interactivity and the X Window System 658
21.1 Introduction 658
21.2.1 The Key Components of Interactivity—Events and Request 659
21.3 The Role of a Window Manager in the User Interface and fvwm 662
21.3.1 Functions and Appearance of the Window Manager Interface 662
21.3.2 The Appearance and Operation of fvwm 662
21.4 Customizing the X Window System and fvwm 666
21.4.1 Command Line Changes to an X Window System Application 667
21.4.2 Preference Changes in.Xdefaults and.xinitrc Initialization Files 670
21.4.3 Typical Changes in.fvwmrc to Customize the fvwm Window Manager 672
Summary 676
Problems 676