UNIX Administration A Comprehensive Sourcebook for Effective Systems Network Management pdf pdf
UNIX Administration
Table of Contents
UNIX Administration—A Comprehensive Sourcebook for Effective Systems and NetworkManagement......................................................................................................................................1
Preface................................................................................................................................................3
Section I: UNIX Administration.........................................................................................................6
Chapter List..............................................................................................................................6 ..........................................................................................................................................6
Chapter 1: UNIX — Introductory Notes............................................................................................7
1.1 UNIX Operating System.....................................................................................................7
1.2 User's View of UNIX...........................................................................................................9
1.3 The History of UNIX.........................................................................................................10
1.3.1 Berkeley Standard Distribution — BSD UNIX.........................................................10
1.3.2 System V or ATT UNIX...........................................................................................11
1.4 UNIX System and Network Administration......................................................................15
1.4.1 System Administrator's Job.....................................................................................16
1.4.2 Computing Policies.................................................................................................19
1.4.3 Administration Guidelines.......................................................................................22
1.4.4 In This Book............................................................................................................28
Chapter 2: The Unix Model — Selected Topics............................................................................30
2.1 Introduction......................................................................................................................30
2.2 Files.................................................................................................................................30
2.2.1 File Ownership........................................................................................................31
2.2.2 File Protection/File Access......................................................................................34
2.2.3 Access Control Lists (ACLs)...................................................................................41
2.2.4 File Types................................................................................................................45
2.3 Devices and Special Device Files....................................................................................49
2.3.1 Special File Names.................................................................................................50
2.3.2 Special File Creation...............................................................................................50
2.4 Processes........................................................................................................................53
2.4.1 Process Parameters................................................................................................53
2.4.2 Process Life Cycles.................................................................................................55
2.4.3 Process Handling....................................................................................................57
Chapter 3: UNIX Administration Starters......................................................................................65
3.1 Superuser and Users.......................................................................................................65
3.1.1 Becoming a Superuser............................................................................................65
3.1.2 Communicating with Other Users...........................................................................65
3.1.3 The su Command....................................................................................................66
3.2 UNIX Online Documentation............................................................................................67
3.2.1 The man Command................................................................................................67
3.2.2 The whatis Database..............................................................................................71
3.3 System Information..........................................................................................................72
3.3.1 System Status Information......................................................................................72
3.3.2 Hardware Information..............................................................................................74
3.4 Personal Documentation..................................................................................................78
3.5 Shell Script Programming................................................................................................79
3.5.1 UNIX User Shell......................................................................................................80
Table of Contents
Chapter 3: UNIX Administration Starters
3.5.2 UNIX Shell Scripts...................................................................................................80
Chapter 4: System Startup and Shutdown....................................................................................87
4.1 Introductory Notes............................................................................................................87
4.2 System Startup................................................................................................................88
4.2.1 The Bootstrap Program...........................................................................................88
4.2.2 The Kernel Execution..............................................................................................89
4.2.3 The Overall System Initialization.............................................................................90
4.2.4 System States.........................................................................................................91
4.2.5 The Outlook of a Startup Procedure.......................................................................92
4.2.6 Initialization Scripts.................................................................................................95
4.3 BSD Initialization..............................................................................................................95
4.3.1 The BSD rc Scripts..................................................................................................95
4.3.2 BSD Initialization Sequence....................................................................................96
4.4 System V Initialization......................................................................................................98
4.4.1 The Configuration File /etc/inittab...........................................................................98
4.4.2 System V rc Initialization Scripts...........................................................................101
4.4.3 BSD−Like Initialization..........................................................................................105
4.5 Shutdown Procedures....................................................................................................106
4.5.1 The BSD shutdown Command..............................................................................107
4.5.2 The System V shutdown Command......................................................................108
4.5.3 An Example...........................................................................................................108
Chapter 5: UNIX Filesystem Management...................................................................................109
5.1 Introduction to the UNIX Filesystem..............................................................................109
5.2 UNIX Filesystem Directory Organization.......................................................................110
5.2.1 BSD Filesystem Directory Organization................................................................110
5.2.2 System V Filesystem Directory Organization........................................................112
5.3 Mounting and Dismounting Filesystems........................................................................114
5.3.1 Mounting a Filesystem..........................................................................................114
5.3.2 Dismounting a Filesystem.....................................................................................118
5.3.3 Automatic Filesystem Mounting............................................................................119
5.3.4 Removable Media Management...........................................................................120
5.4 Filesystem Configuration...............................................................................................120
5.4.1 BSD Filesystem Configuration File.......................................................................121
5.4.2 System V Filesystem Configuration File...............................................................122
5.4.3 AIX Filesystem Configuration File.........................................................................125
5.4.4 The Filesystem Status File....................................................................................127
5.5 A Few Other Filesystem Issues.....................................................................................128
5.5.1 Filesystem Types..................................................................................................128
5.5.2 Swap Space — Paging and Swapping.................................................................130
5.5.3 Loopback Virtual Filesystem.................................................................................132
5.6 Managing Filesystem Usage..........................................................................................133
5.6.1 Display Filesystem Statistics: The df Command...................................................133
5.6.2 Report on Disk Usage: The du Command............................................................135
5.6.3 Report on Disk Usage by Users: The quot Command..........................................138
5.6.4 Checking Filesystems: The fsck Command..........................................................138
Table of Contents
Chapter 6: UNIX Filesystem Layout.............................................................................................141
6.1 Introduction....................................................................................................................141
6.2 Physical Filesystem Layout............................................................................................142
6.2.1 Disk Partitions.......................................................................................................142
6.2.2 Filesystem Structures............................................................................................144
6.2.3 Filesystem Creation..............................................................................................147
6.2.4 File Identification and Allocation............................................................................148
6.2.5 Filesystem Performance Issues............................................................................152
6.3 Logical Filesystem Layout..............................................................................................154
6.3.1 Logical Volume Manager — AIX Flavor................................................................154
6.3.2 Logical Volume Manager — HP−UX Flavor..........................................................158
6.3.3 Logical Volume Manager — Solaris Flavor...........................................................160
6.3.4 Redundant Array of Inexpensive Disks (RAID).....................................................163
6.3.5 Snapshot...............................................................................................................163
6.3.6 Virtual UNIX Filesystem........................................................................................166
6.4 Disk Space Upgrade......................................................................................................167
Chapter 7: User Account Management........................................................................................169
7.1 Users and Groups..........................................................................................................169
7.1.1 Creation of User Accounts....................................................................................169
7.1.2 User Database — File /etc/passwd.......................................................................170
7.1.3 Group Database — File /etc/group.......................................................................172
7.1.4 Creating User Home Directories...........................................................................172
7.1.5 UNIX Login Initialization........................................................................................173
7.2 Maintenance of User Accounts......................................................................................177
7.2.1 Restricted User Accounts......................................................................................178
7.2.2 Users and Secondary Groups...............................................................................178
7.2.3 Assigning User Passwords...................................................................................179
7.2.4 Standard UNIX Users and Groups........................................................................179
7.2.5 Removing User Accounts......................................................................................180
7.3 Disk Quotas...................................................................................................................181
7.3.1 Managing Disk Usage by Users............................................................................181
7.4 Accounting.....................................................................................................................183
7.4.1 BSD Accounting....................................................................................................184
7.4.2 System V Accounting............................................................................................185
7.4.3 AIX−Flavored Accounting.....................................................................................188
Chapter 8: UNIX System Security................................................................................................189
8.1 UNIX Lines of Defense..................................................................................................189
8.1.1 Physical Security...................................................................................................189
8.1.2 Passwords.............................................................................................................190
8.1.3 File Permissions....................................................................................................190
8.1.4 Encryption.............................................................................................................191
8.1.5 Backups................................................................................................................191
8.2 Password Issues............................................................................................................192
8.2.1 Password Encryption............................................................................................192
8.2.2 Choosing a Password...........................................................................................193
8.2.3 Setting Password Restrictions..............................................................................194
8.2.4 A Shadowed Password.........................................................................................195
8.3 Secure Console and Terminals......................................................................................198
Table of Contents
Chapter 8: UNIX System Security
8.3.1 Traditional BSD Approach.....................................................................................199
8.3.2 The Wheel Group..................................................................................................199
8.3.3 Secure Terminals — Other Approaches...............................................................199
8.4 Monitoring and Detecting Security Problems.................................................................201
8.4.1 Important Files for System Security......................................................................201
8.4.2 Monitoring System Activities.................................................................................203
8.4.3 Monitoring Login Attempts....................................................................................203
Chapter 9: UNIX Logging Subsystem..........................................................................................205
9.1 The Concept of System Logging....................................................................................205
9.1.1 The syslogd Daemon............................................................................................206
9.2 System Logging Configuration.......................................................................................207
9.2.1 The Configuration File /etc/syslog.conf.................................................................207
9.2.2 Linux Logging Enhancements...............................................................................211
9.2.3 The logger Command...........................................................................................212
9.2.4 Testing System Logging........................................................................................212
9.3 Accounting Log Files......................................................................................................214
9.3.1 The last Command................................................................................................215
9.3.2 Limiting the Growth of Log Files............................................................................215
Chapter 10: UNIX Printing.............................................................................................................218
10.1 UNIX Printing Subsystem............................................................................................218
10.1.1 BSD Printing Subsystem.....................................................................................219
10.1.2 System V Printing Subsystem.............................................................................222
10.2 Printing Subsystem Configuration................................................................................226
10.2.1 BSD Printer Configuration and the Printer Capability Database.........................226
10.2.2 System V Printer Configuration and the Printer Capability Database.................234
10.2.3 AIX Printing Facilities..........................................................................................236
10.3 Adding New Printers....................................................................................................239
10.3.1 Adding a New Local Printer.................................................................................239
10.3.2 Adding a New Remote Printer.............................................................................242
10.4 UNIX Cross−Platform Printer Spooling........................................................................245
10.4.1 BSD and AIX Cross−Printing..............................................................................245
10.4.2 Solaris and BSD Cross−Printing.........................................................................246
10.4.3 Third−Party Printer Spooling Systems................................................................248
Chapter 11: Terminals...................................................................................................................250
11.1 Terminal Characteristics..............................................................................................250
11.1.1 BSD Terminal Subsystem...................................................................................250
11.1.2 System V Terminal Subsystem...........................................................................257
11.1.3 Terminal−Related Special Device Files..............................................................264
11.1.4 Configuration Data Summary..............................................................................264
11.2 The tset, tput, and stty Commands..............................................................................264
11.2.1 The tset Command..............................................................................................265
11.2.2 The tput Command.............................................................................................266
11.2.3 The stty Command..............................................................................................267
11.3 Pseudo Terminals........................................................................................................268
11.4 Terminal Servers..........................................................................................................270
Table of Contents
Chapter 12: UNIX Backup and Restore........................................................................................272
12.1 Introduction..................................................................................................................272
12.1.1 Media..................................................................................................................273
12.2 Tape−Related Commands...........................................................................................274
12.2.1 The tar Command...............................................................................................274
12.2.2 The cpio Command.............................................................................................276
12.2.3 The dd Command...............................................................................................277
12.2.4 The mt Command...............................................................................................278
12.2.5 Magnetic Tape Devices and Special Device Files..............................................279
12.3 Backing Up a UNIX Filesystem....................................................................................280
12.3.1 Planning a Backup Schedule..............................................................................280
12.4 Backup and Dump Commands....................................................................................282
12.4.1 The SVR3 and SVR4 backup Commands..........................................................282
12.4.2 The fbackup Command.......................................................................................284
12.4.3 The dump/ufsdump Command............................................................................285
12.4.4 A Few Examples.................................................................................................288
12.5 Restoring Files from a Backup.....................................................................................291
12.5.1 The restore Commands......................................................................................292
12.5.2 The frecover Command......................................................................................295
12.5.3 Restoring Multiple Filesystems Archived on a Single Tape................................297
12.6 Tape Control................................................................................................................298
Chapter 13: Time−Related UNIX Facilities..................................................................................301
13.1 Network Time Distribution............................................................................................301
13.1.1 The NTP Daemon...............................................................................................301
13.1.2 The NTP Configuration File.................................................................................302
13.2 Periodic Program Execution........................................................................................307
13.2.1 The UNIX cron Daemon......................................................................................307
13.2.2 The crontab Files................................................................................................309
13.2.3 The crontab Command.......................................................................................311
13.2.4 Linux Approach...................................................................................................312
13.3 Programs Scheduled for a Specific Time.....................................................................314
13.3.1 The UNIX at Utility...............................................................................................315
13.4 Batch Processing.........................................................................................................317
13.4.1 The UNIX batch Utility.........................................................................................317
Section II: Network Administration..............................................................................................319
Chapter List..........................................................................................................................319 ......................................................................................................................................319
Chapter 14: Network Fundamentals............................................................................................320
14.1 UNIX and Networking..................................................................................................320
14.2 Computer Networks.....................................................................................................320
14.2.1 Local Area Network (LAN)..................................................................................321
14.2.2 Wide Area Network (WAN).................................................................................324
14.3 A TCP/IP Overview......................................................................................................326
14.3.1 TCP/IP and the Internet......................................................................................326
14.3.2 ISO OSI Reference Model..................................................................................327
14.3.3 TCP/IP Protocol Architecture..............................................................................329
14.4 TCP/IP Layers and Protocols.......................................................................................331
Table of Contents
Chapter 14: Network Fundamentals
14.4.1 Network Access Layer........................................................................................331
14.4.2 Internet Layer and IP Protocol............................................................................332
14.4.3 Transport Layer and TCP and UDP Protocols....................................................333
14.4.4 Application Layer.................................................................................................335
Chapter 15: TCP/IP Network.........................................................................................................338
15.1 Data Delivery...............................................................................................................338
15.1.1 IP Address Classes.............................................................................................338
15.1.2 Internet Routing...................................................................................................341
15.1.3 Multiplexing.........................................................................................................345
15.2 Address Resolution (ARP)...........................................................................................350
15.2.1 The arp Command..............................................................................................351
15.3 Remote Procedure Call (RPC).....................................................................................352
15.3.1 The portmapper Daemon....................................................................................354
15.3.2 The /etc/rpc File..................................................................................................354
15.4 Configuring the Network Interface...............................................................................355
15.4.1 The ifconfig Command........................................................................................356
15.4.2 The netstat Command.........................................................................................357
15.5 Super Internet Server...................................................................................................360
15.5.1 The inetd Daemon...............................................................................................360
15.5.2 Further Improvements and Development............................................................362
Chapter 16: Domain Name System..............................................................................................367
16.1 Naming Concepts........................................................................................................367
16.1.1 Host Names and Addresses...............................................................................367
16.1.2 Domain Name Service (DNS).............................................................................368
16.1.3 Host Database Files............................................................................................371
16.2 UNIX Name Service — BIND.......................................................................................375
16.2.1 BIND Configuration.............................................................................................376
16.2.2 Resolvers............................................................................................................377
16.2.3 Name Servers.....................................................................................................380
16.3 Configuring named.......................................................................................................382
16.3.1 BIND Version 4.X.X.............................................................................................383
16.3.2 BIND Version 8.X.X.............................................................................................389
16.4 Using nslookup............................................................................................................397
16.4.1 The nslookup Interactive Mode...........................................................................398
16.4.2 A Few Examples of nslookup Usage..................................................................400
Chapter 17: Network Information Service (NIS)..........................................................................402
17.1 Purpose and Concepts................................................................................................402
17.2 NIS Paradigm...............................................................................................................404 17.2.1 yp Processes.......................................................................................................404
17.2.2 To Create an NIS Server.....................................................................................406
17.2.3 To Create an NIS Client......................................................................................409
17.2.4 NIS Domain Name..............................................................................................409
17.2.5 Databases/NIS Maps..........................................................................................410
17.3 NIS Management.........................................................................................................413 17.3.1 yp Commands.....................................................................................................413
17.3.2 Updating NIS Maps.............................................................................................415
Table of Contents
Chapter 17: Network Information Service (NIS)
17.3.3 Troubleshooting..................................................................................................418
17.3.4 Security Issues....................................................................................................420
17.3.5 A Few NIS Stories...............................................................................................421
17.4 NIS vs. DNS.................................................................................................................423
17.4.1 The /etc/nsswitch.conf File..................................................................................423
17.4.2 Once upon a Time...............................................................................................425
Chapter 18: Network File System (NFS)......................................................................................426
18.1 NFS Overview..............................................................................................................426
18.1.1 NFS Daemons.....................................................................................................426
18.2 Exporting and Mounting Remote Filesystems.............................................................427
18.2.1 Exporting a Filesystem........................................................................................427
18.2.2 Mounting Remote Filesystems............................................................................432
18.3 Automounter................................................................................................................434
18.3.1 The Automount Maps..........................................................................................435
18.4 NFS — Security Issues................................................................................................439
Chapter 19: UNIX Remote Commands.........................................................................................440
19.1 UNIX r Commands.......................................................................................................440
19.1.1 The rlogin Command...........................................................................................441
19.1.2 The rcp Command..............................................................................................441
19.1.3 The remsh (rsh) Command.................................................................................442
19.2 Securing the UNIX r Commands..................................................................................443
19.2.1 The /etc/hosts.equiv File.....................................................................................444
19.2.2 The $HOME/.rhosts File......................................................................................444
19.2.3 Using UNIX r−Commands — An Example..........................................................445
19.3 Secure Shell (SSH)......................................................................................................446
19.3.1 SSH Concept......................................................................................................447
19.3.2 SSH Configuration..............................................................................................449
19.3.3 SSH Installation and User Access Setup............................................................452
19.3.4 SSH — Version 2................................................................................................455
Chapter 20: Electronic Mail...........................................................................................................458
20.1 E−mail Fundamentals..................................................................................................458
20.1.1 Simple Mail Transport Protocol (SMTP)..............................................................461
20.1.2 The MTA Program sendmail...............................................................................464
20.2 Sendmail Configuration................................................................................................470
20.2.1 The sendmail.cf File............................................................................................470
20.2.2 Rulesets and Rewrite Rules................................................................................478
20.2.3 Creating the sendmail.cf File...............................................................................484
20.3 The Parsing of E−mail Addresses................................................................................486
20.3.1 Rewriting an E−mail Address..............................................................................486
20.3.2 Pattern Matching.................................................................................................486
20.3.3 Address Transformation......................................................................................488
20.4 Testing sendmail Configuration...................................................................................489
20.4.1 Testing Rewrite Rules.........................................................................................489
20.4.2 The sendmail −bt Command...............................................................................490
20.4.3 The Debugging Level..........................................................................................491
20.4.4 Checking the Mail Queue....................................................................................491
Table of Contents
Chapter 20: Electronic Mail
20.5 Mail User Agents..........................................................................................................492
20.5.1 The Mail Program and .mailrc File......................................................................492
20.5.2 POP and IMAP....................................................................................................494
Chapter 21: UNIX Network Support.............................................................................................500
21.1 Common UNIX Network Applications..........................................................................500
21.1.1 Telnet..................................................................................................................500
21.1.2 FTP.....................................................................................................................502
21.1.3 Finger..................................................................................................................507
21.2 Host Connectivity.........................................................................................................509
21.2.1 The ping Command.............................................................................................509
21.2.2 The traceroute Command...................................................................................511
Section III: Supplemental UNIX Topics........................................................................................513
Chapter List..........................................................................................................................513 ......................................................................................................................................513
Chapter 22: X Window System.....................................................................................................514
22.1 An Introduction to the X Window System.....................................................................514
22.1.1 The Design of X11..............................................................................................514
22.1.2 The X Administration Philosophy........................................................................517
22.1.3 Window Managers..............................................................................................518