Вы находитесь на странице: 1из 716

1. : FreeBSD.................................................................

31
1. FreeBSD................................................................................. 32
2. FreeBSD ................................................................................... 41
3. ...................................................................... 71

2. FreeBSD .............................................................. 81
4. FreeBSD..............................................................82
5. Gnome.................................................................................94
6. Gnome.......................................................................... 101
7. ........................................................................ 113
8. ................................................... 140

3. FreeBSD................................................... 164
9. FreeBSD .................................................................... 165
10. , .................................................. 187
11. ..................................... 206
12. ................................................ 221
13.
................................................................................................. 238
14. ,
............................................ 271
15.
.......................................................................................................284
16. .................................................................................................... 304
17. ....................................................................... 327
18. FreeBSD.............................................................................337
19. ..............................................354
20. FreeBSD........................................ 368
21.
Perl...........................................................................................................390

4. FreeBSD .......................................................... 411


22. ................................................................412
23. .......................................................436
24. .........................................451
25. E-mal .463

6
26. Web-....................................................489
27. FTP- ....................................................516
28. Internet.................................................527
29. ......................................................................................542
30. ...................................................................580
31. (NFS) ...................................................599
32.
Microsoft Windows ................................................................ 610
. DHCP............................................................................... 626
5. X-Window..........................................................................................637
34.
X-Window .................................................................................... 638
6. ......................................................................................671
.
...................................................................... 672
. ............................ 677
.
..................................................................................................... 698
. ...................................................... 704
.................................................................................... 711


...................................................................................................................... 25
............................................................................................. 25
................................................................................................................... 26
................................................................................................................ 26
...................................................................................................................27
............................................................................................... 29
CD-ROM................................................................................................... 30

1. : FreeBSD.................................................... 31
1. FreeBSD.............................................................................. 32
FreeBSD................................................................................................. 33
FreeBSD? ..................................................................... 33
FreeBSD ........................................................................ 34
FreeBSD UNIX............................................................................... 35
BSD ........................................................................................... 35
BSD Intel x86.................................................................................... 36
FreeBSD .................................................................................................... 36
UNIX ..........................................................................................................36
FreeBSD.................................................................................................38
Windows 2000 FreeBSD ......................................................................................... 38
Linux FreeBSD ........................................................................................................ 39
FreeBSD..........................................................................................................40
2. FreeBSD ............................................................................... 41
................................................................................................42
........................................................................................42
DOS Windows................................................ 43
FreeBSD- UNIX-... 44
................................................................................................................... 44
Sysinstall ..................................................................................45
Sysinstall .................................................................................................46
.........................................................46
............................................................................................46
....................................................................................48
Disk Label Editor .......................................................................................................49
..................................................51
.........................................................................53
root..................................................................................................................53
swap................................................................................................................54
...................................................................................55
SoftUpdates ..............................................................................................55
...................................................................................................56
..56

8
.............................................................................................. 57
................................................................................................... 57
............................................................................................................. 59
............................................................................................... 60
Linux ..................................................................................................... 60
................................................................................................ 60
- ................................................................................................. 61
............................................................................. 66
............................................................ 66
.................................................................................................. 67
root ....................................................................................................... 69
Sysinstall .............................................. 69
FreeBSD ....................................................................................................... 70
FreeBSD.............................................................................................. 70

3. ..................................................................71
.................................................................................................. 72
FreeBSD FIPS......................................................... 73
Scandisk .................................................. 73
FIPS ................................................... 73
FIPS .................................................................................................................. 74
............................. 75
FreeBSD DOS, Windows 95/98/Me ............................ 76
FreeBSD Linux.............................................................. 76
Boot- FreeBSD ................................................................................................76
FreeBSD LILO............................................................................................ 77
........................................................................... 77
FreeBSD o FTP ...................................................................................... 78
NFS .....................................................................................................80

2. FreeBSD ................................................. 81
4. FreeBSD........................................................ 82
FreeBSD .............................................................................................83
BIOS ................................................................................................................................83
POST........................................................................................................................... 83
.........................................................................................................83
boot O .................................................................................................................83
boot l .................................................................................................................84
boot 2 .................................................................................................................84
boot 3.................................................................................................................84
.................................................................................................................................84
init.....................................................................................................................86
..............................................................86
..........................................................................86
getty Login ........................................................................................87
FreeBSD .............................................................................................................87
X-Window ...........................................................................................88

9
Gnome.................................................................................................... 88
X-Window ............................................................................................. 90
FreeBSD ...............................................................................................................90
FreeBSD ...............................................................................................................91
shutdown ..........................................................................................................91
halt reboot ............................................................93

5. Gnome............................................................................. 94
Gnome ....................................................................................................................................95
.........................................................................................................................96
Gnome .......................................................................................................................96
.................................................................................................................. 97
.................................................................................................................. 97
..................................................................................................98
Toggle .............................................................................................................................. 99
In Group...............................................................................................................99
Depth ...................................................................................................................99
........................................................................................99

6. Gnome ...................................................................... 101


....................................................... 102
.......................... 102
Gnome ................................................................................................ 103
Gnome ................................................................ 103
Start................................................................................................. 104
Gnome ............................................................................ 105
......................................................................................... 105
Gnome File Manager ................................................................ 106
File Display ................................................................................................... 106
Caching .......................................................................................................... 107
Desktop .......................................................................................................... 107
Gnome Control Center ....................................................................................... 108
................................................................................. 108
............................................................................................................ 109
.......................................................................................... 109
Sawfish .......................................................... 112

7. .................................................................... 113
............................................................................................................... 114
gedit.......................................................................................... 114
vi ................................................................................................................... 118
..................................................................................................123
GIMP ........................................................................................................123
GQview .......................................................................................................................... 126
StarOffice ............................................................................................................................127
StarOffice..............................................................................................127
Web- StarOffice ....................................................................... 128
StarOffice128

10

StarOffice Explorer ................................................................................................. 129


StarOffice ................................................................... 130
............................................................................................................... 130

FreeBSD ............................................................................................................. 130
.................................................................................. 131
................................................................................................................... 131
XMMS ............................................... 133
- mpg123 ............................................. 133
X-Window ....................................................................... 134
................................................................................................... 134
- Netscape ........................................................... 134
- Lynx.................................................................................................... 135
FTP .......................................................................................................................... 135
...........................................................................137
8. ............................................. 140
........................................................ 141
...........................................................141
Bourne (sh) .................................................................141
(csh) .......................................................................142
Korn (ksh pdksh) ............................................... 142
Bourne Again Shell (bash) ..........................................143
Tcsh (tcsh) ................................................................143
?.............................................................................143
......................................................................................... 143
.......................................................................................................144
...............................................................144
........................................................................................................145
........................................................................... 145
... 146
FreeBSD ....................................................................146
.......................................................................................................147
.................................................................................147
....................................................................... 149
............................................................................149
..........................................................................149
...........................................150
................................................................................ 151
................................................................................................ 151
touch ........................................................................................................ 152
.................................................................................................... 152
........................................................................................... 154
- ................................................................. 154
........................................................................ 155
.......................................................... 156
. 157

11

, .................................................................... 157
: more less ..............................................157
....................................................................................................... 158
...................................................................................... 159
tr ...................................................................................... 159
............................................................. 160
fmt ................................................................... 161
- ............................................................. 161
...................... 163

3. FreeBSD .................................... 164


9. FreeBSD................................................................ 165
FreeBSD........................................................................................ 166
.......................................................... 169
df ................................................................................................................... 169
du ................................................................................................................... 170
FreeBSD ................................. 171
mount ............................................................................................................ 171
umount........................................................................................................... 172

............................................................................................... 173
Windows/MS-DOS.......................................... 174
Linux ................................................................. 175
CD-ROM
- ............................................................................................................ 176
- .............................................................. 176
- ........................................................... 177
......................................................................................... 177
/etc/fstab ............................................................................................ 177

fsck ................................................................................................................ 179
........................................ 181
fsck ........................................... 181
................................................................................. 183
, .............................................................. 184

10. , .......................................... 187


................................................................................. 188
? ...................................................................................................... 190
............................................................................................................ 191
chown ........................... 192

chgrp ........................................................................................................ 193
............................................................................. 193
................................... 194

chmod ...................................................................................................... 195

12

.................................................................................... 197
ACL ......................................................... 197
ACL.......................... 197
ACL .......................................... 198
..................................................... 198
ACL........................................................ 199
ACL.................................................................. 201
ACL ....................................................................................... 201
ACL............................................................................. 201
......................................... 201
/etc/passwd /etc/master.passwd ............................................................ 203
/etc/group ...................................................................................................... 205
............................................................................................ 205
11. ............................... 206
FreeBSD ................................................... 207
? .............................................................. 210
..................................................................... 210
/etc/defaults/rc.conf ..................................................................................... 212
/etc/re.conf .................................................................................................... 213
/usr/local/etc /usr/local/X11R6/etc ................................................... 214
................... 215
inetd inetd.conf ........................................................... 216
(syslogd) syslog.conf......................................... 218
/etc/re.local ...................................................................................... 219
12. ....................................... 221
?........................................................................ 222
................................................................... 223
............................................................... 224
/etc/shells ..................................................................................................... 225
.................................. 226
.................................................... 226
....................................... 227
, .... 228
..................................................................... 229
tcsh/csh: .cshrc, .login .logout................................................................ 230
bash: .profile, .shrc .bashjogout............................................................ 231
......................................................... 233
tcsh ........................................................................................................ 233
bash ....................................................................................................... 235
............................... 236
.................................................................................................. 236
............................................................. 237
13.
.................................................................................................... 238
..................................................... 240

13

printf ........................................................................................................................ 241


.................................................................................................................. 242
........................................................................ 243
................................................................................................. 243
............................................................................... 244
........................................................... 245
............................................................................................... 246
..................................................................... 246
........................................................................................................................... 248
while ............................................................................................................... 249
until ............................................................................................................... 250
AND/OR while until ...................................... 250
for................................................................................................................... 251
shift .......................................................................................................................... 252
true false............................................................................................253
....................................................................................................... 253
.................................................................................................... 254
if ...........................................................................................................254
case..........................................................................................................258
AND/OR ......................................................................... 259
............................................................................................................260
...................................................................................261
........................................................................262
.......................................................................................................................263
..............................................................................................263
.......................................................264
r n.....................................................265
r n .....................................................266
............................ ............................................................266
..................................................................................................................267
...............................................................................................270
getopts ............................................................................................270
14. ,
..........................................271
. top .......................................................272
top.......................................................................................................273
. ps..........................................................................275
ps .................................................................................................276
.......................................................................277
kill ............................................................................................................277
kill................................................................................................278
........................................................................278
............................................................................................. 279
rn ....................................................................................................................279
crontab ........................................................................................280
crontab..........................................................281

14

at.................................................282
rn at ................................................................283

15.
.......................................................................................................... 284
FreeBSD ................................................................................................................ 285
..................................................................286
.........................................287
.............................................................................................................289
sysinstall................................................................................289
pkg_add ..............................................................................291
..............................................................................................................293
..........................................................................................................293
..............................................................................................................293
FreeBSD ...................................................................................................294
FreeBSD ...........................................................................................296
..........................................................................................................297
..............................................................................298
..............................................................................................................298
? ........................................................................299
.............................................................................300
,
........................................................................................................ 301
, ................................. 301
Web- Fresh Ports........................................................................................................ 302

16. ................................................................................................. 304


Ipd ........................................................................................................................... 305
........................................................................................................... 305
, .................................... 306
................................................ 306
.................................................................................................. 307
............................................................................................................................. 307
..................................................................................................... 307
PostScript He-PostScript- ...................... 310
Ipf....................................................................................................... 311
................................................................................................ 311
/etc/printcap ................................................................................... 312
...................................................................... 313
Ipd................................................................................................................... 314
.......................................................................................... 314
X-Window ........................................................................................................ 315
StarOffice............................................................................................................ 316
.............................................................................. 317
......................................................................................... 317
.................................................................................................... 319
Ipc ................................................................ 319

15

................................................................................................. 319
........................................................................... 319
Ipc ................................ 323
Ipc .................................................................................... 324
.............................................................................................. 324
.......................................................................................................... 324
, ............................... 324
, ................................. 324
Web-
................................................................................................................ 324
.................................................................................. 325
""................................................................................ 325
,
................................................................................................................. 326

17. ................................................................ 327


....................................................................................................................... 328
? ............................................................. 329
dmesg ............................ 330
.................................................................................. 331
GENERIC ..................................................................... 332
.............................................................. 333
LINT .............................................................................................................. 333
.................................................................. 334
................................................................................... 335
/dev .......................................................... 335
........................................................................................ 336

18. FreeBSD....................................................................... 337


FreeBSD ..................................................................... 338
STABLE CURRENT.................................. 338
......................................................................................... 339
make world?................................................................................................. 340
.................................... 341
, ....................................................... 343

STABLE, CURRENT RELEASE................................................................. 343
UPDATING .................................................................................345
/etc/group /etc/passwd
.............................................................................................. 345
/etc/make.conf .....................................346
........................................................................347
/usr/obj .....................................................................................347
log- .......................................................................................347
make buildworld.......................................................................................................348
.....................................................................................................349
make installworld .............................................
.. 350

16

mergemaster
........................................................................................351
......................................................................353

19. .......................................... 354


IDE/ATA ..............................................................................................355
PIO ..................................................................................................................355
DMA .............................................................................................................. 356
Ultra DMA ....................................................................................................... 356
SCSI .......................................................................................................................357
..............................................................................................359
LBA 528 .................................................................................... 360
Extended INT13 8.4 ................................................................ 360
.............................................................................................. 361
........................................................................ 361
BIOS (Slices) ................................................................................................ 361
BSD ................................................................................................................ 361
(fdisk) sysinstall................................................... 363
............................................................................................... 364
FreeBSD ........................................................................... 364
........................................................................................... 365
.................................................. 366
...................................................... 367

20. FreeBSD.................................368
FreeBSD .......................................................................................................... 369
Windows NT/2000 ................................................................................... 370
"" " " ............................................................................. 378
........................................................................ 380
........................................................................................................... 381
Soft Updates ........................................................... 381
..... .................................................................................... 382
sysctl .................................................................... 383
........................................................................... 383
: .................................................................... 384
....................................................................................... 384
.......................................................................................................... 384
............................................................................................................ 386
..................................................................................................... 387

21. Perl......................... 390


Perl?................................................................................................................... 391
Perl FreeBSD.................................................................................................................. 391
Perl ................................................................................................ 392
Perl ...................................................................................................393
Perl ............................................................................. 393
......................................................................................... 394
, ........................................................ 395

17

....................................................... .......................................397
............................................................................. 399
Perl ................................................................................400
Perl .............................................................................400
....................................................................................................400
....................................................................................................404
..................................................................................................................406
Perl.............................................................................................................407
, Perl .........................................................................409
Web-...............................................................................................................409
.......................................................................................................................409
CPAN .......................................................................................................................410

4. FreeBSD ................................................ 411


22. ............................................................412
............................................................................................................413
...........................................................................................................414
....................................................................................................417
......................................................................................................................417
.................................................................................................................. 419
..........................................................................................................420
......................................................................................................................422
....................................................................................................422
......................................................................................................423
TCP: Transmission Control Protocol........................................................................423
UDP: User Datagram Protocol..................................................................................424
ICMP: Internet Control Message Protocol ...............................................................425
TCP/IP ...........................................................................................................................425
IP- .......................................................................................................................426
ARP -.................................................................................................428
r .............................................................................................................429
............................................................................................430
............................................................................................................431
(Gateways and Network
Address Translation) ...........................................................................................433
..............................................................................................434
DHCP ........................................................................ :...................................................435
23. ................................................. 436
............................................................................437
sysinstall ..........................................438
...................................................................441
ifconfig .......................................................................................... 441
route ........................................................................443
(hostname) ..............................................................................................444
/etc/re.conf.............................................................. 445
/etc/netstart .............................................................................................. 445

18

IP-.............................................................................................447
IP- /etc/hosts........................................................448
ping .................................................................................................................448
DNS /etc/resolv.conf ....................................................................449
.............................................................................450

24. ................................. 451


-.......................................................................................452
, ................................................................ 452
kernel user ..................................................................................453
kernel .....................................................................................453
/etc/resolv.conf ........................................................................................................453
/etc/ppp/options ........................................................................................... 453
chat .................................................................................... 454
pppd................................................................................................ 455
PAP- -.............................................................................. 455
pap-secrets and chap-secrets .................................................................................... 456
........................................ 456
...................................................................... 457
................................................................................................. 457
/etc/ppp/ppp.conf ....................................................................................... 458
................................................................................ 460
user ........................................................... 460
...................................... 460
.............................. 461
.......................................................................................................... 461
................................................................................................... 462

25. E-mail................................................................ 463


SMTP ...........................................................................................464
()
(MUA) ............ ............................................................................................465
()...........................................466
(MUA) .........................467
Sendmail..........................................................................468
Sendmail.......................................................................468
......................................................................................468
DNS-.......................................................................472
Sendmail ............................................................................472
Mail Relay......................................................................................................................474
POP3 ............................................................................................................476
- qpopper ..............................................................................477
qpopper...........................................................477
(Standalone Mode) ...............................................478
(Server Mode)...............................................................479
SSL ............................................................................479
IMAP- IMAP-UW.........................................................................481

19

......................483
Fetchmail -
IMAP- ................................................................................................. 483
Sendmail ......................................... 486
............................................................................. 487
Postfix ...................................................................................................................... 487
Qmail........................................................................................................................ 487
Exim ......................................................................................................................... 487
Smail ........................................................................................................................ 488
26. Web- ..................................................... 489
HTTP ........................................................................... 490
............................................................................. 492
Apache ............................................................... 494
Apache ..................................................... 495
Apache ........................................................................... 496
httpd.conf....................................................................................... 496
.htaccess ......................................... 497
HTTP .................................................................................499
......................................................................... 500
................................................................................... 501
.................................................................................502
................................................................... 504
.................................................................................................. 505
Apache .............................................................................................. 507
................................................................................................ 507
..................................................................... 507
..................................................................................................507
...............................................................................................509
CGI...................................................................................................................511
CGI Apache ....................................................................................... 511
CGI- .....................................................................................513
27. FTP- ....................................................516
FTP ................................................................................................517
FTP ................................................................................519
FTP-................................................520
FTP- ...............................................................................................520
FTP- ..........................................................................................522
/etc/ftpusers...................................................................................................523
/etc/shells .....................................................................................................523
/var/run/nologin ............................................................................................523
FTP.....................................................................524
..................................................................................................525
FTP-............................................................525
WU-FTPD ................................................................................................................526
ProFTPD ...................................................................................................................526

20

28. Internet................................................ 527


? ..............................................................................................528
?...........................................................................................................530
NAT? ............................................................................................................530
NAT FreeBSD ............................................................530 .
.......................................................................531
NAT.................................................................................................................532
................................. 532

Internet ..........................................................................532
natd .........................................................533
....................................................... 533
.............................. 534
Windows 95/98 ........................................................ 534
Mac OS Mac OS X................................................ 535
FreeBSD.................................................................... 536
Linux ......................................................................... 537
Internet ................................................ 538
............................................................. 538
...................................................................................... 540

(DMZ) ............................................................................................................. 541

29. ...................................................................................542
................................................................................................................ 543
................................................................................................ 545
Crack.................... 545
.................................................................................................. 547
............................................................................ 548
S/Key ........................................................ 549
Kerberos ........................................................................................................ 551
, ........................ 552
tcpdump
......................................... : ................................................................. 552
(OpenSSH) .......................................................... 554
( IMAP) ................................................... 555
FTP- ........................................................................................................ 556
Apache.................................................................................................... 557
Apache-SSL .................................................................................................. 558
Apache mod_ssl........................................................................... 558
Web- ............................................................... 559
CGI............................................................................. 559
CGI
CGIwrap ................................................................................................................... 560
(securelevel) .............................................. 561
........................................................................................... 562

21

....................................................................563
IPFW .......................................................................565
....................................................................566
PortSentry ......................................................................................567
/etc/hosts.allow ....................................................................569
Tripwire .........................................................................570
, ......................................................................573
(DoS) ..............................................................................................574
..........................575
...................................................................................576
....................................................................................................577
................................................................577
man security .................................................577
....................................................................................................578
FreeBSD......................................................................578
Web- ...........................................................................................................578
....................................................................................................................... 579
30. .......................................................................580
BIND...........................................................................................581
......................................................................581
.........................................................................................................................582
BIND....................................................................583
................................................................................583
BIND ""...................................................................584
BIND (named.conf) ..................................................584
.........................................................586
................................................587
.....................................................................................................588
DNS.....................................................................589
....................................................................................................590
..............................................................................................................591
SOA .............................................................................................................593
NS............................. ..................................................................................594
......................... , ............... 595
CNAME ......................................... 595
MX ............................................. 595
PTR .............................................................................................................596
DNS .............................................................596
localhost...............................................................................597
....................................................597
31. (NFS) .....................................................599
NFS .................................................................................................................600
NFS .................................................................................602
NFS (nfsd)....................................................................................................603
NFS (mountd) .....................................................................603

22

/etc/exports...................................................... 604
NFS ..................................................................... 605
NFS............................................................................... 606
/ NFS (nfsiod)........................................................................ 606
....................................................... 606

.............................................................................................. 607
(amd) ..............................................................608
32.
Microsoft Windows......................................................................... 610
Samba ......................................................................................... 611
SMB/CIFS............................................................ 611
................................................................................................................ 612
, ...................................................................... 613
Samba ....................................................... 614
smbd nmbd ............................................................................................ 615
smb.conf SWAT.......................................................................... 615
.................................................... 617
......................................................................... 619
............................................................................................. 619
Samba....................................................................... 622
Samba ................................................................................. 622
Samba ......................................................................... 623
Samba ....................................................................... 624
smbfs ............................................................................................. 624
33. DHCP ................................................................................ 626
DHCP..................................................................................... 627
IP- .................................................................................................... 627
DHCP ................................................................627
DHCP .................................... 629
DHCP ..................................................................................... 629
DHCP sysinstall ......................................... 629
DHCP ................................. 630
dhclient...................................................................................................... 631
/sbin/dhclient-script ............................................................................. 631
/etc/dhclient.conf .......................................................................................... 632
DHCP................................................................................................... 633
dhcpd......................................................................................... 634
dhcpconf .............................................................................................. 634

5. X-Window....................... ................................................637
34.
X-Window..............................................................................................638
3.3.6 4.x.................................................................................. 639
SuperProbe........................................................................................... 639

23
X-Window
xf86config ...... 640
................................................................................................... 641
................................................................................................. 642
............................................................................................. 643
.......................................................................................... 645
XF86Config ........................................................................................ 651
XF86Config ............................................................................... 651
"Modules".................................................................................................... 652
"Files".......................................................................................................... 652
"ServerFlags"............................................................................................... 653
"InputDevice" .............................................................................................. 655
"Monitor"..................................................................................................... 658
"Device"....................................................................................................... 658
"Screen" ....................................................................................................... 659
"Display" .............................................................................................. 660
"ServerLayOut" .......................................................................................... 660
X-Window ................................................................................. 661
.xinitrc ....................................................................... 662
........................................................................................... 662
................................................................... 663
............................................. 664
................................................................................................... 665
XF86Config .................................................................................. 665
.......................................................... 666
X-Window ......................................................... 667
xhost
................................................................ 667
............................................................................. 669
................................................. 669
xdm ................................................................................................................................ 669

6. .....................................................................671
.
...................................................................................................................672
. ................................677
.................................................................................................678
..................................................................................678
SCSI- ................................................................................678
CD-ROM.......................................................................................................679
........................................................................................................ 680
USB......................................................................................................683
..............................................................................................683
.............................................................................................683
, X-Window ...............................................684

24

.
...............................................................................................................698
............................................................................. 699
............................... 699
Probing Devices (
) ............................................................................................................... 699
CD-,
, CD-ROM ................................................................... 699
.................................................. 699
Micron ................................................................. 700
3Com PCI Micron .................................... 700
SCSI- HP Netserver ........................... 700
ATI Mach64 ..............................................700
, FreeBSD, .................. 700
, ............................... 701
FreeBSD Missing
Operating System ( ) .................................. 701
FreeBSD "F?" ......................................................701
FreeBSD Read Error
( ) ................................................................................701
FreeBSD , Windows ....................702
FreeBSD ,
........................................................................................702
FreeBSD Device Not Configured (
) CD- ...........................702
Signal 11 .........................................703
top,
ps ...........................................................................703
root ................................................................................703

. ........................................................ 704
, FreeBSD ..........................................................705
Web-.....................................................................................................................705
........................................................................................................ 705
............................ '. .............................................................................. 706
USENET, FreeBSD .................................. 708
IRC .................................................................................................................. 708
, BSD ................................................................ 708
Web-.................................................................................................................... 709
USENET ........................................................................... 709
Internet.................................................................................................. 709
Web-.................................................................................................................... 709
USENET ........................................................................... 710

........................................................................................711


(Michael Urban), ,
UNIX, FreeBSD, Linux Solaris.
, Lion Research
Center. , ,
, Web. Perl
Java, , , .
(Bryan Tiemann) -- FreeBSD
Caltech. - , . , , , . FreeBSD,
Macintosh, .


(Tim Hicks) HomeSide Leading, Inc.

UNIX. HP-UX 10.10 11.00,
Solaris 8 AIX 4.1 .
Sybase Oracle.


, , , ,
. , , Lion
Research Center .
.
, , .
, .

. Sams Publishing,
, , , , .
.
FreeBSD. .
- FreeBSD . ,
FreeBSD , , , .
Lion Research Center
(www.lionresearch.org) , . ,
, ,
- .
, , ,
- . , ,
, , .
TLK-L lionking.org .
, , .


, ,
- ,
? - , Microsoft
, IBM?
? ,
Microsoft ? , 2001 IBM
Linux?

. ,
20 , . ,
Internet . , Internet-
.
Internet- UNIX
.
Linux. ,
.
Microsoft Linux . ,
.
, Linux UNIX; ,
, UNIX. ,
, UNIX, , ,
.
GPL, GNU General Public License,
, , ,
.
, .
GPL, ..
,
.
, .

. GPL :
, ,
. , ,
GPL. ,
.
, ..
,
. .
, ,
,
.
FreeBSD (Berkeley Software Design) ,
. BSD-
, ,
-

28

, , . BSD
, , GPL.
Apple ( NeXT) BSD NeXTSTEP, Mac OS X. Microsoft
FreeBSD Linux,
# FreeBSD. BSD
, BSD-.
, , Linux FreeBSD .
, . FreeBSD
, Linux.
15% , , .
FreeBSD Linux
. FreeBSD .
Linux UNIX. -
: Linux "" , a FreeBSD
. ,
Linux, . . FreeBSD ,
, . UNIX, , ,
UNIX "".
Linux ? UNIX, a
, ? ,
Windows-,
Microsoft? FreeBSD
.
FreeBSD 1997 , 2.2.2.
, Yahoo! Linux, a Hotmail ( Microsoft) FreeBSD
Solaris,
. ( 2000 Microsoft -
Hotmail Windows 2000, , , FreeBSD , .)
FreeBSD . ; . FreeBSD NetBSD, OpenBSD Mac OS X;
Linux FreeBSD Linux,
, RealPlayer StarOffice.

. FreeBSD , Linux,
. , , Linux.

29

, Linux , , . FreeBSD, ,
, Microsoft.
Linux - GPL
. FreeBSD
. , BSD,
: OpenBSD , , a NetBSD
( Intel x86, PowerPC,
Sega Dreamcast).
FreeBSD ;
.
, Internet. FreeBSD
Web-, , ,
,
. :
, .
,
. ,
, .
, .
, FreeBSD ,
. , ,
FreeBSD, .


:
1. : FreeBSD. FreeBSD.
2. FreeBSD.
Gnome ,
.
3. FreeBSD.
, FreeBSD,
.
4. FreeBSD . ,
.
5. X-Window. .
6. . FreeBSD, , .

30
, , .
: , .

, ,
.

,
FreeBSD .

,
.

:
2. , , , . ,
, .
3. - .
- , .
4. .
5. ,
. , ,
.

CD-ROM
1 FreeBSD, 5.0 2
:
mkpasswd.pl Perl, Linux FreeBSD (. 20);
simpledemo.pl Perl, (. 21);
sendcomments.cgi CGI- Perl (. 26);
portsentry.sh PortSentry , PostSentry (. 29);
StarOffice 5.2 Sun Linux,
FreeBSD. ,
, .

:
FreeBSD

FreBSD
FreeBSD

FreeBSD

FreeBSD
FreeBSD?
FreeBSD UNIX
UNIX
FreeBSD
FreeBSD

1. FreeBSD

33

FreeBSD UNIX. Intel


x86 Alpha, Spare
PowerPC. FreeBSD,
.

FreeBSD
, FreeBSD, ,
. , , , FreeBSD
, .
FreeBSD , .
,
,
. FreeBSD :
. Netcraft (www.netcraft.com),

, 50 47 FreeBSD.
Web- 1 1133 !
, FreeBSD.
FreeBSD : Sony; Yahoo!; The Apache Project freesoftware.com FTP- .
.
, ,
..
. FreeBSD : , , ,
Web-.

FreeBSD?
FreeBSD ,
. FreeBSD

. FreeBSD
486 ,
.

"" Warner Brothers


FreeBSD.

FreeBSD,
, :

34

1. : FreeBSD

.
Samba ( . 32)
, ,
Windows. FreeBSD
(Primary Domain Controller) Windows.
Web-. , FreeBSD
Web-. Internet-, FreeBSD .
. FreeBSD
486- .
, DNS- NAT.
, DNS- , ,
Internet .
.
SQL, , . , FreeBSD
Oracle.
. FreeBSD , .
.

FreeBSD
, FreeBSD, . :
Web-. , Web- HTML, . Web- , CGI-,
, . Web- , Web, . FreeBSD .
. FreeBSD Web- .
. , , FreeBSD, . , ,
.
.
FreeBSD .

1. FreeBSD

FreeBSD UNIX, UNIX,


( 30 !) .

FreeBSD UNIX
UNIX Bell Laboratories AT&T.
(Ken Thompson) (Dennis Ritchie) UNIX.
UNIX . 60- AT&T Bell
Laboratories
Multics.
, .
,
, .
DEC PDP-7
.
1969 Bell Labs , Computing Science
Research Center .
,
UNIX. UNIX :
DEC PDP-7, - DEC PDP-11. 1973 UNIX , .
UNIX
. ,
, ,
. UNIX ,
.
, UNIX .

BSD
AT&T ( ,
). AT&T UNIX

. UNIX 80% ,
. ,
UNIX,
Computer Systems Research Group. , 1975
Bell Labs
. -
(Bill Joy).
UNIX.
Berkeley Software Distribution, BSD.
, , vi (
shell).

35

36

1. : FreeBSD

70- :
, Advanced Research Project Agency
UNIX .
, ,
. , , UNIX
.

Sun Microsystem. Sun ,
BSD SunOS.

BSD Intel x86


BSD .
1991 BSD Intel x86.
386/BSD.
, BSD
86.

FreeBSD
1993 ,
UNIX . . NetBSD. .
, NetBSD.
FreeBSD. , . ,
Intel x86. FreeBSD UNIX- BSD.
FreeBSD UNIX .
,
FreeBSD UNIX, :
http://www.bell-labs.com/history/unix/ UNIX
Bell Labs .
http://daemonz.org/bugs/history.ehtml Berkeley Software Distribution.
http://www.freebsd.org/handbook/history.html
FreeBSD.

UNIX
UNIX , 30
? . ,
, , .
UNIX ,
. UNIX
KISS (Keep It Simple, Stupid).
UNIX ,
. ,
UNIX :

1. FreeBSD 37

,
, . , UNIX.
:

, (pipe)

(piping). ""
(Doug Mcllory) Bell Labs. UNIX (
8).

. ,
, .
, , ( e-mail), ..
(~). :
Doe,

John~505

Doe,

Jane~121

Bar,

Foo~501

Some
Any
Some

Street~Anytowm~NY~55555~505-555-1212~jdoe@email.com
Street~Sometown~NY~12121~121-555-1212~jadoe@isp.com
Street~Anytown~NY

55555~505-123-4567~foobar@email.com

50 500 . ,
Anytown,
, .
,
,
. :
awk 'BEGIN {FS="~"} $3
address.txt | sort |

== "Anytown"
1p

{print

"%s\t%s\n",$1,$6}'

adress.txt.
, , Anytown.
( ),
(\t), (\n).
.
, .
- 1, ,
. :
Bar,
Doe,

Foo 505-123-4567
John 505-555-1212

, ,
. ! ,
:

38

1. : FreeBSD

awk 'BEGIN {FS="~"} $3 = "Anytown" {printf "%s\n%s\n$s, $s


$s\n\n",$l,$2,$3,$4,$5}' address.txt | 1p

:
Doe, John
505 Some Street
Anytown, NY 55555
Bar,

Foo

501 Some Street


Anytown, NY 55555

UNIX ( FreeBSD)
, ""
.
UNIX .

FreeBSD
FreeBSD Windows 2000 Linux.

Windows 2000 FreeBSD


Microsoft , , . Windows 2000
,
. , Windows 2000 ,
,
. , Windows 2000
. ,
"" (: ) ""
, .
FreeBSD Windows 2000?
Windows 2000 . ; . FreeBSD
, . . Windows 2000
,
.
Windows 2000
. FreeBSD . , ,
. . FreeBSD,
,
.
Windows 2000,
FreeBSD .
, . FreeBSD -

1. FreeBSD

39

,
.
FreeBSD . FreeBSD
, . FreeBSD , , ,
Windows, Macintosh . Windows 2000 , , Windows. ,
Windows-
Windows.
, . . -,
. , ,
, , .

Linux FreeBSD
Linux . . Linux UNIX. FreeBSD,
, . FreeBSD
Jnux . ,
. Linux ,
"FreeBSD, ,
Linux. , FreeBSD ,
Linux.
FreeBSD Linux:
FreeBSD , Linux 30. FreeBSD
. Linux .
. , Slackware Linux
BSD. Debian Linux Sys V, a Red Hat
Linux Sys V, ,
Sys V. ,
Linux .
FreeBSD , ; Linux , . , Linux,
,
Linux. , , , , Linux, .
Linux. ,
, Linux , .
FreeBSD , , .

40

1. : FreeBSD

Linux.
FreeBSD .
,
Linux. ,
, .
FreeBSD ,
Linux .
FreeBSD, , ,
, Linux. :
,
, .

FreeBSD
FreeBSD . . UNIX, . .
Web-,
, . Windows 2000 .
-: Microsoft "".

FreeBSD

Sysinstall

o Sysinstall


Sysinstall

FreeBSD
FreeBSD

42

1. : FreeBSD

FreeBSD,
. : , , .
, CD- ,
20 . , .
, .
, ,
, , .
,
(, 3).

, , .

, ,
FreeBSD. He , ,
FreeBSD.


, ,
, . ,
:
, .
; X-Window
.
, , IRQ .
(serial, ps/2 bus) .
, .
, , ,
IRQ.
: IP- ; ;
; IP- DNS-; ; (..
).
- ,
Microsoft Windows,
Control Panel.


CD- FreeBSD, , .
CD-

2. FreeBSD

43

FreeBSD - (, ),
(boot disks).
floppies
CD-. CD- ,
FTP- ftp.freebsd.org. /pub/FreeBSD/
releases/5.0-RELEASE/floppies. kern.flp
msfroot.flp. DOS
Windows, fdimage.exe, /pub/
FreeBSD/tools.

,
ftp.freebsd.org. , ftp (,
ftp1.freebsd.org ftp2.freebsd.org).
.

1,44 .

, .
, .

,
, .
, .

DOS Windows
Windows,
DOS. , Windows, DOS, .
CD- DOS ,
CD-:
D:\TOOLS\FDIMAGE.EXE
D:\FLOPPIES\BOOT.FLP
D:\FLOPPIES\MFSROOT.FLP
, D: CD- .
DOS, .
CD
CD- CD- -
floppy-. DOS .
CD- ( D:),
.

44

1. : FreeBSD
:\> cd d:\tools
D:\TOOLS> fdimage \floppies\boot.flp a:

, :
D:\TOOLS> fdimage \floppies\msfroot.flp :

CD-
,
fdimage.exe, boot.flp msfroot.flp DOS , temp , :
:\>cd temp
:\> fdimage boot.flp a:

:
:\> fdimage msfroot.flp a:

FreeBSD-
UNIX-
FreeBSD- UNIX-,
fdimage.exe ( boot.flp msfroot.flp -
).
UNIX- dd . FreeBSD
:
dd if=boot.flp of=/dev/rfdO

dd
:
dd if=msfroot.flp of=/dev/rfdO

, ,
.

: FreeBSD
, FreeBSD (. 3). , CD. , ,
, FTP .
, .
CD-. CD-, , :
boot.ftp. .
, " ". ,
. .
, :

2. FreeBSD
FreeBSD/1386 bootstrap loader, Revision 0.8
(jkh@bento.freebsd.org, Mon Nov 20 11:41:23

Hit [Enter] to boot immediately, or any other key for command prompt.
Booting [kernel] in 9 seconds . . . _

Enter.
, mfsroot Enter.
, UserConfig, :
Kernel Configuration Menu
Skip kernel configuration and continue with installation.
Start kernel configuration in full screen Visual mode.
Start kernel configuration in CLI mode.
Here you have the chance to go into kernel configuration mode, making
any changes which may be necessary to properly adjust the kernel to
match your hardware configuration.
If you are installing FreeBSD for the first time, select Visual Mode
(press Down-Arrow then ENTER).
I If you need to do more specialized kernel
configuration and are an
experienced FreeBSD user, select CLI mode.
If you are certain that you do not need to configure your kernel then
simply press ENTER or Q now.

Skip kernel configuration . ,


, , , .
UserConfig, .

Sysinstall
, FreeBSD
Sysinstall. , 2.1.

2.1

Sysinstall.

45

46

1. : FreeBSD

Sysinstall
Sysinstall, , . ,
2.1.

2.1

, . ,

Select Exit Install.


, ,
.

, /.
, ,
.

, .
. Sysinstall Enter Usage.
Standard ,
DOS. Enter .

:
,
FreeBSD.
,
, FreeBSD.

,
.
, , . FreeBSD ,
3.


, , 2.2.

2. FreeBSD

47

2.2

.

2.2 , ,
.
2.2

adO

- . IDE-,
. Windows DOS,
.

a d1

- . ,
, slave-
, primary- .

daO

daO SCSI-.
SCSI-, Windows DOS,
.

d a1

SCSI-.

fd

ad2 ad3, da2 da3 ..


, ; ,
FreeBSD , .
, , FreeBSD. , .
,
. , , , . Enter .

FreeBSD ,
, ,
Boot-.
, . FreeBSD
Boot- , . , Boot-
. ,
. ,
. ,
FreeBSD, . FreeBSD
Boot- . ,

48

1. : FreeBSD

Boot- ,
FreeBSD.


- :
Disk name:

adO

FDISK Partition Editor

DISK Geometry: 4336 cyls/146 heads/63 sectors = 39882528 sectors (19473MB)


Offset
0

Size(ST)

End

39882528 39882527

Name

PType

adOs1

Desc
3

Subtype

freebsd

Flags

165

The following commands are supported (in upper or lower case):


A = Use Entire Disk

G = set Drive Geometry

D = Delete Slice

Z = Toggle Size Units

= Change Type

U = Undo All Changes

=Create Slice
S = Set Bootable
Q = Finish

Use F1 or ? to get more help, arrow keys to select.

,
ad0. .

.
,
, unused. 2.3
.

19 ,
.

2.3

Offset

Size (ST)

End_

Name

FreeBSD ( ).

Ptype

, .

Descr

Subtype

Flags

:
=: (slice) .

2. FreeBSD

49

>: 1024- .
boot,
1024 . (
BIOS, FreeBSD).
R: root.
: --- BAD144.
: FreeBSD.
: ( ).

z (, ).

FreeBSD , .

FreeBSD dangerously dedicated ( ),


. FreeBSD . - F. , , .

Enter ,
165, FreeBSD, Flags. Q
.

Linux, FreeBSD .
, Disk Label Editor.

, BSD fdisk . Enter


Disk Label Editor.
.
FreeBSD ( -
, ), , , .

Disk Label Editor


,
FreeBSD. :

50

1. : FreeBSD
FreeBSD Disklabel Editor
Disk: adl
Disk: adO

Partition name: ad1s1


Partition name: adOs1

Part

Mount

----

-----

The
=
N =
=

Size Newfs
----

-----

Free: 30033360 blocks (14664MB)


Free: 39882528 blocks (19473MB)
Part

Mount

Size Newfs

----

-----

---- -----

following commands are valid here (upper or lower case):


Create
D = Delete
M = Mount pt.
Newfs Opts
Q = Finish
S = Toggle SoftUpdates
Toggle Newfs
U = Undo
A = Auto Defaults

Use F1 or ? to get more help, arrow keys to select.

, , , .
, FreeBSD.
A (Auto Defaults).
FreeBSD , .
, , Auto Defaults
/var. ,
/tmp root ( /var /tmp
). , , .
FreeBSD?
: root
swap. . root
. ,
root .
FreeBSD .
. ,
UNIX, ,
. ,
,
. ,
, .
,
.
.
,
root.
, ,

2. FreeBSD

51

. root
.
, root,
. -,
DoS- (
). , . ,
, ,
, .
, .
, ,
; Web , log-. Syslogd
(, )
,
. , ,
(, , ),
tmp. , ,
, .
.
. -
, .
,
. , ,
.


:
root (/), swap, (/usr)
/var.
/var /usr , ,
, /var, - . ,
,
, /usr.

FreeBSD , .
. , FreeBSD

. , FreeBSD
, .
[swapping]. , ,
, swap.
, .

52

1. : FreeBSD


2.4, FreeBSD
. , ;
, .
FreeBSD 9.
2.4 FreeBSD .

root. UNIX.
.
root ( ,
, ).
FreeBSD 5.0. root
. 100 .

/boot

FreeBSD 5.0 ,
FreeBSD
, . 5.0.
, ,
. root
( 1024 ), boot .
( , /boot 1024
.)

/usr

/usr
, /usr .

/usr/local

,
(Web- ).
/usr/local .
.
/usr - .

/var

(spool) ,
.
log-. /var . ,
, ,
, Web-. ,
Web- log- .
Web-,
.

/imp


. .
,
, /tmp;
/usr/tmp /var/tmp. /tmp
,
/usr.

/home

.
/usr. ,
, ,
/home , .

2. FreeBSD

53


,
, , ,
. , Usenet (
, ), Web- ( -),
, , Web-
, .

root
/boot, root (/) -
. Disk Label Editor - ,
. .
(. . 2.3).
2.3

, 100 root.
, .
100 Enter. -
. FS A filesystem,
root, Enter. ,
(mount point) . Mount point ,
. /,
, Enter. - :
FreeBSD Disklabel Editor

Disk: adl

Partition name: adlsl Free: 30033360 blocks (14664MB)

Disk: adO
Part
----adOsla

Partition name: adOsl Free: 39882528 blocks (19473MB)

Mount

Size Newfs Part Mount

-----

---- ----- ---- -----

100MB UFS Y

The following commands are valid


= Create
D = Delete
N = Newfs Opts Q = Finish
= Toggle Newfs U = Undo

Size Newfs

---- ----

here (upper or lower case):


M = Mount pt.
S = Toggle SoftUpdates
A = Auto Defaults

Use Fl or ? to get more help, arrow keys to select.

, adlsla (
, FreeBSD ); -

54

1. : FreeBSD

/; 100 ; FreeBSD
(UFS). swap.

swap
FreeBSD : , .
. ,
, ,
swap
.
swap .
.

swap .
, .
, swap
.

: swap? ,
, 2-4 -
. -
. .
256 , , -,
. , 128-256 ,
1:1.
512 , , 256 , -
, .
. -
.
, .

" " (kernel panic). -
. ,
, ,
swap. -
, kernel panic
. - ,
, ?
:

. , ( , ) .

, , , swap,
. , swap,
, swan.

55

2. FreeBSD

FreeBSD, , -
, ,
. ,
. ,
.

FreeBSD kernel panic


.

swap, ,
root, (
swap). swap , -
.


root swap ( , boot),

(, /var, /usr). ,
:
FreeBSD Disklabel Editor
Disk: adO
Partitio n name: adOs1
Free: 0 blocks (OMB) Disk:
ad1
Partition name: ad1s1
Free: 0 blocks(OMB)
Part

Mount

Size Newfs

----

-----

---- -----

adOsla
adOslb
adOsle
adOslf
adOslg
adlsle
The
=
N =
=

/
swap
/var
/tmp
/usr
/home

Part
----

Mount
-----

Size Newfs
---- -----

100MB UFS Y
256MB SWAP
200MB UFS Y
100MB UFS Y
18817MB UFS Y
14664MB UFS Y

following commands are valid


Create
D = Delete
Newfs Opts
Q = Finish
Toggle Newfs
U = Undo

here (upper or lower case):


M = Mount pt.
S = Toggle SoftUpdates
A = Auto Defaults

Use F1 or ? to get more help, arrow keys to select.

FreeBSD,
/home , .

SoftUpdates
5.0 FreeBSD, ,
Soft Updates Disk Label Editor. Soft Updates
9, , .
Soft Updates ,
S . -

56

1. : FreeBCD

SoftUpdates +S
(, UFS+S).
, Q .
W, , .
, .


, (. . 2.4) All.
, X-Window , Develloper. , ,

cvsup. ,
, , cvsup
- .
All.

2.4

.

cvsup ,
FreeBSD ,
cvsup. FreeBSD. , cvsup (. 18).

, .
All, ,
FreeBSD. ,
. ,
, , ,
" ". Enter. . Exit Enter.


(. . 2.5).

57

2. FreeBSD

2.5

, CD-.
(, , ;
), 3,.
. CD-, CD-ROM
Enter. :
User Confirmation Requested Last
Chance! Are you SURE you want to continue the installation?
If you' re running this on a disk with data you wish to save then WE
STRONGLY ENCOURAGE YOU TO MAKE PROPER BACKUPS before proceeding!
We can take no responsibility for lost disk contents!

. . , ? Yes , . ,
, !

? Yes.
"Starting an emergency holographic shell on vty4",
. , Sysinstall /.


, , Sysinstall
, .
.


, -
Ethernet SLIP/PPP.
. ,
, , .

58

1. : FreeBSD

, No
. , Yes,
, 2.6.
, , Enter. , ,
Ethernet- -.
, IPv6. No ( , , IPv6).
DHCP-.
DHCP-, FreeBSD . , No. .
22 23. (. . 2.7).

2.6
2.7
.

. 2.5 .
2.5
.

Host

( , simba.samplenet.org).

Domain

(samplenet.org).

IPv4 Gateway

Internet.

Name Server

IP- DNS-.

IPv4 Address

IP-

Netmask

Extra Options to ifconfig

ifconfig

59

2. FreeBSD

Enter .
, .
n, ,
. Sysinstall
:
?
,
Internet, .., Yes.
FTP- (
FTP)? , Yes.
FTP- .
NFS-? NFS-
. No.
NFS , (. 31).
NFS-? , ,
NFS-.
. 31.
? , No.
.
No, , , . , -Window, X .
(the default medium
security profile), ,
.


FreeBSD, , , ..
, . 2.8.

2.8
.

60

1. :
FreeBSD

.
, .


Sysinstall , .
, .
No. , .
Yes.

Linux
: "Would you like to enable Linux binary
compatibility?" ( Linux?). Yes
Sysinstall mini Linux filesystem /usr,
, , Linux.
, Yes. , , , StarOffice Linux.

Linux FreeBSD ,
. Linux- FreeBSD , Linux.
, FreeBSD , Linux!


FreeBSD , "
" . ,
USB-. , Yes,
(. . 2.9).

2.9

, . X-Widow . , . Flags -3
. - high ( ) - low ( ).

61

2. FreeBSD

FreeBSD 4.4, 86 3.3.6.


5.0, XFree86 4.x.
34.

-Window,
-. Yes, , . 2.10.

2.10

-.

-Window , XF86Setup
-.
, "X" . , ,
. 2.11. , .

, XF86Setup
. , .

X,
.

2.11

XF86Setup.

62

1. : FreeBSD


,
,
. 2.12.
, Enter. ,
. 2.13.
. Sysmouse
.
/dev/sysmouse Enter.
, "Apply"
()
. Enter,
. ,
, , .
, .


,
Emulate3Buttons.

2.12 .

2.13 .

Keyboard , .
(. . 2.14). "Generic 101-key PC". 104
(Enhanced Windows keyboard), . XWindow , . ,
, .
,
.

Card ,
, XF86Setup (..2.15).

63

2. FreeBSD

, .
- ,
.
,
,
"Detailed Setup" (. 34,
-Window). , "Monitor",
2.14 .
- .


!
C
,

.
,
. .

,
. 2.16.
2.1 .

. . .

X-Window 1024x768.
17-, . 15- . 15- 800x600.
14- -Window ,
800x600, 640x480. 19-
21-, 1024x768. .
X-Window ( ).
, :

64

1. : FreeBSD

8- 256 . ,
.
16- 64 . .
24-
16,7 . . .
2.16
32- - .
16,7 . ,
, 3, 24-
.
-
"done" . -.
"X".

, -
, / , , CTRL-ALT-BACKSPACE
-. ,
, .


, (
, ), , , , , . CTRL-ALT-BACKS X .
- "Congratulations. You've
got a running X server!"
, xvidtune .
xvidtune
xvidtune "" , / . , :

65

2. FreeBSD

2.17
xvidtune.

:
2.6 xvidtune.

Left, Right, Up Down

Wider (), Narrower ,


(), Shorter (),
Taller ()
Quit

xvidtune.

Apply

Auto

,
"Apply".
.

Test

.
.
Auto .

Restore

Fetch

-.
Restore ,
Fetch.

Show

XF86Config
( 34).

Next, Prev

,
( , ).

xvidtune , ,
.
Apply , Quit xvidtune.

XF86Setup
xvistune Save Configuration and Exit.
Yes 'X' .

66

1. : FreeBSD


, Sysinstall. .
, , Enter.
, X-Window
. Microsoft Windows,
FreeBSD ' , .. Linux,
, . X-Window,
Gnome + Sawfish. .

xf86cfg, ,
. xf86cfg 34.


Yes FreeBSD.
,
. , CD-ROM.
(

, 2.18 .
,
Enter ). X.
. , D, ,
.
.
. , .


Bash-2.04 " . Linux ,
Linux .
Gnome
Gnome + Sawfish
,

67

2. FreeBSD

, Gnome (/ ).
,
:
eog-0.5_l The Eye of Gnome Image Viewer. , .
gaddr-1.1.4 Gnome.
gedit-0.9.3 Gnome, Notepad,
.
glunarclock-0.ll -- , Gnome
.
.
gno3dtet-1.6.0 SD- Gnome.
gnomeapplets-1.2.4 Gnome.
gnomefind-l.O , , .
gnomegames-1.2.0 , .
gnomemc-4.5.51 Gnome Multiple Commander. Gnome, Windows Explorer.
gnomemedia-1.2.0 - Gnome (CD-
..).
gpaint-0.1.1 -- , Paint Windows.
, , (. . 2.18).
Install, Enter. Sysinstall
.


. Yes . , root , root
. . ,
,
.
, . 2.19,
User
.

, (. . 2.20).
2.19
.

68

1. : FreeBSD


.

.
Login ID:
,
.
- . ,

2.20
.
.
.
!
UID:
, . :
.
Group ID:
, .
, .
Password:
, .
- , .
-
.

! $.
, . ,

, .
, . , , , , .. .
, - , . : - (
!), , . " ", , -
(, : , ,
123
). , ,
. ,
( , .
).

69

2. FreeBSD

, ,
. . . .
: , , .
Full name:
, .
, , .
- .
Member groups:
wheel,

wheel,
root.
Home directory:
.
, .
Login shell:
. Bash,
/usr/local/bin/bash ( !).

,
. Enter.
- , ,
. 2.20. Exit.

root
Enter root.
root:
Changing local password for root.
New password:

. , . , ,
. Enter.
.
,
. No, .

Sysinstall

Exit Install
Enter. CD-
. .

70

1. : FreeBSD


, Eject (] CD-ROM,
. . FreeBSD CD-; -
,
. Yes , .

FreeBSD
FreeBSD , , (
. 4).
.
,
. .

init, .
init ,
,
, FreeBSD -.
init :
FreeBSD/i386 (simba.samplenet.org)

(ttyvO) login:

, (simba.samplenet.org) .
, , Amnesiac.
root.

Copyright

1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994

The Regents of the University of California.

All rights reserved.

FreeBSD 4.4 RELEASE (GENERIC) #0: Mon Mar 26 00:47:09 CST 2001 #

# , ,
. FreeBSD!

FreeBSD
, .
root /sbin/
shutdown -h now. FreeBSD "System halted". .
, ,
FreeBSD. , (clean). .

FreeBSD FIPS
FIPS



Boot- FreeBSD
FreeBSD LILO

72

1. : FreeBSD

FreeBSD ,
, . , FreeBSD
, Windows.
,
. FreeBSD ,
Linux. ,
(NFS) (FTP).


- , , . FreeBSD
, ,
: , .
, .

.
, . , , ,
, .

, , -, Zip Jaz, ,
. (
. . .)
,
. ,
, (,
).
.
, FreeBSD.
:
. .
, ,
Partition Magic. Partition Magic,
. Partition Magic.
FIPS. , , FreeBSD. -,
. FIPS .

73

3.

FreeBSD FIPS
FIPS , DOS.
DOS , .
FreeBSD. ,
FIPS DOS (FAT16 FAT32). FIPS
, - NTFS (Windows NT/ 2000), EXT2FS
(Linux) HPFS (OS/2).
FIPS ,
:
FIPS DOS .
Windows 95 OSR2 Windows 98,
, ,
.
. ,
FIPS , .

Scandisk
FIPS Scandisk DOS Windows
, .
.
FIPS
. ,
- .
, "" .
.

FIPS
FIPS CD- TOOLS FIPS.EXE.
RESTORRB.EXE ERRORS.TXT. FIPS
FTP- FreeBSD ftp.freebsd.org . FIPS
/pub/FreeBSD/tools/fips.exe. restorrb.exe
errors.txt. DOS Windows
.
:
:\> format a: /s
Insert new diskette in drive A:
and press ENTER when ready...
Checking existing disk format.
Verifying 1.44M
Format complete.
System transferred

74

1. : FreeBSD

Volume label

(11 characters, ENTER for none)?

1,457,664 bytes total disk space


388,608 bytes used by system
1,069,056 bytes available on disk
512 bytes in each allocation unit.
2,088 allocation units available on disk.
Volume Serial Number is is 031B-0831
Format another (Y/N)?n
C:\>d:
D:\>cd tools
D:\TOOLS>copy fips.exe a:\
1 file(s) copied d:
\TOOLS>copy restorerb.exe a:\
1 file(s) copied
D:\TOOLS>copy errors.txt a:\
1 file(S) copied
D:\TOOLS>

. -
, DOS fips FIPS.

FIPS
FIPS , ,
.
. , FIPS ,
. .
. :
|
|
Start
|
|
End
| Start | Number of |
Part.|bootable|Head Cy1. Sector|System |Head Cy1. Sector | Sector |Sectors | MB
------ +------- + --------------- + ------ + --------------+------- + -------- + --1
|
yes | 1
0
1|
06h|
12 983
321
32|
409312| 199
2
|
no | 0
0
0|
00h|
0
0
0|
0|
0| 0
3
|
no | 0
0
0|
00h|
0
0
0|
0|
0| 0
4

no |

0|

00h|

0|

0|

0|

Checking root sector . . . OK Press


any Key

, , .
, Press any Key. FIPS
, :
Bytes per sector: 512
Sectors per cluster: 8
Reserved sectors: 1
Number of FATs: 2
Number of rootdirectory entries: 512
Number of sectors (short): 0

75

3.

Media descriptor byte: f8h


Sectors per FAT: 200
Sectors per track: 32
Drive heads: 13
Hidden sectors: 32
Numbr of sectors (long): 409312
Physical drive number: 80h
Signature: 29h

.
.
, . ,
up down
. Enter.

, .
FreeBSD , .

FIPS .
. Continue, FIPS ,
. Yes
.

, .
. , DOS , .

FIPS -t,
, . -
, ,
RESTORRB.EXE .

- ,
RESTORRB.EXE . tips
-t .

fips -t , . Scandisk ,
.



, ,
. ,
.

76

1. : FreeBSD

, FreeBSD 1024 . ,
root 1024 ,
.
root .
DOS Windows , 1024
, DOS Windows
D. D
FreeBSD. , , /boot.
30 .
DOS
Windows FreeBSD. Windows ( DOS) , ,
(master boot record). FreeBSD,
DOS Windows FreeBSD,
.

FreeBSD DOS, Windows


95/98/
FreeBSD (boot manager),
.
, DOS, Windows 95, Windows 98 Windows Me .
FreeBSD ,
.

FreeBSD Linux
FreeBSD Linux, FreeBSD, LILO Linux, a
MBR. Linux Boot- FreeBSD.

Boot- FreeBSD
boot- FreeBSD .
bootOcfg.
bootOcfg . ,
. bootOcfg - MBR.
boot- FreeBSD .
boot-,
, . (.
. 3.1) boot-:

77

3.

3.1 boot-

-v

Boot0cfg .

-b image

image .
/boot/bootO.

-d drive

drive , BIOS .
0x80 0x81 ..

-f file

file , MBR
. , .

- ,
. :
3.2 boot-

packet

noupdate

BIOS , bootOcfg
int 0x13 CHS .
1024 , . , BIOS
,
.
Boot- MBR .
, ,
MBR. noupdate boot-
MBR.

bootOcfg -s, n 1 5,
. -t n; n
ticks (
18,2 ticks).

FreeBSD LILO
Linux FreeBSD, Linux LILO,
. /etc/ lilo.conf Linux
:
other=/dev/hda2
table=/dev/hda
label=FreeBSD

, , .
LILO . root lilo.


- FreeBSD - ,
. , , FTP- NFS-.

78

1. : FreeBSD

FreeBSD FTP
FreeBSD FTP-.
,
Internet.
, , . ,
FTP- anonymous.
FTP-. FreeBSD
FreeBSD, .
FreeBSD FTP-,
(, FTP- ),
.


sysinstall (. .3.1) Options Enter,
, . 3.2.

3.1

sysinstall
FreeBSD.

3.2
Options.

FTP Username .
, FTP-, Enter.
. Enter.
, Q ,
sysinstall.

3.

79

FTP
2,
(Choose Installation Media).
(. . 3.3).
FreeBSD,
. (. . 3.4)
FTP- FreeBSD.
3.4 FTP- lion,
samplenet.org, FreeBSD /FreeBSD.
(. . 3.5).

3.3
FTP-,

FreeBSD.

3.4

FTP- .

3.5
.

80

1. : FreeBSD

2.
,
2. , ,
2.
, .

NFS
NFS (Network File System).
, ,
NFS- FreeBSD.

NFS
NFS.
NFS- ,
FreeBSD. 3.6 lion,
-install/FreeBSD.

3.6

NFS .

(. 3.5).
2. ,
2.

FreeBSD

FreeBSD
Gnome
Gnome


FreeBSD

FreeBSD

BIOS


init
FreeBSD
X-Window
Gnome
X-Winclow
FreeBSD
FreeBSD

83

4. FreeBSD

FreeBSD
X-Window. ,
Gnome.

FreeBSD
FreeBSD,
, .
FreeBSD.

BIOS

FreeBSD,
86 Intel. Alpha FreeBSD ,
.

BIOS (Basic Input/Output Services /)


,
. , BIOS

.

POST
,
POST (Power On Self Test ).
BIOS ,
n, ,
.


BIOS ,
.
BIOS. ,
, CD-.
.
. , , BIOS
. ,
bootO.

bootO
BIOS 0 ,
. 0 (Master Boot
Record, MBR). , MBR, 512 .
,
, .
bootO:

84

2. FreeBSD

Fl

DOS

F2
F3

FreeBSD
Drive 1

Default: F2

,
(, , ). bootO
.
FreeBSD,
.
, bootl.

bootl
bootl .
bootO, 512 .
boot2.

boot2
boot2 .
, . -
.

boot3
- /boot/loader.
FreeBSD, ,
, .
11. ,
. .

/boot/kernel
.
. , FreeBSD,
, ,
.
.
dmesg | more ;
- "".
.
Copyright 1992-2001 The FreeBSD Project.
Copyright 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993,
The Regents of the University of California. All rights reserved.
FreeBSD 5.0-CURRENT #0: Sun Apr 8 15:17:26 CDT 2001
root@simba.samplenet.org:/usr/obj/usr/src/sys/SIMBA

1994

.
.
. .

85

4. FreeBSD


, . root
,
. ,
, .
CPU: AMD-K6(tm) 3D+ Processor (400.91-MHz 586-class CPU)
Origin = AuthenticAMD
Id = 0x591
Stepping = 1
Features=0x8021bf<FPU,VME,DE,PSE,TSC,MSR,MCE,CX8,PGE,MMX> AMD
Features=Ox80000800<SYSCALL,3DNow!>


.
psmO: <PS/2 Mouse> irq 12 on atkbdcO
psmO: model Generic PS/2 mouse, device ID 0
fdcO: <NEC 72065B or clone> at port Ox3f0-0x3f5,0x3f7
2 on isaO
fdcO: FIFO enabled, 8 bytes threshold
fdO: <1440-KB 3.5 drive> on fdcO drive 0

irq

drq

PS/2. psmO.

. fdcO, fdO.
sbcO: -Creative SB AWE64> at port Ox220-0x22f, 0x330-0x331, 388- ~38
irq 5 drq 1,5 on isaO
pcm1:

<SB16

DSP

4.16>

on

sbcO

SoundBlaster AWE 64 . , sbcO


, .
unknown:
unknown:
unknown:
unknown:
unknown:
unknown:

<PNP0303>
<PNPOfl3>
<PNP0501>
<PNP0700>
<PNP0401>
<PNP0501>

can't
can't
can't
can't
can't
can't

assign
assign
assign
assign
assign
assign

resources
resources
resources
resources
resources
resources


FreeBSD. ,
Plug and Play, ,
. .
adO: 19473MB <Maxtor 92049> [39566/16/63] at ataO-master UDMA33
adl: 14664MB <IBM-DJNA-351520> [29795/16/63] at ataO-slave UDMA33


, , , , ,
. ,
. Ultra DMA 33 (.
19).
Mounting rootfrom ufs:/dev/adOsla

,
. ,
, init. init
- .

86

2. FreeBSD

. - ; .

init
FreeBSD ,
, ,
sync,
clean (). FreeBSD ,
clean .


, init, ,
clean. , init
. , init
fsck; , , ,
. fsck Scandisk
Windows Your system
was not properly shut down ( ) Windows.
fsck , ,
,
.
, clean . init
/etc/fstab ,
mount at boot.

fsck .
fsck 9.


, , init , (run control scripts, rc
scripts), /etc /etc/defaults. , init
/user/local/etc/rc.d , init (,
Web-, .).
config.sys, autoexec.bat, system.ini
, Windows.

, init /etc/re.local
; , Web-.
, FreeBSD .
/usr/local/ etc/re.d, /etc/re.local.

87

4. FreeBSD

BSD BYS V
SYS V UNIX,
. . init BSD ,
. ,
.
SYS V, BSD . inittab,
SYS V, BSD . , , ,
rc.conf

getty Login
init (
). , getty.
, getty, xdm,
X-Window. /etc/ttys ,
. , getty.
getty ,
. ,
/etc/ttys. getty
login,
.

FreeBSD
,
:
FreeBSD/i386

(amnesiac)

(ttypO)

login:


, amnesiac.
, .
,
. Enter .
, .
,
, . ,
- :
Last login:
Tue Apr 10 15:19:17 on ttypO
Copyright
1980,
1983, 1986,
1988,
1990,
1991,
1993,
The Regents of the University of California.
reserved.
FreeBSD

5.0-RELEASE

(GENERIC)

#0:

Sun

Apr

15:17:26

1994
All
CDT

rights
2001

bash$

, , ,

88

2. FreeBSD

(Last Login).
.

. , ,
, Sat Sept 15 14:05:29,
, , -
, .
( passwd)
. [ , root ?)

(
). 1.
FreeBSD .

, ,
root. root
#. , , $ (
], % > ( ).
root, (#]
.

,
:
Login incorrect
login:

, ,
. . ,
, .
.
login: .

X-Window
X-Window,
startx, X-Window.

Gnome
Gnome,
, (. 2),
, , . 4.1.

89

4. FreeBSD

4.1 Gnome.

, Windows Macintosh?
. , . 4.1:
1. , Gnome. Start Programs Windows.
2. URL- Web-, FTP, ..
3. Gnome.
4. .
5. . .
6. , . , .
7. . Gnome-PIM, ,
, .

90

2. FreeBSD

8. Web-.
9. .
10. .
11. .
12. .
13. Gnome Start () Windows.
14. Gnome.
15. , .
16. Gnome.
17. Gnome. 18.
Gnome.
19. Web-. Netscape Navigator.
.
20. .
Gnome . ,
, 6. Gnome -
, 34, " "
.
, Gnome ToolTips
. - ,
. "",
.

X-Window
Gnome :
Gnome ,
( -!).
Desktop Log Out.
Gnome Gnome ( )
Log Out.
:
. ,
Save current setup ( ). ,
Gnome ,
.
Gnome, .

FreeBSD
,
( ), . -

91

4. FreeBSD

.
FreeBSD, exit .
, FreeBSD.

.
clear. , .

FreeBSD

FreeBSD (
UNIX). ,
.

shutdown
shutdown.
shutdown :
shutdown []

[]

[ ]

, shutdown,
, ,
, ,
. 4.1
, ,
shutdown:
4.1

shutdown


.

-h

(
).

-k


( root).
.

, init.
, ,
.

-n

-,
() .
.

shutdown
. now ,
. +n,
(

92

2. FreeBSD

). yymmddhhmm,
. , mm , dd , hh ( 24 ) mm . , ,
. ,
, , .
shutdown, " ",
,
.
10
.
, 10-
.
# shutdown -h +10 Hard disk needs to be replaced

shutdown . 10
. ,
:
*** System shutdown message from root@simba.samplenet.org ***
System going down in 10 minutes
Hard disk needs to be replaced

/var/run/nologin.
, -
, .
.
, , ,
:
NO LOGINS: System going down at 17:57
Hard disk needs to be replaced.

, :
init TERM,
.
init /etc/re.shutdown
, .
TERM , , , .
,
TERM, KILL, .
, .
sync
, clean.
.
, shutdown ,
. , -

93

4. FreeBSD

root ( root,
su).
, su Enter.
, root. ,
, :
shutdown

-h

now

, :
System halted
Please press any

key

to

reboot

halt reboot
: halt
reboot, . .
rc.shutdown,
. ,

.
shutdown.

DOS / Windows,
, Ctrl+Alt+Delete. FreeBSD ,
, , reboot.
, . 11 ,
FreeBSD , Ctrl+Alt+Delete
- .


Gnome

Gnome

Gnome

Gnome

95

5. Gnome

(Window Managers) -.
X-Window . X "";
, .
, -Window.

Gnome
. 5.1 X, Gnome. .
,
.
,
Gnome. , Gnome . Gnome Sawfish. , ,
Gnome (, IceWM
Enlightenment). , 6.
, X-Window. UNIX ( , FreeBSD
Linux) Gnome D. , Gnome -
UNIX,
Sun Microsystems, Hewlett-Packard IBM.
D, 7.

5.1 Gnome.

96

2. FreeBSD


, ,
; ,
.
- .


- , , ,
gnomemc

Gnome
Gnome , , ,
. Gnome
: , .
( Gnome)
, Start Windows.
( Gnome) ,
.
. ,
. , ,
. ,
, Gnome.

5.2 Gnome.

97

5. Gnome


,
. , .
, .
.
:
Iconify/Restore (/) .
Shade/Unshade (/) - "" ,
). , .
Stick/Unstick (/) "" , .
Close window ( ) -- , .
Kill app ( ) , , SIGKILL.
, ,
.


, Gnome
, Windows.
:
Delete .
Destroy S1GK1LL,
.
Toggle ,
.
Maximize/Minimize , Windows.
In Group .
Send window to .
Depth ,
..
Frame type .
Frame style , , , . , , .

98

2. FreeBSD

History Remember () . ,
.
,
. .



.
Desk Guide, ,
.
, Workspaces
.
""
, -
, sticky ().
:
,
, Stick ().
, Toggle (), Stick.
"" , .
:
sticky, ,
, sticky.
, Sent window to, Previous workspace Next
workspace.

FreeBSD ;
. :
, , Workspaces, Insert
workspace. .
,
, , , Move workspace left
( ) Move workspace right ( ). .

99

5. Gnome

,
Workspaces, Merge with next ( )
Merge with previous ( ).

Toggle
,
.
Toggle, . ,
Toggle ().
Sticky
Minimize
Shaded -- .
Ignored , , . ,
, , .
Focusable ,
( ). , ,
( , ).
Cyclable ,
, . ,
.
In window list ,
, Windows (). ,
.
In GNOME task list
Gnome, .

In Group
In Group .
.

Depth
Depth () .
Windows, Gnome
.


File Manager Home directory,
. . 5.3.
,
. -

100

2. FreeBSD

, , (, ). .

5.3
File Manager.

Move to trash ( -) Delete


[) . Move to trash ,
, Windows. Delete , ,
.

, File
Manager . File Manager m,
"" .


Gnome


Gnome

Gnome File Manager
Gnome Control Center
Sawfish

102

2. FreeBSD


. ,
Gnome File Manager.
,
.
,
. Link
.
,
New.
. 6.1.
6.1

Terminal

. Directory

.
URL link
Launcher

Web-.
Netscape Web-.
.

. -,
Gnome File Manager , . ,
, Link.
, New,
Launcher. . ,
. ,
. , ,
. FreeBSD , -
. . 6.1
.
, , xcalc (). ( ),
.
1. Name , .

.

6. Gnome

1 03

6.1

.

3
4

Comment , .
Command , .

xcalc.
5
, ,
. Application.
6
Run in Terminal ,
. , . xcalc
. , No Icon. Gnome /usr/XHR6/share/gnome/pixmaps.
7
Advanced
(,
-
, ).

Gnome
Gnome,
, Panel
Properties, Properties.
Panel Global Preferences , ,
Gnome.

Gnome
Gnome .
. Gnome
(, , Start).
Gnome.
. ,
, Move.
, .
Web-, ,

104

2. FreeBSD

Properties. , . 6.2.

6.2

Properties
-
Gnome.

Start
Gnome ( ) Start Windows. , Gnome, .
.
, , Gnome Edit Menus.
Gnome . 6.3.
. (+)
,
. , ,
.

6.3 Gnome.

6. Gnome

105

New Submenu ( ) New Item (


), ,
. ,
, ,
xcalc. He Save.
-
Sort Submenu,
. Sort Sort Submenu Recursive, , , .

Gnome
, Gnome. Gnome
:
. ,
. , , ( ) .
, Remove
from Panel.
. . , , ,
. , ,
, (, ).
Gnome,
, Applets, ,
, , .
( )
Properties.


,
, Panel, Remove this panel.
,
. ,
, , "The applet appears to have died
unexpectedly" ( ), ,
. Reload,
.
, - , Panel Create panel, ,
. 6.2 .

106

2. FreeBSD

6.2 Gnome

,
.

, ,
, .


, .

,
.

( ), All properties. , .

Gnome File Manager


Gnome File Manager
Windows Explorer.
Gnome File Manager , Settings,
Preferences (. . 6.4).

File Display
,
, ,
. :
Show backup files - 6.4. Gnome File
- Manager.
(~).
Gnome File Manager .
, .
Show hidden files " ", .
. ,
.
Mix files and directories ,
, .
.
Use shell patterns instead of regular expressions ,
find.
8.

6. Gnome

107

Determine file types from file content instead of extensions


, .
Confirmation .
VFS , ,
. , , FTP-. Gnome File Manager
FTP, ,
FTP, , . VFS :
VFS timeout () ,
FTP- .
Anonymous FTP password FTP ,
,
.
Always use FTP proxy FTP.
FTP ,
, .

Caching
, Caching,
. :
Fast directory reload ,
( ).
.
Compute totals before copying files , ,
. .
, ,
.
FTP directory cache timeout ,
. ,
Rescan.
FTP, . , .
Allow customization of icons in icon view
. , , , .
, -, .

Desktop

.

108

2. FreeBSD

Automatic icon placement ( )


,
' .
Snap icons to grid ( ) -
, .
Use shaped icons ( ) , .
, .
Use shaped text ( )
, ( ). ,
.

Gnome Control Center


Gnome Control Center ( Gnome) Windows Control Panel ( ).
Gnome.
Gnome Control Center, ,
.


, - .
Gnome Control Center . Background
(. . 6.5).
,
. Gnome
, BMP, JPEG, GIF, PNG .

6.5

.

6. Gnome

1 09

Gnome (. 6.6). ,
Theme Selector, , Gnome.

gtk.themes.org.

6.6

Gnome.


Gnome Sawfish.
. Sawfish, (. . 6.7)
. , ,
. , Gnome, Sawfish, IceWM
Enlightenment.


. , Gnome File Manager .

,
FreeBSD, , ,
gEdit, Emacs
.
mime
mime , Gnome File Manager

. Microsoft Word
FreeBSD, , -

110

2. FreeBSD

Word. , ,
AbiWord .

6.7.

Abiword FreeBSD "editors". 15.

Word,
: ? ,
, , .
mime, Gnome File Manager
Word
(AbiWord). mime
(. . 6.8), , Gnome Microsoft Word.

Mime multipurpose Internet mail extensions (


Internet). mime
, .
WWW. Web-, ,
, .
mime.
, , [
,
). mime, .
mime RFC 2045 2046.

6. Gnome

111

6.8
mime

.

Gnome , mime, . Internet ,


mime, , http://www.isi.edu/in-notes/iana/
assignments/media-types/media-types. , , mime
Microsoft Word application/msword. mime,
"Add" (. . 6.9).
Regular Expression .
,
, mime.
mime , . mime
Edit. . 6.10 Edit.

6.9 mime
Microsoft Word.

6.10
mime Word.

112

2. FreeBSD

Open, View Edit abiword %f. %f


,
. .

, ,
. , %f ,
.
abiword, abiword filename
filename .

, - Word . Select application


abiword .


Sawfish

Gnome Control Center. Sawfish
Configurator. Sawfish,
, Customize, All features (. . 6.11).
, . Focus Focus windows
when they are first displayed. ,
. , -
Dialog windows inherit the focus from their parents (
). Raise windows when they are first
focused ( , )
. Sawfish ,
, Ok.

6.11
Sawfish.



StarOffice

114

2. FreeBSD

FreeBSD ,
, Linux.

. , ,
.


, ,
. , .
, ,
.
:
.
, .
,

,
. ( 11.)
.
. 13 21
FreeBSD;
.
Web-. Web- HTML.
, , Web-.
- Web-
. , WYSIWYG
(what you see is what you get , )
.
. , LayTeX, .
,
X-Window,
, Windows Macintosh.
FreeBSD, .

gedit
gedit , ,
Gnome. Notepad Windows , .
gedit , Notepad. gedit , - FreeBSD,
editors. . 7.1 , gedit.

7.

115

7.1
gedit.

, File , . Edit ,
. .

gedit , . - ,
Plug-ins . gedit . .
Browse
- Lynx, Browse
Web- . , . ,
, .

Diff
Diff ,
, . , , , , .
E-mail
E-mail .
Shell Output

Shell Output .

116

2. FreeBSD

,
, Directory /, Enter shell
command ls -1. ls -l
.
Insert Time
Insert Time .

(Easy Editor) FreeBSD. ,
UNIX. . , .

. (^) Ctrl. 7.1
.
7.1 , .

Ctrl+o

ASCII.
, ;
ASCII.

Ctrl+c

, ,
. , Enter.

Ctrl+y

. ,
, Enter.
.

Ctrl+x

, Ctrl+y;
.

Ctrl+g Ctrl+v
.
Page Up Page Down.


home- .init.ee,
. .
Esc,
(. . 7.2);
settings Enter.
7.2 .

7. 117

7.2 .

7.3
.

7.2 .

Tabs to spaces

. ,
.
,
( Python FORTRAN).

Case-sensitive search

. ,
.

Margins observed

, .. ,
.
,
.

Auto paragraph format

. ,
,
. ,
Margins
observed. Margins observed
.

Eightbit characters
(
)

. 8-
ASCII. ,
.

Info window

.
menu/help. ,
.

Emacs key bindings

.
, Emacs. ,
.

Right margin

, .
80- .

16 bit characters

, 16- ( 8 16-).

118__ 2. FreeBSD

Save editor configuration


.init.ee. , .
home-,
, .
,
home- ,
.

vi
vi , UNIX. UNIX.
, vi ,
. ,
. ,
.
vi? , , . , UNIX,
, . , UNIX,
...
-, , ,
. ,
vi , .
vi, vi.
, , , vi , .
vi .
, ,
. , : a, i .
append (). , .
i insert ().
, .
, open (). ,
, , .
vi insert,
.
,
. ,
; , .

7.

119

,
Escape. vi .
vi
, ,
Page Up / Page Down.
. ,
. ,
.
, Escape
. h,
j, k 1 , , , .
, , :
1 .
h .
j , .
.
k kaif,
.
. 7.3
.
7.3 ,
vi

k .

120

2. FreeBSD

, .

,
1. j , k
, w .
, . , -
, :
5j
75- ,
:
75G

, :
5L

7.3, ^,
, .


,
, (
7.4).
7.4 vi

, Enter

, , ,

z, -

, , ,

z, .

, , .

Ctrl+u

- .

Ctrl+d

- .

Ctrl+f

Ctrl+b

Ctrl+e

Ctrl+y


vi Backspace Delete ,
.

7.

121

vi. 7.5 , vi.


7.5 vi

dd

ndd

n . , 5dd
, .

. ,
r.

, , ,
. ,
Escape, .

.
.

vi
vi.
7.6.
7.6 vi

zz.

:wq

(
, ZZ).

:w

:w !

,
.

:q

. ,
vi .

:q !

vi,
. .

: filename

vi .
, .

:!

122

2. FreeBSD ____________________________________

vi
vi .
7.7.
7.7 vi
()

(, ,
. .), . vi

.

, .
vi
.

.
.

:s/1 /2

1
2.

:%s/1 /2

1 2.

, vi
vi (
yank ). , , . 7.8 yank.
7.8 Yank vi

yw

, .

n , . , 5
, , .

, . . .
, .
, ,
.

7.

123

vi
. , dd,
, , , ,
dd, - ,
dd , .. .


, FreeBSD. Gimp Xfig. , ,
FreeBSD.

GIMP
GIMP The GNU Image Manipulation Program.
, . Adobe Photoshop,
GIMP . GIMP , BMP, GIF, JPEG,
PNG, PCX TIFF, PostScript.
GIMP graphics
FreeBSD. GIMP , , gimp X-Window Run. . 7.4
GIMP.

7.4

GIMP.


, File
Ctr+O. Load Image, .
.
, ,
. GIMP
, , ! . 7.5 ,
GIMP.
GIMP
GIMP
. File,
Acquire (). Screen
Shot ( ).

124

2. FreeBSD

7.5
GIMP


GIMP , GIMP .

, . : RGB (16,7 ), Grayscale
( ) Indexed ( ; ,
256 ).
, Image, a
Mode.

, , .
, Image Colors. ,
RGB Grayscale.
Indexed ( Web-), . , Indexed,
RGB Grayscale. , Indexed.

GIMP ,
Filters ().

7.

125

,
RGB.

Script-Fu
Script-Fu , ,
,
, ..
Script-Fu -
Script-Fu.
GIMP
GIMP ,
. . 7.9 -
, GIMP. -
-
.
7.9 ,
GIMP.

.
.

.
.

.
, ,
.

. ,
,
.

.
.

12

.
.

13

. , ,
.

14

.
.
Ctrl, .

15

. ,
.

16

.
. .

11

.
, , , .

126

2. FreeBSD

. ,
. ,
..

. , -
, .

. - ,
,
, .
.

. .
.

. ,
, .

. , ,
.

.
.

. .
, .
.

/. -
, , ,
, .

. .

. -
, .

(Smudge tool). ,
.

.
.

GIMP 86 , 168 , 40
, 100 200 ,
.

GQview
GQview Gnome. graphics FreeBSD
. GQview

.
GQview , , , . gqview
X.

7.

127

GQview. : , ,
, .
, v . , , ,
Start slideshow.

StarOffice
StarOffice , Sun Microsystems. - Internet.
StarOffice ,
Microsoft Office, Lotus SmartSuite .. StarOffice : , , , , , HTML- . StarOffice
editors FreeBSD.

StarOffice , Microsoft Windows,


Solaris x86 Solaris Spare. Web- wuuw.sun.com/products/staroffice/get.html.
, StarOffice -
Sun. Deluxe $39.95.

StarOffice
. 7.6 StarOffice. StarOffice :
, .

7.6

StarOffice.

128

2. FreeBSD

File, New .
File, New From Template ( ).

Web- StarOffice
Web-, File Open;
Filename URL Web-, .
Web- StarOffice, Web (. . 7.7). Web- Back
Forward. Back Forward, Web-.
StarOffice .
Tools, Option, Web-.

StarOffice
StarOffice .
.
Tools, Options. , ,
(+) General, User Data
(. 7.8).
.
- StarOffice.
, .
, ( ). ; , .

7.7

Web-

Sams Publishing,

-
StarOffice.

7.

129

, Contents Include in update function


. , Remove
messages from server Save document contents locally. ,
Internet.
. ,
, Yes.
7.8

StarOffice.
,



.

, ,
Outbox. SMTP. Server
. , , Sender.
Reply to .

Properties, .

, ,
StarOffice, .
, StarOffice
.
:
StarOffice File, New Mail.
StarOffice;
New, Documents Mail.
New
Mail.

StarOffice Explorer
StarOffice Explorer () ,
, . Explorer :
.visible (), hidden () turned off ().
(Recycle Bin). , .

130

2. FreeBSD

StarOffice
StarOffice
. -, Help Agent. - ,
, . -, Help,
. (. . 7.9)
,
StarOffice, .

7.9

StarOffice.

, ,
.
.
.
StarOffice ,
.

, FreeBSD
, .
, , FreeBSD
.


FreeBSD
,
, . , -

7.

131

, ,
device pcm. , .
/sys/i386/conf/GENERIC.
dmesg | more , . , ,
. , dmesg :
sbcO: <Creative SB AWE64> at port Ox220-0x22f,0x330-0x331,Ox388-0x38b irq 5 drq

1,5 on isaO

pcml: <SB16 DSP 4.16> on sbcO

, FreeBSD SoundBlaster
AWE 64; , .
FreeBSD , , 4Front Technologies.
www.opensound.com. 4Front Technologies, , ,
- device pcm ,
.
- 17.


FreeBSD 4.4 , . root
/dev :
./MAKEDEV sndO

FreeBSD 5.0 DEVFS


.

,
FreeBSD . X mixer.
, :
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer
Mixer

vol
bass
treble
synth
pcm
speaker
line
mic
cd
igain
ogain

is
is
is
is
is
is
is
is
is
is
is

currently
currently
currently
currently
currently
currently
currently
currently
currently
currently
currently

set
set
set
set
set
set
set
set
set
set
set

to
to
to
to
to
to
to
to
to
to
to

75:75
50:50
50:50
75:75
75:75
75:75
75:75
0:0
75:75
0:0
50:50

, ( 0 100) . ,
,

132

2. FreeBSD

. , :
Mixer vol .
Mixer pcm ,
. .wav,
, Real Audio ..
Mixer synth . , ,
MIDI.
Mixer cd -.
Mixer line ,
.
Mixer igain .
Mixer ogain .
, mixer, . , , cd 90%, , , :
mixer cd 90

,
, . ,
100% 80% , :
mixer cd 100:80

75%. , , . , , /usr/local/etc/rc.d . .
, mixerset. ,
:
mixer vol 80:80
mixer cd 90:90
mixer pcm 50:50

root /usr/local/etc/rc.d.
, :
chmod u+x mixerset

, ,
.
, ,
profile. sh,
.profile.
, .login. home-.
12.

7.

133

, , .profile .login . :
mixer vol 80:80
mixer cd 50:50
mixer pn 90:90

,
root, .
, . , ,

.

XMMS
FreeBSD - .
XMMS Winamp, FreeBSD
UNIX. audio FreeBSD.
XMMS xmms. ,
X, Run.
. 7.10 XMMS.
XMMS (skins) Winamp.
. - Winamp
.xmms/Skins home-. XMMS;
Options Skin Browser. , .
7.10

XMMS
, - www.xmms.org/skins.html
XMMS.
Winamp, .xmms/
Skins, . XMMS
tar .tar.gz. UNIX.
XMMS
. audio FreeBSD.

-
123
X-Window,
, -, . mpg!23.
audio FreeBSD.

134

2. FreeBSD

mpg123 mpg123 filename,


filename , .
(. . 8). , mpg123 *.mp3 , .m.
, . -Z . -@, .
mpg123 ,
.
. ,
man mpg123.

X-Window
xmixer,
audio FreeBSD. xmixer . xmixer X
Run. xmixer Athena (
).
xmixer xgmixer. xmixer,
, GTK.
FreeBSD ,
-, , Real Audio
(ripping) . , ,
audio FreeBSD.


FreeBSD . -, ,
FTP ..

- Netscape
FreeBSD - Netscape Communicator.
, FreeBSD, 4.76. Netscape
6, FreeBSD Netscape Linux. ,
Linux ,
, Flash Shockwave.
Netscape Linux. Netscape, Linux, www .
Netscape netscape (
4.76) netscape6 ( 6). 4.76, 6
. Netscape,
Edit, Preferences.

7.

135

- Lynx
Lynx -- -, ,
. , Lynx ,
, Java-. , ALT,
, Lynx .
Lynx , man lynx.

FTP
FTP File Transfer Protocol ( ).
. FTP-, X
ftp , :
ftp

ftp.freebsd.org

,
:
Connected to ftp.beastie.tdk.net.
220 ftp.beastie.tdk.net FTP server (Version DG-4.1.73 983302105) ready.
Name (ftp.freebsd.org:murban):

Name
FTP. , ,
Enter. FTP
anonymous. anonymous
Enter, :
331 Guest login ok, send your e-mail address as password.
Password:

.
- :
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

FTP-
, (. 8). 7.10 ,
FTP-.
7.10 FTP

Is

cd

pwd
.

136

2. FreeBSD _____________________________________

lcd

binary

(
,
).

ascii

ASCII (
).

put filename

filename . filename ,
, .
,
, (
filename). ( ,
.)

mput filel file2 ,


. .
(,
.)
get filename

.
, ,
. ,
(
filename).

mget filel file2 ,


. .
mkdir dirname

dirname ( ,
).

rmdir dirname or dirname ( ,


rm dirname
).
del filename

filename ( ,
).

bye or quit


FTP, .

,
ftp> help. -
, help . :
ftp> help
Commands may be abbreviated.
!
$
account
append
ascii
bell
binary
bye
case
cd
cdup

disconnect
edit
exit
form
ftp
get
gate
glob
hash
help
idle

Commands are:

mdelete
mdir
mget
mkdir
mls
mode
modtime
more
mput
msend
newer

preserve
progress
prompt
proxy
put
pwd
quit
quote
recv
reget
rename

runique
send
sendport
site
size
status
struct
sunique
system
tenex
trace

7.
chmod
image
close
led
cr
less
debug
Ipwd
delete
Is
dir
macdef
ftp> help mdir
mdir
ftp>

nlist
nmap
ntrans
open
page
passive

reset
restart
restrict
rhelp
rmdir
rstatus

137

type
umask
user
verbose
?

list contents of multiple remote directories

man ftp.
- FTP
-Window, ftp .


Internet.
FreeBSD - .
,
X-Window.
Balsa
Balsa Gnome (
mail FreeBSD). Balsa ,
balsa. , ,
.
Balsa -
www.balsa.net.
Pine
Pine - ,
. ,
. Pine mail
FreeBSD. . 7.11 Pine.

7.11


Pine.

138

2. FreeBSD

Pine .
,
. , Pine , , . , , Pine
.

, root, ,
Pine .
Pine. root ,
, .
25.

Mutt
Mutt - , . mail FreeBSD. Mutt
. , "", . Mutt Elm (
) Pine (, ,
Elm). Mutt , .
Mutt . . - Mutt www.mutt.org , ,
.
uuencode uudecode
uuencode uudecode. , uuencode .

. . ,
, , ,
. :
begin 644 gunzip.exe
M35HZ `4D`````.16_____ /6`````.`,4( '````$Q: .3'_\ 8X&W<F_S9 ( `/M&
`'_XN&\ #'EX9+[F@(%FO_!X/$#,N058OL@^P$NO'B7^,1OR,70ZX!'?=

M#B;_A\ 7X#A3HQ?@*%- [HH?_K'\ (AD, 1>_(/&!-MW<. ,_#>X (-GX#@S@)O]W


MBP<FT<==2+Y5W+D/V4 ` U-KD/U8SV*0^ ! %HD/@ /E/ @ 1=*<6E/@ ?N' C>@ J/X
M$8BC^ ' \ H] 7#NGONEY/@ . $+C>ML 'N^ `X (N, _N^ ! #A[O@OZ^ [X$/> =_^[X$/CN
M^! `#. [X#E[UE=6QT;Z$!\ ` 107?48 (%L-'^P; [FE(#QP4&, ,@WBC/B&)

begin , uudecode. ,

7.

139

( , ) , . ,
program.txt.
:
uudecode program.txt

,
, begin .

gunzip.exe.
, .
, , gunzip.exe.
uuencode gunzip.exe gunzip.exe > gunzip.txt

: ,
(gunzip.exe); , ( gunzip.exe);
gunzip.txt,
. ,
.
, -
.








-.

141

8.


X-Window Gnome.
, FreeBSD -
. ,
UNIX, , ,
30 .
, FreeBSD,

.

UNIX
UNIX.
,
,

.
,
Windows Macintosh
().
,
.1
, , , .
,
().
,
. 8.1.
17.
,
. , ,
.


FreeBSD ,
. ,
. ,
: - Bourne,
sh.

Bourne (sh)
Bourne Bell Labs
(Steven Bourne) AT&T UNIX.
FreeBSD, UNIX, -

142

2. FreeBSD

, POSIX,
Bourne ,
, , ,
-- , Bourne.

(csh)
csh BSD.
- Berkeley,
Bourne, -
BSD. ,
. csh
Bourne, -: .
, - ,
Bourne. csh ,
,
. Bourne .
csh, , Bourne:
,
. , , csh,

.
csh
, .
-, .

Korn (ksh pdksh)


AT&T Korn 1986 .
- (David Korn).
AT&T csh. Korn Bourne. ,
, , ,
- ,
. - , Korn
vi Emacs (..
- ).
, - ,
, -
. Korn
UNIX.
Korn: pdksh.
- FreeBSD, ,
15.
, vi Emacs,
Korn , , UNIX,
- bash ( ),
- vi Emacs (
).

143

8.

Bourne Again Shell


(bash)
Bourne Again Shell ( : Bourne Again
Bourne Born Again )
Bourne , (Free Software Foundation) (FSF). -
bash Linux.
n, , -,
, -
, ,
.
bash UNIX.
, bash,
UNIX.

Tcsh (tcsh)
tcsh . ( "t" TENEX DEC PDP-10;
tcsh
.) tcsh ,
,
bash ( ). , tcsh
, bash, -
(: "Are you sure you want to delete ALL files?").
tcsh , . , bash. , ,
, , . ,
Bourne, .

?
, ?
FreeBSD .
, , , .
, Korn, bash tcsh. rn bash,
, , .


bash,
. , -
, (

144

2. FreeBSD

foo , , $
):
$ grep oo /etc/passwd

? ,
. :
foo:*:1001:1001::Foo Bar:/home/foo:/usr/local/bin/ksh
.
( /usr/local/bin/ksh).
, ,
n. :
# /bin/sh. Bourne, POSIX.
# /bin/csh. ,
tcsh. /bin/csh tcsh.
# /bin/tcsh. tcsh.
# /usr/local/bin/ksh. n.
# /usr/local/bin/bash. bash.
bash , bash -
. 12 , -
.

UNIX FreeBSD . Grep, grep


greP FreeBSD . , ,
: No such file or directory ( ),
, .


, , . FreeBSD , .
man _. , man, man
man. ,
Page Up/Page Down.


, , - .
-k man. ,

, .
man -k search. 8.1.

145

8.

8.1 man -k
bios(9), bios_sigsearch(9), bios32_SDlookup(9), bios32(9) - Interact
with PC BIO

bsearch(3)
- binary search of a sorted table
devclass_find(9)
- search for a devclass
device_find_child(9)
- search for a child of a device
lkbib(l)
- search bibliographic databases
lookbib(l)
- search bibliographic databases
lsearch(3), lfind(3)
- linear searching routines
manpath(l)
- determine user's search path for man pages
res_query (3), res_search(3), res_mkquery(3), res_send(3), res_init(3),
dn_comp(3
) , dn_expand(3) - resolver routines
tsearch(3), tfind(3), tdelete(3), twalk(3) - manipulate binary search
trees
Search::Dict(3), look(3) - search for key in dictionary file
bash$

, .
.
"pattern" () ( 8.2),
.
8.2 man -k
$ man -k pattern
gawk(l) - pattern
scanning and processing language
glob(3), globfree(3)
- generate pathnames matching a pattern
grep(l) , egrep(l) ,fgrep(l), zgrep(l) - print lines matching a pattern
lptest(l)
- generate lineprinter ripple pattern
menu_pattern(3)
- get and set a menu's pattern buffer
bash$

, grep.
,
. , man grep,
no grep , .


, ,
( , , /usr/bin /usr/
games). -f man
( ) . , ,
/usr/games , :
$ man -f pom
pom (6) display the phase of the moon
bash$

(6) :
, .


,
. 8.1.

146

2. FreeBSD

8.1

1: User Commands
( )

, Is,
rm, cp grep.
FreeBSD.

2: System Calls
( )

API FreeBSD.
.

3: Subroutines ()

.
.

4: Devices ()


FreeBSD.

5: File Formats
( )


, , crontab
, .

6: Games ()

.

FreeBSD.

7: Miscellaneous ()

, , .

8: System Administration
(
)

,
, , fsck (
).

9: Kernel Interfaces
( )

. , crontab 1 ( crontab) 5 ( crontab).


man , .. crontab 1. 5, man 5 crontab. , -S
, .



MS-DOS,
. .

FreeBSD
, FreeBSD . FreeBSD . . FreeBSD
.

147

8.

. .
.
Windows Macintosh. , Windows
Macintosh
, FreeBSD .
Windows DOS , , . FreeBSD .
,
. -
9. .


UNIX ( ) (home-).
" ". , , , .
FreeBSD, .
.


ls.
, , :
$ ls
Mail
fbu

letter-to-boss
mail

program
program,

proposal-draft

. ls ,
. -F,
. :
$ ls - F
Mail/
fbu@

letter-to-boss
mail/

program*
program.

proposal-draft

.
:
/: .
*: .
@: .
"program". Windows,
FreeBSD , .com, .exe
.bat. , , ,
. FreeBSD
. .com.

1 48

2. FreeBSD

. , -F man ls.
Is -G,
.
Is , dot-, .. , .
-:
$ ls -
.forward
.hushlogin
.addresshook
.muttrc

.login
.sh-history

.mailrc
.mysql_history
.rhosts
.cshrc

..profile
.project
.login.conf
.mail_aliases

Mail
fbu
mail

. , . -
, :
, dot- -.
-1
(. 8.3):
8.3 Is -I
$ ls -1
total 3
drwx------ 2
murban
lrwxr-xr-x 1
murban
/home/murban/documents/books/fbu
-rw-r--r-1
letter-to-boss
drwx------ 2
murban
-rwx------ 1
murban
-rw-r--r-1
program.
-rw- r-- r-- 1
murban
draft

murban
murban

512 Feb 15 16:04 Mail


15 Mar 20 06:55 fbu ->

murban

murban

murban
murban
murban

512 Mar 24 15:12 mail


15221 Feb 21 18:11 program
murban 1571 Feb 21 17:51

murban

2521 Feb 25 18:51 proposal-

782 Mar 15 09:21

.
( ):
. ls -1
. 10. , , ( ).
. , . (
), ( ).
- .
, .
- . . .
. .
. , .

149

8.

. .
:
fbu -> /home/murban/documents/books/fbu

fbu /home/murban/
documents/books/fbu. ,
.


cd.
, . 8.2.
8.2 cd

cd

cd /

, /, "".
(
).
.

cd /usr/local/bin

"bin",
"local", "usr",
.

cd bin

"bin" ( ),
.
, cd . ,
/, .

cd ../

"../"
.
. .

cd ../bin

"bin",
( ).

cd ../../bin

"bin",
.

...
,
. pwd . ( , ,
. 12.)


. -
, ( ),
. --

150

2. FreeBSD

, .
. 8.3.
8.3
file1 file2

file1 file2.

file1 /archive

filel "archive",
.

filel mystuff/newfile

filel mystuff .
"newfile" , filel "newfile"
. "newfile" , filel
"mystuff" "newfile".

filel file 2 /archive

filel file2 "archive",


.

, . , file1 file2 file2 filel, file2


. -i ( )
.

, ,
, -R. :
$ -R dirl /dir2

, dir1, -
dir2. dir2 , dir1
. dir1 dir2, dir1
dir1 dir2.
, , , -
, -R - ( -i,
, ).

, , ,
:
$

-R /*

/old

old,
. , old ,
old. ,
old.
.


mv.
. 8.4.

151

8.

8.4 mv

mv fil1l file2

file1 file2.

mv /dir1 /dir2

dir1 dir2. dir2


, .

mv file1 /dir2

file1 dir2, .

mv file1 /dir2/file2

file2 , file1 /dir2/file2.


file2 , file1 dir2 file2.


rm. ,
rm , .
. , ,
-R. . 8.5.
8.5

rm

rm file1

file1.

rm file1 file2

file1 file2.

rm -R dir1

dir1 , .

( ) , rm,
. 8.6:
8.6

-f

rm , ,
.
.

-i

.
rm - ( ) -R.


.
, .
.

-W

, rm.


rmdir.
. -,
, .
, rm -R.

1 52

2. FreeBSD

touch
touch : .
:
touch _, _ ,
.
touch , .
.


, FreeBSD .

. : (hard links) (soft
links). .

(hard link) ,
( ), .
.
, .
ln . :
$ ln /home/foo/documents/books/fbsd/filel.txt ./file.txt

filel.txt, , /home/foo/documents/books/fbsd/
file1.txt. , , , vi
file1.txt vi documents/books/fbsd/file1.txt. , .
. Is 1, :
-rw------- 2 foo bar 26896 Mar 25 19:18 file.txt

, , ? ,
. ,
2 , .
, ,
( ). ,
, ,
. , ,
/home/foo/documents/books/fbsd/ filel.txt ,
ln.
.
/home/foo/documents/books/fbsd/file1.txt .

153

8.

, , ( ).
, .
:
.
" " .
,
, .

(soft links, symbolic links symlinks)
Windows. , ,
.
, . - ln
-s. :
$ ln -s

/home/foo/documents/books/fbsd/filel.txt file.txt

ls -1 :
lrwxr-xr-x 1 foo bar 31 Mar 25 19:56 file.txt -> /home/foo/documents/
books/fbsd/filel.txt

:
. , ( , , ) .
.
, . , , . , (..
).
, ,
, .

. , .
-> .
, , , , . , .

, "No such file or directory"


( ], , - Is, ,
, .
-I, , -, .
, -
.

154

2. FreeBSD

:
. , . , ,
.

:
. , ,
. ( ] ,
,
. , -
, .


, , , . 8.7.
8.7

-i

, ,
.

-v

.
.

-f

,
(, ,
; ,
, ).

, UNIX
, , ,
. UNIX , Windows. UNIX
, , , -.
, (, ,
, ,
], -i. ,
.

-
-.
.

DOS: , -
, , UNIX FreeBSD -

155

8.

DOS. , UNIX
, . -
UNIX, , DOS.

, FreeBSD,
. 8.8.
8.8 -

. , file?.txt
file1.txt, file2.txt fileA.txt. file10.txt fileAB.txt.

. , f*
f, foo, file, file1.txt, file2.txt, fileA.txt, file10.txt fileAB.txt.

[]

(. ).


.
, fil[1-3] filel, file2, file, ffle4.
, , , file[a-c]
filea, fileb filec.

, ASCII- .
, file[A-b] fileA fileb, fileB, fileC .. fileZ.
, . -,
,
Z.

,
. , fil[1234]* , file1, file2,
file3 file4 ( ). ,
-.
.
, - .
, file[!1234]* , filel, filel,
file3 file4.

- , rm,
, . ,
rm note* rm note *.
.
: " , note", "
note "!
rm -i.


UNIX ( , -

156

2. FreeBSD

, ), -
, , , (-) ( _ ). , UNIX , , , .
. .
, ,
.
: .
, .
.


,
. , , :
*
File 1

File\l.txt
file"3".txt

file4.txt
file5.txt

file6.txt

.
!
*. ? UNIX rm *. , ,
,
-! , ,
.
escape-,
. (\). ,
( ) . rm -i \* ,
.
File\l.txt. .
rm File\l.txt Filel.txt: No such file or directory.
, : rm -i
File\\l.txt.
, File 1.
, rm File 1
: File 1. ,
: rm -i "File 1".
file"3".txt? rm ffle"3".txt file3.txt: No such file or directory. , (")
, :
file\"3\".txt.

, rm -i.
, , .
, , ,
.

157

8.

?
(, , -
). FreeBSD find, -
. :
$ find

-name "lostfile*"

, lostfile -
, . , ,
, , ,
NFS, -
. . -
, , ,
. find
, , .
find - man find.
, , locate, , ,
, . ,
. , ,
locate,
.
( ). man locate.


, AT&T ,
UNIX, . UNIX FreeBSD
. -
.

,
, wc. . , ,
, , ,
, 1160 , 7823 51584 :
$ wc fbu8mcu
1160
7823

51584 fbu8mcu.html

we , :
-l , -w - .

: more less
,
less. , less ()
, more ().

158

2. FreeBSD

less ( more)
. , .
, less (
), . 8.9.

8.9 , less

/pattern

pattern .

.
, less
.

.
b , less
.

" " " "


#g

.
# . g. less
.

#%

# 0 100. less
, .

less . ,
, ( 2000
!).


grep.
: grep, , egrep, ,
fgrep, .
UNIX fgrep "fast grep" (
grep), , , grep.
fgrep , grep.
, textfile cat.
grep :
$ grep cat textfile

, cat.
, , .
, cat,
catnip, catbird, catfish concatenate,
cat. ,
:
$ grep "

cat "

textfile

159

8.

grep: -i , -
, , -n
( ), -v
, .
egrep ,
13.


. -,
/ .
sort.
sort ASCII-
. . 8.10.
8.10 sort

-d

" ". ,
, .

-b

-f

() (
). ,
.

-n

-t

- .
sort .

-u

,
.

, , -.
, (
- ).

, sort .
-m, sort , ,
, .

tr
tr.
:
$ tr 'a-z' 'A-z '
. tr
(, )
( , ).
, tr

160

2. FreeBSD

-. tr,
:
$ tr

'a-z'

'A-Z'

< file1 > file2

filel,
, file2.
tr -d. tr
. ,
filel file2:
$ tr -d

'AB '

< filel > file2


.
cut. , , phone.txt
:
Doe, John~105 Some Street~Anytown~NY~55555~123-555-1212
Doe, Jane~105 Some Street~Anytown~NY~55555~123-555-1212
James, Joe~251 Any Street~Sometown~CA~51111~321-555-1212


cut -cl-5 phone.txt:
Doe,
Doe,
James

cut . cut ,
.
$ cut -fl phone.txt

, ,
, -d.
$ cut -fl d`~` phone.txt Doe,
John Doe, Jane James, Joe

cut . -
(~).
, , cut
/etc/passwd:
$ cut -f 1 -d':' /etc/passwd
frank
bob
alice
joe
simba
lee

161

8.

fmt
fmt , 65 ( ). , , .
:
Until he extends his circle of compassion to include all living things, man
will not himself find peace.
-- Dr. Albert Schweitzer

105 , .. ,
( , ).
, (, ), ,
.
$ fmt quote.txt
Until he extends his circle of compassion to include all living
things, man will not himself find peace.
-- Dr. Albert Schweitzer

.
fmt:
Until he extends
his
circle of
compassion to
include all living
things
man
will not himself
find peace
Albert Schweitzer

fmt :
Until he extends his circle of compassion to include all living
things man will not himself find peace
Dr. Albert Schweitzer

, .
, , -: log-
Web-, .. , . , , , sed awk.
.
FreeBSD .
, .

-
, UNIX ,
. ,

162

2. FreeBSD

-. , ls,
, :
$ ls

> filelist.txt

filelist.txt,
. .
, ls -
more:
$ Is I more

, more . .
,
. , , ,
mail. ,
. , cat,
mail
:
$ cat quote.txt | mail useraddress

, :
$ mail useraddress < quote.txt

mail ,
quote.txt. , cat, -- .
, .
, tr, , :
filel, file2:
$

tr

'a-z'

'A-Z'

< filel > file2

( , < >, ,
.)
:
$ cut -fl -d' ' access.log | sort | uniq - | more
log- Web-,
NCSA, : 1, , Web-, sort , uniq -.

, .
more. ,
, Web.
-:
$ cut -fl -d'

' /var/log/httpd-access.log | sort | uniq -c > hits.txt

163

8.

, ,
.



.
, .
, bash ( ),
, tcsh, . (
) Tab. ,
.
,
"" (,
).
Tab (bash) Ctrl+D (tcsh). ,
Ctrl+D
( - ) tcsh.
!
$ has[Tab]
basename
bash

bashbug

Tab :
$ Is show[Tab]
showchars.cgi*
showfavepics.cgi* showprofile.cgi*
showcomments.cgi* showpopular.cgi*
showrequests.cgi*

showuploads.cgi*


.
.
tcsh 100 ).
. Enter.

.
, : tcsh .history,
bash .bash_history. "" , . ,
-, ,
, ,
. .
rm ~/.history rm ~/.bash_history,
.

FreeBSD

FreeBSD

FreeBSD

FreeBSD

Perl


FreeBSD

FreeBSD


FreeBSD

CD-ROM
-
/etc/fstab


fsck

166

3. FreeBSD

, FreeBSD,
, . , .
FreeBSD FFS (BSD Fast File System,
BSD). , UNIX
BSD UFS (Universal File System, ) UNIX
File System ( UNIX). -
! , ,
(, mount), UFS
. BSD
UFS, , "" UFS
BSD FreeBSD.
FFS , FreeBSD, OpenBSD,
NetBSD , Mac OS X ( , Darwin,
FreeBSD). Linux, , Ext2FS, Windows NT NTFS, a Windows 95/98/Me VFAT.
, .

, , http://www.penguin.cz/~mhi/fs/.

FreeBSD
, UNIX UNIX- , FreeBSD, , (. . 9.1).
FreeBSD Linux, Solaris UNIX . , Windows Macintosh,
FreeBSD . , UNIX,
. , ,
(. . 9.1).

167

9. FreeBSD

Is /
FreeBSD. : /,
@, *.
9.1 FreeBSD

bin/

,
.
, ,
, , /.

boot/

,
. , FreeBSD 5.0
. ,
.
17

compat@

,
, Linux.

dev/

. , ,
,
, .

etc/

,
.
,
.

home@

,
/usr/home.
.

mnt/

modules/

(procfs).
. ,
(..
).

root/

root.
/home , ,
.

Sbin/

,
. , /bin, ,
, /bin
.

stand/

(hard-linked programs),
"-FreeBSD"
(standalone mode). ,
, sysinstall.
2.

sys@

, ,

tmp/

. .

168

. FreeBSD


usr/

"" : ,
, ,
.
.

var/

. runtime-,
, log-, (spool) ,
.

FreeBSD.
, FreeBSD UNIX- , , Linux, .
FreeBSD , : ",
, /usr/local".
, FreeBSD (. 15).
/var/lib, /etc,
FreeBSD ,
/usr/local/lib /usr/local/etc. ,
/usr/local/etc, ,
, /usr/
local/etc/rc.d.
/etc/rc.d.
FreeBSD,
( , , ). , /usr/local
, .
, . , FreeBSD.
, Linux Solaris, FreeBSD
, , ,
FreeBSD. , , . , , Python Linux, Python
/usr/bin/python, FreeBSD, Python,
, ,
/usr/local/bin/python. ,
, , .

FreeBSD, /usr/bin/python,
/usr/local/bin/python.
FreeBSD
man hier.

169

9. FreeBSD

UNIX- , Windows, (mount points). Windows/


DOS (, :),
. , CDROM :, D: :, . UNIX
. ,
. :
Windows , , UNIX
,
(. . 9.2).

9.2

FreeBSD (UNIX)
Windows.

/dev/adO
s1a FreeBSD

, : - (
). ,
. Windows
Mac OS ,
. FreeBSD . , , ,
, "" , .

df
df (disk free ) ; -

170

3. FreeBSD

df ( . 14). , . df
:
Filesystem
/dev/adOsla
/dev/adOslf
/dev/adOsle
proofs

1K-blocks
49583
4254901
19815
4

Used
28427
1959405
12058
4

Avail
17190
1955104
6172

Capacity Mounted
62% /
50% /usr
66% /var
100% /proc

on

(slice) (partition)
. ,
IDE (/dev/adO), /,
/usr /var. FreeBSD .
, (/) 50 , a /var
20 . /usr. ,
,
/usr /var.

op /var , log-
/var/log.
, - /war /usr/war,
.
19.

du
df :
. ,
, .
du (disk usage ).
# du -d 1
22572
9
31
1520
66211

/home/
/home/bob
/home/fred
/home/alice
/home/torn
/home/pat

du ,
. -d, ,
( ). -s
(summary),
. du, , : man du.
. , . : (quotas).
.

171

9. FreeBSD


FreeBSD
UNIX- -.
, (/dev/adO)
(primary slave).
/dev/adl. ( SCSI /dev/daO ..)
(
19) ,
. ( .)

mount
, , , . ( df du), /usr
/usr/home. He ,
.
50
FreeBSD /dev/adlsle (100 ), /dev/adlslf (8 ) /dev/adslg
(40 ). () . .
/home 40 , .
/home , , /usr/home,
rm /home. ( /usr/home .) /home , , , mv /home
/home.old.
. , ; ,
, . ( (union
filesystems), .)
mkdir /home.
. FreeBSD mount . 40-
/dev/adlslg :
# mount

/dev/adlslg

/home

,
. df:
Filesystem 1K-blocks
/dev/adOsla
49583
/dev/adlslg 39245453
/dev/adOslf
4254901
/dev/adOsle
19815
proofs
4

Used
28427
3362491
892410
12058
4

Avail
17190
32119340
3140012
6172
0

Capacity
62%
12%
22%
66%
100%

Mounted
/
/home
/usr
/var
/proc

on

172

3. FreeBSD

! /usr/home ( /home.old,
) /home.
.
,
. , ,
Incorrect super block ( -)
Invalid argument ( ).
-
mount ( FreeBSD
). /dev/adlsle,
/dev/acdO /dev/ad3sl ,
(slice mode) (dedicated mode). ,

. 19.
mount -f,
. , , , . ,
-f. ,
"" , .. ,
. , fsck ( ,
), .
options, (), . ,
-.
-, -r ( rdonly)
. mount , man mount.

umount
,
umount ( "unmount"). /home,
:
#

umount

/home

umount /dev/adlslg, a umount -


, .
,
. . , , /usr /var,
, .
/home ,
, , , /home,
. , ,
mount umount, .
: !
: Device busy (

173

9. FreeBSD

). :
cd /.
mount, umount -f,
. - ;
.



FreeBSD.
, , ,
, Linux, Windows 98 NT? .
FreeBSD ,
. 9.2.
9.2 ,

FFS

(Berkeley Fast Filesystem)

MFS

(Memory Filesystem)

NFS

(Network Filesystem)

MSDOSFS

MS-DOS (MS-DOS Filesystem)

CD9660

ISO 9660 (CD-ROM)

PROCFS

(Process Filesystem)

, (. 17).
9.3

FDESC

(File Descriptor Filesystem)

KERNFS

(Kernel Filesystem)

NTFS

Windows NT (NT Filesystem)

NULLFS

NULL (NULL Filesystem)

NWFS

Novell NetWare (NetWare Filesystem)

PORTAL

Portal (Portal Filesystem)

UMAPFS

UID map (UID map Filesystem)

UNION

(Union Filesystem)

CODA

CODA (CODA Filesystem)

EXT2FS

Ext2 (Ext2 Filesystem) (Linux)

, ;
, , ,

174

3. FreeBSD

, . -
Ext2FS NTFS .
, , ,
.
, , ,
/modules;
.
, CODA, PORTAL, NWFS, NULL, NTFS, UNION ,
, .
, (, MSDOSFS), , , FreeBSD
. /sbin:
mount_od9660*
mount_devfs*
mount_ext2fs*
mount_fdesc*
mount_kernfs*
mount_linprocfs*

mount_mfs*
mount_msdos*
mount_nfs*
mount_ntfs*
mount_null*
mount_nwfs*

mount_portal*
mount_procfs*
mount_std*
mount_umap*
mount_union*

mount . ,
mount_* -t mount. . ,
. , mount -t nfs /mat, , mount_nfs /mnt.
, .


, man mount_*. , . , man
mount_ntfs , ,
, a man mount union
. !


Windows/MS-DOS
Windows 98 MSDOSFS
FreeBSD. mount_msdos.
, , , -W -L,
,
FAT32/VFAT. , .. ISO 8859-1, ,
root.
# mount_msdos /dev/adlsl /mnt

: , DOS Linux "" (partitions)


FreeBSD (slices), (partitions) BSD, .

175

9. FreeBSD

Windows 98 /dev/adlsl , ,
, FreeBSD,
( /dev/adlslg).
DOS (extended DOS partition),
Invalid argument ( ).
, DOS 5,
: /dev/adls5.
MS-DOS :
UID/G1D , root;
, ;
, ..
man mount_msdos.

- Windows ,
MS-DOS 8.3 Windows 95/98 ( ). mount_msdos, FreeBSD
. .
, .
mount_ msdos
-I -s, .

Linux
Linux- Ext2FS.
Ext2FS ,
. ( Ext2FS
, .)
17.
:
options

EXT2FS

, Linux :
# mount_ext2fs /dev/adlsl /mnt

, mount_ext2fs mount, .
FDISK
, , fdisk:
# fdisk /dev/adl
******* working
on device
/dev/adl
*******
parameters
extracted
from in-core
disklabel
are:
cylinders=1247
heads=255
sectors/track=63
(16065

blks/cyl)

Figures below won't work with BIOS


for partitions
not in cyl
parameters
to be used for BIOS
calculations
are: cylinders=1247
heads=255 sectors/track=63 (16065 blks/cyl)

176

3. FreeBSD

Media sector size is 512


Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 131,(Linux filesystem)
start 63, size 2104452 (1027Meg), flag 0
beg: cyl 0/ sector 1/ head 1;
end: cyl 130/ sector 63/ head 254
The data for partition 2 is:
sysid 130,(Linux swap or Solaris x86)
start 2104515, size 787185 (384 Meg), flag 0
beg: cyl 131/ sector 1/ head 0; end:
cyl 179/ sector 63/ head 254
The data for partition 3 is:
sysid 131,(Linux filesystem)
start 2891700, size 17141355 (8369 Meg), flag 0
beg: cyl 180/ sector 1/ head 0; end:
cyl 1023/ sector 63/ head 254
The data for partition 4 is:
<UNUSED>

[ FreeBSD) (sysid].
Linux Ext2FS 131, FreeBSD 165. ,
fdisk, /usr/src/sbin/i386/fdisk/fdisk.c.


CD-ROM -

CD-ROM -. CD-ROM
CD9660, , , FFS ( FreeBSD),
MS-DOS.

-
CD-ROM
. IDE /dev/acdOc, SCSI
/dev/cdOc, .
, "" (dedicated mode).

http://www.FreeBSD.org/
handbook/disks-naming, html.
# mount_cd9660

/dev/acdOc

/cdrom

- . ,
/dev/fdO; , , fdcO.
- ISA,
fdO fdl , .

mount /dev/fdO /floppy


mount_msdos /dev/fdO /floppy

177

9. FreeBSD

: - ,
CD-ROM , FreeBSD
!
- rdonly, -. , , ,
. CD-ROM
- rdonly,
!

-
- ,
, .
: Windows . Mac OS
- ,
. FreeBSD ( UNIX 86) , ,
.
CD-ROM ( ).
, . , , , -
, .
, ,
, .
: - (umount/cdrom) (umount/floppy)
. ,


, , .
USB FireWire, DVD. Zip .
FreeBSD Zip vpO, a USB Zip umass. ,
, .

- .

/etc/fstab
: , , , .
, IDE,

178

3. FreeBSD

NFS, MS-DOS SCSI- CD-ROM,


? !
/etc/fstab. cat /etc/fstab:
# Device
/dev/adOslb
/dev/adOsla
/dev/adOslg
/dev/adOslf
/dev/adOsle
/dev/acdOc
/dev/fdO
proc

Mountpoint
none
/
/home
/var
/usr
/cdrom
/floppy
/proc

FStype
swap
ufs
ufs
ufs
ufs
cd9660
msdos
proofs

Options
sw
rw
rw
rw
rw
ro,noauto
rw,noauto
rw

Dump
0
1
2
2
2

Pass#
0
1
2
2
2

, : , , , -
. fstab mount.
.
fstab ,
. ,
: mount -.
,
fsck -p, .. preen (), ,
clean (). mount -a -t nonfs
, /etc/fstab, NFS.
, .
/etc/fstab, mount; , :
# mount /home

fstab, ,
/dev/adOslg UFS (, FFS), -. ,
- :
#

mount /floppy

, !
noauto, /cdrom /floppy mount,
. NFS,
, CD-ROM - , noauto
.
, .
fstab mount, . , , , man mount man mount_*,
.
/etc/fstab "Pass#"; ,
fsck ( ). , ,
.

179

9. FreeBSD

, 1, .. ;
, 2 ( , ). .
-, ,
, ,
.
, (pass #), (dump level number). dump.
UNIX, .
dump,
. , ,
1, , 1 (
: " ").
, /etc/fstab
.

20. dump,
, , CVSup.


fsck
fsck ( File System Consistency checK ) Microsoft ScanDisk ,
, .
/etc/fstab
. preen () -. ,
, clean
() .
, fsck
. ,
- :
/dev/adOsle:
103469 files, 858450 used, 9066025 free
(25777 frags, 1130031 blocks, 0.3% fragmentation)


He , fsck. ,
2-3% ( ) ,
. DOS/VFAT
50% .
. UNIX , ,
. UNIX
( . .).
", " ,
.

1 80

3. FreeBSD

,
.
UNIX
, .
, .
.
fsck.
(unclean) , fsck
(investigative mode). ,
"" , .
.
, ,
( . man fsck), fsck
. . , , , , ,
. , ,
. , .
fsck #.
boot
reboot. , ,
- .
fsck ,
.
, ! ,
. fsck, (single-user mode):
# shutdown +5

(multiuser
mode) . , , ,
. .
"" , fsck.
, , -
dmesg ( root) , ,
. fsck (
fsck -p /dev/adlslg)
( exit) () .
fsck , , -
. fsck
, /etc/fstab.
fstab -
. , fsck (
, ). .

181

9. FreeBSD

, -
, !

.
(logging) , -
. fsck,

, .
FreeBSD .
(Soft Updates). -
log- , (
FreeBSD 5.0 )
, ,
log-. -
,
. , : , .
FreeBSD 5.0 diskcheckd.
( )
,
fsck ,
. /etc/diskcheckd.conf;
,
man diskcheckd. , diskcheckd, syslogd ( 11).
diskcheckd ps:
# ps - | grep diskcheckd
251
?? Ss
0:00.28 diskcheckd:

adO

13.26%

(diskcheckd)


fsck FreeBSD fsck -,
, , ,
fsck Linux. , , .

-
http://www.mckusick.com/softdep/
http://www.ece.cmu.edu/~ganger/papers/CSE-TR-254-95/.

fsck

, , ,
, , , .

182

3. FreeBSD

:
- ,
.
16 31 .
, FreeBSD
. ,
.
32,
.
, (,
), .
mount : "/dev/adlslh on /mnt: Incorrect super
block". fsck.
#
**

fsck /dev/adlslh
/dev/adlslh

BAD SUPER BLOCK: MAGIC NUMBER WRONG


LOOK FOR ALTERNATE SUPERBLOCKS? [yn]
USING ALTERNATE SUPERBLOCK AT 32

** Last Mounted on /home2


** Phase 1 - Check Blocks and Sizes
** Phase 2 - Check Pathnames
** Phase 3 - Check Connectivity
** Phase 4 - Check Reference Counts
** Phase 5 - Check Cyl groups
148 files, 15660 used, 7038840 free (208
fragmentation)

frags,

879829 blocks,

0.0%

UPDATE STANDARD SUPERBLOCK? [yn]


***** FILE SYSTEM WAS MODIFIED *****

Bo FreeBSD :
, , ,
32. fsck

.

, , newfs
-N (
):
# newfs -N /dev/adlslh
Warning: 2672 sector(s) in last cylinder unallocated
/dev/adlslh: 14558608 sectors in 3555 cylinders of 1 tracks, 4096 sectors
7108.7MB in 223 cyl groups (16 c/g, 32.00MB/g, 7936 i/g)
super-block backups (for fsck -b #) at:
32, 65568, 131104, 196640, 262176, 327712, 393248, 458784, 524320, 589856, 655392,
720928, 786464, 852000, 917536, 983072, 1048608, 1114144, 1179680, 1245216,
1310752, 1376288, 1441824, 1507360, 1572896, 1638432, 1703968, 1769504, 1835040,
1900576, 1966112, 2031648, 2097184, 2162720, 2228256, 2293792, 2359328, 2424864,
2490400, 2555936, 2621472, 2687008, 2752544, 2818080, 2883616, 2949152, 3014688,
3080224, 3145760, 3211296, 3276832, 3342368, 3407904, 3473440, 3538976, 3604512,
3670048, 3735584, 3801120, 3866656, 3932192, 3997728, 4063264, 4128800, 4194336,
4259872, 4325408, 4390944, 4456480, 4522016, 4587552, 4653088, 4718624, 4784160,
4849696, 4915232, 4980768, 5046304, 5111840, 5177376, 5242912, 5308448, 5373984,
5439520, 5505056, 5570592, 5636128, 5701664, 5767200, 5832736, 5898272,

183
5963808,

9. FreeBSD
6029344, 6094880, 6160416, 6225952, 6291488, 6357024, 6422560,

6488096, 6553632, 6619168, 6684704, 6750240, 6815776, 6881312, 6946848,


7012384, 7077920, 7143456, 7208992, 7274528, 7340064, 7405600, 7471136,
7536672, 7602208, 7667744, 7733280, 7798816, 7864352, 7929888, 7995424,
8060960, 8126496, 8192032, 8257568, 8323104, 8388640, 8454176, 8519712,
8585248, 8650784, 8716320, 8781856, 8847392, 8912928, 8978464,

9044000,

9109536, 9175072,

9568288,

9240608, 9306144,

9633824, 9699360, 9764896,

9830432,

9371680,
9895968,

9437216,

9502752,

9961504, 10027040, 10092576,

10158112, 10223648, 10289184, 10354720, 10420256, 10485792, 10551328,


10616864, 10682400, 10747936, 10813472, 10879008, 10944544, 11010080,
11075616, 11141152, 11206688, 11272224, 11337760, 11403296, 11468832,
11534368, 11599904, 11665440, 11730976, 11796512, 11862048, 11927584,
11993120,

12058656, 12124192, 12189728, 12255264, 12320800, 12386336,

12451872, 12517408, 12582944, 12648480, 12714016, 12779552, 12845088,


12910624, 12976160, 13041696, 13107232, 13172768, 13238304, 13303840,
13369376, 13434912, 13500448, 13565984, 13631520, 13697056, 13762592,
13828128, 13893664, 13959200, 14024736, 14090272, 14155808, 14221344,
14286880, 14352416, 14417952, 14483488, 14549024

, . [ , ), , fsck
- 2490400 /dev/ad1s1h 2490400.


, ,
? ,
20 . (quotas).
. ,
:
options

QUOTA

17. ,
/etc/rc.conf.
:
enable_quotas="YES"
check_quotas="NO"

,
(quotacheck
-), , . , YES ( YES,
).
( )
. /etc/fstab userquota /
groupquota. : .
/dev/adOslg
/dev/adOslf
/dev/adOsle

/home
/var
/usr

ufs
ufs
ufs

rw,userquota,groupquota 2
rw,userquota
rw,gropquota

2
2
2

2
2

. .
( )

184

3. FreeBSD

UID (
UID). ,
edquota,
( chfn,
). , edquota,
EDITOR, vi,
, , pico , setenv EDITOR pico.
# edquota -u bob
Quotas for user test:
/usr: blocks in use: 65, limits (soft = 50, hard = 75)
inodes in use: 7, limits (soft = 50, hard = 60)
/var: blocks in use: 0, limits (soft = 50, hard = 75)
inodes in use: 0, limits (soft = 50, hard = 60)


:
# edquota

-p

bob

1001-9999

UID
( ).
.
. ,
"".

,
. ,
, df fsck. ,
.
8192 . .
1024 . ,
, .
fsck, .
, , ,
, FreeBSD
, (
Windows). , , 8192 ,
. , .
, .
, . , .
.
:

UID GID

185

9. FreeBSD


,
,

FreeBSD ,
, : 12 ,
. , 96
. , : , .
, .
2048 8- ,
16 . , 2048 ,
, 2048
8- . 32 .
, ,
70 ! ,
UFS - .
.
(hard limit)
, .
(soft limit)
.
(grace period),
( edquota -t).
.
, . ,
, , .
:
# quota bob
Disk quotas for user bob (uid
Filesystem
blocks
quota
limit
/home
1812
20000 40000

1015):
grace

files
37

quota
0

limit grace
0

quota (
) . ,
(*), (grace)
:
#

quota

bob

Disk quotas for user bob (uid 1015):


Filesystem blocks quota limit grace files
/home
28121* 20000 40000 6days 189

quota

limit

grace

186

3. FreeBSD

, , mount -.
,
/home:
/dev/adOsla
/dev/adOslf
/dev/adOsle
procfs
on

on
/
(ufs,
local)
on
/home
(ufs,
local,
on
/usr
(ufs,
local)
/proc
(procfs,
local)

with

quotas)

with quotas , , .
/etc/fstab, /etc/rc.conf . , .

: , enable_quotas="NO"
/etc/rc.conf; /etc/fstab
edquota, - .
, UID edquota -p.
, , ,
, UNIX.
, FreeBSD, ,
, , ,
- , .
19,
.

10

u
?


[ACL]

188

3. FreeBSD

. , UNIX. ,
.
, ,
( Windows).
Windows 95/98/ Mac OS , , , . , ,
, . , ( , , ..), , ,
.
(guest), , - .
Windows NT 2000 , FreeBSD.
, ,
. root, . . , Windows NT/2000 (
, , ,
root), . ,
, .
NT-, ,
.
,
(terminal server). , , NT,
.
, ,
. Windows 2000
,
.
FreeBSD . , UNIX
.
(, Telnet SSH),
. , FreeBSD,
, . FreeBSD
, NT-, ,
.


, FreeBSD (
UNIX), . : -

10. ,

189

, root.
. root ,
6 .
(, Windows NT/2000) ,
,
. ,
-. , , ,
Web- (
26). -,
, - ,
.
FreeBSD
(home directory).
root su.
- root , . root
UNIX-. root
, ,
. root
, ,
.
root
( 29). .
. -
.
su
, wheel. FreeBSD
root, wheel
: , root (
su). su,
.

FreeBSD Linux UNIX , ( Telnet SSH) root . .


root (,
wheel] su.
, root wheel. ,
.
, /etc/ttys,
secure network Pseudo terminals ():
ttypO
ttypl
ttyp2

none
none
none

network
network
network

secure
secure
secure

, . ,
su.

,
, ( bin, operator, daemon, nobody ).
, .
,

190

3. FreeBSD

, ,
,
.
:
( ),

(. . 10.1). , (user
1), , - ,
-, - (user 2),
. -
.
, , user 1 -- root.
" " .
root ,
, ,
, "" ,
.
.
, - root.

10.1
,
.

?
.
. ,
users.
( ) .
"" man adduser.
, -
wheel ( /etc/ group).
,
root.
wheel: ,
root, su.
. , , -

10. ,

191


, , ,
, (. . 10.2).
,
.
"" .

10.2



,
.


. UNIX
: ,
. ,
- .
(. 10.1).
1s -1 ( )
- ( , , .. ,
):
10.1
# ls -la/home/frank
total 3126
drwxr-xr-x
3 frank
drwxr-xr-x
52 root
-rw-r--r-1 bob
-rw-rw-r-1 bob
-rw-r--r-1 frank
-rw-r--r-1 bob
drwxr-xr-x
2 root
drwxr-xr-x
12 root

users
users
users
bob
users
users
users
wheel

512 May12
9216 Mar
291090 Jan23
2703 Dec22
3657 Jan
92195 Sep
512 Jan
1024 Feb18

2000
7 13:37
2000 l.bmp
1998 contents.html
9 14:11 file. txt
11 21:31 1 . uu
2 14:19 files
1999 more-files

, ? ,
drwxr-xr-x, .
(user), (group)
(others) .
, ,
: (read), (write) (execute).
:

1 92

3. FreeBSD

1
2
3

r ;
w , ;
.

, -rwxrw-r-- . -
, , (rwx)
, rw- ,
, (r--)
.
rw-r--r--.
,
, (.. -
). .
, contents.html
; .

, , : , .
rm (remove ) :
.
# ls -l tempfile
-rw-r--r-- 1 root users 0 Aug
# rm tempfile
override rw-r--r-- root/users

21:44

for

tempfile

tempfile?


chown

. , root:
.
chown (change owner
):
#

chown

bob

file.txt

file.txt ( -) bob.
, frank, bob ,
a frank .
chown :
#

chown bob

/home/frank

, , "." (. -
10.1). , ".."
. /home/frank 10.1 ,
.
bob ,
, . ,
, ,

10. ,

193

.
- . 10.1.

chown: -R.
, .. ,
, . , ,
,
:
#

chown

-R bob

/home/frank


chgrp
chown chgrp.
, . :
#

chgrp

users

contents.html

contents.html :
-rw-rw-r--

1 bob

users

2703 Dec 22

1998

contents.html

, ,
users , bob.
FreeBSD : , bob bob.
: bob, bob. (, frank)
bob, . , bob frank .
chgrp chown; :
#

chown

bob.users

contents.html

contents.html bob users.


:
#

chown

.users

contents.html

chown, chgrp -R, .


10.1. ,
. ,
d. , .
,
, :
( ls);
4
w (
),
;
5
,
.

194

3. FreeBSD _____________________________________

, , drwxr-xr-x , (d), ,
. :
,
. "".
,
.
.

. 10.1 , ,
, ,
.
10.1

(rm), ,
;
# rm file.txt
override rw-r--r-- bob/users

for l.uu?

, , , !
, ,
("") .
rm -f.
FreeBSD TOT , ,
mv (move ).
-, . , ,
.
, ,
- , .
- ,
.

10. , 195


chmod

chmod (change mode ). chmod
: .



,
. : ,
. , ,
, . .
10.2.
10.2

0

# ( )
#
4

, " " 6, " " 5, ", " -- 7.
,
- . . 10.3.
10.3

755

// , /

644

/ ,

600

/ ,

:
#

chmod

755

testscript.sh

, "" :
.
- , .
6
0 .
7
1 . :
,
,
.

196

3. FreeBSD

2 , setgid.
, , , , .
4 , setuid. , ,
, , .
( , ).
755 0755. , ,
, , 3755 setgid 755.

, ,
. . -
chmod . , ,
. - .

chmod - man
chmod.

. 10.4.
. , (u , g -,
, ( , )).
(+,-,=), .
10.4

go+w

-r

ugo=rw

a=rw

ugo=rw

+t

(sticky bit)

+s

setuid setgid

# chmod g+w file.txt


chmod.

chown chgrp, chmod -R.

10. ,

197

, , FreeBSD 5.0,
FreeBSD 4.x .

(Access Control Lists, ACL) FreeBSD


5.0. ,
.
, ,
. -
(maximum permission mask), ,
ACL.
ACL UFS. ,
, .

ACL
, FreeBSD 5.0 UFS
(UFS Extensions) . ,
. , -
.
, ,
UFS . -,
Intel x86 /usr/src/sys/
i386/conf/GENERIC, Alpha /usr/src/sys/alpha/conf/GENERIC.
ACL , :
options
options
options

UFS__EXTATTR
UFS__EXTTR__AUTOSTART
UFS__ACL

, , . ,
. , ,
17.

, ACL.


ACL

extattrctl. , ACL
. , ACL , -
/usr, :
, root, /usr/.attribute /usr/
.attribute/system:
mkdir

/usr/.attribute

/usr/.attribute/system

/usr/.attribute/system (cd /usr/.attribute/system)


extattrctl ACL :
extattrctl initattr -p /usr 388 posixle.acl_access

198

3. FreeBSD

.
( ):
extattrctl initattr -p /usr 388 posixle.acl_default
, .

, ,
. -,
.

, . ACL
.

ACL
ACL- -
getfacl. , acltest.txt
ACL 644 getfacl acltest.txt
:
#file:acltest.txt
#owner:
#group:0
user::rwgroup::r-other:: ------

.
( root).
. ,
.


(maximum permissions mask) , -
( ), ACL.
, , ACL
.
, , . ,
ACL, .
, ACL
setfacl. :
setfacl

action

permissions

filename

action ( , , ..), permissions


ACL, filename .
acltest.txt ACL :

10. ,

199

setfacl -m m::r acltest.txt


getfacl acltest.txt
#file:acltest.txt
#owner:0
#group:0
user::rwgroup::r-mask::r-other:: ------

setfacl -m , ACL-
, m:: , , r read
. ,
m::rw. , , .
getfacl :
.

ACL
ACL
setfacl. ,
foobar :
setfacl -m u:foobar:r acltest.txt
getfacl
acltest.txt
#file:acltest.txt
t#owner: 0
#group: 0
user::rwuser:foobar:r-group::r-mask::r-other:: -----

, ACL foobar.
, .

:
setfacl -m u:foobar:rw
#flie:acltest.txt
towner:0
#group:0
user::rwuser:foobar:rwgroup::r-mask::rwother:: --

acltest.txt

getfacl , foobar .
,
.
( , , ), ACL
-n. , ACL
foobar,
, :
setfacl -n -m u:foobar:rw acltest.txt

200 3. FreeBSD

. -n ( m]. , : setfacl: acl_from_text() failed: Invalid


argument.

, ACL -n
. , ACL
, -
. , -n.

-n , ,
ACL ( ].
. , ACL- ,
.
-n.

foobar
ACL :
#flie:acltest.txt
#owner:
#group:0
user::rwuser:foobar:rwgroup::r-mask::rwother:: --

,
ACL , :
setfacl

- m::r

acltest.txt

getfacl :
#file:acltest.txt
#owner:
#group:0
user::rwuser:foobar:rwgroup::r-mask::r-other:: -----

effective:

r--

, foobar
.
.
ACL, .
:
setfacl -n -m u:foobar:rw,u:guest:r,g:visitors:r acltest.txt

foobar,
guest visitors. , -n

10. , 201

,
, .

ACL
ACL
,
- , . ,
ACL foobar, :
setfacl -m u:foobar: acltest.txt

foobar - acltest.txt,
- , . ACL
, .

ACL
- setfacl ACL. , foobar:
setfacl -x u:foobar: acltest.txt

ACL
ACL -b. : setfacl -b
acltest.txt

ACL, ACL
, getfacl setfacl.

, ,
.
adduser.
adduser useradd, Linux, . -
adduser root.
adduser
. -s (silent
), -
. 10.2
:
10.2 adduser
Use option ``-silent" if you don't want to see all warnings and questions.
Check /etc/shells
Check /etc/master.passwd
Check /etc/group
Enter your default shell: csh date ksh no sh tcsh [ksh] :

202.

3. FreeBSD

Your default shell is: ksh -> /usr/local/bin/ksh


Enter your default HOME partition: [/home]:
Copy dotfiles from: /usr/share/skel no [/usr/share/skel]:
Send message from file: /etc/adduser.message no
[/etc/adduser.message]:
Use password-based authentication (y/n) []:
Enable account password at creation (y/n) []:
Use an empty password (y/n) [n]: n
Ok, let's go.
Don't worry about mistakes. I will give you the chance later
correct any input.
Enter username [a-zO-9_-]: joe
Enter full name [ ]: Joe User
Enter shell csh date ksh no sh tcsh [ksh]:
Enter home directory (full path) [/home/joe]:
Uid [1005]:
Enter login class: default []:
Login group joe [joe]:
Login group is ``joe". Invite joe into other groups: guest no
[no] :
Use password-based authentication (y/n) []:
Use an empty password (y/n) [n]: n
Enter password [ ]:
Enter password again [ ]:
Enable account password at creation (y/n) []:

Name:
Password:
Fullname:
Uid:
Gid:
Class:
Groups:
HOME:
Shell:
OK? (y/n)

to

joe
****
Joe User
1005
1005 (joe)
joe
/home/joe
/usr/local/bin/ksh
[y] :

Added user ``joe"


Send message to ``joe" and: no root second_mail_address [no]:
Joe

User,

your account ``joe" was created. Have fun!


See also chpass(l), finger(l), passwd(l)
Add anything to default message (y/n) [n]:
Send message (y/n) [y]: n
Copy files from /usr/share/skel to /home/joe
Add another user? (y/n) [y]: n
Goodbye!

Enter
.
(- ), ,
; ,
. , -
, , , -
.

10. ,

203

FreeBSD 4.0 csh, ,


tcsh, .. csh
, tcsh ,
csh.

/etc/adduser.message,
- .

25).
, , ,
(
Is - ):
.cshrc
.login_conf
.mail_aliases
.profile

.mailrc
.shrc

.rhosts .login

12.

- (UID GID,
).
. .
,
UID .
.
rmuser, ( adduser
), 10.3.
10.3 rmuser ________________________________
I rmuser j oe
Matching password

entry:

joeiIRBpIrE/nkDQo:1008:1008::0:0:Joe
Is this the entry you wish to
(/home/joe)?
Updating
Updating
done.
Removing
Removing
Removing
Removing

user:/home/joe:/bin/csh

remove?

Remove user's

password file, updating databases, done.


group file: (removing group joe -- personal

home directory

group

user's home directory (/home/joe): done.


files belonging to joe from /tmp: done.
files belonging to joe from /var/tmp: done.
files belonging to joe from /var/tmp/vi.recover:

is

empty)

done.

matching password entry ( ) ,


. .

/etc/passwd /etc/master.passwd
, UNIX, /etc/passwd,
.
( ).
-
(vi, pico, , emacs .).
:

204

3. FreeBSD

/etc/passwd, ,
root. . /etc/shadow, -/etc/security/master.passwd. FreeBSD /etc/ master.passwd.
passwd ,
, (:).
: , , -,
, (,
, , : " ", "
", " ").
/etc/passwd 0644, a /etc/master.passwd 0600.
, ,
/etc/passwd, root /etc/master.passwd,
, -
. FreeBSD MD5.
/etc/passwd:
joe:*:1008:1008:Joe

User:/home/joe:/bin/csh

/etc/master.passwd:
joe:$1$32iknJXS$TnJOJj9LzYGwWRZonOu/IO:1008:1008: Joe
/bin/csh

User:/home/joe:


.
. 25 ,
.
FreeBSD /etc/pwd.db /etc/ spwd.db.
db,
/etc/passwd /etc/master.passwd, .

pwd_mkdb chfn, passwd
adduser/rmuser.
chfn (change full name )
. edquota, 9,
chfn , EDITOR (
vi). , -
/etc/master.passwd - pwd_mkdb -p
.
, /etc/master.passwd.
FreeBSD-,
master.passwd /etc
:
#

pwd_mkdb

-p

/etc/master.passwd.new

, /etc
master.passwd.new. /etc/master.passwd , a /etc/ pwd.db,
/etc/spwd.db /etc/passwd . - -
pwd_mkdb /etc/passwd; , /etc/ passwd
. -,
.

10. ,

205

FreeBSD /etc/passwd ,
.
/etc/pwd.db

/etc/group
(
/etc),
, /etc/ group ( /etc/passwd )
(
root).
/etc/group. ,
: , "" (
),
-.
wheel:*:10:root,bob,frank

/etc/group ,
.
, , , ,
. " " FreeBSD
. ,
.


,
, .
/etc/group
, .
.
adduser
.
,
. ,
, , , Web-
.
100 1000. , 1000,
( -
). , 100, ,
.

. - ,
, .
.

11

FreeBSD

inetd inetd.conf
[syslogd]
syslog.conf
/etc/re.local

11.

207

FreeBSD, ,
. , , Windows Mac
OS. , ,
( , "")
.
UNIX-
, FreeBSD
Linux. , , fsck
, Linux. A boot-
, LILO ( Linux). , FreeBSD
(runlevel), Linux Solaris.
FreeBSD , , ,
, .


FreeBSD
(bootstrapping process) FreeBSD ,
. ,
. .
, BIOS CMOS.
, IDE SCSI.
, .
, .
.
BIOS (Master Boot Record) (MBR)
.
MBR -,
. ,
. 512 (.. MBR
). .
0 (bootO). MBR ,
.
Fl FreeBSD
F2

Linux

F3

??

Default:

Fl


. , ,
.
1 (bootl). , (slice), bootO. -

208

3. FreeBSD

disklabel,
( 19)
boot2. , boot l .
# 2 (bootl). , ,
,
, .
FreeBSD , ,
( ). , (loader), .
# (loader). /boot. /boot/defaults/loader.conf /boot/loader.conf,
. ( /boot/loader.conf
, /boot/defaults/loader.conf,
/etc/rc.conf, .)
10 . ,
, . Enter,
,
: -
(single-user mode) boot -s, - boot
kernel.old, CD-ROM boot -. ,
, - ()
( man boot).
-.
. , ,
(, /modules/portal.ko) ,
. , ,
.
ok, :
ok load portal. ko
/modules/portal.ko
text=0xld18
data=0xlf4+0x4
syms=[0x4+0x8d0+0x4+0x6bf]
ok Ismod
0x100000: kernel (elf kernel, Ox355be4)
Ox455be4: /boot/kernel.conf (userconfig script,
0x456000: portal.ko (elf module, )

Ox4c)

? .
load ( ) Ismod (
, ).
, , ,
.
man loader.
, , .
FreeBSD: ,
,

1 1 . 209

(resource configuration), ,
.
(kernel).
, . . dmesg,
dmesg.

dmesg ,
, .
dmesg, dmesg I less .

init. , init, .
Automatic reboot in progress ( ). init Resource Configuration script (/etc/re). , /etc/
fstab, 9.
fsck ,
, (mount -a -t nonfs)
. fsck , ,
fsck .
, .
, .
, , .

, ,
(boot -s loader), ,
root. -, , ,
.
, . /etc/ttys, (, ,
(] ], secure insecure
console:
console none

unknown off insecure

, . .


console .
(
Alt+F1, Alt+F2 ..].
. secure insecure :

210

3. FreeBSD

root , root su.

, ,
( ,
). , Ctrl+Alt+Delete
.
.
(, ),
.
, :
options

SC_DISABLE_REBOOT

17.

?
.
, , .
, scndmail httpd (Apache);

.
, Sendmail, Apache,
; DNS, /etc/
resolv.conf. ( TCP/IP 23.) ,
, , - ,
. -
,
. ? , ,
/etc/resolv.conf, FreeBSD-;
Sendmail Apache
. ,
127.0.0.1 (localhost) .
, init mount -a -t nonfs
.
(NFS) -, , ,
. mount,
9, NFS (
). init ,
NFS, /etc/re. NFS.
/etc/fstab (, noauto)
.
NFS,
!


/etc, ,
. , , -

11. 211

FreeBSD .
- ,
, . /etc
-,
. /etc/rc.conf.
, FreeBSD, . 11.1.
11.1

/etc/re

config.

/etc/rc.diskless1

init
.

/etc/rc.diskless2
/etc/defaults/rc.conf

init ,
, .

/etc/rc.conf

/etc/
defaults/rc.conf. /etc,
!

/etc/re, sysctl

.
.

/etc/re, serial

/etc/re, pccard

PC- .

/etc/re.network

TCP/IP.

/etc/re.network6

re.network,
IPv6.

/etc/re.atm

re.network; ATM WAN.

/etc/rc.firewall

re.network;
ipfw.

/etc/rc.firewall6

re.networkG;
ip6fw.

/etc/re.i386

, 86 (,
).

/etc/re.shutdown

init .

/etc/re.suspend

, .

/etc/re.devfs

(device
filesystem).

/etc/re.local


.
rc.d!

/usr/local/etc/rc.d/
/usr/local/X11 R6/etc/rc.d/

, ,
(
).

212 3. FreeBSD

/etc/defaults/rc.conf, /etc/rc.conf
rc.d. , FreeBSD , .

/etc/defaults/rc.conf
/etc/rc. , ;
,
; , , .
/etc/rc .
.
FreeBSD , ,
.
FreeBSD /etc/
rc.conf. , /etc/rc
. .
, , . , , rc.conf . ,
/etc/re.
/etc/defaults,
rc.conf . /etc/rc.conf , , .
, /etc/defaults/
rc.conf. (IP-, ,
..) , , sendmail sshd.
/etc/defaults/rc.conf,
11.1.
11.1 /etc/defaults/rc.conf
# named sandbox, . man
#s e c u r i t y .
#
named_enable=MNO"
# named, DNS- ( NO
# ()).
named_program="named"
# named,
# .
named_flags=""
# named.
#named_flags="-u bind -g bind"
# named.

, /etc/r ,
named.
/etc/defaults/rc.conf , YES/NO. ,
"". NO, ; YES, (, named_flags
).

11.

2I 3

/etc/rc.conf
, named. , ,
/etc/rc.conf (, "
) :
named_enable="YES"

named_* /etc/defaults/rc.conf ; ,
init, , ""
YES. ,
/etc/rc ( named).
. , mynamed. , bind, (
). , (, mynamed
, named), /etc/rc.conf
:
named_program="mynamed"
named_flags="-u bind
-g

bind"

, init:
# grep "named_enable"
/etc/re.network:

/etc/re*
case ${

named_enable)

in

, /etc/rc.network.
, :
network_pass2 ()
echo

-n

'Doing

${named_enable}
echo -n
$ {named_flags}
esac

additional

network

setup:' case

in [*] [] [Ss])
' named';
${named__program:-named} ~

;;

, named_* rc.conf ;
, Doing additional network setup:
named, , .

13.
.

, /etc/rc.conf , TCP/IP. , , -
FreeBSD . 11.2
/etc/rc.conf :

214

3. FreeBSD

11.2 /etc/rc.conf
# ,
#
,

/etc/defaults/rc.conf

#

#

sysinstall
generated deltas
-- #
kern_securelevel="l"
kern_securelevel_enable="YES"
linux_enable="YES"
sendmail_enable="YES"
s shd_enable="YES"
portmap_enable="NO"
nfs_server_enable="NO"
inetd_enable="NO"

network_interfaces="fxpO

lo0"

ifconfig_fxp0="inet
10.6.7.101
netmask
defaultrouter="10.6.1.1"
hostname="freebsdl.testnetwork.com"
usbd_enable="YES"

255.0.0.0"


, ,
(, NFS-) .
;
/etc/rc.conf . ,
sysinstall (
). , (
), , /etc/re ,
-
/usr/local/etc.

/usr/local/etc /usr/local/X11R6/etc
, 9 : ", ,
/usr/local"? ,
. /usr/local/etc /etc, ,
.

, /etc /usr/local/etc , , . /usr/


local/etc , -
[
, ). ,
/etc , ,
FreeBSD. /usr/local/etc ,
. ,
/usr/local/etc , .

/usr/local/etc , . 15, .

11.

215

rc.d ( Resource
Configuration for Daemons ).
init /usr/local/etc/rc.d ,
/etc/re.*. , .sh,
. , ,
apache.sh, mysql-server.sh samba.sh.
, start stop;
init , start. ,
-, ,
:
# /usr/local/etc/rc.d/apache.sh

start

.sample (,
samba.sh.sample). , . Apache, , ,
- config ( , ,
). apache.sh,
. , Samba
; ,
. ,
( .sample), init.
/usr/local/XHR6/etc /usr/local/etc, ,
XII GNOME,
, , .. rc.d.
/usr/local/ etc/rc.d.
.
rc.conf:
local_startup="/usr/local/etc/rc.d
.

/usr/XHR6/etc/rc.d"



,
.
.
/usr/local/etc/rc.d.
, init , rc.d start .sh (
).
man re:
#!/bin/sh

case "$1" in
start)
/usr/local/sbin/foo

-d

&&

echo

-n

'

foobar

foo'

216

3. FreeBSD ______________________________________

;;
*)
echo "unknown option: $1 - should be 'start'" >&2
;;
esac

, , foo.sh. ,
(chmod +x foo.sh)!
: perl, . ,
.sh.
! 13.

inetd inetd.conf
,
.conf /etc, inetd, .
.
inetd
. ,
inetd telnet-.
telnet, ,
telnetd. ,
23, telnetd .
, inetd ( - ),
/usr/libexec. ,
;
, - (,
).

inetd telnetd,
, telnetd
. (sshd httpd sendmail ] ""
, inetd. ( root)
, ,
. ,
, inetd root,
. ,
, .

/etc/inetd.conf , .
. 11.2.
11.2 , inetd

ftp

File Transfer Protocol (


)

21/

telnet

23/T

11.

217

comsat

biff (

512/UD

)
ntalk

chat-

518/TCP,UDP

ftp (IPv6)

File Transfer Protocol (


)

IPv6

telnet (IPv6)

IPv6

, , , , . 11.3.
11.3 inetd

Post Office Protocol ( )

110/

imap4

Interim Mail Access Protocol


( )

143/

smtp

Qmail ( SMTP-
Sendmail)

25/

netbios-ssn
netbios-ns Windows Samba

139/
137/

finger

79/

- ,
inetd :
# ps -waux | grep inetd
root
110
0.0
0.6 1032
# kill -HUP 110

752

??

Ss

11: 57PM

0:00.01

inetd

1 (
, 1 Medium ), inetd .
, , inetd. -
, inetd -wW/.
, /etc/rc. conf :
inetd_enable="NO"

inetd FreeBSD, . .
/etc/inetd.conf, ,
, .
, cvs ,
. Samba (netbios-ssn netbios-ns)
, smbd nmbd - /usr/local/sbin,
, -Samba
. Samba inetd,
, .

218

3. FreeBSD

(, ) ,
/usr/Iocal/libexec. ,
/usr/local, ,
.
inetd. qpopper ( ), qpopper popper.
:
stream top

nowait root /usr/local/libexec/qpopper qpopper

. inetd , .
inetd man
inetd.

(syslogd)
syslog.conf
/var/log. ,
syslogd, .
/etc/syslog.conf, log- . ,
( auth, authpriv, console, cron, daemon, ftp, kern, Ipr,
mail, mark, news, ntp, security, syslog, user, uucp localO local7)
"", .
( ) emerg, alert, crit, err, warning, notice,
info debug.
, FreeBSD,
log- syslogd; Sendmail
syslog() , mail;
- syslogd syslog.conf.
syslog.conf :
* . err;kern.debug;auth.notice;mail.crit
/dev/console
*.notice,'kern.debug;Ipr.info,'mail.crit;news.err
/var/log/messages
security.*
/var/log/security
mail.info
/var/log/maillog
1pr.info
/var/log/lpd-errs
cron.*
/var/log/cron
*.err
root
*.notice,'news.err
*.alert
*.emerg

root
root
*

: err , debug ,
notice, crit (..
, FreeBSD-).
, ,
/var/log/security, info
/var/log/maillog. /var/log/messages
log- . ( Linux, ,
syslog.)
log-, . syslog.conf ,

11.

219

err, notice alert


- root, emerg .
11.4 syslogd
.
11.4 syslogd

/path/to/file

@some.hostname.com

syslogd
some.hostname.com ( syslog).

userl

,
userl .

root,userl ,user2

| "mail root"

root
.

syslogd
man syslogd man syslog.conf.

log- /var/log .
, /uar/log/maillog
periodic. , /var/log/cron /var/log/messages,
( , ).
, , gzip. gzcat
:
# gzcat /var/log/messages.2.gz

| grep "rejected"

/etc/rc,local
/etc/rc.local, ,
. ,
FreeBSD Linux.
, /usr/local/etc/rc.d, ,
.
rc.d, ,
. :
, /usr/local /etc.
, /etc/rc.local,
, .
.
, rc.d.
rc.local ,
, , - FreeBSD.
rc.local /etc/rc,
11.3.

220

3. FreeBSD

11.3 /etc/rc, /etc/.local


# grep - 5 re.local /etc/rc
# ( ) rc.local,
# . ,
# /etc/defaults/rc.conf
# /etc/rc.conf, .
# /etc/rc.
# Use /etc/rc.local
#
# --- re.local --#
if [ -r /etc/defaults/rc.conf ]; then

. /etc/defaults/rc.conf

source_rc_confs
#
elif [ -r /ete/rc.conf ]; then
#
. /ete/rc.conf
# --- re.local --#
if [ -r /ete/rc.local ]; then
echo -n 'starting local
sh /etc/re.local
echo '.'
fi
#
# *.sh
#
----------------------------------

daemons:'

$local_startup,

, sh /etc/rc.local.
, rc.local.
rc.d.

12

222

3. FreeBSD

, FreeBSD X-Window, , , . ,
, .

.

?
8.
,
, FreeBSD.
:
.
, (shell) , Windows Mac OS.
COMMAND.COM MS-DOS,
Windows, .
, .
(shell).
UNIX ,
, , ,
. (
17). . ? , ! .
12.1.
.
"" , . , , .

12,1
,

12.

223

,
. ,
,
. , ,
,
.
(shell) . , , -
. Windows 95 ,
, (Windows 3.1, DESQview MSDOS). "" DOS (..
). , ,
. " " (shelling out)
(.. DOS UNIX).
8 FreeBSD, , , . sh, csh, bash, ksh tcsh.
, . 13
Bourne (sh), .
.



FreeBSD , /bin/tcsh. , FreeBSD
tcsh, bash ( Linux),
BSD System V (
Linux),
UNIX. .
UNIX ,
. Linux FreeBSD ,
GNU BSD. ,
Linux bash, FreeBSD tcsh.
bash GNU-, Linux , GNU (GNU
Public License, GPL), bash Linux , bash tcsh ,
-. , .
, Linux, bash
. , ksh zsh. : , .
tcsh bash.
.

224

3. FreeBSD


FreeBSD
( . 15). .
, .


sysinstall (package manager).
/stand/sysinstall, Configure, Packages.
CD-ROM ( -
FreeBSD) FTP.
, ,
Shells .
(X).
Enter .
" " Install.
.
sysinstall, Exit
Configuration, Exit Install . ()
. , /usr/local/bin, , man bash.


( 15) . ,
, , ( , /usr/local, FreeBSD).
, /usr/ports
, , sysinstall.
/usr/ports/shells .
. (
/usr/ports) , .
, , Makefile,
, .
44bsd-csh/
Makefileesh
README.html
bashl/
bash2/

es/osh/rc/vshnu/
/pash/ruby-shell/wapsh/
flash/pdksh/sash/zsh/
ksh93/perlsh/scsh/sh-devel/
nradsh/pkg/tcsh/

make: , ,
. make install. -

12.

225

make clean,
, :
# cd /usr/ports/shells/bash2
# make
# make install #
make

clean

tcsh, rehash,
, , -
. -
(, -
].

/etc/shells
, , /etc/shells. ,
, . /etc/shells
:
# cat /etc/shells
# $FreeBSD: src/etc/shells,v
#
#

1.3

1999/08/27

23:23:45

peter

Exp

chpass(l).

# Ftpd ,
# .
/bin/sh
/bin/csh
/bin/tcsh
/usr/local/bin/bash
/usr/local/bin/zsh
/usr/local/bin/ksh

/etc/shells , , , . ,
, ,
, .
setuid ,
UID , ( 10).
setuid root,
root. , ,
, . chsh

, /etc/shells.

/etc/master.passwd (
/etc/passwd). 8:

226

. FreeBSD

/etc/master.passwd:
foo:*:$!$LXZkCuzD$70a8LyRgbjYOb.XrXiBad.:1001:1001::999066364:0:Foo
Bar:/hom e/foo:/usr/local/bin/ksh /etc/passwd:
foo:*:1001:1001::Foo Bar:/home/foo:/usr/local/bin/ksh

( /usr/local/bin/ksh),
/etc/shells,
, FTP. ,
FTP . /etc/shells, ,

adduser (. 10).
,
/etc/shells.
: root
, /etc/shells,
( telnet/ssh) ,
.
FTP,
. , -
( /etc/shells
),
( root).
,
telnet ssh, FTP
. ,
/etc/shells.
- .

,
. : - Linux bash,
,
(
). ,
.


.
tcsh, bash (,
-), bash
tcsh.
# bash
bash-2. 0 4 #

: :
bash, tcsh.
(login shell)
.

12.

227

,
, ,
.login ( , ),
. ,
,
/etc/shells.
chsh (change shell ).
. , , Linux, chsh
, . FreeBSD
chsh chpass, chfn
: ,
.
chsh , . vi. , ,
pico, EDITOR.
( .)
chsh. root
,
.
# chsh frank
#Changing user database
Shell: /bin/tcsh
Full Name: Frank Allen
Office Location:
Office Phone:
Home Phone:
Other
~
~

information

for

frank.

information:

vi .
.
. ,
. vi
,
. , :q!, Enter.
.
:q!
, frank
/bin/tcsh /usr/local/bin/bash. .
vi ( chsh frank), tcsh.
(change ) w (word ).
$, :
Shell:

/bin/tcs$

228

3. FreeBSD

tcsh bash Escape .


/bin/bash.
( bin) i (insert ) . /usr/local
Escape. /usr/local/bin/bash.
:w (write ),
Enter . :q Enter.
, /etc.
,
/etc/master.passwd /etc/passwd.
/usr/local/bin/bash /bin/tcsh.
(, /etc/shells),

.

,
. (, /sbin/nologin),
.
,
UNIX (, TinyFugue).
.
, .
/usr/bin/mail ( ).
.
.
, chsh -,
- .
. ,
:
pty (),
,
pty . ,

. (
), , (
telnet)
, :
FreeBSD/i386 (stripes.somewhere.com)

(ttyp2)

login: frank
Password:
Last login: Sat May 5 18:35:52 from w044. Z064002043.
Copyright (c) 1980, 1983, 1986, 1988, 1990, 1991, 1993, 1994
The Regents of the University of California.
All rights
reserved.

12.

229

FreeBSD 4.3-RELEASE (STRIPES) #0: Wed Jan 31 18:45:43 PST 2001


Welcome to the system! Today's news: nothing.
You have mail.
login: /usr/local/bin/foosh: No such
Connection closed by foreign host.

file

or

directory

, , ,
. ,
(, ),
,
/etc/motd (
).
/etc/ mold
, ,
.
, , .
/sbin/nologin , . ,
. , , :
You have mail.
This account is currently not available.
Connection to stripes.somewhere.com closed.

, /sbin/nologin : , .
,
, . , telnet ssh,
. . ,
. /bin/Is /usr/bin/fmger.
, ,
. ,
, ,
, .
. !

- ,
,
!
. , ,
root ( setuid root),
. 8
!


, . ,
-

230

3. FreeBSD

, ..
,
.
tcsh bash , . FreeBSD
,
tcsh bash . ,
.

,
/usr/share/skel ( dot ] . /usr/local/share/skel, , -
/etc/adduser.conf , .
, -
.

tcsh/csh: .cshrc, .login .logout


, tcsh,
/etc/csh.cshrc. /etc/csh.login.
, FreeBSD ,
(. 12.1).
12.1 /etc/csh.cshrc /etc/csh.login ____________
# cat /etc/csh.cshrc
# $FreeBSD: src/etc/csh.cshrc,v 1.3 1999/08/27
#
# .cshrc csh(l).

23:23:40

peter

Exp

# cat /etc/csh.login
# $FreeBSD: src/etc/csh.login,v 1.19.2.1 2000/07/31 20:13:26 rwatson
Exp $
#
# .login csh(l).
# ,
4.2, -
# setenv BLOCKSIZE

#
#
# login.conf(5), charset lang.
# locale- /usr/share/locale/*
#
#
# msgs -f
#
# mesg

, ,
. , , ,
, ,
.
, -

12. 231

.
: .cshrc .login.
.cshrc ( /usr/share/skel/dot.cshrc)
- . ,
:
alias
alias
alias
alias
alias

h
j
la
If
11

history 25
jobs -1
Is -a
Is -FA
Is -1A

:
set path = (/sbin /bin /usr/sbin /usr/bin /usr/games
sbin /usr/local/bin /usr/XHR6/bin $HOME/bin)

/usr/local/

,
:
setenv
setenv
setenv

EDITOR
vi
PAGER
more
BLOCKSIZE

.
.csfarc .
.login, , ,
. ,
.login ( /usr/share/skel/dot.login) fortune
:
#
#

:
[ - /usr/games/fortune ] && /usr/games/fortune

-s

,
. , ,
/tmp,
. /etc/csh.logout,
- :
# cat /etc/csh.logout
# $FreeBSD: src/etc/csh.logout,v 1.3 1999/08/27 23:23:41 peter Exp $ #

# .logout csh(l).

.logout
, . .

tcsh . .
, (
). .login .logout (
) .

bash: .profile, .shrc .bashjogout


bash tcsh:
, .

532

3. FreeBSD

/etc/profile, ( /etc/csh.cshrc) ,
, ( 12.2).
12.2 /etc/profile
# cat /etc/profile
#
$FreeBSD: src/etc/profile,v 1.12.2.1
2000/07/31 20:13:26 rwatson Exp $
#
6.
.profile sh(l).
#
7.
,
8.
4.2,
9.
BLOCKSIZE=K; export
BLOCKSIZE
#
10.
11. login.conf(5) , charset lang.
12.
locale- /usr/share/locale/*
13.
14. setlocale(3).
#
15.
16. msgs -f
17.
18. mesg

, /etc/profile
/etc/csh.cshrc /etc/csh.login. bash ,
.
.profile,
( PATH)
Bourne:
# /usr/games /usr/XHR6/bin
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/
XllR6/bin:$HOME/bin; export PATH
BLOCKSIZE=K;
EDITOR=vi;
PAGER=more;

export BLOCKSIZE
export EDITOR
export PAGER

6.
ENV ,
7.

sh.
ENV=$HOME/.shrc; export ENV

ENV .shrc.
.
.profile. ,
tcsh .cshrc, a , ,
( ):
#
alias h='fc -11
alias j=jobs
alias m=$PAGER
alias 11='Is -laFo1
alias l='ls -1'
alias g='egrep -i1
# # set prompt:

` `username@hostname$

' '

# PSl="'whoami'(T hostname | sed 's/\..*//''"

#
#

case

'id

-u~ in
0) PS1="${PS1}#

";;

12.
#

*)

PS1="${PS1}$

233

";;

# esac

.logout tcsh, bash


.bash_logout, . .

bash ,
. .profile,
.bashrc FreeBSD .


,
( ) .

. , ,
.
, tcsh bash.
, ,
.

,
csh/tcsh, bash, , man builtin

tcsh
(alias).
.
, ,
.
.cshrc:
alias

11

Is

-1

11 /usr/local Is -1 /usr/local.
,

?
tcsh.
man tcsh. ,
\!^ ( \!:1), \!:2, \!:3
.. , , :
alias lookup

grep \! /etc/passwd


lookup frank. unalias:
unalias

lookup

234

3. FreeBSD

. prompt:
, , , ,
Perl. , ,
"" . !. , ,
sed (stream editor , ) :
# set prompt="{
{ root@www:23}

'whoami'@'hostname

sed

's/\..*//'":!}

"

,
, pwd (present working
directory ):
#
{

set prompt="{
/root:24}

'pwd':!}

"

tcsh ( ). ,
, " ".
, set,
, .
, :
set path = (/sbin /usr/sbin /bin /usr/bin /usr/local/bin /usr/
contrib/bin /usr/XllR6/bin /usr/local/sbin /usr/games . /usr/local/
mystuff)

stty. . , , ,
delete backspace .
:
#

stty

-a

speed 38400 baud; 60 rows; 80 columns;


Iflags: icanon isig iexten echo echoe -echoic echoke -echonl echoctl echoprt -altwerase -noflsh -tostop -flusho pendin .
-nokerninfo -extproc iflags: -istrip icrnl -inlcr -igncr
ixon -ixoff ixany imaxbel
-ignbrk brkint -inpck -ignpar -parmrk oflags: opost onlcr
-oxtabs cflags: cread cs8 -parenb -parodd hupcl -clocal -cstopb crtscts
-dsrflow -dtrflow -mdmbuf
cchars: discard = ^0; dsusp = ^Y; eof = ^D; eol = <undef>;
eo12 = <undef>; erase = ^?; intr = ^C; kill = ^U;
lnext = ^V; min = 1; quit = ^\; reprint = ^R;
start = ^Q; status = ^T; stop = ^S; susp = ^Z;
time = 0; werase = ^W;

, (erase) ^, :
# stty erase ^H

12.

235

, (watch),
, , .
:
set watch=(l any any)
set who="%n has %a %1

from %M."

tcsh, ,
autologout. 60 .
.
:
unset

autologout;

,
,
, ,
rehash.

bash
bash , tcsh. -
=, . ,
, ,
tcsh, , , lookup bash .
alias

11=4s

-laFo1

bash. bash
,
(primary) (secondary) (PS1 PS2),
. , .
, tcsh, (
!,
, tcsh):
#
{

PS1="{
'whoami'( hostname
root@www:17)

sed

's/\

. . * / / ' ' :\!)

"

, ,
:
#
{

PS1="{ -pwd-\
/root:18}

:!}

path
PATH. , . ,
export.
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/usr/local/bin:/usr/
XllR6/bin:$HOME/bin; export PATH

(.. ) .

236

3. FreeBSD



tcsh bash
. 13, , . ,
.


, ,
. ,
. , . , chfn , EDITOR, TERM ,
, .
BLOCKSIZE du df: , . , ,
, , .

, printenv,
12.3.
1 5 . 3 p r i n t e n v _
# printenv
PATH=/sbin : /usr/sbin : /bin: /usr/bin : /usr/local/bin : /usr/contrib/bin : /usr/

XllR6/bin:.
MAIL=/var/mail/frank
BLOCKSIZE=1k

FTP_PASSIVE_MODE=YES
USER=frank
LOGNAME=frank

HOME=/home/frank

SHELL=/bin/tcsh
SSH_CLIENT=192.168.173.230
SSH_TTY=/dev/ttypO
TERM=vtlOO
HOSTTYPE=FreeBSD
VENDOR=intel
OSTYPE=FreeBSD
MACHTYPE=i386
SHLVL=1
PWD=/home/frank
GROOP=users

50095

22

HOST=stripes.somewhere.com

REMOTEHOST=192.168.173.230
PATHSET=true
EDITOR=vi
VISUAL=pico


, . -

12.

237

COLOR gold tcsh -:


# setenv COLOR gold

B bash ,
:
4 COLOR=gold
5 export COLOR

, .
null .


, .

. .
, , -
, .
tcsh
bash. set. -
tcsh set. tcsh
, :
# set history
noclobber

100 #

set

bash , :
# VISUAL=pico

unset : #
unset autologout
13, -,
.

13

g









n

13. 239

8 ,
. ,
.
:
, -
.
FreeBSD
. FreeBSD
, "",
. .
. FreeBSD ,
.
, ,
, ,
, , , -,
.. ,
, , Internet
.
-
Perl , " DOS", . ,
bat- DOS,
, . ,
, , ,
,
.
FreeBSD,
.
,
FreeBSD:
. FreeBSD,
, , , .
. ,
, 510
.
. ,
100 , "for" .
. ,
, .
FreeBSD , .
.
. FreeBSD " -".

240

3. FreeBSD

,
.
. , ,
, , ,
.
, FreeBSD.

, Bourne.
rn ,
POSIX. , ,
, ,
.

csh .
, ,
( STDOUT STDERR].
Bourne.



"Hello, World!".
Bourne:
1.
2.
3.
4.
5.

#!/bin/sh
# "Hello, World!",
# Bourne.

echo
echo "Hello World!"
echo
exit 0

! .
. . .
:
chmod

u+x

hello

(,
hello).
. :
bash$ ./hello
Hello World!
bash$

.
1: " "
#!, FreeBSD, ,
.

13.

24 I

Bourne, /bin/sh. Perl


: /usr/bin/perl, Python
/usr/local/bin/python ..
2 5: .
, ( ).
.
3 4: . #
. .
:
, .
6: echo , STDOUT
(, ). -
. echo STDOUT .
7: echo "Hello, World!" STDOUT.
,
(.. ,
). ,
. , .
. .
8: echo .
9: exit
. ( ,
- .) , 0,
, , , 0,
. ,
: .

.
,
-. ,
.
,
- , .

printf
echo
printf. ,
. , , printf
echo:
1.
#!/bin/sh
2.
3.
# "Hello, World!",
4.
# Bourne.
5.
10.printf
"\nHello World!\n\n!"
11. exit 0

242

3. FreeBSD

, printf
. ,
, (, , , ).
"n" .
echo, , printf. ,
.
, printf .
, . ,
, printf -:
printf "Hello,
"World!\n\n"

" printf

"Hello, World!",
. , printf
. echo
printf, "Hello" "World!" .
printf :
13.1 printf

.
.
.

"backspace".

\f

" ".

\n

, (
)

\t

\v

\`

\"

\\

\num

, ASCII- num.
, .

, .
.

,
, . -

13.

243

,
, (.. ).

: .
, ,
, .
, ,
, , .
.


:
myvar=5

myvar 5.
$. , echo
${myvar} 5 STDOUT, .. .

. myvar=5 5 myvar. myvar = 5 ,
myvar , , .

, ,
. .
, :
myvarB=$myvar
myvar myvarB.
myvarB - , .
, STDIN
( ). .
. , .
export. , :
MYVAR=5 export
MYVAR

MYVAR, , -
, ,
.


. ,
. . ,
.
, . , ,
avg_rainfall (_), ,
xyz123.

244

3. FreeBSD

,
.
,
, , , .


, -
STDIN.
( ,
STDIN).
read. "Hello,
World", STDIN, , ,
:
I.
2.

#!/bin/sh

3.

# Hello,

21. .
22. .
echo
echo -n "Please enter your
read name
8.
echo
8. echo "Hello,
${name}!"
9. echo
1 1 . exit 0

name:

Id,

"

:
Please enter your name:
Hello, Mike!

Mike

, :
6: echo. -n
, , echo. , Please enter
your name:.
7: read STDIN,
. . Enter,
read name. read
, , , .
9: echo Hello,
name. .
read (.
13.1). -
, .
13.1.

13.

245

13.1 read
#!/bin/sh
echo
echo -n "
: "
read varl
echo

echo
echo
echo
echo
exit

var2

var3

"The value of varl is:


"The value of var2 is:
"The value of var3 is:

${varl)"
${var2)"
${var3)"

:
, : 557 2024 57240
The value of varl is: 557 The
value of var2 is: 2024 The
value of var3 is: 57240

He , . read
.
, , ,
, . , , ,
. ,
:
Enter three numbers separated by spaces or tabs: 1 2 3 4 5 6 7 8 9 0
The value of varl is: 1
The value of var2 is: 2
The value of var3 is: 3 4 5

6 7 8


. . ,
. .
$1-$9. ,
POSIX, ${10}, ${11} ..
,
, Bourne
$1-$9. $0 , $@ , $# . :
#!/bin/sh
echo
echo "The name of the program is: $0"
echo "The total number of arguments received is:
echo "The complete argument string is: #@"
echo "Your first name is: $1"
echo "Your last name is: $2"
echo
exit 0

$#"

246

3. FreeBSD

:
bash$ ./yourname Michael Urban
The name of the program is: ./yourname
The total number of arguments received is: 2"
The complete argument string is: Michael Urban"
Your first name is: Michael
Your last name is: Urban
bash$


FreeBSD, POSIX, getopts
.
.
Bourne- (.. sh), UNIX-,
getopts, Bourne.
.


. `.
.` ( , , ~). , :
TodayDate='date'

date TodayDate.
.


Bourne , - , . , :
var3='expr varl + var2`

varl varl var3. ,


.
varl+var2 .

.
. ,
-. . ,
5 / 2 - 2.
(%). , 5 % 2 1.
, , .
, pr 2 * 2 ,
* -. (*)
: 2 \* 2.
.

13.

247

( ). , 1.
0. , :
2 + 2 = 4 + 1

0 ( ),
2 + 2 = 3 + 1

1 ( ).
!= .
" ". , , 5 != 3 1 ().
. : < > ,
. /
. , 5 \> 4 1 ( ).
, (\>=) (\<=).
.
. , "The quick brown fox jumped over the lazy dog"
= "The quick brown fox jumped over the lazy dg" (
).
,
. ( ), ,
, bc.
, , be , . 13.2
, bc
.

13.2 bc
_______________________________________________________________________________
1.
#!/bin/sh
2.
#
# .
5.
6.
pi="3.14159265"
# .
7.
#
# .
10.
11. echo
8
echo "This program computes both the circumference and the area
of"
9
echo "a circle."
17
echo
18
echo -n "Please enter the radius of the circle: "
19
read
radius
17.

18. # . 19.
circumference='echo
"$radius*$pi"
|
be
-1r'
area='echo
"$radius^2*$pi"
|
be
-It*
22 .

248

3. FreeBSD

23. # .
24.
25. printf "\n\nThe circumference is:\t$circumference\n"
26. printf
"The
area
is:\t\t$area\n\n"

27.

exit 0

, , ,
,
.
6: pi .
,
. pi
3.14159265. . -,
. -, .
, ,
. ,
, .
16: , read STDIN.
radius.
20: 20 circumference . bc ,
echo, bc.
21: 20. ^ be .
$radius 2 ( ,
, ). ,
.
25 26: . printf, , echo. \t .
bc.
, ,
, bc ,
.
.

,
(, , ).
. Bourne
: while, until for. .

13. 249

while
while , , ,
. -: while
, .
, . , while
1 20.
1.
#!/bin/sh
# Count from 1

i=l
while

to

20

[ $i -le 20 ]

do
# echo $i
# i='expr $i +
8.
done
9.exit 0

:
3: i 1. i
( ),
.
4: while , .
,
test. .
test , : -1
" ". ,
, i 20. , , 13.2.
13.2 test

-eq

-n

-gt

-g

-It

-le

5: do , , , . do done
.
6: i.
7: , i , i.

250

3. FreeBSD

8: . while .
i 20, . i 20, , done ( , exit 9,
, 0).
,
. .
, .
, .
.
[ .
. , [ $VarA -gt 5 ] , a [$VarA -gt 5] .

until
until while.
, . .
, .
while until . ,
, . , , while until. 4
:
4.

until

[$i

-gt

20

. ,
, i 20,
while , i 20.
.

AND/OR while
until
while until AND/OR. AND , , OR
. AND:
#!/bin/sh
# AND
VarA=l
VarB=5
while [ $VarA -eq 1 ] SS [ $VarB -gt 7 ]
do
echo "VarA is equal to 1 and VarB is greater than 7"
done
exit 0

13.

251

echo , $VarA
1, SVarB 7. while ,
, 0 ().
, , ,
while OR. ,
- :
#!/bin/sh
# OR
VarA=l
VarB=5
while [ $VarA -eq 1 ]
|I
[ $VarB -gt 7 ]
do
echo "VarA is equal to 1 or VarB
done
exit 0

is

greater

than

7"

,
. $VarA 1,
echo. ( ,
Ctrl-C.)

for
for while until.
for
-. for ,
. for ,
. ,
. , for be
10 20.
#
#
#
#
#
#
#
#

#!/bin/sh
# 10 for num in 'jot 10 10 20'
do
square_root='echo "scale=5;
sqrt($num)"
echo $square_root
done
exit 0

20
|

be

-1r

:
3.16227
3.31662
3.46410
3.60555
3.74165
4.00000
4.12310
4.24264
4.35889
4.47213

3: for.
jot. ,
. jot
10 , 10 20 (10 10 20).
for -

252

3. FreeBSD

num
.
5: bc $num. scale=5 bc,
.
scale. , . sqrt bc
. , bc , . , bc. -1
, sqrt.

shift
shift for.
, , -
while shift.
, $1 $9.
shift . ,
, , $1 , - $2
$1. :
19.
#!/bin/sh
20.
#
21.
while [ $# -ne 0 ]
22.
do
5.
echo "The value of \$1 is now $1."
6.
shift
6 done
7 echo
8 exit 0

shift.

:
bash$ ./shiftl
The value of
The value of
The value of
The value of
The value of

a b o d e
$1 is now a.
$1 is now b.
$1 is now c.
$1 is now d.
$1 is now e.

bash$

: while. $#
. while ,
$# . $# , , , .
5: $1. , $1 $ ,
.

13.

253

6: shift
. $1 ( ), $2 $1, $3 $2 ..
shift ( for)
, , .

true false
true false. (0) (1), .
. , .
, . .
1.
9.
10.
11.
5.
8.
9.
10.
11.
10.

#!/bin/sh
# .
while true
do
echo "This line will print forever."
done
echo "This line will never print since the program will"
echo
"never get past the loop."
exit 0 # ,
# .

, ,
. 3 . (true) , .
710 ,
. (
Ctrl-C.)


.
: break continue.
break
break , ,
. 13.3 .
13.3 ______________________________________________________
14.
15.
16.
4.
2.
3.
1.
2.
3.
10.

#!/bin/sh
# .
while true
do
echo "This line will print forever... But..."
break
done
echo
echo "The break statement in the loop causes the loop"
echo "to terminate immediately and go the first statement"

254
5.
6.

3. FreeBSD
echo "after the loop."
exit 0

:
This line will print forever... But...
The break statement in the loop causes the loop
to terminate immediately and go to the first statement
after the loop.
bash$

( break , ,
.)
continue
continue .
, continue, . 13.4:
13.4
1. # ! / b i n / s h
2 . # .
3. while
true
4 . do
1.
echo "This line will print forever."
2.
continue
2.
.
echo "But this line will never print even though it is inside"
3.
.
echo "the loop because the preceding continue statement"
1.
echo "causes the loop to jump back to the top and re-evaluate"
2.
echo "the test."
11.done
7.
echo "This line will never print since the program will"
8.
echo "never get past the loop."
9.
exit 0 # ,
15.
# .

"This line will print forever".


, continue
.


, (
) . : if, case
AND/OR.

if
if . , if. , :
. ,
.
if else, ,
. , :
" , , , , ".

13.

255

, if , .
1, . ,
, .
5.
6.
7.
8.
5.
9.
10.
11.
12.

#!/bin/sh
# ifprog: if.
if [ $# -ge 1 ]
then
echo "You supplied $# command line arguments."
fi
echo
echo "Program exiting..."
echo

13.

exit 0

:
1:
bash$ ./ifprog filel file2 file3
You supplied 3 command line arguments.
Program exiting...
bash$

2:
bash$ . /ifprog Program
exiting... bash$

if ,
$#, . 1,
, then fi. (fi if .
.) , , fi. .
,
else, , (
). 13.5.
13.5
1.
2.
3.
4.
5.

6.

7.
1.
2.
8
9
10
11
12

#!/bin/sh
f ifprog: if.
if [ $# -ge 1 ]
then
echo "You supplied $# command line arguments."

else

echo
exit 1

echo "Usage: $0 filel file2..."


fi
echo
echo "Program exiting..."
echo
exit 0

1,
else (, $0
?). 9,

256

3. FreeBSD

, 1 (
). else, 10-14
.
then if , else .
, then , .
, .
. :
if [ $myvar -gt 5 ]
then
: # He , if
else
# , , . fi

elif

.
elif.
elif else if. elif,
if. , ,
(.. , fi).
, elif. ,
, if.
, elif .. ,
, . ,
, else ( ).
13.6 , if, elif else.
.
13.6
I.
2.
3.
4.
5.
6.
7.
8.
12.
13.
II.
26.
27.
28.
29.
30.
31.
32.
33.
34.
28.
29.
30.
31.

#!/bin/sh
#
clear
guess_count=l
# 1
echo
echo "Number guessing game written in bourne shell script."
echo
echo -n "Enter upper limit for guess: "
read up_limit
rnd_number=`jot -r 1 1 $up_limitij
#
echo
echo "irve thought of a number between 1 and $up_limit."
echo
echo -n "Please guess a number between 1 and $up_limit: "
read guess
# .
while true
do
if [ $guess ^gt $rnd_number ]
then
echo
echo "Your guess was too high. Please try again."
guess_count=`expr $guess_count + 1`
echo -n "Please guess a number between 1 and $up_limit: "

13. 257
25.
read guess
1. elif [ $guess -1t $rnd_number ]
2. then
12.
13.
14.
31.
32 .
33.
34.
35.
16.
17.
18.
19.
20.
21.
22.
23.

else
fi

echo
echo "Your guess was too low. Please try again."
guess_count=`expr $guess_count + 1*
echo -n "Please guess a number between 1 and $up_limit: "
read guess
break
done
# , .
echo
echo "Correct!"
echo
echo "You guessed the number in $guess_count guesses."
echo
exit 0

:
Enter upper limit for guess: 10
Irve thought of a number between 1 and 10.
Please guess a number between 1 and 10: 5
Your guess was too low. Please try again.
Please guess a number between 1 and 10: 8
Your guess was too high. Please try again.
Please guess a number between 1 and 10: 7
Correct!
You guessed the number in 3 guesses.

, , .
3 . 4 1 guess_count,
, . 23 30
guess_count 1 . 10
: jot rnd_number
1 , . 17 . 19 :
, , . , , guess_count 1,
. , ,
guess while .
, elif , . , , guess_count 1,
. while . ,
, else ( ,
, , ). else
, , done.
, , (
guess_count).
if AND (&&) OR (||).

258

3. FreeBSD

case
, ,
if. case, , ,
. 13.7 case
.
13.7 case
21.
#!/bin/sh
22.
# .
23.
quote_num=`jot -r 1 1 5'
24.
case "$quote_num" in
5.
1) echo
25. echo "\"Until he extends his circle of compassion to include"
26. echo "all living things, man will not himself find peace. \""
8.
echo" Albert Schweitzer"
9.
echo ;;
10.
2) echo
11.
echo
"\'With regard to excellence, it is not enough to
know, but"
4.
echo "we must try to have and use it.\'"
5.
echo "-- Aristotle"
6.
echo ;;
15.
3) echo
10.
echo "\"Imagination is more important than knowledge.
Knowledge"
11.
echo "is limited. Imagination encircles the whole world.\""
12.
echo "-- Albert Einstein"
13.
echo ;;
20.
4) echo
1.
echo "\"It is not the strongest of the species that
survive, nor"
2.
echo "the most intelligent, but the one most responsive to
change. \""
3.
echo "-- Charles Darwin"
4.
echo ;;
5.
esac
6.
exit 0

jot ,
1 4. case 4. : case variable
in, variable , .
5. ,
case. if, case ,
, esac (
case ). .

, .
case -. :
case "$myvar" in
a) # ""
;;
b)

# ""
;;

13.

*)

259

;;

esac

Smyvar
b. , . , -,
. Smyvar , b, .
, case -, ? (
, ), ,
case . , Y | )
Y .
. , , [Yy]|[Yy][Ee][Ss])
"" "yes",
.
CGI-
, Web-, ,
, , ,
.
case. , , CGI-. CGI-
Web- .
CGI- 26.

AND/OR
AND/OR if. .
:
tar cvfz backup.tar.gz documents/2000/* && rm -r documents/2000

: " , . ". :
" . ,
".
documents/2000 backup.tar.gz. ( tar 0), &&, documents/2000.
( tar , 0), && (, , ).
|| OR. : " , . , ". :
tar cvfz backup.tar.gz documents/2000/* | | echo "Archive operation
~failed."

B , (tar 0), || . (tar , 0), , ||,


.

260

3. FreeBSD


FreeBSD . 0. , 0, , .
. .
"$?".
:
bash$
bash$

1s > /dev/null
echo $?

bash$
bash$ Is -2 /dev/null
Is: illegal option 2
usage: Is [-ABCFGHLPRTWabcdfgiklnoqrstul]
bash$ echo $?

[file

...]

bash$

$? 0 (
Is /dev/null).
. Is $? 1.
. AND/OR. ,

. AND/OR, ,
if:
if
tar
then

cvfz

backup.tar.gz

documents/2000/*

rm -r documents/2000 e l s e
echo "Archive operation

failed"

fi

.
if tar. 0,
then, .. . 0, else.
test.
, test .
, test .
:
if [-f program, conf] then
: # else
touch program.conf
done

"program.conf.
, 0 then.
. ( .

13.

261

). , 1, else, touch.
test , . test 13.3.
13.3

-f

-d

-s

-r

-w


,
, . ,
exit. ,
. $? , . . , , ,
.
, , 0 1.
. 0
, .
. , , .
, :
if
[-r
program.conf]
then
: #
else
exit 1 fi
if
[touch
/tmp/program.lock]
then
: #
else
exit 2
fi

#
exit

program.conf. 1.
if /tmp/program.lock.

262

3. FreeBSD

,
2. , ,
0.
, . .


, FreeBSD , - kill, (, Ctrl-C). , , Ctrl-C,
. .
, . , :
#!/bin/sh
#
trap 'echo "Interrupt received. Quitting." 1>$2'
echo -n "Enter a number: "
readln num
exit 0

15

1, 2, 3 15. . ,
"Enter a number", Ctrl-C, 2 (INT). , "Interrupt
received" .
echo. , , . 1>&2
echo STDERR.

. STDERR 1>&2.

. ,
, ( ).
Ctrl-C,
, . :
trap

''

, 2 .

, .
.
,
. 13.4.

1 5 ( kill) kill
, 9 (SIGKILL)

13.

263

, .
, .
13.4

HUP ( )

2INT (Ctrl-C)

QUIT (Ctrl-\)

15

TERM kill

, .
" ".
. ,
, . , , ,
.
,
-. , :
#!/bin/sh
on_exit() {
rm -rf /tmp/myprogram.*
mv logflie logfile.old
mail foo@bar.com < report.txt
}
trap on_exit 0 1 2 3 15

, ? ,
. , , . , ,
. , .
. ,
. ,
, , . , , .


, .
.
:
F.D. STDIN. . , - .

264

3. FreeBSD

F.D. 1 STDOUT. .
, , , .
F.D. 2 STDERR. . ,
.

.
exec. :
#!/bin/sh
# F.D. 1 (STDOUT)
exec > testfile.txt
# STDOUT,
testfile.txt
echo "Line 1 of the file"
echo "Line 2 of the file"
echo "Line 3 of the file"
echo "Line 4 of the file"
echo "line 5 of the file"
exit 0

exec STDOUT
testfile.txt. , echo testfile.txt, ,
.
, , -
. .
STDIN read. :
#!/bin/sh
# F.D.
exec < testfile.txt
while read string do
echo $string
done
exit 0

(STDIN)

testfile.txt, , ,
:
Line
Line
Line
Line
Line

1
2
3
4
5

of
of
of
of
of

the file
the file
the flie
the file
the file

?
read.
read , read
. , read .


,
. ,

13.

265

.
-xv #!/bin/sh. :
#!

/bin/sh -xv

more
less, STDOUT STDERR .
, . :
#!/bin/sh -xv
#

result=`echo "2 * 12 / ( 2 + 2 ) ' | ` echo


$result
exit 0

STDOUT STDERR
more. :
. /xvtest 2>&1 | more

:
1.
2.
3.

./xvtest 2>&1
|
more
#!/bin/sh
-xv
#

15. result='echo "2 * 12 / ( 2 + 3 ) "
16. + echo 2 * 12 / (2 + 3)
6.
+ be

7.
9.

1
2
3

+ result=4 8.
echo $result
+ echo 4

8.
4
exit 0
+ exit

, .
+ . , 3 result. 4, 5 6. 4 echo, 5 bc , ,
6 (4) result.
, "" .
8-10. 8 echo.
9 ,
"echo 4". 10 echo.


rn
n ,
. . : UNIX Bourne,

266

3. FreeBSD

rn. , .
, ,
Bourne.
rn.

, , POSIX, FreeBSD /bin/sh.


, POSIX , -
, #!/bin/sh -
, . .


, .
(The Public Domain Korn Shell) - FreeBSD ( sysinstall),
/usr/ports/shells/pdksh.
, #!/bin/sh #/usr/local/bin/ksh. Korn Bourne, .. ,
rn. , : rn Bourne.

rn.


rn . , r,
Bourne. , rn .
, ,
exec.
rn
. let. :
let x=7+5

12.
, :
if (( < z))
, let. , , , test Bourne. < >
-It -gt. , , : , ,
((5 * 3)) 5 \* 3.

13.

267

, n,
13.5.
13.5 Shell Math Operators

+

>

<

>=

<=

!=

&&

||

+=

-=

*=

/=

%=

n .
, .
.
.
. ,
. set. ,
,
temperature, .
:
set -A temperature 57 52 58 61 63 65 71 70 68 66 64 62

268

3. FreeBSD

temperature 12 .
( ksh]
,
. 0. ,
. :
ksh$ echo ${ temperature [0] }
57
ksh$
echo
${
temperature[11]}
62
ksh$
echo
${
temperature!*]}
57 52 58 61 63 65 71 70 68
ksh$

66

64

62

512 (0511).
]
, :
temperature[0]=55

:
0
,

. echo $temperautre[l] . : ${ temperaturefl]}.


1
.
?
. , ,
, :
14
#!/usr/local/bin/ksh
# # .
# set -A temperature 57 52 58 61 63 65 71 70 68 66 64
# i=0
1 printf "\nMonth\t\tTemperature\n\n"
2 while ((i < 12))
7.
do
8.
(( month = $i + 1 ))
9.
printf "$month\t\t${temperature[$i]}\n"
10
(( total_temp += ${temperature[$i]} ))
11.
(( i += 1 ))
12. done
# avg_temp=$ (( total_temp / 12 ))
# echo
1 echo
"Average temperature for whole year: $avg_temp"
2 echo
exit 0

:
Month
6 57
7 52
10 58

8 61
9 63
10 65
11 71

Temperature

62

13.
8
9
10
11
12

269

70
68
66
64
62

Average

temperature

for whole year:

63

, , -
, .
, . ,
.
2
1: ,
/usr/local/bin/ksh. #!/bin/sh,
, .
3
3: 3 temperature
( ) set.
4
4: .
5
6: 6 , , i
12.
6
8: month.

$1+1. .
$i 1? ,
11 ( ), 1-12.
7
9: ,

temperature. ,
. $i , $I, , .
8
10: $total_temp,

temperature $i,
$total_temp. ,
.
9
11: $i 1.
$i
12, .
10
13: :
$total_temp 12. avg_temp.
11
15: .

, 63. ,
.
63.083333, , . , ,
, , .

, ?
, -

270

3. FreeBSD

, .
,
.

, for
while. ,
(--) .



, , Bourne.
:
today_date=$(date)

. ,
, .

getopts
getopts
- , Bourne,
. getopts
-option, FreeBSD. ,
.
getopts :
getopts

, ,
. , ,
.
SOPTARG. SOPTIND
.
getopt .
while,
. ,
getopt:
getopts

abc:d:

MyVar

, getopts a, b, d. , c d
- , SOPTARG.
- MyVar. , , ,
getopts, myprog
:
./myprog

-a

foobar

getopts (, while).
$MyVar , -- ,
$OPTARG foobar. ,
SOPTIND,
getopts ,
,
.

14

. top
top
. ps
ps



cron

at
cron at

272

3. FreeBSD

, FreeBSD, . FreeBSD
, . (Windows, )
( )
. Windows , ,
. FreeBSD . Ctrl+Alt+Delete
Windows ,
. , ,
,
. FreeBSD ,
, , -
.. , ,
. " -
". FreeBSD
.
, FreeBSD ,
.
, . ,
, , , UNIX-. ,
" " . ,
, , .
UNIX.
, : ps, top kill. ,
. , on,
, . , .

. top
top.
, -
. top,
FreeBSD,
. , , 30
.
top :
. , . ,
kill renice ( ), ,
.
, .
, , .

14. , ... 273

top
, 14.1:
14,1 top
last pid: 30283;
load averages:
0.51,
0.89,
0.87
up 52+15:48:43
11:19:03
126 processes: 1 running, 124 sleeping, 1 zombie
CPU states:
0.7% user,
0.0% nice,
2.8% system,
0.7% interrupt,
95.8% idle
Mem: 142M Active, 35M Inact, 59M Wired, 7496K Cache, 35M Buf, 4256K
Free
Swap: 500M Total, 48M Used, 452M Free, 9% Inuse
PID USERNAME PRI NICESIZE RES STATE
19460 mysql
2

25908 2692K poll


30283 bob
2

1360 976K sbwait

30282
245
18427
86694
86
80717
61945
80
56054
73772
40567
40581

root
root
root
frank
root
root
root
root
root
root
www
www

29
2
2
10
2
10
2
2
2
2
2
2

2076

868

7592
1700
-12
1296K

2132

1868

916

2168

8956

9880
10008

1236K CPU1
232K select
5092K select
56K nanslp
412K select
472K nanslp
360K select
320K select
584K select
2540K select
2872K sbwait
3796K sbwait

0
1

TIME
112:20
0:00

0
1
0
0
0
0
0
0
0
0
1
0

0:00
177:39
80:24
76:46
6:28
5:53
3:29
3:26
3:12
3:12
0:57
0:55

WCPU
2.20%
6.02%

CPU COMMAND
2.20% mysqld
1.56% qpopper

3.14% 0.93% top


0.00% 0.00% healthd
0.00% 0.00% named
0.00% 0.00% elm
0.00% 0.00% ntpd
0.00% 0.00% telnetd
0.00% 0.00% inetd
0.00% 0.00% syslogd
0.00% 0.00% sshd
0.00% 0.00% httpd
0.00% 0.00% httpd
0.00% 0.00% httpd

top ,
, ( , "") .
, .
, , ,
. "i" top , .
, , load averages (
) . " "
. ( ) 1, 5 15 ,
. , .

, , .
1. ,
, 2-3. 5 .

. , , sendmail 12. 20-30,
( race
condition], , .
, , .
" " (death spiral).

274

3. FreeSSD _______________________________________

, UNIX-,
(
, ).
telnet ssh (
). ( -)
.

-
. ,
( ).
14.1. , Free ()
. ,
. , (..
, ),
Active (). -,
. -
. ,
, , .
Swap () . (
). top : Used () Free ().
Swap , :
( Used
50% ), ,
. , ,
RAM. , FreeBSD ,
. (, , UNIX-)
: , .
. ,
. , ...
, CPU
. ,
. , 100,
. : CPU states
, .
CPU. WCPU
(weighted CPU, )
, ps .
, .
. , .
TIME. He ( )
:. ,
, .
, -

14. , ... 275

. , ( mysqld
14,1), , , , .
.
CPU.
SIZE RES. SIZE ,
, , , .
, ,
. RES ,
. "", RES
, (
, Windows Mac OS).
top , . ,
, . PID
, .. , , OWNER , , . STATE , , ,
zomb zombie ( , ,
).
, top
. i
, ,
.
+. k kill,
. t ()
top. -
man top.
top ,
, , .
: top ,
. ps.

. ps
top,
, ps Is ( !).
.
, top, .
ps ,
(.. ).
,
. man ps. ,
:
# ps -waux

: (wide)
(w), , ;

276

3. FreeBSD_____________________________________

(u), ,
(), , ().
,
.
, . , , , ( , -U,
, -U frank). ps. , ps grep ( 9), , , :
14.2 ps, gr
#

ps

444
445
446
447
448

- |
??
??
??
??
??

gre
S
S
S
S
S

httpd
0:54.73
0:55.30
0:56.03
1:00.16
1:05.13

/usr/local/sbin/httpd
/usr/local/sbin/httpd
/usr/local/sbin/httpd
/usr/local/sbin/httpd
/usr/local/sbin/httpd

ps
ps -waux:
14.3 ps
USER

PID

%CPU

root
root
root
root
root
root
root

1
2
3
4
5
24
80

0.0
0.0
0.0
0.0
0.0
0.0
0.0

%MEM

VS2

RSS

TT

STAT

0.0
0.0
0.0
0.0
0.0
0.0
0.1

528
0
0
0
0
208
916

72
0
0
0
0
0
320

??
??
??
??
??
??
??

ILs
DL
DL
DL
DL
IWs
Ss

STARTED

31Jan01
31Jan01
31Jan01
31Jan01
31Jan01
31Jan01

TIME COMMAND

1: 05.94
14:41.63
2:38.4 7
0:33.21
79:52.61
0:00.00
3: 2 7 . 8 0

/sbin/init
-(pagedaemon)
(vmdaemon)
(buf daemon)
(syncer)
adjkerntz
-i
syslogd
-s

ps (
). ,
, top, .

: %CPU ps CPU
s top, WCPU. -,
"" .
, ps top .
, %CPU ,
100%.

top; ps
, . ,
top, . , , -

14. , ...

277

( ).

.


, , .
root ( su) top
:
14.4 top, , -
________________________________________________________________________
last pid: 67469;
load averages:
8.32,
5.49,
2.47
up 53+01:04:22
20:34:42
90 processes:
1 running, 88
sleeping,
1
zombie
CPU states:
93.2% user,
0.0% nice,
0.2% system,
0.8% interrupt, 5.8%
idle
Mem: 153M Active, 23M Inact, 60M Wired, 7252K Cache, 35M Buf, 5112K Free
Swap: 500M Total, 44M Used, 456M
Free, 8% Inuse
PID
19460
67468
245
18427

USERNAME
frank
root
root
root

PRI NICESIZE
RES STATE
2
25908 2816K poll
28

2036 1024K CPUO


2
868
232K select
2

7592 5124K select

TIMEWCPU
CPU COMMAND
0 131:15
0.00% 92.43% testprog
0
0:00
0.43% 0.20% top
1 178:48
0.00% 0.00% healthd
0 81:01
0.00% 0.00% named

, . ,
frank . ,
92% .
"" - ( ,
, ) (
, ).
, .
,
. testprog .
k. top kill kill,
, . ,
( 19460).
root, , .
, , ,
.
. ,
. kill, top,
. kill.

kill
kill () .
,
. , root

278

3. FreeBSD ____________________________________

.
kill :
# kill

12553

kill
, , TERM.
"", UNIX.
. ,
14.1.
14.1

kill

HUP ; ,

INT

QUIT
6

ABRT

KILL ,

ALRM

TERM

:
#
#

kill
kill

-9 12553
-HUP 12553

super-kill,
.
, kill -TERM ,
, , :
.
, .
, .
,
, (
).
,
, -.
(
).


kill, ,
, top. ,
, renice,
( nice) .

14. , ... 279


-20 20, -20.
top: NICE .
. ,
- .
- nice,
, ,
.
( root) (..
nice).
10 renice:
#

renice

-10

1442


nice . ,
(.. ) . (
], :
#

renice

--10

1442

top , r
renice, ( -20 20)
. NICE.
testprog:
20.
.

nice. nice :
#

nice

10

1s

, Is 10.


, , ,
, , . FreeBSD
, , , log-
.
(, Mac OS Software Update), FreeBSD ( UNIX- ) , ,
.

ron
UNIX, FreeBSD ron.
ron FreeBSD (Paul Vixie),
Linux. -

280

3. FreeBSD _______________________________________

, ron ( crontab) . ,
, , ,
. ron ,
.
crontab (/etc/crontab) (/var/cron/tabs),
crontab. ,
/etc/crontab. ,
/usr/local/etc/rc.d /etc/rc.local (. 11), /etc/crontab
. crontab root
/var/cron/tabs. , .

crontab
crontab :
# DO NOT EDIT THIS FILE - edit the master and reinstall.
# (/tmp/crontab.tqWGz91396 installed on Thu Feb 1 09:29:43 2001)
# (Cron version -- $FreeBSD: src/usr.sbin/cron/crontab/crontab.c,v
1.12.2.1 2000 /11/09 11:05:36 dwmalone Exp $)
0 3 1,15 * * cat ~frank/faq.txt | mail -s "FAQ Auto-Post"
mylist@ testsystem.com

:
. 03:00 .
? ,
. ( ,
. rn .)
14.2.
14.2 crontab

minute ()

0-59

hour ()

0-23

day of month ( )

1-31

month ()

1-12

day of week ( )

0-7

, ,
, , "1-10". (*)
. ( )
( ).
, , .
( ) 0 7 .

,
"" (, "*/n"]. */5 "
", .. , 5, 10, 15, 20, 25, 30, 35, 40, 45, 50, 55.
man(5) crontab.

14. , ...

281


. 14.3.
14.3

@reboot

@yearly

11*

@annually

yearly

@monthly

0 0 1 * *

@weekly

00**

@daily

0 * * *

@midnight

daily

@hourly

0 * * * *

/etc/crontab
. /etc/crontab command who (),
( , ):
1

root

periodic

daily

command : ,
.
(;), ,
. , ,
/etc/crontab, n
PATH , who,
PATH, . ,
, ron
.
, ron, ,
, crontab (
, /etc/crontab).

crontab
root, /etc/crontab,
. ( ).
, crontab .
crontab (/var/cron/tabs) 0600,
,
. crontab:
# crontab -e

, root, crontab Frank, :


# crontab -e -u frank

282

3. FreeBSD

crontab chfn edquota.


, VISUAL ( EDITOR,
). ( )
, ,
. , /tmp,
/var/cron/tabs, .
crontab , ron .


at
, ron .
, (, -
)? ron,
crontab crontab -u, . at.
, at : at ( ), atq (
) atrm ( ). batch,
at, ,
( 1.5).
at , ,
/bin/sh.
( ) .
. , 14.4.
14.4 at

at 10pm

10:00 (
22:00 )

at 8:00am May 15

8:00 15

at midnight Jan 1 2002

2002

at teatime tomorrow

16:00

at
man at. Enter
, .
, , Enter.
Ctrl+D. .
:
# at -f my commands noon + 5 days

at mycommands ( DOS)
, /bin/sh,
.

14. , ... 283

atq:
#
atq
Date
23:00:00

03/28/01

Owner
root

Queue

Job#
2

atrm:
# atrm 2

at atrun, (
FreeBSD) .
, . atrun
/etc/crontab, , , .

ron at
,
ron at. , , IRC eggdrop,
, , ,
crontab, . . ?
(, , )
ron at. deny allow.
/var/cron/allow /var/cron/deny : crontab. /var/cron/allow ( ) ( ,
) ,
crontab. -: /var/cron/deny , crontab.
, /var/cron/allow.
/var/at/at.allow /var/at/at.deny .
.

15

FreeBSD

FreeBSD

Web- Fresh Ports

15.

285

,
UNIX. , ,
, , ,
.
.
FreeBSD BSD-, Linux
UNIX? ,
.
Solaris, ,
,
( ,
). , Solaris, , gcc (
GNU C/C++).- , , IRIX HP-UX, gcc,
, ,
( , )
.
Linux ,
"", ,
, , .
, RPM (Red Hat Package Manager), GNU,
, , FreeBSD.
Red Hat ,
Slackware. RPM
,
.
FreeBSD
. ( pkg_*),
, , "".
.
FreeBSD, .

FreeBSD
(Jordan Hubbard), FreeBSD,
. , FreeBSD,
NetBSD .
.
(
config, ),
. ,
.
. RPM FreeBSD, ,
. ,
, ,
FTP-, ,
,
.

286

. FreeBSD

FreeBSD Linux.
, Linux,
glibc ( , FreeBSD)
. RPM
, .
.
Linux, FreeBSD
,
.
9, /usr/local
, ,
, .
/usr/local . 15.1.
15.1

/usr/local

bin

( )

etc

include

info

lib

libexec

man

sbin
)

(,

share
..)

, ( ,

var

, , /usr (
, /usr/local/man, /usr/local/ share/man,
). FreeBSD
/usr/local /usr.
.


(shared library) .
. ,
,
. .
(dynamic linking)
(static linking), -

15. 287

.
. , , . , , Windows
DLL (Dynamic Link Libraries, ).
FreeBSD ,
, ,
. ,
, , FreeBSD.
/usr/lib, , ,
/usr/local/lib.
/usr/lib, /usr/local/lib.
/etc/rc.conf (. 11).
, ,
(). , , ,
,
.


,
. : pkg_add,
pkg_delete, pkg_info, pkg_update, pkg_version pkg_create.
. ,
FreeBSD: "" ,
.
/var/ db/pkg,
Is.
, (.. )
. pkg_info
, 15.1.
15.1 pkgjnfo ________________________________
# pkg_info
ImageMagick-5.2.7_2 An Xll package for display and interactive
manipulation of i
analog-4.16
An extremely fast program for analyzing WWW
logfiles
apache-1.3.19
The extremely popular Apache http server. Very
fast, very
arc-5.21e.8
Create & extract files from DOS .ARC files
aub-2.0.5
Assemble usenet binaries
autoconf-2.13
Automatically configure source code on many Un*x
platforms

dict-1.4.9
Dictionary Server Protocol
(RFC2229)
client
elm-2.4ME+68
A once-popular mail
user
agent,
unofficial
clone
emacs-19.34b
GNU editing macros
_________________________________________________________________________________

-v. RPM,
FreeBSD , ,
. RPM-, ,

288

3. FreeBSD

, , ,
"" . FreeBSD , , , ,
name-version.tgz, bzip-0.21.tgz.
.tgz (tar-). .tar.gz (
UNIX:
tar, gzip). ,
pkg_info -v , ,
15.2.
15.2 pkg_jnfo ____________________
# pkg_inf -v pgp-2.6.3ia
Information
for
pgp-2.6.3ia:
Comment:

PGP MIT
masses

or

International version

Public-Key encryption for

the

Depends on:
Description:
PGP (Pretty Good Privacy) is a public key encryption package to protect E-mail and data files.
It lets you
communicate securely with people you've never met, with no
secure channels needed for prior exchange of keys.
It's
well featured and fast, with sophisticated key management,
digital signatures, data compression, and
good
ergonomic
design.
WWW: http://www.pgpi.org/
Packing list:
Package name: pgp-2.6.3ia
CWD to /usr/local
File: man/manl/pgp.1. gz
Comment:
MD5:aOabl7dlfe83aaf159cb80falabf5462
File: bin/pgp
Comment:
MD5:625e99562f936a3d9bOac3c5d5a94ba9
File: lib/pgp/pgp.hlp
Comment:
MD5:d5da3783ea26bc60f4b7584df4227866
File:
lib/pgp/pgpdocl.txt
Comment:
MD5:260ca85cd0263275cb7df6cd276e2b9f
File:
lib/pgp/pgpdoc2.txt
Comment:
MD5:e3defe467fbf5c5c4809f8b5cl3404al
File:
lib/pgp/language.txt
Comment:
MD5:bcecOf56b207846725fe7e4a612383ef
File: lib/pgp/config.txt
Comment:
MD5:b2518ad2566a9a4bce071936311d3c93
Deinstall directory remove: lib/pgp
UNEXEC 'if [ -f %D/info/dir ] ; then if sed -e 'l,/Menu:/d' %D/
info/dir | grep -q IA[*] ' ; then true; else rm %D/info/dir; fi; fi'

, :
( MD5).
, , "
" , .
lib/pgp (/usr/local/lib/pgp
. ,
/usr/local/lib. ,
. ,

15. 289

UNEXEC /usr/local/info/dir.
, . ,

.
, ? pkg_version. ,
. .
. pkg_version ,
. pkg_version
,
, (. 15.3).
15.3 pkg_version
# pkg_version -v
ImageMagick-5.2.7_2
apache-1.3.19
arc-5.21e.8
aub-2.0.5
autoconf-2.13
bash-2.04
bnc-2.8.2
bulk_mailer-l. 12
bzip2-0.9.5d
cclient-4.8
cvsup-16.1
demoroniser-1.0

<
=
=
=
=
*
=
<
<
<
=
=

needs updating
up-to-date with
up-to-date with
up-to-date with
up-to-date with
multiple versions
up-to-date with
needs updating
needs updating
needs updating
up-to-date with
up-to-date with

(port has 5.2.9_1)


port
index
index
index
(index has 1.14.7,2.04)
index
(index has 1.13)
(index has 1.0.1)
(index has 2000c)
index
index

-v pkg_version ,
. ,
. , ,
.


. ,
. , , , Linux,
FreeBSD,
, -
Linux.
,
/usr/ports.
. /stand/sysinstall.

sysinstall
sysinstall (. . 15.1) Configure, Packages.
- FreeBSD,
CD-ROM. Internet, FTP.
( , )
, . 15.1.
Enter.

290

3. FreeBSD

15.1. Packages sysinstall.


FreeBSD 18.
, .
Options sysinstall , .
"" FreeBSD (.. , -), Release Name
. -STABLE
-CURRENT [ 18), ,
, , #.#-STABLE ( #
). uname,
. , Release Name
FTP-, sysinstall . (
] , .
ftp://ftp.FreeBSD.org/pub/FreeBSD/ releases/
( , ). 4.2STABLE, 4.X-STABLE.
, 4.2-STABLE. "
", , . FTP-
, .
, .
15.2. Packages.

A program for uu/xx/Base64/ElinHex de-/encoding

15.

29 1

, . 15.2,
. (
"X"). Cancel (
" "). , ,
Install .

, Packages.
, Install
sysinstall ( , ).

,
/usr/tmp pkg_add.
, FreeBSD (
, sysinstall). - ,
sysinstall , ,
. sysinstall, Exit Install.
, . ( )
, /usr/local/etc,
/usr/local/bin. ,
, rehash (
).
.
11,
. /usr/local/etc conflg
(, < >.f , ,
). .sample,
,
( .sample).
.
, , .

, FreeBSD, .
,
, . , ,
. .

pkg_add
. ,
,
, , ,
.., .. ,
. , -, ""
FreeBSD ( Linux), -,
,
FreeBSD.

292

3. FreeBSD

, ,
sysinstall. ,
( , ).
pkg_add. ,
, sysinstall.
pkg_add .tgz (
) . ,
:
f fetch ftp://ftp.FreeBSD.org/pub/FreeBSD/releases/1386/4.x-STABLE/ ~
packages/www/roxen-1 .3.111. tgz

pkg_add

roxen-1.3.Ill.tgz

#
pkg_add
ftp://ftp.FreeBSD.Org/pub/FreeBSD/releases/i386/4.x-STABLE/
packages/www/roxen-l. 3 . 111. tgz

, ,
, ,
/usr/tmp . pkg_add
, sysinstall.
pkg_add , ,
.
,

pkg_add -nv ,
, ( " " dry
install).

,
.
, sysinstall.
, sysinstall ,
.
FTP- ,
.

FTP- FreeBSD ,
, . ,
, .
, pkg_add .tgz-, ,
FreeBSD. "" .
,
,
. " " UNIX,
, !
sysinstall , , .tgz- FTP-
FreeBSD. , , checksum
MD5 .

15.

393

, , ,
.
man pkg_add.


/stand/sysinstall .
,
.
pkg_info.
/var/db/pkg.
. , ,
pkg_delete:
#

pkg_delete

roxen-1.3.Ill

, pkg_delete
, -f, . ,
"" .
, pkg_delete (
-f). pkg_add, ,
(-v) " " (-n).


pkg_update .tgz
. , .
.tgz pkg_update, :
#

pkg_update

newpackage.tgz


, FreeBSD. FreeBSD.
UNIX- , .
: HTTP- FTP- (
, gopher archie), ,
.tar.gz .tgz .
README,
configure,
( UNIX
).
make,
Makefile .
( ) -

294

. FreeBSD ____________________________________

,
, (, /usr/local/
bin). Makefile install make install
.
.
, . , .
, , UNIX
.
FreeBSD.

,

,
,
. ,
,
(, , ,
).

FreeBSD .
, ,
FreeBSD.
, "" ,
FreeBSD Makefile,
: make install.
,
.
FreeBSD ,
, , OpenBSD NetBSD.
UNIX,
(, ),
.

FreeBSD
/usr/ports. ,
15.4. ,
sysinstall, . ( ,
100% , .)
15.4 /usr/ports _________________________________________
# Is -sF /usr/ports/
total 1447
1 .cvsignore
1296 INDEX
11 LEGAL
4 Makefile
1 Mk/
2 README
4 README.html
1 Templates/
1 Tools/

10 devel/
3 distfiles/
4 editors/
2 emulators/
1 french/
1 ftp/
6 games/
1 gentian/
5 graphics/

1
1
3
1
1
4
1
3
4

news/
palm/
print/
russian/
science/
security/
shells/
sysutils/
textproc/

15.
1
1
4
1
1
#
#

2
1

archivers/
astro/
audio/
benchmarks/
biology/
cad/
Chinese/
comms/
converters/
databases/
deskutils/

1
1
9
1
2
3
4
3
1
4
7

Hebrew/
ire/
Japanese/
Java/
korean/
lang/
mail/
math/
mbone/
misc/
net/

1
1
6
3
1
1
1
2
3
2

295

Ukrainian/
Vietnamese/
www/
xll/
xll-clocks/
xll-fm/
xll-fonts/
xll-servers/
xll-toolkits/
xll-wm/

,
( UNIX, ),
, .
.
(., , 15.5).
15.5 ()
# Is -sF /usr/ports/audio/
total 230
1 Maaate/
5 Makefile
11 README.html
1 afsp/
1 amp/
1 ascd/
1 aumix/
1 aureal-kmod/
1 autozen/
1 bladeenc/

1
1
1
1
1
1
1
1
1
1

mpg123/
mpgl23.el/
mpg321/
mpinf20/
mq3/
musicbox/
musicbrainz/
mutemix/
mxv/
napster/

, . README.html. , ,
? . , README.html
, .
Web- :
Netscape, X-Window, lynx
( . 15.3).

15.3.
README.html
lynx.

296

3. FreeBSD ____________________________________

FreeBSD

, ,
.
. 15.2.
15.2

Makefile

, ,
, .

README.html

, , HTML.

distinfo

MD5,
tar-.

files/
patch-aa patch-ab

, ,

pkg-comment

pkg-descr
.

"" ; URL

pkg-plist

, ,
, ,
.

Makefile , ,
, .
(. 15.6).
15.6 Makefile-

makefile :
amp
:
23 1997
:Vanilla I. Shu <vanilla@MinJe.com.TW>
$FreeBSD:
Exp $

ports/audio/amp/Makefile,v

PORTNAME=
PORTVERSION=

amp
0.7.6

CATEGORIES=

audio

1.10

2000/04/08

21:23:11

mharo

#MASTER_SITES= f t p : / / f t p . r a s i p . f e r . h r / p u b / m p e g /
# , .
MASTER_SITES= ftp://ftp.clara.net/pub/unix/Audio/
MAINTAINER=

vanilla@FreeBSD.org

GNU_CONFIGORE= yes
USE_GMAKE=
yes
MAN1=

amp. 1

do-install:
. include

@ ${ INSTALL_PROGRAM) ${WRKSRC}/amp ${PREFIX}/bin


@ ${ INSTALL_MAN) ${WRKSRC}/amp.1 ${PREFIX}/man/manl
<bsd.port.mk>

_____________ 15. 297

, ,
( Makefile) ,
maintainer). ,
, ,
, ,
.
Makefile , clean, install all.
Makefile ,
Makefile (bsd.port.mk, /usr/ports/Mk
). .
Makefile
, /etc/rc.conf /etc/defaults/ rc.conf),
, , ,
.


, . , , cd make.
. make install.
, , ,
. make
make- ( . 15.3), .
.
, .
15.3 make Makefile-

fetch

tar- /usr/ports/
distfiles

checksum

MD5 checksum

extract

tar-

patch

files

configure

build

, make extract ,
MD5 checksum .
( /usr/ports/Mk/bsd.port.mk),
.
( fetch checksum)
.extract_done.
. , fetch ,
/usr/ports/distfiles. extract

298

3. FreeBSD

checksum.
,
.*_<done-. make.
, .
Makefile fetch, ,
.
,

( ), .
/var/db/pkg. .
pkg_*,
sysinstall.


deinstall (make deinstall).
, Makefile,T.e. , .
, make deinstall
. pkg_delete.


, make install
. ,
. (
pkg_delete) (
) .
pkg_version , ,
. ,
:
apache-l . 3.12
apache-1.3.14
apache-l. 3.17
apache-1.3.19

<
<
<
=

needs updating
needs updating
needs updating
up-to-date with

(index has
1.3.19)
(index has
1.3.19)
(port has
1.3.19)
port

,
. , , pkg_info,
pkg_version /var/db/pkg. ,
:
#

pkg_delete

apache-1.3.12

config- . apache, ,
pkg-plist @unexec,
, ,
. ,
config-.
, ,
. .
:

15.

299

, ,
.

?
. 4000 ,
( , ).
,
, . ,
,
. , pkg_version, ,
.
CVSup.
18, ,
, .
, cvsup-bin .
, , CVSup ,
Modula-. ,
Modula-. ,
.
, Internet.
/usr/ports/net/cvsupit. , .
config-, CVSup. make,
make install. cvsupit (
), . 15.4.

15.4

cvsupit.

".", . HEAD -
, .
CVSup (
).
CVSup No.
/etc/cvsupfile . ,
src- (, ,
). # .

300

3. FreeBSD

CVSup ( cvsupit):
# /usr/local/bin/cvsup -g -L 2 /etc/cvsupfile

CVSup
. .
CVSup , ,
( diff).
, .
CVSup .
. 18.
.
pkg_version -v ,
.
, , , 24 .
CVSup periodic- ( 14):
/usr/local/etc periodic, daily.
lOO.cvsup-ports :
#!/bin/sh
/usr/local/bin/cvsup

-g

-L

/etc/cvsupfile

, periodic,
. CVSup
.


,
. FORBIDDEN Makefile.
- ,
:
cd /usr/ports/lang/perl5
make
===>
perl-5.005 is forbidden:

perl

is

in

system.

,
"". ,

. ,
.
CVSup .
,
, FORBIDDEN Makefile.
,
, , , security/ssh:
# cd /usr/ports/security/ssh
f make
===> ssh-1.2.27_3 is forbidden: OpenSSH is a superior version of SSH
which has been included in the FreeBSD base system since 4.0-RELEASE.

15.

301

This port is now deprecated and will be removed at some point in the future.
To override this warning set the REALLY_WANT_SSH environment variable and
rebuild.

,
. csh tcsh,
:

# setenv REALLY_WANT_SSH yes

bash :
* REALLY_WANT_SSH=yes

make
.

,


,
. ,
,
:
# make clean


. tar- /usr/ports/distfiles,
.

, tar /usr/ports/distfiles. ,
, .
,
- , patch-,
.
tar-.

make clean
. Makefile : /usr/ports
. , , (
make, , /usr/ports/www). ,

. make clean /usr/ports.

, , . ,
,
(, GNOME D),
. , :

302

3. FreeBSD

"*** Error code 1" - . ,


.
, , "" .
, ,
, . make clean,
.
, Web- FreeBSD http://www.freebsd.org
Mailing Lists. .
Ports, ,
( ).
, - .
, . Makefile
MAINTAINER, .
, ,
(, uname -). , ,
, !
(Upgrade Kits)
, , " ".
, ,
(upgrade kit). . ,
.
include-,
. include-
/usr/ports/Mk,
CVSup. ,
/usr/ports, , , /usr/share /etc.
FreeBSD,
, ,
, . ,
pkg_add.
http://www.freebsd.org/ports,

-STABLE. .
, .
18.

Web- Fresh Ports


CVSup ,
. Web- (. . 15.5),
FreeBSD, Fresh Ports (www.freshports.org).

15.

303

15.1
Web-
Fresh Ports.

FreeBSD, Web- Fresh Ports


, CVS- .
.
Web- .
,
, .
, ,
, .

16

Ipd

,
<

/etc/printcap
Ipd

X-Window
StarOffice




16.

305

FreeBSD ,
. FreeBSD
, , (Control
Panel) , , . FreeBSD
, , ,
. PostScript,
. ,
FreeBSD.
, ,
PostScript -PostScript .

GDI- ( Win-) FreeBSD. ,
,
.
, (
Windows). ,
. FreeBSD.

, , .
FreeBSD ,
,
. .
, , PostScript .
.

Ipd
, , Ipd.
.
, ( )
.


(print queue) ,
, . , , .
, .
.
, .
, .
, .
(, ,
DOS):
, , , ,
.

306

3. FreeBSD

. - , , . ,
: ,
, , .
. , ,
, ,
. , , .
, , /var/spool. ,
, /var/spool/lpd /var/spool/output/lpd.
.
.

,

, ,
, .
dmesg.
: dmesg | grep Ipt0.
( DOS Iptl,
FreeBSD 0). :
IptO:
IptO:

<Printer> on ppbusO
Interrupt-driven port

, ( ) .
, FreeBSD .
device Ipt
. , device ppbus. ,
, 17.


Iptcontrol.
,
, , , root.
: Iptcontrol -x -d /dev/lptO, - ,
:

16.1 Iptcontrol

-\

(polled mode)

( )

-s

( )

16.

307

BIOS ,
, -.
-d . , Iptcontrol /dev/lptO .
, :
lptcontol -`e -d /dev/lptO

, Iptcontrol : /etc/
rc.local, /usr/local/etc/rc.d.
. (,
chmod 655 _.)
Ipd .


, , .
/var/spool/lpd,
.
, . ,
.
, , . :
mkdir

/var/spool/lpt/laserjet

, .
daemon daemon.
, .
. :
chown
chmod

daemon.daemon /var/spool/lpd/laserjet
770 /var/spool/lpd/laserjet

Ipd.

. Ipd
, STDIN, STDOUT .


, (text filter) Ipd
.
, cat, , .
, GhostScript.
PostScript , PostScript-.
Ipd :

308

3. FreeBSD

#! /bin/sh
/bin/cat &&
exit 2

exit

, /usr/local/libexec.
, , /usr/local/libexec/if-text.
, Ipd .
chmod 555 /usr/local/libexec/if-text.
,
/bin/sh ( ).

- , 13,
. .

cat,
STDIN STDOUT. && ,
, . , . cat
, ,
. , && ,
, 2. ( Ipd
2, , ,
.)
,
PostScript. , PostScript-
.
, PostScript.
POSTSCRIPT?
PostScript ,
. ,
, PostScript, PostScript -
. Adobe 1985 ,
.
, , PostScript,
. , ,
. PostScript ,
, GhostScript.
PostScript. .

,
PostScript. a2ps
FreeBSD. ( , , . 15.)
PostScript- ,
. PostScript, ,
. ( PostScript
, , PostScript-.)
, PostScript, .

16.

309

PostScript "%!".
"%!". ,
PostScript . ,
, a2ps -
PostScript.
:
16.1 PostScript
#!/bin/sh
#

PostScript-

read header
ps_test='expr "$header" : '\(..\)''
if [ "$header" = "%!" ]
then
# PostScript-, .
Echo "$header" && cat && printf "\004" && exit 0
exit 2 else
# . .
` (echo "$header"; cat) | /usr/local/bin/a2ps && printf "\004" &&
exit 0
exit 2
fi

(, /usr/local/libexec/if-ps)
chmod 555 /usr/local/libexec/if-ps, Ipd .
, Ipd,
header.
ps_test. if
, ps_test. %! (.. PostScript),
then, .
, ( cat) .
printf \004,
0. &&
: " , ". -
, .
, 2. Ipd ,
, .
%!, PostScript, ,
else.
( cat) /usr/local/bin/a2ps. a2ps
PostScript .
, \004 (
printf), 0.
( then), - ,
2.
a2ps , ,
PostScript-, . a2ps
.

310

3. FreeBSD

PostScript PostScript-
He-PostScript-,
. ,
PostScript , .
, PostScript UNIX
FreeBSD, , .
,
PostScript- ( ).
(, StarOffice)
, UNIX .
PostScript. , PostScript,
.
, Aladdin
GhostScript, PostScript-.
PostScript , -PostScript-.

GhostScript .
http://wvuw.cs.wisc.edu/~ghost/doc/printer.htm.

GhostScript FreeBSD print.


15.
, .
:
PostScript, ,
GhostScript , -PostScript. ( FreeBSD Handbook),
PostScript HP DeskJet 500, PostScript.
16.2 GhostScript HP DeskJet 500 ___________
#!/bin/sh #

ifhp - PostScript- ( GhostScript)

DeskJet 500


/usr/local/libexec/hpif

#
#
LF CR+LF:
#
printf "\033sk2G" || exit 2
#

#

#
read first_line
first_two_chars='expr "$first_line" : '\(..\)'`
if

["$first_two_chars" = "%!" ]; then


#
PostScript,
.

Ghostscript

16.

311

#
# , PostScript
# ,
# stdout, , .
# stdout stderr,
# 3 stdout.
# Ghostscript. :
# Ghostscript stderr
# , .
#
exec 3>&1 1>&2
/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \ sOutputFile=/dev/fd/3 - && exit 0

#
else

/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \


-sOutputFile=- - && exit 0

# , HP/PCL,
# .
# , .
#
echo $first_line && cat && printf "\033S10H" &&
exit 0
fi
exit 2

, . , -
, , %!.
, PostScript then, ..
GhostScript. , ,
.

GhostScript . -
http://www.cs.wisc.edu/~ghost/index.html.

Ipf

FreeBSD Ipf, .
, ( , ..).
man cap.


(conversion filters) ,
, .
1,
.
1 ( ,
).

312

3. FreeBSD

. 16.2 , lr:
16.2 Ipr

-d

DVI ( .)

-f

FORTRAN.

cifplot.
FreeBSD.

-g

, (plot
routines) UNIX. FreeBSD.

-d

troff, .
, FreeBSD.

-t

// troff.

-v

(
). .

. , , cifplot , - - .
, , UNIX, ,
.
,
groff ( ) PostScript ( ):
#!/bin/sh exec
grops

grops ,
groff PostScript.
grops.
/usr/local/Iibexec g2ps,
groff PostScript. -t
1, groff , :
lpr

-t

myfile

myfile , .
, /etc/printcap (
).

/etc/printcap
/etc/printcap "", , , . : , , ,
.

16.

313

/etc/printcap ,
. , , - / .
/etc/printcap . :
simba|lp|local line printer:\ #
:sh:\
:lp=/dev/lptO:sd=/var/spool/lpd/simba:lf=/var/log/lpd-errs:
:if=/usr/libexec/if-ps:

, .
simba, 1 ( ,
), .
. ,
, ..
, .
. :1 local printer ( ).
/dev/lptO (LPT1 DOS). :sd
/var/spool/lpd/simba ( ,
). :lf log file, .. ,
, .
, .
if-ps ( PostScript).


.
( ), .
:if. . 16.3
:
16.3 /etc/printcap

/etc/printcap

DVI

:df

FORTRAN

:rf

cifplot

:cf

plot

:gf

dittroff

:nf

troff

:rf

raster

:if

, .
,
. , , groff PostScript
( ):
:rf=/usr/local/libexec/g2ps:

314

3. FreeBSD

,
:if.
, , Ipd ,
.

Ipd
, /etc/printcap ,
Ipd. root, Ipd.
, /etc/ rc,conf
:
lpd_enable="YES"

, , . ,
, .


1 .

Ipr file_name

file_name , .
, .
, ,
-. , 1 .
. ,
, .
PRINTER, .
LPDEST, 1
.
1,
/etc/printcap.
PRINTER LPDEST
/etc/printcap 1,
.
Ipr .
. 16.4:
16.4 Ipr

-I

,
.

r. r
66 ,
, , .

16.

-h

. ,
.

315

-r

. ,
, .
-s ( ), .

-s

.
,
. , ,
. ,
.

-#n

n .

-J job

job , .
.

, .
. -.

-i n

n , .

-w n

n .
-.

X-Window
-Window . Netscape, Web.
Netscape File, Print.
Print, . 16.1.
Print To: ,
. Printer, Print Command: . ,
Ipr, .
Ipr (,
).
, Ipr .
-Window .
PostScript,
PostScript- GhostScript -PostScript.
Netscape PostScript ,
Ipr . , -
. UNIX, Netscape
. PostScript.

301

. FreeBSD

16.1
Print
Netscape.
,
File
,
netscape.ps.,
Netscape
PostScript.

StarOffice
StarOffice, ,
Printer Setup . , -
, . 16.2.
StarOffice , GhostScript PostScript. , Add new
printer, .
Configuration.
, StarOffice Generic Printerin,
PostScript 1.
GhostScript,
( StarOffice),
StarOffice,
GhostScript

16.2
Printer
Configuration
StarOffice. ,


( ).

16.

317


, ,
Ipq. ,
. : PRINTER, . ,
, 1 /etc/printcap.
Ipq , , , .
Ipq :
bash$ Ipq -P simba
simba is
ready and printing
Rank
Owner Job
Files
active
mike 5
/home/murban/sample.txt
2nd
mike 6
/home/murban/samplel.txt
3rd
jack 7
/home/jack/myfile. txt
4th
jack 8
...

Total
2000
2500
3200
5500

Size
bytes
bytes
bytes
bytes

-P . Ipq
simba, . Ipq
- .
, Ipq, .
, .
. , , .
: , . .
3, job, , .
( ), .
4 . ,
. ,
.
Ipq . 16.5.
16.5 Ipq

-P name

Ipq name,
.

-I

Ipq
, . (
.)


lprm ,
. , ,

318

. FreeBSD

.
, Iprm, . root, .
Iprm
(, ). , root . :
bash$ Iprm 5
dfA001simba.samplenet.org
cfA001simba.samplenet.org
bash $

dequeued
dequeued

, ,
(, ), .
, Iprm (
). , Iprm "", .
.
, , Iprm Permission denied (
).
Iprm , .
. 16.6.
16.6 Iprm

- name

, .
,
PRINTER Ip.
,
. root,
.

user_name .
root,
.

.
, -
. , (
) .

, (
).

16.

319


1. . ,
, "". , 1
,
( ) .
Ipc ,
. 1 ,
.
1.

Ipc
, 1
:
1>

? help ( ,
Enter), help ( ) .
( ,
). , status stat, sta, start 1 .
, , 1 ?Ambiguous command ( ). - , ?Invalid command (
).


status, ,
, stat. . all
( ) . , :
lpc> status lp lp:
queuing is enabled
printing is enabled
2 entries in spool area
waiting for lp to become

ready

(offline?) lpc>

. ,
, .
, .
status ,
.


abort stop , (

320

3. FreeBSD

). : all (
) ( ).
abort , . :
lpc> abort 1
lp:
printing disabled
daemon (pid 597) killed lpc>

status:
lpc> status all
lp:
queuing is enabled
printing is disabled
2 entries in spool area
printer idle lpc>

:
, . abort
. .
.
, .
, .
, . ,
, , .
stop abort, ,
,
. abort, stop . , . , .

(,
), /etc/printcap.
, I -
. ,
. , -
- . ,
, .


abort, stop . , abort,
, , ,
. , , .
.

16.

321

disable. : all ( ) ( ). :
lpc> disable lp
1p=

status
lp:

lpc>

queuing
all

disabled lpc>

queuing is disabled
printing is enabled
3 entries in spool area
waiting for lp to become

ready

(offline?)

, . , , ( ),
.
, , :
bash$ Ipr myfile.txt
Ipr: Printer queue is
bash$

disabled

down.
disable, , , .
, down stop, , disable, . .
status .
Ipq, , .
:
lpc> down
lp:

lp

printer

Printer
and

is

down

queuing

for maintenance.

disabled

lpc>

Ipq, :
bash$ Ipq
Warning: lp is down:
Warning: lp queue is
Printer is down for
Rank
Owner
bash$

Printer is down
turned off
maintenance.
Job
Files

for maintenance.
Total

Size

, , enable all ( ) .
:
lpc> enable lp
lp:
queuing enabled lpc>
status lp
lp:
queuing is enabled
printing
is
disabled

322

3. FreeBSD

3 entries in spool area Printer is down for


maintenance.
lpc>

, ,
, .
, . down, up.
, , ,
.
. restart,
.

,
, ,
restart. , . ,
( ).
"" .
restart : all ( ) , . :
lpc>

restart

lp 1:
daemon (pid 2102)
daemon started lpc>

killed lp:

B , restart ,
( ). - Ipq.
: Warning: no daemon present (: ),
, , .
restart l, .


clean 1 . ,
(, , ). 1, : all, , .


topq.
. : topq printer_name numjob(s), num Job(s)
- , .
, . , .. , , :

16.
Rank
1st
2nd
3rd
4th

Owner
murban
murban
murban
murban

Job
8
9
10
12

Files
myfile.txt
cardlist.txt
lions.txt
schedule.txt

323

Total Size
151625 bytes
38311 bytes
1113 bytes
6599 bytes

topq 1
12 10 9 8.
lpc>
lp:

lpc>

topq lp
moved
moved
moved
moved

12

10

9 8

cfA008simba.samplenet.org
cfA009simba.samplenet.org
cfA010simba.samplenet.org
cfA012simba.samplenet.org

-:
Rank
1st
2nd
3rd
4th

Owner
murban
murban
murban
murban

Job
12
10
9
8

Files
schedule.txt
lions.txt
cardlist.txt
myfile.txt

Total Size
6599 bytes
1113 bytes
38311 bytes
151625 bytes

topq . topq
.
, topq . ,
, ,
. , -
Iprm.
l
1 quit exit
1>. .

l

l . : , , .
1 , ,
. :
# Ipc restart lp lp:
daemon (pid 2280)
lp:
daemon started
#

killed

, .

324

3. FreeBSD

l
1, root. operator.
, operator, 1, .
,
.
, ,
, 10.


.
/etc/printcap :
simba|1|local line printer:\

:lp=::rm=nova:rp=simba:sd=/var/spool/lpd/simba:lf=/var/log/lpd-errs:

simba nova.
, ( 1)
. . , ,
, , r 2.
, .
, .
, ,
.
, ,
.


.
,
.

Ipq , .
Warning: no daemon present, 1
. , l, , .

He-PostScript- PostScript-. ,
PostScript.

Web-

PostScript- , . He-PostScript-

16.

325

. GhostScript
" PostScript He-PostScript-".


(polled mode) (,
). :
lptcontrol

,
. . , Iptcontrol.

""
:
Line

one

of

the

file.

Line two of the file.


Line three of the file.

, .
, ,
UNIX DOS/Windows (LF). Windows
, :
. , UNIX ,
. -
DOS, , ,
.
.
, , .
.
, LF
CR LF.
HP-PCL, :
#!/bin/sh #
# hpif - Ipd ,
400
HP-PCL.
401

/usr/local/libexec/hpif
#
500
stdin stdout.

# .
#
# .
printf
exit

"\033Sk2G"

&&

cat

&& printf

LF

CR+LF.

"\033S10H"

ss exit 0

, ,
.
HP-PCL, LF CR LF
tr. :

26

3. FreeBSD

#!/bin/sh
# , "" ,
# PCL.
/bin/cat | tr '\ 13' '\ 13\ 10' && exit
exit 2

,

, , "". . , , LF
CR. ,
.
,
CR LF . .
, , "".

17





/dev

328

3. FreeBSD

UNIX
: .
,
, .
.
FreeBSD
.
100%, ,
, .
.


.
.
, TCP/ IP
, , .
MS-DOS Windows
. , . Windows,
, C:\WINDOWS\SYSTEM, Mac
OS . UNIX-
. FreeBSD
/boot. ("" )
, ,
, , .
, - .
Windows, ,
. ,
.
, , .
FreeBSD (microkernel architecture), ..
.
Windows NT Mach (, Mac OS X)
, -
,
. Linux Windows 95/98 (monolithic) ,

.
,
, .
, , Linux, , , FreeBSD .
-
, .
: -

17.

329

, ,
.
, .
,
, -.
, , , ,
. FreeBSD
, .

?
FreeBSD GENERIC. , FreeBSD
.
86 , .
,
(, IRIX SGI Mac OS X Apple),
. GENERIC
,
,
( ). , .
,
.
. , .
, GENERIC.
, , .
,
(, , ).
,
,
FreeBSD.

GENERIC .
(. ]. , (
]. , , , ,
, .

, USB-, , SCSI .., ,


. (, EXT2FS,
. 9). ,
.
(-

330

3. FreeBSD

, ,
). .
, (SMP, Symmetric Multi-Processing)
GENERIC. ,
, .

dmesg

, ,
, .
,
.
, .
dmesg.
dmesg, , ,
less, 17.1.
17.1 dmesg less
# dmesg | less
Copyright () 1992-2001 The FreeBSD Project.
Copyright () 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993,
1994
The Regents of the University of California. All rights reserved.
FreeBSD 4.2-STABLE #1: Sun Mar
4 14:05:42 PST 2001
btman@stripes.arclight.net:/usr/obj/usr/src/sys/STRIPES
Timecounter "i8254"
frequency 1193182 Hz
CPU: Pentium Ill/Pentium III Xeon/Celeron (598.06-MHz 686-class CPO)
Origin = "Genuinelntel"
Id = 0x683
Stepping = 3
Features=Ox383f9ff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,SEP,MTRR,PGE,MCA,CMOV,
PAT,PSE36,MMX,FXSR,SSE>

real memory
= 132907008 (129792K bytes)
config> di snO
config> di IncO
config> di ieO
config> di feO
config> di edO
config> di csO
config> di btO
config> di aicO
config> di ahaO
config> di advO
config> q
avail memory = 125018112 (122088K bytes)
Preloaded elf kernel "kernel" at Oxc044aOOO.
Preloaded userconfig_script "/boot/kernel.conf" at Oxc044a09c.
Pentium Pro MTRR support enabled
mdO: Malloc disk
npxO: <math processor> on motherboard
npxO: INT 16 interface
pcibO: <Host to PCI bridge> on motherboard
pciO: <PCI bus> on pcibO
pciO: <Intel model 1132 VGA-compatible display device> at 2.0 irq 11
pcibl: <PCI to PCI bridge (vendor=8086 device=244e)> at device 30.0
on pciO
pcil: <PCI bus> on pcibl

17.

331

fxpO: <Intel PLC 10/100 Ethernet> port Oxde80-0xdebf mem OxffSfeOOO 0xff8fefff
irq 11
at device
8.0
on pcil
fxpO:
Ethernet
address
00:dO:b7:o7:74:f1
fxpl: <Intel Pro 10/100B/100+ Ethernet> port OxdfOO-Oxdf3f mem
Oxff700000-Oxff7f
ffff,0xff8ff000-0xff8fffff irq 11 at device 9.0 on pcil
fxpl: Ethernet address 00:dO:b7:bd:5d:13
isabO: <PCI
on pciO

to

ISA

bridge

(vendor=8086

device=2440)>

at

isaO: <ISA bus> on isabO


atapciO: <Intel ICH2 ATA100 controlled port OxffaO-Oxffaf
31.1 on pciO
ataO: at OxlfO irq 14 on atapciO
atal: at 0x170 irq 15 on atapciO

device

31.0

at device

,
. ,
.
, .
(
) , .
, config>, ,
, (. di), .
dmesg. ,
.
not found, ,
. dmesg , , .


FreeBSD linuxconf Red Hat Linux make config,
Linux. FreeBSD
. ,
, .
" ",
/ . .
,
, diff grep, GENERIC,
NOTES -.
,
,
/ .
, ,
. FreeBSD config-,
""
.
FreeBSD ,
/sys/i386/conf. GENERIC.

332

3. FreeBSD

Alpha, 86,
1386 alpha. , ,
.

GENERIC
GENERIC . ,
( GENERIC ). ,
. , ,
"" :
machine
cpu
cpu
cpu
cpu
ident
maxusers

i386
I386_CPO
I486_CPU
I586_CPU
I686_CPU
GENERIC
32

"" : , GENERIC
, . ,
17.2.
17.2 GENERIC
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options
options

MATH_EMULATE
#Support for x87 emulation
INET
#InterNETworking
INET6
#IPv6 communications protocols
FFS
#Berkeley Fast Filesystem
SOFTUPDATES
#Enable FFS soft updates support
MFS
#Memory Filesystem
MD_ROOT
#MD is a potential root device
NFS
#Network Filesystem
NFS_ROOT
#NFS usable as root device, NFS required
MSDOSFS
#MSDOS Filesystem
CD9660
#ISO 9660 Filesystem
DEVFS
#Device Filesystem
PROOFS
#Process filesystem
COMPAT_43
#Compatible with BSD 4.3 [KEEP THIS!]
SCSI_DELAY=15000
#Delay (in ms) before probing SCSI
UCONSOLE
#Allow users to grab the console
USERCONFIG
#boot -c editor
VISUAL_USERCONFIG
#fvisual boot -c editor
KTRACE
#ktrace(l) support
SYSVSHM
#SYSV-style shared memory
SYSVMSG
#SYSV-style message queues
SYSVSEM
#SYSV-style semaphores
P1003_1B
#Posix P1003_1B real-time extensions
_KPOSIX_PRIORITY_SCHEDOLING
KBD_INSTALL_CDEV
# install a CDEV entry in /dev

device. ,
GENERIC.
. device,
. . 17.3.

17.

17.3 , GENERIC
# PCI Ethernet NICs that use the common MII bus controller code.
#
NOTE: Be sure to keep the 'device miibus' line in order to use
#
these NICs!
device
miibus
# MII bus support
device
dc
# DEC/Intel 21143 and various workalikes

device
device

devicerl
devicesf
devicesis
deviceste
devicetl
devicetx
devicevr
devicewb
devicexl

fxp
pen

#
#
#
#
#
#
#
#
#

Intel EtherExpress PRO/100B (82557,


# AMD Am79C79x PCI 10/100 NICs

82558)

RealTek 8129/8139
Adaptec AIC-6915 ( " Starfire'')
Silicon Integrated Systems SiS 900/SiS 7016
Sundance ST201 (D-Link DFE-550TX)
Texas Instruments ThunderLAN
SMC EtherPower II (83cl70 ''EPIC1')
VIA Rhine, Rhine II
Winbond W89C840F
3Com (''Boomerang'', ''Cyclone'')



FreeBSD 5.0, FreeBSD 4.x ,
.

FreeBSD , (device hints),


,
.
:
device

ataO

at isa? port IO_WD1 irq 14

device

atal

at isa? port IO_WD2 irq 15

:
device
ata
, ata
/boot/device.hints, .
, :
hint.ata..at="isa"
hint.ata.0.port="OxlFO"
hint.ata.0.irq="14"
hint.ata.1.at="isa"
hint.ata.1.port="0x170"
hint.ata.1.irq="15"

, -
(IRQ interrupt request) ata.
. ,
:
# statically compile in device
#hints
"GENERIC.hints"

wiring instead of /boot/device.hints


#Default places to look for devices.

LINT
/sys/i386/conf LINT,
, .

334

3. FreeBSD

, .
.
, GENERIC,
LINT. (
). ,
.
. ,
, LINT.
FreeBSD
LINT, .
, .
, FreeBSD 5.0 LINT , NOTES, . NOTES LINT,
. LINT
NOTES, make lint. ,
,
( , ,
).


, . GENERIC
,
. , ,
, .
, .
CUSTOM:
#

GENERIC CUSTOM

CUSTOM . ,
, GENERIC CUSTOM.
cu , , maxusers.
Pentium III:
machine
cpu
ident
maxusers

1386
I686_CPU
CUSTOM
64

maxusers: , ( device pty <num>).


: , , (
16*maxusers+20). ,
4.
, .

. NOTES,
, , dmesg -

17.

335

. , ! , #.
- .
GENERIC, , ,
, - , , .


, .
, ( )
:
#

cd /usr/src

#
#

make
make

buildkernel KERNCONF=CUSTOM
installkernel KERNCONF=CUSTOM

KERNCONF ,
, GENERIC. , ,
, /boot (
/boot/kernel.old).
, .
make :
#

make

kernel

KERNCONF=CUSTOM

schg (-). , root


, . make
installtarget .
securelevel 1 (
/etc/.conf, . man securelevel),
. (
shutdown ) .

/dev

FreeBSD 5.0,
DEVFS /dev
.

, ,
/dev. ,
, . ,
, .
. /dev MAKEDEV:
#

. /MAKEDEV

336

3. FreeBSD

, , " " /dev,


.
(,
sndO).
:
# ./MAKEDEV sndO


, .
,
, ( "*** Error code 1"),
, .
, ,
. , Web- FreeBSD (http://
www.freebsd.org)
, .
(
18), , , ( -CURRENT -STABLE) .
: freebsd-current freebsd-stable ( Web-
FreeBSD).
: ,
, .
,
. ,
.
. ,
. ( 10
) /boot/kernel.old ,
.
!
, /boot/kernel.old
(.. ]. ,
kernel.old , , /boot/kernel.frank. -
.

: ,
, ps, top w, .
, , , , libkvm .
- libkvm.
, .
, make
world (. 18).

18

FreeBSD

FreeBSD
make world?

mergemaster

338

3. FreeSSD

,
. , ,
.
,
. , Internet (
, ),
,
!
.
Microsoft "-" (service pack)
Windows NT/2000.
Windows Macintosh
- . Linux.
FreeBSD .
- ,
.
FreeBSD (4.0, 5.0) - , (3.4, 4.1.1), , - .
, ,
, . "
", , FreeBSD (,
CVSup make world).

FreeBSD

.
, - ( )
- , 2.
. ,
.
FreeBSD CVS (CVS
repository), . Linux (
,
, ), FreeBSD ,
. ,
, CVS.

STABLE
CURRENT
FreeBSD .
, ( ),
, .
. ,
.
.

18. FreeBSD

339

, , -

. CURRENT (),
- STABLE ().
(3.x, 4.x,
5.x ..) ,
.. "" . :
,
, 18.1.
.
FreeBSD,
, CURRENT --
CURRENT STABLE.
, ! CURRENT , .
. CURRENT
,
, , STABLE ().
CURRENT,
(, 5.0), . CURRENT
STABLE . CURRENT ,
, a STABLE CURRENT,
. .
CURRENT
, STABLE -.
, .


, ,
. : ,
, -
; -, CVSup.
( , 15.)
.

.
, CVSup.
RELENG RELease ENGineer ( ). ,
FreeBSD.

, (
), RELEASE. . 18.1
.

340

3. FreeBSD

18.1

RELENG_5_0_0_RELEASE

FreeBSD 5.0

RELENG_4_2_0_RELEASE

FreeBSD 4.2

RELENG_4_1_1_RELEASE

FreeBSD 4.1.1

RELENG_3_5_0_RELEASE

FreeBSD 3.5


, ,
RELEASE ( ). ,
, FreeBSD
,
. . . 18.2.

, . 18.2 2001 . -
.
http://www.freebsd.org/handbook/cvsup.html.

18.2

RELENG_5

FreeBSD 5-CURRENT

RELENG_4_3

FreeBSD 4.3-STABLE

RELENG_4

FreeBSD 4-STABLE ( )

make world?

,
FreeBSD:
, .
. -
FreeBSD
, .
make world.
,
. , - ,
, ,

. "" ,
,
.
,

18. FreeBSD

341

. :
. ,
, , . , .
( -)
29. -.
(world) :
( ),
. ,
.



, , . . -
. , ,
.
, make world , , .
(,
on-line),
,
.
FreeBSD (FreeBSD Group) , make world
(,
). ,
. (make world)
,
,
. ,
: , ,
. , STABLE CURRENT
(
). ,
-.
, FreeBSD-
. make world
.
STABLE CURRENT,
freebsd-stable@freebsd.org freebsd-current@freebsd.org,
. ,
, , ,
. -
freebsd-stable@freebsd.org
, (make world)
,

342

3. FreeBSD

.
, ,
, ,
, .

majordomo ,
:
subscribe freebsd-stable

majordomo@freebsd.org. freebsdstable freebsd-current! Internet!


, .
, , -
. , , subscribe
unsubscribe .

, , make world ,
.
, (,
/usr/src) STABLE CURRENT.
.
( ) ,
( ,
), /usr/src
. ,
( 29).
, , FreeBSD .
. ,
.

, FreeBSD, .

http://wvuw.FreeBSD.org/cgi/query-pr-summary.cgi.
http://www.freebsd.org Bug Reports ( ).
.
. send-pr. ,
,
.
GNATS .
, , , .
LJRL .
, :
freebsd-stable freebsd-current. -
, , -
. , , ,
.

18. FreeBSD

343

, .
RELEASE, ,
. , .
( )
. , ,
.
, , , .
, ,
,
.
, (CD-R, DVD-RAM, DVD-R ..),
,
, , NFS CVSup.
( 20).
. ,
. , , .
.
. .


STABLE, CURRENT RELEASE
. , FreeBSD, , Anonymous CVS CVSup.
.
Web- FreeBSD Synchronizing Your Source (
). CVSup,
.
CVSup
CVSup 15.
, , CVSup cvsupit,
15. .
cvsupit ( ),
, .
STABLE, STABLE . , ,
4.3-RELEASE, RELENG_4_3. ( ) , ".",
.
Enter . , ,
.

344

3. FreeBSD

3. .
. , /etc/cvsupfile.
cvsupit . periodic, 15.
.
, ! STABLE CURRENT,
, .
CVSup RELEASE
CVSup
RELEASE, .
( ).
cvsupit .
cvsupit /etc/cvsupfile.
cvsupit /etc/cvsupfile . ,
18.1.
18.1 /etc/cvsupfile, cvsupit ________
*default
*default
*default
*default

*default

*default

host=cvsup8.FreeBSD.org
base=/usr
prefix=/usr
release=cvs
tag=RELENG_4

delete

use-rel-suffix

src-all
*default tag=.
ports-all doc-all

. , 4.3-RELEASE :
*default

tag=RELENG_4_3_0_RELEASE

, CVSup, ""
(
STABLE CURRENT). .
make world
/etc/cvsupfile .
,
. .

, CVSup ,
, , , .
.
CVSup (Connection refused
).

18. FreeBSD

345

CVSup. (,
cvsup8.freebsd.org), . , CVSup , (, ).
CVSup , .
, NAT, IP-. CVSup NAT,
. , CVSup. 5999.
CVSup /usr/src!
, . CVS .
, . ,
.

UPDATING
, UPDATING
/usr/src. , , ,
( ! ). UPDATING
( )
, .
,
make world. , .
, /etc make world . . ,
, ,
- .
. UPDATING, ,
. ,
mergemaster,
/etc. mergemaster ,
make world.

/etc/group /etc/passwd

/etc .
,
. , make world
- .
- .
, .

/etc/group.
/usr/src/etc/group.
20 . /etc/group ,
/usr/src/etc/group , /etc/group. , .
, , 100.

346

3. FreeBSD

diff. 18.2.
18.2 /etc/group /usr/src/etc/group diff
#
diff
-
/etc/group
/ usr/ sr c/etc/group
|
***
/etc/group
Wed
May
2
09:57:10
---- /usr/src/etc/group Fri Aug 27 16:23:41 1999

less
2001

***************
*** 8,24 ****
bin:*:7:
news:*:8:
man:*:9:

wheel:*:10:root,frank,joe
games:*:13: uucp:*:66:
xten:*:67:xten dialer:*:68:
+ network:*:69:
- mysql:*:88:
- users:*:100:
nogroup:*:65533 :
nobody:*:65534:

, /etc/group, -, /usr/src/etc/group +. /etc/group


network.
, GID ,
group. , ,
/etc/group . ,
( )
.
find:
#

find

-group <GID> -print

chmod, 10.
, .
passwd, /usr/src/etc/master.passwd.
, group. /etc/master.passwd adduser.

/etc/make.conf

make.conf ,
- make, make world.
FreeBSD /etc/make.conf, (
/etc/rc.conf /etc/ defaults/rc.conf) /etc/defaults/make.conf,
.
. ,
.
FreeBSD (FreeBSD handbook)
( /etc/defaults/make.conf /etc/make.conf):
CFLAGS= -
NOPROFILE=

-pipe
true

# Avoid compiling profiled libraries He


#

18. FreeBSD

347

,
.


, . ,
.
make world ,
. 18.3. , .
18.3 , make world

make buildworld
make installworld

make world

make buildkernel
make installkernel

make kernel

make world make kernel , , . .

/usr/obj
, make world .
, /usr/obj .
, , ,
.
/usr/obj ( ),
. rm -rf.
schg (), root. , , rm -rf \.*.
, :
1
2
3

cd /usr/obj
chflaqs -R noschg
rm -rf *

, securelevel 1
( /etc/rc.conf, . man securelevel 29).
schg. ,
.

log-
make world log-. , ( ) . , ,
,
, .

348

3. FreeBSD

script. , "
", . script exit.
f script -/buildworld.out
Script
started,
output
# make buildworld

file

is

-/buildworld.out

...

# exit
Script done,

output

file

is

-/buildworld.txt

, .
. make world
log-.

log- /tmp!
, , .

make buildworld
/usr/src,
make:
# make buildworld

buildworld - , .
-j, :
# make -j4 buildworld

.
(
10).
/usr/src
. /usr/obj.
, /usr/src/usr.sbin,
.

CVSup,
, , , . .
# "signal ".
11 . ,
, . ,
. , FreeBSD
. ,
.
# "*** Error code I ****.
, -
. buildworld ,

18. FreeBSD

349

, .
, , /usr/obj .

, . /usr/obj
.
, http://www.freebsd.org (
stable/freebsd-stable current/freebsd-current)
. ,
, uname -,
CVSup .


, , .
.
GENERIC
GENERIC ( 17),
:
# make buildkernel
# make

installkernel

:
#

make

kernel

/kernel (/boot/kernel FreeBSD 5.0),


/kernel.old (/booVkernel.old FreeBSD 5.0).

,
.
, (.. ) GENERIC,
.
.
/usr/src :
#

make

buildkernel

KERNCONF=GENERIC

GENERIC, . /boot/kernel /boot/


kernel.prev ( , ,
). :
#

make

installkernel

KERNCONF=GENERIC

kernel.GENERIC:
#

/boot/kernel

/boot/kernel.GENERIC


:
# make buildkernel KERNCONF=CUSTOM

350

3. FreeBSD

, CUSTOM
. /boot/kernel:
# make installkernel KERNCONF=CUSTOM

, , , . 18.4.
18.4 (FreeBSD 4.4)

/kernel

/kernel.GENERIC

GENERIC

/kernel.old

, , GENERIC ( 11).
, .

make
world. ,
, . .
.
,
( ). , .
!
securelevel 1 , make
installkernel schg .
. , ( boot
-s loader),
. mount -
/usr/src make installkernel.

make installworld

, ( ), .
.
.
reboot. loader ( )
boot -s. , , . .

18. FreeBSD

351

( ,
..),
. , ,
( , , , ).
make world . ,
,
.

root. /usr/src ,
make world.
, ,
. ,
. log-.
# make installworld

.
, ps top, ,
. , . , ,
.


make installworld - , , , , . ,
.
# ,
.
/etc/group /etc/master.passwd
. ,
, .

mergemaster

: /etc ( , , /var/log
/usr/share) . , make world /etc, .
/etc ,
- . mergemaster,
FreeBSD, , .
mergemaster , . ,
, /etc. :
# -Rp /etc /etc. old

352

3. FreeBSD

, mergemaster ,
. -v (
) - ( diff, ).
# mergemaster -cv

mergemaster
( ,
). , -
/var/tmp/temproot. , /etc
(, ,
, ).
/etc /var/tmp/temproot. -
diff, -
, PAGER (
). diff -,
. . 18.3.
18.3 mergemaster ___________

***************
***
---

321,326 ****
327,333
--kern_securelevel="-l"
update_motd="YES':
start_yinum=""
+ unaligned_print="YES"
alpha (or NO).

# range: -1..3 ; '-!' is the most insecure


# update version info in /etc/motd (or NO)
# set to YES to start vinum
# print unaligned access warnings on the

###############################################
### Define
Use
Use
Use
Use
again

'd'
'i'
'm'
'v'

to
to
to
to

Default is

source_rc_confs,

the mechanism used by

/etc/re.*

##

delete the temporary ./etc/defaults/rc.conf


install the temporary ./etc/defaults/rc.conf
merge the old and new versions
view to differences between the old and new versions
to

leave

the

temporary

file

to deal with by hand

, ,
/var/tmp/temproot . -
, mergemaster .
'm' ,
sdiff. .
() () .
*** Type h at the sdiff prompt
pccard beep="l"
%

# pccard beep

(%)

to get usage help

pccard_beep="2"

# pccard beep

,
. , , ,
. -w -
:
# mergemaster -cv -w 120

18. FreeBSD

353

sdiff 'h', .
mergemaster. (
). .
, mergemaster , /var/tmp/temproot. ,
, "n".
/var/tmp/temproot
.

mergemaster , , , , , /etc.
.
/etc !
. (, /etc.old),
mergemaster, Ctrl+C, /etc.
Mergemaster , /var/tmp/temproot!
mergemaster , . /var/tmp/temproot "n".


:
?

buildworld?

?
?
installworld?
, ps top?

/etc ?
"", .
#

reboot

, ps
top. ? , uname -
:
#

uname

-a

FreeBSD stripes.somewhere.com 4.3-STABLE FreeBSD 4.3-STABLE #0: Wed Jan 31 18:45:43


PST2001 frank@somewhere.com:/usr/src/sys/compile/CUSTOM i386
, !
make world.

19

IDE/

SCSI



19.

355

. Windows ( BIOS ) Macintosh (


), UNIX- ,
, . FreeBSD
.
9, UNIX
,
. :
,
(slices) , , .
, ,
. sysinstall -
.

IDE/ATA
IDE
(Integrated Drive Electronics ).
, , ,
, (,
, SCSI). ATA (Advanced Technology
Attachment ). IDE . IDE/ATA SCSI.
, IDE-.
, .
SCSI- .

IDE (
). IDE
, 86.
,
, FreeBSD.

IO
IO (Programmed I/O - )
. ,
IO BIOS
.
DMA Ultra DMA. ,
IO .
IO
. 19.1.
19.1 IO

, /

162

3,3

163

5,2

356

3. FreeBSD

PIO

, /

# 8,3

# 11,1

-2

# 16,7

-2

PCI.
, ISA,
PIO Mode 2.
.

DMA
IO ,
.
SCSI-, , . 90- DMA.
. 19.2. , . , .
.
19.2 DMA
DMA

, /

Single Word Mode 0

2,1

ATA

Single Word Mode 1

4,2

ATA

Single Word Mode 2

8,3

ATA

Multiword Mode 0

4,2

ATA

Multiword Mode 1

13,3

ATA-2

Multiword Mode 2

16,7

ATA-2

DMA , , .
, . DMA ,
- DMA , Windows
95. ,
.

Ultra DMA
, Ultra DMA.
DMA . / SCSI,
.
Ultra DMA DMA. , -

19.

357

. ,
33 /. Ultra DMA . 19.3. IDE: 80 40.
19.3 Ultra DMA
Ultra DMA

, /
#

16,7

ATA/ATAPI-4

25,0

ATA/ATAPI-4

33,3

ATA/ATAPI-4

44,4

ATA/ATAPI-5

66,7

ATA/ATAPI-5

100,0

ATA/ATAPI-6

, 1998 , UDMA,
:
, Ultra DMA;
80- IDE;
( IDE), Ultra DMA;
Ultra DMA ( BIOS).
, ,
, , -
IO, BIOS. , UDMA, ,
"" . BIOS ( UDMA), UDMA ,
, .
FreeBSD Ultra DMA. ,
,
. , dmesg:
ad0:
6194MB
UDMA33

<HITACHI_DK239A-65>

[13424/15/63]

at

ataO-master

using

UDMA
, , ( ), MS-DOS
UDMA. ,
.

SCSI
IDE-
, SCSI.
SCSI ( . 19.4) ,
IDE.

1. 3. FreeBSD
19.4 SCSI


, / ,

, ,

SCSI-1

SCSI

50

SCSI-2

Fast SCSI

10

50

SCSI-3

Wide SCSI

10

16

68

Fast Wide SCSI

20

16

68

20

1,5-3

4-8

50

Wide Ultra SCSI

40

1.5-3

4-16

68

Ultra2 SCSI

40

12

50

Wide Ultra2 SCSI

80

12

16

68

Ultra3 SCSI

160

12

16

68

Ultra SCSI

Ultra160 SCSI

160

12

16

68

Ultra320 SCSI

320

12

16

68

, SCSI
. . . ,
SCSI- SCSI-,
, .
SCSI , ,
8 16. , IDE/ATA
( ). ,
. ,
. , - ( SCSI ), .
SCSI . IDE/ATA . ()
, , Iomega ZIP, ,
. SCSI , FireWire (IEEE 1394).
SCSI- ... . SCSI-
IDE- 1,52 .
SCSI-, (
SCSI-, ,
, ). .
, SCSI ,
: , SCSI BIOS, (
). , ,
. SCSI- ,
, Web- PC Guide http://www.pcguide.com.

19.

359


,
fdisk ( ).
FreeBSD
, , ,
Windows. Pentium 166
FreeBSD. : 70- IDE- 8 .
. ,
.
, ,
, ,
IDE .
, ,
(. . 19.1), , .
, .

19.1

, .
. ,
8 .
. .
( 64, 63).
(, 512).
.
. ,
fdisk 9, :
# fdisk /dev/ad1
******* Working on device /dev/adl *******
parameters extracted from in-core disklabel are:
cylinders=1247 heads=255 sectors/track=63 (16065 blks/cyl)
Media sector size is 512

( /) :
1247 cylinders
10.2GB

255

heads

63

sectors/track x 512 bytes/sector =

! 255 ? ? ,
. , , 64 ,
.
, -

360

3. FreeBSD

, .
, BIOS. ,
( LBA Extended INT13).

LBA 528
- , -
, 528 . -
, , BIOS ,
. . 19.5.
19.5 ,

10

210-1 = 1023

28-1 = 255

26-1 = 63

, 255 1023 .
(, ,
). ,
. 16 , ..
528 . , BIOS 1023
.
1993 ,
. - !
BIOS LBA (Logical Block Addressing
). LBA BIOS
1024 " ", ,
, ( 255). ,
1852 16
463 64 . ,
, BIOS. ... .

Extended INT13 8.4


, LBA
, -
. 8,4 .
, .
BIOS, Extended INT13 ( 13),
Windows ( BIOS, FreeBSD).
16- (Disk
Addressing Packet), - (
, ).

19.0

361

Extended INT13, .
- ,
8,4 , , 16383 , 16 63 .
, ,
. , FreeBSD
, "". , ,
IDE 137
65536... (
. . )


FreeBSD , , , LBA, -
. , , , ,
8,4 10 . , .
, SCSI FireWire (IEEE 1394),
.
, IDE/ATA.


: ,
, . , SCSI-
IDE-, .
, .
, IDE-
40 (slave) .
, 9, /dev/adl. (SCSI /dev/dal.) , .
, adl,
. ,
, , .

BIOS (Slices)
. ,
FreeBSD , . BIOS,
BIOS . ,
"" (partitions).
Windows Macintosh,
BIOS.
FreeBSD BIOS "" (slices).
. FreeBSD ,
, , . " BSD".

BSD
FreeBSD,
: /var, /usr, /home .. ,

# 3. FreeB

. BSD, .
19.6. BSD ( ,
),
.
19.6 BSD

(/)

swap

"" . (""
, .
FreeBSD 4.4 5.0)

( Disklabel Editor)

. 19.2 . (adl)
. IDE/ATA adO ad3 (
). , 1 (s1).
, BSD (e).
1

BSD e

19.2

/dev/ad1s1e


,
FreeBSD: , DOS (Extended DOS Partition)
DOS/Windows- ( ). Linux.
, FreeBSD.
.
DOS, , FreeBSD
, DOS, 5 (..
DOS).
. .
, FreeBSD DOS/
Windows, Linux- . Linux

19.

363

( FreeBSD ) , FreeBSD:
, .
FreeBSD Linux . 19.7, .
,
/ DOS FreeBSD.
19.7 Linux FreeBSD
Linux FreeBSD
/dev/hdb4

/dev/ad1s3a

/dev/hdb5

/dev/ad1s3b

/dev/hdb6

/dev/ad1s3e

/dev/hdb7

/dev/ad1s3f

(fdisk) sysinstall
root /stand/sysinstall
"Configure". "Fdisk", "Slice (PC-Style
partition) Editor". ,
. , adl ( , slave- ). , , . ,
, /var/run/dmesg.boot. ,
. , ,
,
"Single". ,
- "Master", "Slave".
, ()
fdisk (fixed disk ).
,
BIOS (). fdisk , , , sysinstall. ,
, !
. , , .
. BIOS
- FreeBSD, Linux DOS. , ,
"Use Entire Disk" ( ).
. 19.3. ,
.
: , "" , , FreeBSD (adlsl)
"" ( ),
.

3. FreeBSD

19.3

Slice Editor (
"Use Entire Disk").

.
, W.
Slice Editor Q. ,
. , ,
None (). , FreeBSD
Boot Manager (BootMgr). , ,
.
"Standard" , DOS fdisk /MBR,
MBR , - ( LILO
Linux BootMgr FreeBSD), , , Windows.


, FreeBSD,
. Disklabel Editor ( ).
sysinstall, Label (), Disklabel Editor.
.
adl . Disklabel Editor
disklabel. BSD.

Disklabel Editor FreeBSD .


, ,
, !

FreeBSD
, "Adding a New Disk".
, Disklabel Editor
BSD FreeBSD, , /usr,
/var . FreeBSD ,
, , .

19.

365

"Auto Defaults for all!" (


). ,
(. . 19.4). FreeBSD-
, .
19.4
Disklabel Editor
( "Auto
Defaults for all!".

.
log- /var. 100 ,
, Web- log-
100 , /var 20 . , /var
.
, Disklabel Editor.
, /var /usr.
D. , "Free:" ,
.
. (, ,
W.)
"Partition name: adlsl", "",
. , .
/var 200 , . (
, .) , ,
"200m". FS ( ).
/var.
, "Free:" .
"/usr",
.
. 19.5.


BSD. He ,
.
"Partition name: adlsl" , .
BSD (, 40
/home), , .. .

366

3. FreeBSD

-: (, 20G), , , .

19.5

( ) FS
. . ,
/etc/fstab .
.
, . ,
D. , .
W.

, "" ,
; , .
d "" X, .


FreeBSD newfs.
sysinstall. , Newfs Y, .
.
, .
Part. , ,
d , . 19.6.
. ,
, , : adlsle, adlslf ..
.
W . , newfs, . Q sysinstall.

19.

367

, . .
,
/etc/fstab. mount
/etc/fstab 9.
: -
FreeBSD. mount .
, , , /mnt/newdisk. (
.) mount:
#

mount

/dev/adlsle

/mnt/newdisk

, , df. To
,
. umount:
#

umount

/mnt/newdisk


FreeBSD!

20

FreeBSD

FreeBSD


:

20. FreeBSD

369


FreeBSD, , .
, -
. ,
FreeBSD. .
: ,
. -
. ,
,
.
.
FreeBSD Windows,
FreeBSD Linux. , ,
, ,
. , , , ,
.

FreeBSD
15-20% UNIX-
FreeBSD.
Linux. NetBSD, OpenBSD .
, Windows NT/2000 20-30% ,
UNIX- ( , )
65%. , , FreeBSD
. , ,
.
FreeBSD . , , Linux
UNIX, FreeBSD. .
,
- Linux.
, FreeBSD
,
Web- .
, FreeBSD .
-,
, .
FreeBSD Windows NT/2000 Linux
: .

370

3. FreeBSD

,
"" , FreeBSD .
FreeBSD
.

Windows NT/2000
Windows NT/2000 ,
. ,
Windows NT/2000 .

UNIX-.

Windows NT/2000 . ,
, Services. , DOS .
, -
. ,
, .
.

-
Windows
: , .
. , ,
, . -
Windows ,
.
FreeBSD, , .
Web- (, ..),
. Telnet ( SSH)
UNIX. ,
, .
, , -
, . ,
, .
: , ,
( )
- Windows,
, .

Windows NT/2000 . ,
. o-

20. FreeBSD

371

, Windows,
FreeBSD .
root Administrator. .
root : ,
( , ). ,

Windows NT/2000 FreeBSD.
FreeBSD User, Group Other. Windows NT/2000 (Access Control Lists). FreeBSD 5.0 ACL (. 10), Windows NT/2000
.
Windows NT/2000 " " (trusted
paths), , . , Windows "" ,
( ), . FreeBSD .
Kerberos (
29).
FreeBSD 16
. .
Windows NT/2000 27
. FreeBSD , root, setuid
( set-user-ID ). .
FreeBSD UNIX . Windows NT/2000
. FreeBSD .
.
Windows UNIX. (, , Domain Controller Windows NT/2000) NIS (yellowpages, " ").
NIS man nis.
, NetBIOS
Windows, UNIX- NFS.
Samba FreeBSD
Windows. NFS 31, Samba
32.

372

3. FreeBSD


Windows Authenticode.
"",
. ,

. UNIX ,
/ FreeBSD
, .
. 15.
Windows NT/2000 , -
, UNIX, , . Windows
: ,
. FreeBSD,
. , UNIX (,

), ,
UNIX-. , , SANS (System
Administration, Networking, and Security) - ,
http://www.sans.org.


,
Windows, FreeBSD (. . 20.1).
20.1 Windows

Windows NT/2000

FreeBSD

Mail (SMTP)

Microsoft Exchange

Sendmail

Mail (POP)

Microsoft Exchange

qpopper

MAIL (IMAP)

Microsoft Exchange

IMAP-UW

News (NNTP)

Microsoft Exchange

inn

Microsoft SMS

syslogd


Web/HTTP

Microsoft IIS

Apache

FTP

Microsoft IIS

ftpd

Web-

Cold Fusion, ASP

PHP

DNS

Microsoft Active
Directory

BIND

Remote Access
( )

Microsoft Terminal
Server

Telnet, SSH

Directory Services
( )

Microsoft Active
Directory

OpenLDAP

20. FreeBSD

373

, Windows ,
.
: , Web-, DNS-cep
.. UNIX
:
UNIX- -
. ,
.
UNIX ,
Windows, "" .
, UNIX.
, ,
UNIX, , Windows-.


Microsoft
(service packs).
, .
(, )
(hotfixes), Web- Microsoft.
, FreeBSD ,
, , , ,
. FreeBSD ,
, ,
.
CVSup ,
.
FreeBSD, ,
(patches).
.
, FreeBSD Security Officer (, ), , .
.
. , -.
, ,
. make world, 18.
, FreeBSD,
.
, 18,
RELEASE, ,
, .

374

3. FreeBSD

Linux
, Linux FreeBSD, Windows NT/2000.
UNIX,
.
(, FreeBSD
Linux). ,
, .
Linux FreeBSD , , , , Windows.
Linux FreeBSD:
12

13

14

15

16

17


FreeBSD? : ,
, /usr/local. FreeBSD
, ""
(/usr/bin, /var/lib ..). . 20.2 . ,
Linux.
20.2 Linux FreeBSD

Linux

FreeBSD

Apache

/var/lib/apache

/usr/local/www

Apache

/var/lib/apache/conf

/usr/local/etc/apache

/var/lib/apache/sbin

/usr/local/sbin/

Sendmail

/usr/lib/sendmail

/usr/sbin/sendmail

MySQL

/var/lib/mysql

/var/db/mysql

/etc/rc.d

/etc/re.*

/etc/rc.d

/usr/local/etc/rc.d

/usr/bin

/usr/local/bin

/usr/lib

/usr/local/lib

/usr/share

/usr/local/share

20. FreeBSD 375

RPM (
Linux ) / FreeBSD,
.
(Linux System V,
FreeBSD, , BSD).
FreeBSD 15.


Ext2FS, Linux,
DOS: BIOS,
" ", ""
. "",
. ( !), .
FreeBSD : BIOS,
(slice), , ( BSD).
, ,
.
, . 19.
FreeBSD UFS/FFS. Linux
FreeBSD , FreeBSD Ext2FS. ,
, 17.


, Linux, ,
RPM. FreeBSD,
( ,
, /usr/lib).

FreeBSD (pkg_*) .

, Linux UNIX,
.
FreeBSD . ,
, , .
(committers).
15.


FreeBSD , Linux: , .
Linux .
.
, Linux-,
. -

376

3. FreeBSD

,
.
,
FreeBSD CVSup, 18.
(hotfixes) ( Linux RPM,
) FreeBSD
: .

( )
, ( ].
"" , ,
make world (. 18].
, , ( /usr/lib]
(/usr/include) /usr/bin
/usr/sbin.


Linux FreeBSD (shadow passwords).
10. FreeBSD /etc/master.passwd
, a /etc/passwd ( ).
Linux /etc/shadow ,
. /etc/passwd
/etc/shadow Linux-, master.passwd
FreeBSD.
. Perl,
20.1 ( CD- mkpasswd.pl).
20.1
Linux FreeBSD
#!/usr/bin/perl
5
bash FreeBSD- (
6
), /bin/csh
$newshell = "/bin/csh";
open (PASSWD,"/etc/passwd");
@passwd = <PASSWD>;
close (PASSWD) ;
open (SHADOW,"/etc/shadow");
@shadow = <SHADOW>;
close (SHADOW);
foreach $user (@shadow) {
@sdata = split(/:/,$user);
$passhash(@sdata[0]} = @sdata[l];

# /etc/passwd
# /etc/shadow

#
#

}
foreach $user (gpasswd) {
@pdata = split(/:/,$user);
@pdata[6] = $newshell."\n" if (@pdata[6] eq "/bin/bash\n");
@pdata[l] = $passhash{@pdata[0]};
# ""

20. FreeBSD
splice (@pdata,4 ,0 ,undef , "" , "") ;
foreach (gpdata) {
print " $_" ;
print ":" unless ($_ =~ /\n/) ;
}

377

#
#

root Linux, : % ./mkpasswd.pl > new. master . passwd


new.master.passwd FreeBSD- /etc
(pwd_mkdb ). , - /etc/
master. passwd FreeBSD. , 15 ,
( daemon, bin, news ,
Linux FreeBSD ).
/etc/master.passwd new.master.passwd.
/etc/master.passwd. ,
pwd_mkdb hash-:
# pwd_mkdb -p /etc/new. master .passwd

, . , root.
. ,
pwd_mkdb, ,
.


Linux FreeBSD .
:
10 FreeBSD System.map. Linux

(jump vectors)
. FreeBSD ,
.
11 FreeBSD tcsh,

bash. , tcsh csh , .. . bash,


.
12 Linux ( )

/compat/linux, , Linux- .
linux.ko ( kldstat). "" Linux. ,
. , FreeBSD, .

378

3. FreeBSD

FreeBSD
root. /etc/ttys
(. 10).
5.0 FreeBSD DEVFS
/dev, "" .
, DEVFS, 17.
PCI FreeBSD , . PCI
"" . Linux ,
, , "" . , Ethernet
ethO ethl Linux FreeBSD , ,
fxpl fxpO.
, Linux FreeBSD
.

"" " "


,
, .
.
, :
.
, , ,
"" . ,
freebsd-ports@freebsd.org. , ,
.
(, ) .
setuid, , , .
CVSup.
, ( ).
sudo (/usr/ports/security/sudo) .
, sudo ,
.
ntpd ntpdate .
/etc/rc.conf:

20. FreeBSD

379

ntpdate_enable="YES"
ntpdate_f lags="tick.usno.navy.mil"
xntpd_enable="YES"

NTP- ntpdate,
, . ntpd,
NTP-, /etc/ntp.conf.
man ntp.conf.
13 , FreeBSD. 15 ( Linux;
Microsoft ).
14 , .
? ,
. ,
, , Web- ,
, . ,
. 29.
15 FreeBSD.
, freebsdsecurity@freebsd.org. freebsdports@freebsd.org freebsd-questions@freebsd.org.
STABLE CURRENT, freebsd-stable@freebsd.org
freebsd-current@freebsd.org.
16 log-. httpd-access.log httpd-error.log, Apache, ,
Web- .
Apache rotatelogs n, log-. /var , ,
,
.
"".
:
.
, , , Soft Updates
. . , ,
.
PortSentry
. -

380

3. FreeBSD

IP-, .
,
IP-, "" .
shutdown
(, ),
securelevel 1 . .
boot -s .
. !
. ,
, 350-, ,
. .
( ) wheel !
root .
. ( ,
, ,
, \ Document.txt), , ( , ).
Perl
Windows-, FTP.

, ,
(, #!/usr/bin/perI) . CGI- , , , ASCII-.
. .


FreeBSD
, .
,
, , Linux Windows.
, FreeBSD .
. , FreeBSD
, ,
-.
FreeBSD .

20. FreeBSD

381

. ( 17), .


,
. GENERIC
,
.
, .
, MAXUSERS (
32). ,
(
), ,
( , NMBCLUSTERS ..).
MAXUSERS 128 256 (
).

NMBCLUSTERS, (MAXUSERS * 1) + 512,


( netstat -m).
, , MAXUSERS
, NMBCLUSTERS ,
, 16384 32768. :
.
/boot/loader.conf kern.ipc.nmbclusters="16384".

Soft Updates
, FreeBSD
, (synchronous writes). ,
,
.
, .
, ,
, "" .
, , .
9 Soft Updates, ,
, .
- (I/O)
.
Soft Updates GENERIC
.
tunefs.
FFS, FreeBSD. tunefs
, ,
, , -

382

3. FreeBSD

. tunefs /sbin, .
( boot -s ). :
tunefs -n enable / tunefs n enable /usr tunefs -n
enable /var

. ,
/sbin/tunefs tunefs.
( Soft Updates)
,
.
, .
, (
).
,
, async mount /etc/fstab.
mount, , :
# mount - async /usr /dev/adOslf

async
/etc/fstab, :
/dev/adOslf

/usr

ufs

rw,async


FreeBSD,
. , ( ,
, ), -
.
,
. , ( , , -,
-:
, ,
).
, . ,

. , :
, ( ,
). /var, /usr /home (,
).

20. FreeBSD

383

UNIX , , , , . ,
, 256 512 .
,
.

sysctl
sysctl (,
kern.ipc.nmbclusters, ).
. /etc/sysctl.conf,
.
/etc/sysctl.conf .
:
vf s.vmiodirenable=l
kern.ipc.maxsockbuf=2097152
kern.ipc.somaxconn=8192
kern.ipc.maxsockets=l6424
kern.maxfiles=65536
kern.maxfilesperproc=32768
net.inet.tcp.rfc1323=l
net.inet.tcp.delayed_ack=0
net.inet.tcp.sendspace=65535
net.inet.tcp.recvspace=65535
net.inet.udp.recvspace=65535
net.inet.udp.maxdgram=57344
net.local.stream.recvspace=65535
net.local.stream.sendspace=65535

, , ,
. , /etc/
sysctl.conf, sysctl :
# sysctl vfs.vmiodirenable
vfs.vmiodirenable: 0

, -w:
# sysctl -w vfs.vmiodirenable=l
vfs.vmiodirenable: 0 -> 1


man tuning.
,
, ,
.
man tunefs tunefs
Soft Updates, , FFS. , man

384

3. FreeBSD

sysctl
.

:
, ,
- ,
, .
, ?
,
. ,
, . ,
.


-
, ,
. -,
.
/etc/rc.conf. .
/etc/master.passwd. .
.
/etc/mail/myconfig.mc. sendmail.
.
etc/fstab. .
/usr/local/etc/*.
.
, .
, , .
tar-
(, FreeBSD-).
, :
# tar cvfz /etc/rc.conf /etc/master.passwd /etc/fstab /usr/local/etc |
uuencode seedflies.tar.gz | mail -s "Seed Files" me@myaccount.com

/etc/periodic/daily crontab -
root.


.
, ,
. ,
, .

20. FreeBSD

385

,
.
UNIX
dump. dump, /etc/ fstab (.
9). "" ,
, -
.
.
, .
(/dev/rsaO ),
,
. ,
, SCSI.
SCSI-. Fire Wire (IEEE 1394).
, - IDE/ATAPI.
, , FreeBSD !
dump ,
.

/home:
# dump -Ou -f /dev/nrsaO /home

0 0 (.. ),
/etc/dumpdates. ,
dump, "" ,
.

nrsaO rsaO , "" . ,


. , SCSI-, , dump . .
. 20.3.
20.3

/dev/saO

/dev/rsaO

dump

/dev/nrsaO

dump

/dev/ersaO

dump

"" ,
, dump:
#

dump -lu -f /dev/nrsaO /home

386

3. FreeBSD

dump ,
. ,
3, 4, ,
3.
2, , - 3 4,
. , . 0
, ,
.
:
0, 1,
( ). .
. man dump.

restore.
.
, , .
cd, restore
:
# restore

-if

/dev/nrsaO

: cd, Is, pwd, add, delete .


,
( add). (
) delete. extract ,
.
restore man restore.
restore> add frank
restore> extract

:
# restore

-rf

/dev/nrsaO

,
. , -
. ,
,
. mt (magnetic tape
).
, , . , , fsf
(fast forward ):
mt -f /dev/nrsaO fsf 2

fsf 2 mt , ..
.
( mt) fsf:

_____________________ 20. FreeBSD

387

mt -f /dev/nrsaO rewind mt
-f /dev/nrsaO fsf 1

dump restore ,
. : -s
restore
, mt,
, .
, dump restore,
http:// www.nethamilton.net/dump.html. ,
dump, restore mt.


. , .
, (, ). , .
,
,
FreeBSD-, . - ,
.
CVSup.
, -
. CVSup
,
. , CVSup.
, : /home,
usr/local/www, /var/mail /etc. , , .
, cvsupd (
/usr/local/sbin cvsup), , .. .
root, :
#
#
#
#

cd /usr/local/etc
mkdir -p cvsup/sup
cd cvsup/sup
mkdir home www mail etc

:
.cvs releases. "" cvsupd
. home home.cvs
:
upgrade home
rsymlink

388

3. FreeBSD

releases :
home list=home.cvs prefix=/

,
.cvs .
cvsupd:
# cvsupd -b /usr/local/etc/cvsup - 1 -1 /dev/stdout

, .
/etc mirror-supfile ( ).
20.2, serverl.hostname.com
.
20.2 CVSup (mirror-supfile)
*default
*default
*default
*default

host=serverl.hostname.com
delete use-rel-suffix
compress
preserve

*default base=/usr
*default release=home
home
*default base=/usr/local
*default release=www
www
*default base=/var
*default release=mail
mail
*default base=/usr
*default release=etc
etc

: /etc
/etc, /usr/etc. ! , CVSup .
mirror-supfile .
CVSup :
# cvsup -L 2

/etc/mirror-supfile

, ,
.
Ctrl+C. CVSup , . , , .
.
/usr/etc ,
master.passwd pwd_mkdb
( "

20. FreeBSD

389

Linux"). , . CVSup , .
, !
- , , CVSup
. CVSup 4-5 15 ,
,
/etc/periodic/daily crontab root.
. , -L.
. /usr/local/etc/cvsup/sup
mirror-supfile. cvsupd
.
,
. ,
, , . , , FreeBSD .
. , , .

21

Perl

Perl?
Perl FreeBSD
Perl
Perl
Perl
, Perl

21. Perl

391

UNIX Internet
Perl. "", Perl . Perl , ,
, .
, ,
Perl ,
. , , Perl
, C++ ( FreeBSD
).
Perl .

Perl?
Perl , , , . FreeBSD
.
"Practical Extraction and Report Language"
( ). Perl
(Larry Wall)
awk. , .

Perl 6.
Perl . , , , "" ,
Perl. , Perl ,

( ) . ,
, , Perl
FreeBSD , Internet.

Perl FreeBSD
, FreeBSD,
Perl. , , C++ -
. , -, , , "", ..
. Perl . ,
-, Perl /usr/bin/perl.
13,
/bin/sh.
. Perl .
, -

392

3. FreeBSD

" "
(batch programs, MS-DOS). , ,
. A Perl
,
, Web- .
Perl , ,
, ( ). Perl
, ,
, , adduser,
, .
Perl FreeBSD. ,
, adduser, pkg_version sockstat. ,
, , majordomo (
). ,
Perl, .
Perl , , , .

Perl
Perl
( ) (
). ,
, , , ,
-, ,
, ,
, ,
. Perl ,
.
Perl , -
CGI- Web- .
Internet ,
.
Perl :
, , , ,
. Perl
, , - . Perl
,

.
Perl
. ,
" " , .
, ( Internet -

21. Perl

393

),
. Perl , Linux, IRIX, Windows FreeBSD.

Perl
Perl
. .
, Perl .
Perl ,
, .
Perl , , ,
. , ,
, , , ,
. Perl
" " .
PYTHON , PERL
Perl ,
. (REBOL, Java, Ruby ]
, Perl " " .
, , Python.
Pytyon -, Perl, .
, ,
. ,
Python "" ((
""), , Perl.
Perl ( ) , a Python ( .)
, .
, -
. Python , Perl,
. ,
, Perl.
Python FreeBSD,
/usr/ports/lang/python. Perl ,
Python , , Python /usr/bin
.

Perl
Perl ,
13. ,
:
#/usr/bin/perl

( ) ,
, , , .. :

394

3. FreeBSD

#!/usr/bin/perl
$string = "Hello world!";
$hostname = 'hostname';
if ($hostname eq "uncia")
print $string."\n";
print "date';
}

, if
"if/fi" "case/esac". ,
(;), .
: "$ = 1"
, "$=1". Perl ,
. , Perl ,
.
Perl ,
: ,
.. Perl
"" .
. Perl , ,
,
(, adduser majordomo).
Perl, chmod:
#

chmod +x myscript.pl

, 0755 (
10):
-rwxr-xr-x

1 frank

frank

170 Jun 14

2000 myscript.pl*

, , ./ "." (.. ), , :
# ./myscript.pl
Hello world!
Sat Apr 28 15:29:17

PDT 2001

Perl , , , . ,
perl:
#

perl myscript.pl

perl . -w
. , :
#

perl -w myscript.pl

#!/usr/bin/perl -w


Perl , . .

21. Perl

395

( ),
, Perl "" (literals). ( ) ($).
Perl , , (, ..).
, . Perl . ,
. Perl ,

. , , , , , "123blah" "123".
: (+, -, =), (++ ),
(+=, -=, *=), (**),
(%), (>, <, =>, =<, == !=),
(.), (). , Perl
, . , Perl,
.
, , (literals) :
$ = 5;
$++;

$b = $ ** 2;
$ = "test" . $b;
print "$c" ;

"test36". , , Perl.

,
. $, $b $
. .
.
:
@arrayl = ("blah",5,12.7,$);
@array2 = ($, $, $) ;

, , , "at" (@), .
,
. , ,
..
.
@!
$![2]. , !

396

3. FreeBSD

@, $. , , , @1[1,2]. ,
. @1[2]
, . ,
, $1[2].
. .
"". ""
push( ), pop( ), shift( ) unshift( ). . 21.1,
@arrayl.
21.1

push( )
( )
unshift( )
shift( )


push(@array1,"test");
@array1 =

("blah",5,12.7,6,"test")

$d = pop(@array1);
@array1 = ("blah", 5, 12. 7, 6),

$d = "test"

unshift(@array1,"test"); @array1 =

("test", "blah", 5, 12. 7, 6)
$d = shift(@array1);
@array1 = ("blah", 5, 12.7,6),

$d = "test"

, ,
( ] . , =
push(@array1, "test") , [@1] .

sort( ).
sort(@arrayl) , .
, sort( ). ,
numerically(), sort numerically (@arrayl).
/etc/passwd, . ,
. , .

, " ". :
$size = @arrayl;

Ssize 4.

21. Perl

397

split( ).
, -.
$mystring = "Test|my name | Interesting data|123";
@mydata = split {/\ | / ,$mystring) ;

, -
, (|) ,
, ,
. @mydata
"Test", "my name", "Interesting data" "123".
(associative array).
(hash table),
.
(%), , , , $. :
$assocl{ keyl}
$assocl{ key2)

= "valuel";
= "value2" ;

- :
@myvalues = values (%assocl) ;
while ( ($mykey,$myvalue) = each (%assoc1 )) {
print "$mykey -> $myvalue\ n" ; }

, CGI, HTML-
,
.


Perl , "" .
.

if/ elsif /else


if:
if ($a = = 5) {
print "It's 5\n";
} elsif ($a > 5) {
print "Greater than 5\n" ;
} else {
print "Must be less than 5\n" ;
}

, ($ == 5) ==, =. == -

398

3. FreeBSD

. , , -
: eq ==, It <, n != ..

foreach
Perl foreach. .
foreach $line (@gbuffer)
print $line;
}

, ($line
), , $_,
.
foreach, , .
for
Perl for, . for ,
. for ( ,
),
. , ,
: , :
for ($i; $i<100; $i++)

print "$i\n";
}

100 , 0 99.
$i,
(.. , ), ,
.

while/until/do
, Perl while, for
. , .
, .
while ($i < 100)
$i += 5 ;

$j++;
}
print "$j\n";

20 print 20.
until, : , .
, :
until ($i == 100)
$i += 5;

21. Perl

399

$j++;
}
print "$j\n";

: do...while do...until.
, ,
, :
do {

$i += 5;

$j++;

}
while ($i < 100) ;
print "$j\n";

(` ) Perl-
,
. Perl
, /bin/sh
. ,
, :
$date =

`date`;

, , , \n, chomp( )
, , :
chomp($date =

`date`);

, Perl "" .
, ,
-
. :
@who = `/usr/bin/who`;


Perl
-. ( )
- @ARGV. :
# ./myscript.pl test "My String" 123

, @ARGV[0] "test", @ARGV[1] "My String"


@ARGV[2] - "123". CGI-,
26. URL , + (
), @ARGV
:
http://www.some-host.com/myscript.cgi?test+My%20String+123

400

3. FreeBSD

Perl
, 21.1, , .
- simpledemo.pl.
21.1 Perl (simpledemo.pl)
#!/usr/bin/perl
#<STDIN> -,
# .
# , .
#chomp / ,
print "Please enter your name: " ;
chomp ($name = <STDIN>) ;
srand;
# .
@namelist = ("Bob","Jane","Frank");
@colorlist = ("green","red","blue","yellow");
foreach $testname (gnamelist) {
# rand().
$colors{$testname) = $colorlist[rand(@colorlist)];
}
while (($name,$color) = each(%colors)) {
print "$name: $color\n";
undef ($n);
# undef() .
# NULL.
do {
$color = @colorlist[$n+l];
$n++ ;
} until ($color eq "blue");
}

Perl
Perl,
.
, ,
Perl . .


( regexp regular expression) .
, ,
, ,
.. UNIX,
, , grep,
. Perl , grep,
.
. , ,
..

21. Perl

401


.
= ~,
:
if

($string =~ /abcl23/)

...

, , ,
< >,
, ( o
). $_ ( "
", foreach),
:
if

(/abcl23/)

...

. "abc123"
, , .
^: /^b123/.
: $.
.
, , , "abc!23" :
if

(/^123$/)

{ ...

.
"" , [abc], a, b ,
, ,
.
( ) . 21.2.
21.2

[abc123]

"abc123"

[^abc123]

"abc123"

[-g]

abc1|abc2

: abc! abc2

(abc123)

( ,
)

( > 0)

1 ( > 1)

*?

*,

402

3. FreeBSD

{m}

{m,n}

n m

{m,}

\b


Escape-

(.. , ) X
(,".")

\r

\n

\f

\t

\d

( [0-9])

\w

, ( [a-zA-ZO-9_ ] )

\s

( [\r\t\n\f])

\D

HE

\W

HE

\S

HE

\###

ASCII- ### ( )

Control+X ( X )

,
, , , .

,
. . , i
: /abc/i.
,
UNIX-.

, ? Perl "": s///,


"" tr/// , , substr( ).
=~,
, . , , -

21. Perl

403

s, , - . :
$mystring =~ s/^test[0-9]/foo/g;

, HTML- :
$myhtml =~ s/</&lt;/g;
$myhtml =~ s/>/&gt;/g;

g , c
. , .
, ([0-9]) ?
. ,
,
. \#, #
, . , ,
/abc(123)(.*)\l\2/, \1 123, \2 .*. , 0, 1. .
,
, , \1 \2, $1
$2. , ,
,
. :
$mystring =~ s/^test([0-9])/foo$l/g;

, ,
, , , .
tr///.
tr s.
( ,
).
. , tr =,
=~. :
$mystring = "cat and dog";
$mystring = tr/abc/def/;

Smystring fdt dnd dog.


, ,
. ,
.
d, "" ,
.
, tr
. :
$mystring = tx/A-Z/a-z/

, Smystring .

404

3. FreeBSD

substr( ). Perl.
, . :
$mystring = "cat and dog";
$newstring = substr($mystring,0,3);

Snewstring "cat".
substr( ) index( ). , :
$mystring = "cat and dog";
$newstring = substr($mystring,index($mystring,"cat"),index($mystring,"dog"));

Smystring "cat and " ( ).


(filehandles) , , .. , .
(diamond
operator) ( ).
( ) (
). , ,
:
while

(< >) {

print

$_;

, :
# ./myscript.pl filel.txt file2.txt ...

, cat.
.
, .
.
n( ). ,
. , :
open (FH,"/path/to/filel.txt");
@contents = <FH>;
close

(FH);

, Perl , ,
, . die: die, ( ) .

21. Perl

405


- :
open (FH,"/path/to/filel.txt")
@contents = <FH>;
close

|| die ("Can't open filel.txt!");

(FH);

, . ,
, .
> () >> ()
|, . , ,
.
open (FH,">/path/to/file2.txt");
print FH $_ foreach (@contents);
close (FH);
open (MAIL,"| /sbin/sendmail -oi -t");
print MAIL "From: me\@somewhere.com\n";
print MAIL "To: you\@somewhereelse.com\n";
print MAIL "Subject: Check it out!\n\n";
print MAIL $_ foreach (@contents);
close (MAIL);

, @, ( , ), , Perl
. .

print. ,
<STDOUT>
( ), .
<STDIN>. /
, select( ):
select

(FH);

print FH. FH STDOUT .


opendir( ) readdir( ).
, :
opendir
(DIR,"/path/to/dir");
@files = sort readdir (DIR);
closedir (DIR) ;

, . , /etc/passwd, , 1000,
.
#!/usr/bin/perl
open (PASSWD,"/etc/passwd")
@passwd = <PASSWD>;
close (PASSWD);

|| die ("Can't open passwd file!");

406

3. FreeBSD

foreach (gpasswd) {
@userdata = split(/:/,$_);
if (@userdata[2] > 1000) {
print "@userdata[0]:

guserdata[4]\n";

}
}

He , !
Perl .
, ,
.

Perl , .
. Perl.
, Perl ( , CGI-), ( Perl
).
. ,
"".
, ,
. :
sub sum {
$mysum += $_ foreach (@_) ;
$mysum;
# $mysum
# ,

}
(
):
$newsum = &sum(45,14,2134,89);

@_ , @ARGV , .
( ), :
sub printname {
($name, $number, $passwd) = @_;
print "$name/$number" if ($passwd);
}

, ,
. Perl : . , , , (, local( )). @_
. .
local( ), , :

______________ 21. Perl

407

sub sum {
local($mysum);
$mysum += $_ foreach (@_) ;
$mysum;
# $mysum , ,
# ,
}

. , .
:
my

($mysum,

$name,

$hash);

Perl " " (strict mode), ,


, ,
.
, Perl, ,
.
.

Perl

, Perl . , Perl (
) Perl-
.m ( Perl module - " Perl"). ""
Internet , , ,
FreeBSD. Perl . .
.m Perl (, mylib.pm)
, , use ( .m
):
use mylib;

FreeBSD Perl /usr/lib/perl5. Perl


. ,
/usr/local/lib/perl5. :
man (
Perl), (site_perl). (
) ,
. , i386-freebsd,
,
Perl (,
).
: ,
(::) . C++. ,
Net::TeInet Perl,
Telnet, a Net::DNS .
/usr/local/lib/perl5/site_perl/5.005 Net
Telnet.pm DNS.pm.

408

3. FreeBSD

Perl.
use: use Net::Telnet;
,
, &.
, ?
perldoc. man, ,
(, ), , . Image::Size (.
21.2):
21.2 Perl
# perldoc Image::Size
Image::Size(3) User Contributed Perl Documentation Image::Size(3)
NAME
Image::Size - Image::Size (
)
SYNOPSIS

use Image::Size;
globe.gif
($globe_x, $globe_y) = imgsize("globe.gif");
# , =60 Y=40
use Image::Size 'html_imgsize' ;
# "HEIGHT=X WIDTH=Y"
# HTML-
$size = html_imgsize("globe.gif");
# $size = "HEIGHT=40 WIDTH=60"
use Image::Size 'attr_imgsize';
# ,
# CGI.
@attrs = attr_imgsize("globe.gif");
# @attrs == ('-HEIGHT', 40, '-WIDTH', 60)
use Image::Size;
#
($buf_x, $buf_y) = imgsize($buf);

, ,
, ,
.

Perl
"" Perl? ,
! /usr/ports .
, 5-. Perl,
FreeBSD. (
.) ,
, ,
. .

21. Perl

409

, /usr/ports/net/p5-Net-Telnet Net::Telnet.
:
.
Perl. ,
. Perl , , , .
,
: cd make make install. Perl make test,
, .
make.
Perl pkg_info
pkg_version. , /usr/local/lib/perl5.
: pkg_add tar, a pkg_update .

, Perl
Perl , ,
, .
"" Perl.

Web-
Perl,
Internet. , ,
.

www.perl.org
www.perl.org Web- Perl Mongers ( Perl).
. , , ,
, , www.perldoc.com,
Perl.

www.perl.com
"" Web- Perl, O'Reilly.
, Perl. , , ,
Perl, .

, Perl,
Perl O'Reilly.
, .
410

3. FreeBSD

("Camel" Book)
Perl (Programming Perl)
, (Larry Wall) ( Perl), (Tom Christiansen) (Jon Orwant) ( O'Reilly,
2000). Perl. , Perl,
"" .
.

("Llama" Book)
Perl (Learning Perl), .
(Randal L. Schwartz) (Tom Phoenix) ( O'Reilly, 2001), -

"" . .
Perl ( ,
). ""
, Perl.

Perl (Perl Developer's Dictionary)


Perl (Perl Developer's Dictionary),
(Clinton Pierce) ( Sams, 2001),
Perl.
. Perl,
,
Perl.

CPAN
CPAN (Comprehensive Perl Archive Network, Perl)
. , ,
, .
. ,
, ( ), ,
.
CPAN http://www.perl.com/CPAN-Iocal/.
CPAN ,
.

FreeBSD

Internet

Web-

FTP-

lnternet-

DNS-
NFS

Microsoft
W in dow s
DHCP-

22


TCP/IP
IP-agpeca



DHCP

22. 413

,
.
UNIX- (.. ), , AIX, IRIX, Digital UNIX, BSDI,
Novell NetWare VMS. ,
Windows Mac OS. ,
, ,
,
.
.
. Mac OS X ( FreeBSD
Mach) Windows 2000/XP ,
. ,
. TCP/IP, Internet,
,
FreeBSD.
FreeBSD, ,
. , ,
. FreeBSD-, , , , .
FreeBSD, Internet.



. Internet
: , HTML- , ( ), m. , ,
,
.
. , Internet .

() TCP/IP. TCP/IP, ,
.
.
ARPAnet ( ),
, 1969 .
TCP/IP 1974 , ,
"
", Internet (Vint Cerf)
(Bob Kahn). . TCP (Transmission Control Protocol -

414 4. FreeBSD

) IP (Internet Protocol ).

,
. , 1977 , Bell Labs
UNIX-,
. , UDP (User Datagram Protocol,
) ICMP (Internet Control Message Protocol, Internet).
TCP/IP Internet
.
, (WAN).
(LAN),
, , . , -
Ethernet.
TCP/IP .
TCP/IP . 4 : , ( ), (Internet) . , , FTP, Telnet, NFS DNS. TCP UDP .
IP (Internet Protocol) RIP (Route Information Protocol). . -,
TCP/IP-
FreeBSD.


,
, ..
. FreeBSD- :
, , -,
, Internet
( ).
22.1 ,
.

1, , DSL ( ).

(33-56 /)
-48 -192,
. -
22.1.

25. 415

22.1 , ,
, .

22.1

56 /

ISDN

56 128 /

DSL

192 / 1,5 /

1 5 /

1,5 /

24 DSO

43,2 /

28 1

-3

155 /

100 1

-12

622 /

4 -3

-48

2,5 /

4 -12

-192

9,6 /

4 -48

.
, , "",
,
- .
Internet-,
, , ,
, . 22.2.
DSU (Data Service Unit,
) CSU (Central Switching Unit, )
, ,
, Ethernet.
, , .

416 4. FreeBSD

22.3 .
Internet-, - , . ,
, . ,
,
.

22.2

,
Internet-:


,
Internet
1.

22.3


Internet

.

25. 417


.
. , , .

Ethernet- ,
, : 10 / Ethernet, 100 / (Fast Ethernet) 1 /
Gigabit Ethernet.
.
Ethernet- ( ).
, , , Ethernet-,
, .
Ethernet 22.2.
22.2 Ethernet-

, /

10Base-2

Ethernet

10

185

10Base-5

Ethernet

10

DB-15,
DIX/AUI

500

10Base-T

Ethernet

10

UTP
RJ-45
3, 5

100

100Base-TX

Fast
Ethernet

100

UTP
5

RJ-45

100

1000Base-T

Gigabit
Ethernet

UTP
5

RJ-45

100

1 /


DIX: Digital, Intel, Xerox
AUI: Attachment Unit Interface
BNC: Bayonet Nail Concelman ,
British Naval Connector - UTP:
Unshielded Twisted Pair

Ethernet . ,
. , ,

418 4. FreeBSD

.
( 50 ),
. , , ,
.
, . Ethernet
"",
. ,

"" .
,
, - , RJ45 (
).

22.4



: (RJ-45),
(DB-15)
(BNC) Ethernet.



. BNC-
,
.
. ,
RJ-45
.
.


RJ-45
(Straight-through and Crossover Cables).
.
?
, -.
RJ-45 :
(). , , . , .
,
. .
,
( ) ,

22. 419

. :
,
.
uplink-,
.
.
,
.
, .
,
.
- ,
, . - uplink-,

. , -
uplink- - .
, , ?
, .
,
, .
. 22.5, . 22.6.

() ,
. RJ-45, , 4
24, .
$40 , ,

420 4. FreeBSD

10base-T
100base-TX.
( 10 /, 100 /). , (N-Way), .
, 19- ,
.
. :
telnet, , ,
. ,
.

. hub ,
, concentrator
, .
, , ,
.

, ..
. , ,
, ,
. , uplink-, , ,
.
(upstream device). Uplink- ,
, .. uplink-, . , 5-
4 , (uplink-
), 3
( ). DIP-.
.
, .

(Half Duplex) (Full Duplex).
, , .. .
. , Fast Ethernet 100 / ,
100 / .

(switch) , ,
, . , , RJ-45. ,
.

22. 421

, ,
. ,
.
. , , , ,
, ,
(collision domain). ,
. , , ,
. , : , ,
, .
, .
,
. ,
. .
. , , ,
, .
,
.
,
.
ARP- .
,
. ,
. ,
. ,
(telnet) . ,
.
( ) . , 8-
100base-TX ,
100 /, 8 . , ,
, .
( OSI).
,
100 /. . , 8- 100- 100 /
, 8- 100- 800 /.
, .
, , ,
""
. , - (tcpdump EtherPeek),

422 4. FreeBSD

promiscuous mode,
, .
. ,
. (
, )
. , , ,
, - ,
.
, , , uplink, ( )
, ,
. :
,
, uplink-
.

(bridges) , , . . ,
4- TCP/IP.
, ,
, ,
.
, , ,
Ethernet Token Ring.

(routers) .
, , .
, ,
. ,
( TCP/IP).
. ,
, .

, ,
.
,
, .
""
. ,
,

22. 423

. ,
Internet. 28.

RJ-45 AUI, .

/ DSU/CSU
, (1,
). , : , , ,
. , ,
.


, Internet- TCP/IP, . ; ,
. IP Internet-.
Internet-.
OSI (Open Systems Interconnection). Internet-
.
TCP/IP TCP, ,
.
, ICMP, ping
traceroute.
.

TCP: Transmission Control Protocol


TCP UDP . , TCP
,
, , , . , TCP .
, TCP , ( ). TCP-
(Acknowledge ).

. -
, ""
, , .
, ,
( ,
).

424 4. FreeBSD

TCP
,
. , TCP
, ,
,
, ,
. UDP .
, TCP ,
/ .
, , HTTP- Internet,
FTP ..

UDP: User Datagram Protocol


UDP .
. , UDP-
, .. ,
, .
, UDP-
, .
UDP- ,
"" ,
. , UDP-
, . , NFS,
, ,
, UDP-,
31. , ,
UDP? ,
NFS-
, .
TCP ,
UDP,
NFS. , UDP- , NFS
( ).
UDP . , , , , .
-,
-
. , ,
, .
, (
- / ).
,

22. 425

.
, .
UDP .

ICMP: Internet Control Message Protocol


ICMP ,
, IP IPX; ,
TCP UDP. : ICMP
, . , ICMP-
, IP-,

.
ICMP .
ping traceroute,
, ICMP.
ICMP ,
,
. - (echoreply). , ICMP
, , UDP-
, (Port Unreachable),
UDP- () . ICMP 16
.

TCP/IP


?

TCP/IP


, ,
-


. 22.7


,

(
),

,
( ).
,
, . TCP-, UDP, ,

( ).
, IP-
, -

426 4. FreeBSD

IP- .
, (
)
. - .
, ,
( ).
. ,
, ,
, .
.
, , , -.
,
IP- .
, , , ,
FreeBSD.
TCP/IP, Addison-Wesley, 1994.
,
,
.

IP-
IP-
Internet, ,
. , IP- , , ,
.
IP- 32- , IP-,
: . 32-
8 , ..
0 255. : 111.112.113.114.
IP-, , , (, ).
, IP- ,
. ,
IP. , ,
IP-, IP. ,
, IP-.
(..
). , Ethernet-, -
802.11.
IP- ,
, ifconfig,
22.1. - (-

22. 427

) . (, 10)
. inet IP; , !0 IP-
.
22.1 ifconfig _______________________
# ifconfig -a
xlO: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet
64.41.131.102
netmask
OxffffffOO
broadcast
64.41.131.255
inet6
fe80::201:2ff:fe55:1256%xlO
prefixlen
64
scopeid
Oxl
inet 209.154.215.246 netmask Oxffffffff broadcast 209.154.215.246
ether
00:01:02:55:12:56
media: autoselect (lOObaseTX) status: active
supported media: autoselect lOObaseTX <full-duplex> lOObaseTX
lObaseT/UTP <full-duplex> lObaseT/UTP lOObaseTX <hw-loopback>
1pO:
flags=8810<POINTOPOINT,SIMPLEX,MULTICAST> mtu 1500
gifO: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gifl: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gif2: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
gif3: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
loO:
flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384 inet6
fe80::l%loO prefixlen 64 scopeid 0x7
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask Oxff000000
pppO: flags=8010<POINTOPOINT,MULTICAST> mtu 1500
slO:
flags=c010<POINTOPOINT,LINK2,MULTICAST> mtu 552
faithO: flags=8000<MULTICAST> mtu 1500

IP-, . -,
, ,
64.41.131.0. 64.41.131 , , . ,
255. . ,
64.41.131.255 , 64.41.131,
64.41.255.255 , 64.41.

.
JNTERNET- (IPV6]
, , 32 ? , 232 4,3 .
, 30 . . ,
Internet, , , ,
. ,
4,3 . . . 256 , 16,7 .
. ,
16,7 . .
NAT (Network Address Translation
) IP-.
IP-,
.
. ,
,
IP- 32- .

428 4. FreeBSD
IP-,
IPv6. 128- ,
, IPv4. 3,4x1038
. , , ,
.
,
,
, IPv6, .
. FreeBSD
IPv6 ,
.

ARP -
IP-, , FTP- , , ,
. , IP-, ,
IP-.
TCP/IP, IP- .
, .
, ,
.
-,
, - (Media Access Controller).
-, . , - - .
, , ,
-. , , . , -, ,
IP-. .
.
, ifconfig, ether.
00:01:02:55:12:56, 3Com. 48- , . 6 2 800 000 000 000 000
, 30 . , .
. 3- , IEEE (Institute of
Electrical and Electronics Engineers ). 3 .
16,7 . ,
16,7 . .

22. 429

, .
, ( )
, , IP-,
. ,
-, IP-.
-
, IP-?
ARP.
ARP (Address Resolution Protocol) ,
IP- -.
IP- 10.5.6.100,
,
- ARP-,
IP- -,
. , 10.5.6.100
, ARP- ,
,
IP-.
IP-.
( 255 ff:ff:ff:ff:ff:ff).
, ,
IP- .
,
IP- 10.5.6.100
-, ARP-
. , 10.5.6.100,
.

, , ARP-.
ARP, , , ARP,
, . ARP, , ,
.

r
ARP TCP/IP.
,
ARP-. , r -:
# r -
w001.sjc-ca.dsl.cnc.net (64.41.131.1) at 0:0:5:7:7:fO [ethernet]
w013.sjc-ca.dsl.cnc.net (64.41.131.13) at 0:30:65:4:9:5 [ethernet]
w063.sjc-ca.dsl.cnc.net (64.41.131.63) at ff:ff:ff:ff:ff:ff permanent
[ethernet]

ARP- ,
. ( , IP, , ).
, , -

430 4. FreeBSD

, ,
IP-.
- .
,
IP-:
# arp -d w001.sjc-ca.dsl.cnc.net
# arp -d 64.41.131.13
# arp -d -a


TCP/IP, .
(netmask) , ,
() (), IP- .
( ARP-, TCP/IP-)
, , , IP- ,
.
32- , IP-,
255.255.255.0. IP-,
.
IP-, IP-. ,
64.41.131
64.41.131.45. IP-
, and,
, .
, .
, .
, TCP/IP.
( ),
, .. .
IP- ,
, ARP-.
,
. , 64.41.. (64.41 , .. ). R1
, ,
R2, 64.41.131.
64.41.132.. 64.41.131.
, 64.41.132 (. . 22.8),
,
255.255.255.0, .
255.255.0.0,
, 64.41.131. ,
64.41.132, , .
-

22. 431

, , (
, 255.255.0.0,
, 64.41.13l.xxx ,
64.41 13l.xxx!)
22.8

,

.


OxffffffOO (255.255.255.0) OxfffffcO (255.255.255.192), 64 1 64.
,
, CIDR (Classless Inter-Domain Routing ), ,
, . , 255.255.255.0 -
64.41.131 CIDR 64.41.131/24,
3 (24 ), 1. 255.255.255.192 CIDR
64.41.131/26, 26 ,
. ,
.

,
. , ,
,
portsentry,
29.
, , IP-
. FreeBSD
, ,
netstat -rn:
# netstat -rn
Routing tables

432 4. FreeBSD
Internet:
Destination
default

64.41.53.101/32

Gateway
Flags
hsrp-gw.netnation.UGSc
localhost

UGScB

net-64-40-lll.netn link#l

UC

ip6.somewhere.com
ip6.somewhere.com
hsrp-gw.netnation.
64.77.63.139/32

UHLW
UGScB
UHLW
UGScB

ip3.somewhere.com 0:50:b:b:98:13
ip4.somewhere.com 0:50:ba:b:95:bb

0:1:2:55:12:56
localhost
0:0:c:7:ac:le
localhost

Toronto-ppp218408.localhost

localhost
localhost
goo. cs.und. nodak. e localhost

OHLW
UHLW

UGScB

UGScB

Refs
126
0

2
0

0
0
119
0
0

Use Netif
1379327 xlO

Expire

3 loO

xlO =>

357107 xlO
2272 xlO

118941
0
8814
0

loO =>
loO
xlO
loO

735
500

405

0 loO

45 45210727 loO
0
0 loO

:
(Destination). IP-, ,
( FreeBSD CIDR) , , (default route). ,
, .
(Gateway address). , , , . IP-,
-, ( ), . FreeBSD link#l, ,
, ( ).
(flags). .
. ,
2 5 .
man netstat.
(Network Interface). ,
.
IP- R ( ). ,
Internet. ,

, , -
.
Internet, ,
. ,
, , , ,
.
. ,
, , IP. ,

22. 433

, , ,
, ,
.
,
, .
.
. - ,
.
, , ,
, ,
- .
,
,
(router loop):
traceroute to arclight.net (209.237.26.189), 30 hops max, 40 byte packets
3 r2-72-core-van.netnation.com (10.10.4.253) 101.878 ms 135.377 ms 85.218 ms
4 dis2-vancouver-atml-0-0-33.in.bellnexxia.net (206.108.110.189) 132.023 ms
80.653 ms
81.686 ms
5 core2-vancouver-posll-l.in.bellnexxia.net (206.108.101.45) 102.365 ms
61.537 ms
68.561 ms
6 core2-seattle-posl2-0.in.bellnexxia.net (206.108.102.209) 79.989 ms 109.389
ms
115.587 ms
7 bx3-seattle-pos5-0.in.bellnexxia.net (206.108.102.202) 86.434 109.678 129.128
12 seal-bellnexxia-ocl2.seal.above.net (208.184.233.73) 91.201 67.287 79.369
13 core2-corel-oc48.seal.above.net (208.185.175.178) 74.219 79.480 93.121
14 sjc2-seal-oc48.sjc2.above.net (216.200.127.117) 188.692 212.627 181.123
15 corel-sjc2-oc48.sjcl.above.net (208.184.102.25) 195.260 194.973 272.053
10 mainl-corel-ocl2.sjcl.above.net (208.185.175.246) 344.104 318.313
11 corel-sjc2-oc48.sjcl.above.net (208.184.102.25) 195.260 194.973 272.053
12 mainl-corel-ocl2.sjcl.above.net (208.185.175.246) 344.104 318.313
13 corel-sjc2-oc48.sjcl.above.net (208.184.102.25) 195.260 194.973 272.053
14 mainl-corel-ocl2.sjcl.above.net (208.185.175.246) 344.104 318.313
15 corel-sjc2-oc48.sjcl.above.net (208.184.102.25) 195.260 194.973 272.053
16 mainl-corel-ocl2.sjcl.above.net (208.185.175.246) 344.104 318.313
17 corel-sjc2-oc48.sjcl.above.net (208.184.102.25) 195.260 194.973 272.053
18 mainl-corel-ocl2.sjcl.above.net (208.185.175.246) 344.104 318.313

,
. ,
,
,
.

(Gateways and
Network Address Translation)
, ,
.

, .. . 22.8:
H1 2 ,
, .
R2.
H1 2 R1.

434 4. FreeBSD

. R2,
, ;
,
, .
, .
, .
NAT-, , , . NAT : , .
FreeBSD NAT-, natd, 28.


Internet , , -
, .. IP-. Internet ,
,
. ,
, IP- . .
DNS- ,
Network System Inc. , . DNS-
. FreeBSD BIND, DNS-
/etc/namedb.
30.
, ,
tiger Pluto, .
Internet,
tiger, somethere.com.
,
IP-. , . somethere.com
IP-, , IP ,
. , HTTP- www.somethere.com
64.41.131.45, FTP- ftp.somethere.com 213.11.31.221. ,
DNS TCP/IP.
.
: IP- , IP-.
, ARP IP- -, DNS
IP-. , , IP-, -.

22. 435

DHCP
, IP-
Ethernet-, 23 ,
DHCP (Dynamic Host Configuration Protocol,
).
IP- .
DHCP,
DHCP-. ( , ARP) . DHCP-
IP- ,
( ,
).
33.

23


sysinstall

IP-
IP- /etc/hosts
ping
DN5 /etc/resolv.conf

33.

437

, ,
, .


,
, IP . , , ,
IP-,
. ,
IP-.
,
. 23.1
, FreeBSD.
, ,
, 23.1 (PCI-, ). , FreeBSD
,
. , , (. /sys/1386/conf/NOTES).
17.
23.1 , FreeBSD
.
PC/ Cards
de

Intel DC21x4x ("Tulip")

vx

3Com 3c590, 3c595 ("Vortex")

PCI/Mil Cards
fxp

Intel EtherExpress Pro/100B (82557, 82558)

tx

SMC 9432TX (83c170 "EPIC")

wx

Intel Gigabit Ethernet Card ("Wiseman")

dc

DEC/Intel 21143 and various workalikes

pcn

AMD Am79C79x PCI 10/100 NICs

rl

RealTek 8129/8139

sf

Adaptec AIC-6915 ("Starfire")

sis

Silicon Integrated Systems SiS 900/SiS 7016

ste

Sundance ST201 (D-Link DFE-550TX)

tl

Texas Instruments ThunderLAN

vr

VIA Rhine, Rhine II

wb

Winbond W89C840F

xl

3Com 3c90x ("Boomerang," "Cyclone")

438

4. FreeBSD

ISA Cards
ed

Novell NE1000/NE2000, 3Com 3c503, Western Digital/SMC 80xx

ISA Cards
ex

Intel EtherExpress Pro/10 (82595)

ep

3Com 3c509

fe

Fujitsu MB86960A/MB86965A

ie
AT&T StarLAN 10 and EN100; 3Com 3c507; unknown N15210; Intel
EtherExpress
Inc

Lance/PCnet cards (Isolan, Novell NE2100, NE32-VL, AMD Am7990 and

Am79C960)
cs

IBM Etherjet and other Crystal Semi CS89xO-based adapters

sn

SMC 9000

PCMCIA Cards
wi

Lucent WaveLAN 802.11

an

Aironet 4500/4800 802.11

xe

Xircom/Intel EtherExpress Pro100/16

.
, ,
/ s ys / i 3 8 6 / c o n f / G E N E R I C .

PCI-, . , , IRQ, DMA ,


( ISA-).
ISA- .


sysinstall

sysinstall. ,
TCP/IP .
sysinstall, , /stand/sysinstall.
Configure , Media.
FTP FTP- : Running multi-user, assume that the network is already configured? ( , , ?)
No.
.
, FreeBSD . , , , .

S3.

439

, 1 ( )
SLIP - giro faithO. IPv6 . , ,
. fxpl,
PCI- Intel EtherExpress Pro/100B.
, : IPv6, DHCP. .
, 23.1.

23.1

sysinstall.


,
.
(Host). ,
. ,
www.somewhere.com, www.
(Domain). , ..
somewhere.com. ,
, - cslab.ivyleague.edu.
IPv4 (IPv4 Gateway). IP- ,
.
, ( ).
(Name server). IP- . , -.
IPv4 (IPv4 Address). IP-,
. ,
, IPv4 Gateway,
,
.
(Netmask). () () . IP- :
255.255.255.0, 255.255.0.0 255.0.0.0.

440

4. FreeBSD

. - , ,

. , ,
ifconfig, sysinstall.
, OK, , a sysinstall FTP-. ,
.
FreeBSD
,
, .
ISA-
-, PCI- .
, , ,
, ,
:
fxpO: <Intel PLC 10/100 Ethernet> port Oxde8O-Oxdebf mem Oxff8feOOO-Oxff8fefff irq 11
at device 8.0 on pcil
fxpO: Ethernet address 00:dO:b7:c7:74:fl
fxpl: <Intel Pro 10/100B/100+ Ethernets port OxdfOO-Oxdf3f mem Oxff700000Oxff7fffff,0xff8ff000-0xff8fffff irq 11 at device 9.0 on pcil
fxpl: Ethernet address 00:dO:b7:bd:5d:13

ISA- ,
. , ISA-
,
- .
0x300 280, IRQ 9 10.
, ,
.
DOS-, .
FreeBSD , , .
, ,
. MS DOS
, . ,
. ,
, FreeBSD.
, ,
17. /boot/device.hints, -.
:
hint.ed.0.at="isa"
hint.ed..port="0x300"
hint.ed.0.irq="10"

, , .

23.

441


, sysinstall ,
, ,
. , . , .

, , IP-
, sysinstall. ,
(, IP-),
sysinstall, , . ,
sysinstall ,
.

ifconfig
ifconfig (. Interface Configurator)
( ). IP- (), ,
UNIX,
.
ifconfig. man-,
.
, ifconfig
. , ifconfig - : ,
, :
# ifconfig fxpl
fxpl: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu
1500
inet6 fe80::2dO:b7ff:febd:5dl3%fxpl prefixlen 64 scopeid 0x2 inet
64.41.131.102 netmask OxffffffOO broadcast 64.41.131.255 ether
00:dO:b7:bd:5d:13
media: autoselect (lOObaseTX <full-duplex>) status: active
supported media: autoselect lOObaseTX <full-duplex> lOObaseTX
lObaseT/UTP <full-duplex> lObaseT/UTP

, , , . , , telnet
ssh; ,
!

, , IP-, ,
:
# ifconfig fxpl 64.41.131.103

64.41.131.103 , a fxpl , .
IP-, .. , ,
-

442

4. FreeBSD

, , ,
fxpl:
inet 64.41.131.103 netmask Oxff000000 broadcast 64.255.255.255

IP-, .
, . ifconfig
network,
, , /etc/networks:
#
#
#

ifconfig fxpl 64.41.131.103 netmask


ifconfig fxpl 64.41.131.103 netmask
ifconfig fxpl 64.41.131.103 netmask

255.255.255.0
OxffffffOO
your-netmask

,
.
IP- .
, ARP, .
:
# ifconfig fxpl
64.41.255.255

64.41.131.103

netmask

255.255.0.0

broadcast

MTU (Maximum Transmission Unit,


) .
MTU 1500 ( 1500 ).
, MTU
. , .
:
# ifconfig

fxpl

mtu

536

, ifconfig media. .
, ,
(, , , 22.4
), . ,
10/100 Ethernet, 100 , 10 ,
media mediaopt. , , ifconfig fxpl
:
media: autoselect (lOObaseTX <full-duplex>) status: active
supported media: autoselect lOObaseTX <full-duplex> lOObaseTX
10baseT/UTP <full-duplex> lObaseT/UTP

ifconfig , (lOObaseTX
<full-duplex>). lObaseT. , 10baseT/UTP,

23.

443

,
mediaopt. ,
, , :
autoselect
lOObaseTX
<full-duplex>
lOObaseTX
10baseT/UTP <full-duplex>
10baseT/OTP

,
10- ( ) :
#
#

ifconfig
ifconfig

fxpl media
fxpl media

10baseT/UTP
10baseT/0TP mediaopt

full-duplex

, .. 100- ,
:
# ifconfig fxpl media autoselect

,
, lObaseT
10 , 10baseT
- 10 ,
.. .
,
.

man- , ,
, man fxp.

route
, , , DNS-. (
sysinstall ).
.
ifconfig ,
.
FreeBSD,
(. 28), (default
route). , .
.
route , ,
ifconfig.
add delete.

, FreeBSD,
. (

449

4. FreeBSD

] . telnet- ssh-,
. ,
ifconfig.

, ,
netstat -.
:
# netstat -rn
Routing tables
Internet:
Destination
Gateway
default
64.41.131.1
...

Flags
UGSc

Refs Use
1
1

Netif
fxpO

Expire

, . : , ,
. , route .
, . .
: ,
.
# route delete default
delete net default
# route add default 64.2.43.1
add net default: gateway 64.2.43.1

route , UNIX
-. .
, UNIX- ( FreeBSD, Solaris, IRIX Linux),
, .
, portsentry (
/usr/ports/security) /usr/local/etc/portsentry.conf.
, , 9 ( 9 ) , .

(hostname)
(hostname) . hostname -
:
#

hostname tiger.somewhere.com

,
( ), ( ) :
# hostname

tiger.somewhere.com
# hostname -s
tiger

23.

445

/etc/rc.conf
, , IP, , , ,

/etc/rc.conf ( 11).
/etc/defaults/rc.conf,
, , , /etc/
rc.conf. , . ,
, .
Ethernet- sysinstall,
/etc/rc.conf :
# - - sysinstall generated deltas - - #
ifconfig_fxpl="inet
64.41.131.102
netmask
network_interfaces="fxpl
fxpO
loO"
defaultrouter="64.41.131.1"
hostname="tiger.somewhere.com"

255.255.255.0"

/etc/rc.conf ,
, .

, ,
sysinstall, ,
( network_interfaces); ifconfig_xxx#, ; ,
(hostname defaultrouter, ).
: ifconfig, route,
hostname.
, DNS? , DNS
TCP/IP. DNS
. ,
.

/etc/netstart
, FreeBSD /etc/netstart,
.
, . ,
, . ,
. :
-
. .
FreeBSD,
:
(, , /etc/netstart),
, /etc/rc.network,
.

446

4. FreeBSD

/etc/netstart /etc/
rc.conf .
/etc/defaults/rc.conf; ,
/etc/rc.conf. /etc/rc.pccard /etc/
rc.network. , /etc/defaults/rc.conf /etc/rc.conf rc.network
. , /etc/netstart, ,
rc.network ,
.
ifconfig, route, hostname /etc/rc.network,
,
. /etc/netstart
.
,
.
. , /etc/netstart
route; ,
, , .
, /etc/rc.network ( /etc/netstart)
,
, , , ,
route delete default . ,
/etc/netstart ,
23.1:
23.1 /etc/netstart
# route delete default
delete net default
# /etc/netstart
Doing stage one network startup:
Doing initial network setup:.
fxpO:
flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
inet6 fe80::2dO:b7ff:fec7:74fl%fxpO prefixlen 64 scopeid
Oxl
inet 64.41.131.101 netmask OxffffffOO broadcast
64.41.131.255
ether 00:dO:b7:c7:74:fl
media: autoselect (lOObaseTX <full-duplex>) status: active
supported media: autoselect lOObaseTX <full-duplex>
lOObaseTX lObaseT/UTP <full-duplex> lObaseT/UTP loO:
flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
inet6 fe80::l%loO prefixlen 64 scopeid 0x9
inet6 ::1 prefixlen 128
inet 127.0.0.1 netmask Oxff000000
add net default: gateway 64.41.131.1
Additional routing options: tcp extensions=NO TCP keepalive=YES.
Routing daemons:.

, . (
telnet, ), .
, . ,
/etc/netstart,
-

23.

447

, . , ,
. , ( , )
. , ,
(; ) , . , , , ,
:
# route delete default; /etc/netstart

IP-
He , -
IP-. 1-, , IP. IP- .
IP-, IP-
-,
.
, IP-
(.. ) IP- (IP-aliasing). ,
route, UNIX-
. FreeBSD ifconfig alias,
:
#

ifconfig

fxpl

64.41.131.103

netmask

255.255.255.255

alias

, 255.255.255.255!
IP-,
, IP- . (
. .)
TCP/IP? , 1.
, TCP/IP ,
. ,
- . , ,
-, ,
. ,
.
,
, TCP/IP.
ifconfig IP-.
/etc/rc.conf
ifconfig_xxx#_alias#,
ifconfig_xxx#. , /etc/
rc.conf:
ifconfig_fxpl="inet 64.41.131.131 netmask 255.255.255.0"
ifconfig_fxpl_aliasO="inet 64.41.131.132 netmask 255.255.255.255"
ifconfig_fxpl_aliasl="inet 64.41,131.133 netmask 255.255.255.255"

448

4. FreeBSD

ifconfig_fxpl_alias2="inet 64.41.131.134 netmask 255.255.255.255"


ifconfig_fxpl_alias3="inet 64.41.132.161 netmask 255.255.255.0"
ifconfig_fxpl_alias4="inet 64.41.132.165 netmask 255.255.255.255"
ifconfig_fxpl_alias5="inet
64.41.132.166
netmask
255.255.255.255"

IP-
/etc/hosts
IP-. DNS,
.
/etc/hosts.
/etc/hosts , : IP-, -,
. , , DNS, ,
, ,
,
. -
.
/etc/hosts:
64.41.131.132
64.41.131.133
64.41.132.165
114.235.123.11

ns
www2
www3
www.foobar.com

ns.somewhere.com lion.somewhere.com
www2.somewhere.com
www3.somewhere.com
fred


( ), ( ), IP ( ).

ping
( sysinstall /etc/netstart).
, .
ping, ICMP.
. , ping : , ..
ping .
, ( ).
, Ctrl+C:
# ping fred
PING fred (114.235.123.11):

56

data bytes

64 bytes from 114.235.123.11: icmp_seq=0 ttl=243 time=485.344 ms


64 bytes from 114.235.123.11: icmp_seq=l ttl=243 time=351.589 ms
^
-- fred ping statistics
2 packets transmitted, 2 packets received, 0% packet loss roundtrip min/avg/max/stddev = 351.589/418.466/485.344/66.877 ms

23. 449

ping
TCP/IP: fred -. (-), ping .
, ,
DNS ( ), ,
.
# ping 64.41.131.133
PING 64.41.131.133
(64.41.131.133):
ping: sendto: Host is down
ping:
sendto: Host is down
ping: sendto: Host is down
ping: sendto: Host is down
^C
-- 64.41.131.133 ping statistics -10 packets transmitted, 0 packets

56

data

received,

bytes

100%

packet

loss

DNS /etc/resolv.conf
DNS-, , .
DNS-, .
/etc/resolv.conf.
search somewhere.com
nameserver 64.41.131.132
nameserver 207.78.98.20
nameserver 64.40.111.102

nameserver , ,
,
,
..
search , , .. . ,
nslookup www,
www.somewhere.com. search /etc/resolv.conf , :
search

somewhere.com

foobar.com

cslab.ivyleague.edu

, /etc/resolv.conf ,
DNS, - /etc/hosts.
DNS-. , ,
30, .

resolu.conf -
. DNS-
, , resolu.conf .
,
, DNS-
resolv.conf.

450

4. FreeBSD


, . ,
. , man <filename>, man inetd.conf.
/etc/networks: , , , .
/etc/hosts.allow: , , .
, ,
.
/etc/inetd.conf: inetd, ,
,
.
/etc/inetd.conf ( , ),

. 29.
/etc/services: , ( ) IP-, .
,
, , .
/etc/protocols: .
IP-.
/etc/rpc: , NFS NIS, ,
,
.
/etc/pam.conf: Pluggable Authentication Modules ( )
(, S/Key, Kerberos .). 29.
/etc/host.conf: , , .. ,
hosts, bind.
, ,
hosts, . FreeBSD
/etc/nsswitch.conf.
hosts, man nsswitch.conf.

24

: . \

kernel user

kernel

452 4. FreeBSD

(Point to Point Protocol) ;


.
FreeBSD pppd,
, , .
, .

-
,
-. ,
-, . ,
,
. , ,
:

, ?
-, ,
.

?
FreeBSD?

FreeBSD ( Windows Macintosh).

,
,
:
,
. DOS- UNIX : coml cuaO, com2 cual, com3 cua2.
IP- DNS- ,
IP-.
() dialup- , .. .
(login password),
.
.
:
login , PAP (Password Authentication
Protocol) CHAP (Challenge Handshake Protocol),
.
IP- ( ,
) ?

, , ,
.

24. 453

kernel user
FreeBSD
. . ,
, ,
,
. , , ,
, ,

kernel
pppd-,
/etc/ppp.
, /etc/resolv.conf.

/etc/resolv.conf
, /etc/resolv.conf
IP-. domain.
domain , .. ,
, ,
.
nameserver, IP- DNS. /etc/resolv.conf:
domain samplenet.org
nameserver 111.111.11.1
nameserver 222.222.22.2

root.

/etc/ppp/options
, , ,
pppd, , ,
, (
pppd). , ,
, , . IP-

. - -
.
/dev/cuaaO 115200
crtscts
modem
connect "/usr/sbin/chat
noipdefault
silent

-f

/etc/ppp/opions/chat.script"

domain
samplenet.org
defaultroute

454 4. FreeBSD

/dev/cuaaO 115200: ,
( coml)
, 115200 /;
crtscts:
/ ;
;
modem: pppd ,
CD (Carrier Detect) ,
;
connect: ;
,
chat, ;
noipdefault: , IP- ;
silent: pppd LCP- (Line
Control Protocol );
domain: ,
, (
);
defaultroute:
- ,
.

IP-,
noipdefault - 333.333.333.33:444.444.444.44,
IP-, , (
) IP- ,
, .. . ,
(
).

(, 486- ) . ,
UART,
115200 /. 576
/ .

chat
pppd
chat. , " " - "
", .
, ,
chat , ,
. ,
chat
( , -
, ).

24. 455

. ,
root:
ABORT BUSY ABORT 'NO CARRIER' "" AT OK ATDT5551212 CONNECT "" TIMEOUT
10 ogin: 00 TIMEOUT 5 sword: bar

: ABORT ,
BUSY NO CARRIER. AT
(- . Attention ),
. ATDT (Attention Dial Tone)
. , (
, ATDP). CONNECT,
- 10 ,
ogin ( ,
login, Login). . chat
foo ( login) 5
(TIMEOUT 5) -sword ( password).
, bar ( ).
( -), .
, ,
, ,
.

, , minicom, .

chat , . . CHAP.
.

pppd

, .
pppd. ,
.
, kill pid
( ps), killall pppd.

- -
(shell) . ,
.
,
chat .
, , ,
-

456 4. FreeBSD

. pap-secrets chat-secrets
root. , ,
.
, , /etc/ppp/options.
,
. (user
line) ( ),
.
: user foo, foo login. ,
:
refuse-chap: , ,
;
refuse-pap: -;
require-chap: -;
require-pap: , .
(chap-refuse, pap-refuse)
/etc/ppp/options, ,
, ,
,
.

pap-secrets and chap-secrets


/etc/ppp/chap-secrets /etc/ppp/pap-secrets
- -, .
: username hostname password, username login, hostname
, , a password
. hostname ,
. ,
:
foo * bar, foo login, bar
.

, pap-secrets chap-secrets
root, .

(dial-on-demand) pppd
,
(.. ).
(persistent connection) 24 ,
(
).

24. 457


pppd
, . (/etc/ppp/options)
:
demand: ;
idle : , ..
.
, ,
pppd .
. pppd /etc/rc.local.
, pppd,
/usr/ local/etc/rc.d. ,
.

pppd, dial-on-demand, Fetchmail, .


, .
DNS-.
"" sendmail

25.


pppd .
persist /etc/ppp/options.


pppd /etc/ppp/ip-up.
/etc/ppp/ip-down.
pppd ,
, .
Fetchmail ip-up
ip-down
. ,
, .


- kernel , user .
, .
,
user .
, (
, ).
,
/sys/i386/conf pseudo-device tun 1.
, .

458

4. FreeBSD

/etc/ppp/ppp.conf
user PPP,
ppp.conf, .
- -, ,
, . 24.1 -
, . ,
, .

2 4 . 1

/ e t c / p p p / p p p . c o n f

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#
#
#
#
#
#

Sample Configuration File


Originally written by Toshiharu OHNO
Simplified 5/14/1999 by wself@cdrom.com
See

/usr/share/examples/ppp/

for

some

examples

# $FreeBSD: sro/etc/ppp/ppp. oonf , v 1.7 2001/02/22 23:28:12 brian Exp $

# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
default:
ident

user-ppp

VERSION

(built

# ,

# ,
#
set
device
/dev/cuaal

COMPILATIONDATE)

"set device"

.
(cuaaO = COM1 , cuaal = COM2)

set log Phase Chat LCP IPCP CCP tun command


set speed 115200
set dial "ABORT BUSY ABORT NO\\sCARRIER TIMEOUT 5 \
\"\" AT OK-AT-OK ATE1QO OK \\dATDT\\T TIMEOUT 40 CONNECT"
set
ifaddr
10.0.0.1/0
10.0.0.2/0
255.255.255.0
0.0.0.0
set timeout
180
# 3 -
add default HISADDR
#
enable dns
# DNS -
papchap:

#
#
#

,
.

#
set phone PHONE_NUM
set authname USERNAME
set authkey PASSWORD

:
set device: , , - UNIX- : coml /dev/
cuaaO, com2 /dev/cuaal .;
set log: , ; ( . ,
);
set speed: ;
, 115200, ,

24. 459

,
57600 ;
set dial: , chat;
,
;
set ifaddr: , (10.0.0.1/0),
, ;
IP-,
; (10.0.0.2/0) ,
; ,
; ,
(255.255.255.0) ,
, ;
set timeout: idle , -;
,
- ;
set default HISADDR:
, .. ; ,
ifaddr,
, ,
:
enable DNS: /etc/resolv.conf
(.. ),
,
;
set phone: ;
set authname: ;
set authkey: ;

, , - - -
( ), ppp.conf
. -, papchap,
set phone, set authname set authkey, -,
set dial :
Provider:
set phone "5551212"
set login "TIMEOUT 10

"\

"

"\

"

gin:

foo sword:

bar"

foo bar .
, , ,
,
, .
, chat:
" " " ",

, .. .

460 4. FreeBSD


- - user
-background
papchap.
-background provider.
. ,
,
Enabled .
ps pid
kill killall .

user
, ,
/etc/ppp/ppp.conf allow users.

, , ,
.


,
-auto. : -auto papchap -auto
provider ( ).
, /etc/rc.conf
ppp_enable="YES". ,
, ,
:
:

, timeout
/etc/ppp/ppp.conf;
; , /etc/rc.conf
ppp_profile="provider";
NAT (Network Address Translation),
, IP: , /etc/rc.conf
ppp_nat="NO".
/etc/rc.conf
.

,
/etc/ppp/ppp.conf set timeout.
: -ddial papchap -ddial provider
- -, .
, /etc/rc.conf
: -enable="YES" ppp_mode="ddial".
:

24. 461

;
, /etc/rc.conf
ppp_proffle="provider";
NAT,
, IP-;
, /etc/rc.conf
ppp_nat="NO".

/etc/rc.conf .

, kernel ,
.
/etc/ppp/ppp.linkup ( ,
) /etc/ppp/ppp.linkdown ( ).
:
papchap:
command_to_run_here

papchap ,
. , papchap
provider.
-
, (
25).

, ;
, (115200)
57600 /;
; ,
( )
, , ;

, :
, ; ,
;

;
chat , ,
;
,
, a kernel
;

462 4. FreeBSD

,
:
/etc/resolv.conf;
, /etc/host.conf host bind.
,
. /etc/ppp/options
debug, , kernel
, set log /etc/ppp/ppp.conf
user . kernel /var/log/messages,
user /var/log/ppp.log.
tail -f /var/log/messages tail -f /var/log/ppp.log, ,
:
10 , .


, ,
, .
, .
, : man
pppd ( kernel ) man ( user ). , usr/share/examples/ppp
.

25


E-mail

SMTP

[]
[MUA]
Senclmail

Mail Relay

- qpopper
IMAP- IMAP-UW

464

4. FreeBSD

Internet . ,
Web-
, Internet
. . UNIX-
,
,
. FreeBSD .
, Sendmail,
SMTP-, Internet,
.
- Sendmail ,
.
, :
POP IMAP, .
, , Sendmail. ,
.

SMTP
SMTP Simple Mail Transfer Protocol ( )
Internet. ,
1971 ( ,
ARPA). (Ray Tomlinson).
SMTP .
Internet,
. SMTP-
SMTP- .
SMTP . 25-
. ,
,
, .
. , . SMTP

. SMTP
. , SMTP-
. 25.1.
,
.
25.1 SMTP _____________________________________
# telnet destination.com 25
Trying 64.41.134.166...
Connected to destination.com.
Escape character is `^] ' .
220 destination.com ESMTP Sendmail 8.11.1/8.11.1; Wed, 16 May 2001
22:55:37
-0700 (PDT)
HELO stripes.sender.com
250 destination.com Hello w012.z064002043.sjc-ca.dsl.cnc.net [64.2.43.12],
pleased to meet you
MAIL From: frank@sender.com

25. E-mail
250 2.1.0 franlc@sender.com...

RCPT To: bob@destination.com

465

Sender ok

250 2.1.5 bob@destination.com...

DATA

Recipient ok

354 Enter mail, end with "." on a line by itself


From: frank@ sender.com
To: bob@destination.com
Subject: Testing, 123...
This is a test message.
250 2.0.0 4H5uCu53501 Message accepted for delivery

QUIT

221 2.0.0 destination.com closing connection


Connection closed by foreign host.

, .
. .
, bob@destination.com,
:
From: frank@sender.com To:
bob@destination.com Subject:
Testing, 123...

. ,
, . SMTP-,
, ,
(/var/mail/bob, FreeBSD-). , ,
. SMTP- ( Sendmail)
,
.
SMTP- Internet-,
. ,
. SMTP-
SMTP , DNS,
TCP/IP, Internet.
, ,
.
(, , )
SMTP- ,
.
, SMTP- .
SMTP-.

()
(MUA)
. 25.1.
, -

466

4. FreeBSD

, : (Mail User Agent) (


), SMTP-.
SMTP- ,
(Mail Transfer Agent, MTA) (, Sendmail)
. , ,
SMTP- , relaying
().
. (MUA)
( , ,
).
Sendmail ?

25.1

,

. MUA .

()
, Internet:
Sendmail. , .
(Eric Allman) 1983 . . Sendmail, Inc. (http://www.sendmail.com) , Sendmail UNIX Linux. Sendmail (http://www.sendmail.org)
, . ,
, FreeBSD (Sendmail
)
Microsoft Exchange. Sendmail Windows, (, NNTP, LDAP), Exchange
Microsoft .

25. E-mail

467

Postfix. , (Wietse Venema)


Sendmail, , ,
, Sendmail.
Qmail. Qmail, Sendmail, (Dan Bernstein). , . Postfix
( Sendmail , , ), Qmail
Sendmail .
, FreeBSD, /usr/ports/
mail.


(MUA)
(Mail User Agents) ,
(, Microsoft Outlook/Outlook Express, Eudora, Apple Mail, Netscape Mail
..). MUA,
FreeBSD.
Pine. "Program for Internet News and E-mail". . Pine
, ,
, (message composer)
pico ( Pine).
Elm. , Pine. Elm
mail mailx,
, Internet.
Elm .
Mutt. MUA Elm,
Pine . Mutt . ,
, ,
MUA .
,
, Telnet
SSH. , HTML- ( , ).
,
, ,
Telnet SSH. ! Internet
, Windows/Outlook.

468

4. FreeBSD

Sendmail
FreeBSD Sendmail,
. Sendmail (
), /etc/rc.conf :
Sendmail_enable="YES"

Sendmail ,
Internet.
. Sendmail ,
,
Sendmail.

Sendmail
Sendmail :
/etc/mail: Sendmail.
/var/mail: .
/var/spool/mqueue: .
Sendmail /usr/sbin/sendmail, a log-
/var/log/maillog ( ,
14).

Sendmail
/usr/lib/sendmail. ,
, FreeBSD :
#

In -s

/usr/sbin/sendmail

/usr/lib/sendmail

(.. ) /var/mail
. , 600 (
). .
, lock- POP,
.username.pop. ,
-. - .


/etc/mail, Sendmail.

/etc/mail/sendmail.cf
Sendmail. ,
, .
Master Config (.mc),
sendmail.cf.

25. E-mail

469

sendmail.cf , .
. - sendmail.cf
.

/etc/mail/freebsd.mc
Master Config. ,

, /etc/rc.conf /etc/defaults/rc.conf.
. m4
( Sendmail ). .m cf.m4, Sendmail
( /usr/share/sendmail /usr/src/contrib/sendmail).
.cf,
sendmail.cf.
, sendmail.cf, , , .m ,
, ,
m4,
. ,
.
m4 dnl.
"delete through newline" " ", dnl
( ).
, dnl ,
.
/etc/mail Makefile, .cf-
freebsd.mc make cf.
(freebsd.cf) sendmail.cf, make
install.
# make cf
/usr/bin/m4 -D_CF_DIR_= /usr/share/sendmail/cf/ /usr/share/sendmail/cf/m4/ cf.m4
freebsd.mc > freebsd.cf
# make install
install -c -m 444 freebsd.cf /etc/mail/sendmail.cf

/etc/mail/Makefile , .

/etc/ mail/aliases
/var/mail .
, ,
( - Internet)
( ).
/etc/mail/aliases.
, , :
tiger: @ tripes.com fsmith: frank

470

4. FreeBSD

pager: "|/usr/local/bin/pageme" dump:


"/home/frank/dump2me"
mylist:include:/home/frank/list.txt

.
. :
, .
/etc/mail/aliases,
aliases.db,
( /etc/master.passwd, 10).
newaliases
make aliases:
* make aliases
/usr/sbin/sendmail -bi
/etc/mail/aliases: 22 aliases, longest 10 bytes, 213 bytes total


. , , - , /etc/mail/aliases, root. , .
, home-
.forward, .
echo:

# echo "frank@somewhereelse.com"

>

.forward

, .

/etc/mail/access
access ,
, .
. OK, REJECT, RELAY,
DISCARD 550 <message>. /etc/mail/access
, / :
cyberspammer.com
FREE.STEALTH.MAILERS
another.source.of.spam
okay.cyberspammer.com
128.32
64.2.43
RELAY

550 don't accept mail from spammers


550 We don't accept mail from spammers
REJECT
OK
RELAY
RELAY

OK ,
, .
REJECT , .
DISCARD ,
, .
RELAY ,
( ).

25. E-mail

471

550 <message> "", , .


SMTP- ,
.

/etc/mail/access , access.db. make maps,


, make maps. Sendmail access.db,
make restart:
# make maps
/usr/sbin/makemap hash access.db < access
# make restart
/bin/kill -HOP 'head -1 /var/run/sendmail.pid'

/etc/mail/local-host-names
( sendmail.cw) , . , ,
( ). local-host-names file,
: MX list
for <domain> loops back to myself; local configuration error message ( MX
<domain> ; ).
. ,
DNS. , make restart.
# make restart
/bin/kill - 'head -1 /var/run/sendmail.pid'

/etc/mail/virtusertable
/etc/mail/virtusertable .
,
.
.
, , mycave.org. ,
webmaster@mycave.org bill, info@mycave.org anne@elsewhere.com,
@mycave.org . (- ):
webmaster@mycave.org
info@mycave.
@mycave.org

bill
anne@elsewhere.com
errorinouser User unknown

, , . virtusertable.db
. , virtusertable.db
, :

472

4. FreeBSD

# make maps
/usr/sbin/makemap hash virtusertable.db < virtusertable
# make restart
/bin/kill -HUP 'head -1 /var/run/sendmail.pid'

virtusertable
Web- Sendmail http://www.sendmail.org/
virtual-hosting.html.

/etc/mail/Makefile, ,
FreeBSD. , Sendmail.
. -
Sendmail Linux , ,
Makefile .

DNS-
Sendmail , DNS
, . FreeBSD, IP-
, : . SMTP-, Sendmail, , ,
. Sendmail, ,
DNS-- .
nslookup IP- :
# nslookup stripes.somewhere.com
Server:
lion.somewhere.com
Address:
64.41.131.132
Name:
Address:

stripes.somewhere.com
64.41.131.102

DNS-.
Sendmail . :
# nslookup stripes.somewhere.com
Server:
lion.somewhere.com
Address:
64.41.131.132
*** lion.somewhere.com can't find stripes.somewhere.com: Non-existent host/
domain

, ( , ) , . ,
DNS-,
DNS- ,
Internet. DNS 30.

Sendmail
Sendmail : "" ,
25, , -

25. E-mail

473

,
.. /etc/re.
Makefile
/etc. ,
make start:
# make start
(. /etc/defaults/rc.conf; source_rc_confs;
"YES" -a -r /etc/mail/sendmail.cf ] ; then
sendmail_flags} ;
fi )

if [ "${ sendmail_enable} " =


/usr/sbin/sendmail ${

, ,

, , -q30m (
) -bd ( ). Sendmail ,
sendmail_enable rc.conf NO.
:
# make restart
/bin/kill -HOP 'head -1 /var/run/sendmail.picT
# make stop
/bin/kill - 'head -1 /var/run/sendmail.pid'

Sendmail ps
grep.
.
(51248) (54150):
51248 ?? Ss
0:00.17 sendmail: accepting connections (sendmail) 54150
??
I
0:00.02 sendmail: ./f4GKwVW16827 mail.backstreetboys.com.: user
open (sendmail)


, , /var/spool/mqueue.
30 sendmail
-q, .
, , , .
, . , Microsoft Exchange,
, ,
, Sendmail .

,
.
,
, root
, .
, Sendmail, mailq, , .

474

4. FreeBSD

# mailq
/var/spool/mqueue (2 requests)
--- S i z e ----- Q-Time ---- ---------- Sender/Recipient -----f4H!Ahu36976
6246 Wed May 16 18:10 MAILER-DAEMON
(Deferred: Operation timed out with mlists.acmecity.com.)
<fredgacmecity.com>
f4GKwVW16827
706 Wed May 16 13:58 www
(host map: lookup (hotamil.com): deferred)
Bob bobghotamil.com

---- Q-ID

mailq, , -
. , .
, , .
, , ,
mailq . . ,
Sendmail hotamil.com
, .
/var/spool/mqueue ,
mailq. dff4GKwVW16827
qff4GKwVW16827. ,
. (qfF4GKwVW16827)
, hotamil.com hotmail.com,
. . ,
.
sendmail -q -v. ,
Sendmail SMTP .
Sendmail ,
. ,
( ).
Ctrl+C .

Mail Relay
Sendmail (..
) . , Sendmail 8.9
(relaying)
.
, , , , SMTP , -
. . 25.2,

SMTP-:
, .
(relaying) MX (MX record) SMTP- DNS (
SMTP- ), -

25. E-mail

475

, SMTP- (S1) (Mail


eXchanger). Sendmail
, . ,
S1 .
, Relaying denied error
( ).
25.2

Mail Relay.
,

S1,
S1 S2.

, Relay-
host:

# host somecompany.com
somecontpany.com has address 164.199.3.78
somecompany.com mail is handled (pri=30)

by mail-l.somecompany.com

SMTP

. Internet , DNS ,
MX SMTP Relay-.
Internet, ?
S1
Relaying denied error, SI
. ,
.
"" /etc/mail/relay-domains,
.

. Sendmail.
, , ,
, , ,
.
(/etc/mail/access).
RELAY ,
.
-

476

4. FreeBSD

.
, , .
,
Sendmail, /etc/mail/freebsd.mc, sendmail.cf
( ).
, From: (relay_local_from).
. (Realtime Blackhole List, RBL).
.
freebsd.mc, . dnl .

promiscuous_relay.
Sendmail. . Internet
"" , Internet
" ". , ,
! , .
: ,
SMTP-, ISP. SMTP, . (, , From:)
-, SMTP-
.

http://www.sendmail.org/tips/relaying.html.


SMTP Sendmail, ,
. SMTP .
, : POP.
(Post Office Protocol) , , Internet ,
, , Pine Mutt, . MUA,
Microsoft Outlook Eudora Qualcomm, , (. . 25.1),

25. E-mail

477

, , , .
.
SMTP, POP3 ( POP, ) . , . ,
, .
. , . -, qpopper,
FreeBSD. qpopper
(/usr/ports/mail/qpopper). Berkeley -. ( ) Qualcomm, Eudora.
- inetd. TCP UDP TCP- 110
/etc/services, , .
qpopper /usr/local/libexec/qpopper. (
- libexec ,
- ,
.) qpopper ,
, , ,
, . .
qpopper, , ,
.
.
, , . 4.0 qpopper
SSL (Secure Sockets Layer), FreeBSD , SSH (Secure Shell) secure
HTTP. , qpopper
.

- qpopper
-. ; , inetd; " ", ; TLS/SSL. .
.

qpopper
, ,
. qpopper (/usr/ports/qpopper),

478

4. FreeBSD

(. 15). qpopper sysinstall . inetd. /etc/inetd.conf.


inetd.conf , .
,
:
#

# stream
stream

tcp
tcp

nowait
nowait

root
root

/usr/local/libexec/popper
/usr/local/libexec/qpopper

popper
qpopper

-s

inetd, killall: #
killall -HUP inetd
, ,
110 Telnet. QUIT.
# telnet localhost 110
Trying 127.0.0.1...
Connected to localhost.
Escape character is '*]'.
+OK Qpopper (version 4.0.2) at stripes.somewhere.com starting.
<4763.990313780@stripes.somewhere.com>
QUIT
+OK Fop server at stripes.somewhere.com signing off.
Connection closed by foreign host.

, , - .

(Standalone Mode)
inetd . , Medium High,
/etc/rc.conf , inetd:
inetd_enable="NO"

inetd
standalone. , , Makefile.
/usr/ports/mail/qpopper, Makefile,
-enable-standalone CONFIGURE_ARGS:
CONFIGURE_ARGS= enable-apop=${PREFIX}/etc/qpopper/pop.auth \
enable-nonauth-file=/etc/ftpusers \ withapopuid=pop without-gdbm \ enable-keep-tempdrop \ enable-s tandalone

make make install qpopper, .


/usr/local/libexec. , .
qpopper . /usr/local/etc/rc.d
qpopper.sh (. 11). , qpopper
inetd

25. E-mail

479

(Server Mode)

,
qpopper .
. , ,
.
- , , -,
, -, .
qpopper .
-S inetd.conf ,
:

stream
qpopper -s -S

tp

nowait

root

/usr/local/libexec/qpopper

qpopper .
,
. . qpopper ,
/usr/local/etc/qpopper (, qpopper.conf), inetd.conf -f:

stream tcp
nowait root
/usr/local/libexec/qpopper
qpopper -s -S -f /usr/local/etc/qpopper/qpopper.conf

qpopper.conf , , group-server-mode groupno-server-mode. group 1 group2


group3:
set group-server-mode=groupl
group-server-mode=group2
group-no-server-mode=group3

set
set

.
- ( ). ,
,
.qpopper.options, set server-mode. , .qpopper.options, -U - /var/mail
,<_>^.8. . -S, ,
!

SSL
TLS/SSL qpopper . ,
(security certificates).
:

480

4. FreeBSD

# mkdir -p -m665 /etc/mail/certs


# chown root:mail /etc/mail/certs
# chmod 660 /etc/mail/certs


openssl. .
(cert.pem)
root.
# openssl req -new -nodes -out req.pem -keyout /etc/mail/certs/cert.pern
# chmod 600 /etc/mail/certs/cert.pern
# chown root:0 /etc/mail/certs/cert.pern


(Certifying Authority, ), , VeriSign.
eq.pem, (signed
certificate). cert.pem:
# cat signed_req.pem /etc/mail/certs/cert.pern

TLS/SSL /usr/local/etc/
qpopper/qpopper.conf ( ).
SSL . ,
SSL, .
set tls-support = stls
set tls-server-cert-file = /etc/mail/certs/cert.pern


() , (self-signed certificate),
. SSL
.
(
!), :
# openssl genrsa -des3 -out ca.key 1024
# openssl req -new -x509 -days 365 -key ca.key -out ca.crt


(req.pem):
# openssl x509 -req -CA ca.crt -CAkey ca.key -days 365 -in req.pem -out
signed-req.pern -Cacreateserial

qpopper SSL
. ,
!
Web- qpopper http://www.eudora.com
qpopper. ,
PDF ( Documentation),
qpopper. Linux.
,
FreeBSD. man qpopper.

25. E-mail

481

IMAP- IMAP-UW
IMAP (Interactive Mail Access Protocol ) POP,
. ,
POP SMTP. IMAP POP ,
POP ,
IMAP .
IMAP , -,
,
. ,
, .
MUA, Mutt Pine,
Outlook Eudora.
IMAP POP.
IMAP- IMAP-UW,
( , Pine).
/usr/ports/mail/imap-uw (. 15).
SSL, USE_SSL=YES
: make make install.

IMAP-UW : ,
IMAP
. .
, . ,
. : , ;
IMAP-; IMAP, POP.

IMAP-UW , mboxtest,
, /usr/local/libexec. , ipop2d . ipop3d,
POP- ( 2 , ),
, qpopper.
POP IMAP-, IMAP, -.
IMAP-UW . /etc/inetd.conf ( IMAP- inetd, qpopper) /etc/pam.conf ().
/etc/inetd.conf
IMAP-UW. :
# imap4
I
imap4

stream

tcp

nowait

root

/usr/local/libexec/imapd

inetd:
# killall -HUP inetd

imapd

482

4. FreeBSD

TCP- 143.
Telnet. Ctrl+] quit.
# telnet localhost 143
Trying 127.0.0.1...
Connected to localhost.somewhere.com.
Escape character is `A ]'.
* OK [CAPABILITY IMAF4 IMAP4REV1 LOGIN-REFERRALS AUTH=LOGIN]
localhost.somewhere.com IMAP4revl 2001.303 at Sun, 10 Jun 2001 11:21:26 0700 (PDT)
^]
telnet> quit
Connection closed.

imap /etc/
pam.conf ( ), .
:
imap

auth

required

pam_unix.so

try_first_pass

pam_unix.so
pam_unix.so
pam_deny.so

try_first_pass

:
imap
imap
imap

auth
required
account required
session required

To :

auth
required
account required
session required

pam_unix.so
pam_unix.so
pam_deny.so

try_first_pass

/uar/log/messages IMAP -
, "", /uar/mail
1777. IMAP-UW (
Pine).
FreeBSD 775, .. ,
/war/mail setgid
. IMAP-LJW setgid // mail
lock-,
. /war/mail 1777.
,
. , .

SSL/TLS ,
. , make
USE_SSL=YES make install USE_SSL=YES make make install.
, cert, ,
qpopper, /usr/local/certs ( IMAP-UW ).
, qpopper ,
/usr/local/certs.
stunnel. 29.

25. E-mail

483


. ,
Gnome D
.

Fetchmail
- IMAP-
(Outlook, Eudora, Netscape Messenger),
- IMAP-.
.
MUA FreeBSD.
, MUA, , Mutt, Elm
Pine, . /var/ mail
, .
,

UNIX.
- IMAP-, , FreeBSD, , -
1-
. Fetchmail , ,
(Eric Raymond).
Fetchmail (/usr/ports/mail/fetchmail)
. .fetchmailrc, home-
. - IMAP-, ,
, , . Fetchmail

25 , Sendmail.
Fetchmail , .fetchmailrc
. .
fetchmailconf. Fetchmail
, Python. (SDK X Window).
fetchmailconf , Python TCL/ .
.fetchmailrc .
. man- Fetchmail.

484

4. FreeBSD

.fetchmailrc
,
.fetchmailrc. . ,
, . ,
.
.fetchmailrc .
-.
, Fetchmail
. ,
.
.fetchmailrc .
,
.
, ,
, - Fetchmail.
:
set daemon 600
set postmaster foobar
set logfile ./.fetchmail.log

Fetchmail
600 (10 ).
. , Fetchmail
.
(fallback address). ,
Fetchmail ,
. , ,
Fetchmail.
, log-, Fetchmail
. set
syslog, syslogd.
,
.
, .
.fetchmailrc .
, .
, :
poll mail.samplenet.org
proto no dns

mail.samplenet.org
, set daemon .
skip mail.samplenet.org
, Fetchmail .

25. E-mail

485

,
, Fetchmail.
, Fetchmail
. . : , , .
DNS. Internet , .
.
man fetchmail.
.fetchmailrc . .
:
user foobar pass
secretword fetchall
flush

,
ISP-.
Fetchmail ,
, .
, " " (flush) (
). , .
, ,
. -
Fetchmail.
Fetchmail :
set daemon 600
set postmaster foobar
set logfile ./.fetchmail.log
poll mail.samplenet.org
proto no dns
user foobar pass
secretword fetchall
flush

: " 600 .
'foobar'.
.fetchmail.log. mail.samplenet.org 10
DNS.
foobar secretword,
".

.fetchmailrc ,
, .
, , 60. chmod

486

4. FreeBSD

600 .fetchmailrc. .
.fetchmailrc , Fetchmail .

Sendmail

Fetchmail , 25
Sendmail ( ). , Sendmail
, ,
. , Mutt
Sendmail, SMTP-.
Sendmail ,
Internet . "" ,
.
/etc/mail/freebsd.mc :
dnl Dialup users should uncomment and define this appropriately dnl
define("SMART_HOST', 'your.isp.mail.server')

define, dnl
your.isp.mail.server .
, make cf make install
/etc/mail.

, SMTP-
SMTP-, ISP-.
. MUA, ,
Mutt Pine, Sendmail, SMTP SMTP-, -
, Windows-.
SMART_HOST Sendmail
SMTP- ISP-.
. , SMTP , IP-, -
DNS-, ISP DNS
, .
FreeBSD . ISP- SMTP, (
, MUA Windows),
SMART_HOST .
, , . Sendmail 30
( -q30m,
/etc/defaults/rc.conf).
, .
/etc/rc.conf , :
sendmail_flags="- bd -qlOm"

25. E-mail

487

, -q30m Internet.
, sendmail -q, -v.
, sendmail -q
, , -up,
24.


Sendmail , .
,
m4,
(, virtusertable),
. , Sendmail
( ),
. ,
, , ,
Sendmail. , , .

Postfix
, Sendmail
Postfix, (Wietse Venema).
.
Sendmail, ,
Sendmail .
, Postfix ( , , , Qmail, ). Postfix ,
"" Sendmail Qmail.
Postfix http://www.postfix.org.

Qmail
(Dan Bernstein) Qmail Sendmail
.
Internet, Hotmail, Network Solutions Yahoo! mail.
Qmail , Sendmail. ,
Qmail Sendmail. Qmail
,
. Qmail http:// www.qmail.org.

Exim
, Exim
: , -

488

4. FreeBSD

. , . , Exim
Sendmail ,
. ,
SMTP- Sendmail. Exim
http://www.exim.org.

Small
, Smail,
. , Sendmail
( Exim), Sendmail. ,
Smail .

26

Web-

HTTP
Apache

Apache
HTTP


Apache

CGI

490

4. FreeBSD

, Internet,
Web-.
,
Web- .
, FreeBSD Web,
. FreeBSD
Sendmail ,
. , Web-
.
. 90% Web- Apache.
(, Roxen AOLserver),
Apache Internet,
NCSA httpd.
Apache , , ,
Sendmail, .
Apache
. ,
, . ,
. Apache
Web-

. ,
,
Perl.
, Apache .

HTTP
HyperText Transfer Protocol (HTTP, ) World
Wide Web. 1993
CERN (), ,
. . HTTP
,
( HTTP-)
. HyperText Markup Language (HTML,
).
HTTP .
, , HTML-.
WWW ( GIF JPEG
1994 ).
, HTTP . -

26. Web-

491

HTTP/1.1, , (
).
.
SMTP, FTP , HTTP "". , HTTP
, . HTTP . , , , , , . SMTP: (relaying), MX, ..
HTTP- , , .
HTTP/1.0 .
HTTP , 80 HTTP-
GET. :
f telnet www.somewhere.com 80
Connected to www.somewhere.com.
Escape character is 1 A ]'. GET /
HTTP/1.0
HTTP/1.1 200 OK
Date: Sun, 20 May 2001 22:45:55 GMT
Server: Apache/1.3.20 (Unix)
Content-Location: index.html
Vary: negotiate,accept-language,accept-charset
TCN: choice
Last-Modified: Fri, 31 Mar 2000 01:45:46 GMT
ETag: "6531f-54e-38e4034a;3a977613"
Accept-Ranges: bytes
Content-Length: 1358
Connection: close
Content-Type: text/html
Content-Language: en
Expires: Sun, 20 May 2001 22:45:55 GMT
<HTML>
<TITLE>test page</TITLE>
<BODY>

test
</BODY>
</HTML>

( ),
HEAD. ( Enter)
.
.
, HTTP- , Server:. ,
Content-*:, , Web- . , Content-Length: ,
, a Content-Type:
(HTML, , GIF JPEG ..).

492

4. FreeBSD

/1.0 , ,
cookies, , ..
( ), .
, . /1.1
/1.0, , (Host:)
. -
( Web- ).
, , Web-
. Web- IP-- ,
, HTTP-- IP- (
TCP/IP 22), ,
. -
Host:.
# telnet www.somewhere.com 80
Connected to www.somewhere.com. Escape
character is 1 A J '. GET / HTTP/1.1
Host: www.somewhere.com

, ( Lynx), HTTP/I.I Host:. (


, HTTP/1.1. , Netscape Navigator
HTTP/1.1, /1.0.) ,
, Host: ( IP- ), .
.


(GET, HEAD POST,
HTTP/1.1), , .
. . 26.1
HTTP- ( Apache
).
26.1 HTTP-

200

201

Created ()

202

Accepted ()

203

Partial Information (
)

204

No Content ( )

26. Web-

493

300

Multiple Choices

MultiViews CheckSpelling

302

Moved Permanently

303

Moved Temporarily

304

Not Modified

402

Bad Request ( )

403

Unauthorized

403

Forbidden

404

Not Found

501

Internal Server Error

502

Not Implemented (He )

503

Bad Gateway ( )

504

Service Unavailable

CGI-

,
,

404 403, 500,


CGI-. 304.
.
,
, log- (/var/log/httpd-access.log).
, (, GIF
HTML-), GET, If-Modified-Since
. ,
. , (
200), , 304 (Not Modified),
, .
, , ,
301 (Moved Permanently). ,
URL http://some.host.com/Subdirectery, Subdirectory
. URL
http://some.host.com/Subdirectory/. , , URL
, .
, 301,
URL, . URL
,

494

4. FreeBSD

. ,
. ServerName Apache,
.
Web- W3 (WWW
Consortium) www.w3.org/Protocols. /1.0 RFC 1945, a HTTP/1.1 RFC 2068.

Apache
Apache, , "A Patchy Server"
( ), "" , , 1995 NCSA httpd-. Apache
.
AIX Windows, BeOS Mac OS X, , ,
FreeBSD.
HTTP-,
. !
- ,
. Apache
60% ( ) .
Apache (/usr/ports/www/apache13) .
Apache 1.3 ,
.
Apache. .
"" (,
,
Apache). Apache 2.0 ,
, ,
. Apache 2.0 , Apache 1.3, ,
/usr/ports/www/apache2 (,
).
Apache FreeBSD ,
FreeBSD, , URL
Rewrite (mod_rewrite), (Ralf Engelschall), a
. , Apache
FreeBSD.
Apache
, .
, Apache
http://httpd.apache.org.

26. Web-

495

Apache
Apache
/usr/local. , /usr/local/www, ,
.
Apache . 26.1. Apache
/usr/local ( FreeBSD), log-
( /var/log log- ).
,
, .
. ,
/usr/local/www/data.default

/usr/local/share/doc/apache, a /usr/local/www/data (
, .. , HTML ) .
. , /usr/local/www/cgi-bin /usr/Iocal/www/cgi-bin.default ( ). , cgi-bin, cgi-bin.default, cgi-bin .

26.1


Apache.

/usr/local/etc/apache
.default-. ,
, -
.
Sendmail, ,
Apache .
FreeBSD Apache ,
Linux, Solaris Windows.
, :
" ", , , /usr/local/www FreeBSD,
, Apache. Linux , , /var/ lib/apache.
, Apache,
, log-, ,
. -

496

4. FreeBSD

, FreeBSD, , ,
, .

Apache
/etc/mail ( 25), /usr/local/etc/
apache ( Apache) ,
:
httpd.conf. Apache.
, , .
mime.types. , MIME ( Content-Type) ,
Apache. , .
magic. MIME magic - "
", , , .
file.
access.conf srm.conf. , httpd.conf.
- , , ( ),
.
, .default-.
. ,
, .
Apache .default.
, diff .

httpd.conf
httpd.conf , ( /etc/mail/
sendmail.cf) .
. ,
. , Apache
, .
Apache .
.
httpd.conf :
#
# , .
# , , ,
# .

26. Web-

497

#
ServerAdmin ou@your.address
#
# ServerName ,
# , ,
# (, www
# ).
#
#ServerName new.host.name

, ServerName
301 ( ).
, Apache 301 (Moved
Permanently) URL, . Apache URL
, ,
URL. , URL http://some.host.com/images/foo,
/images/foe. /1.1,
Host:, Apache
URL. ServerName.
HTTP/1.1 ,
ServerName. (
), Apache
ServerName Host: .
ServerName.
, ServerName.
Apache URL-.
Web- Apache Group http://
httpd.apache.org/docs/.

.htaccess

httpd.conf.
, -.
. ,
, .htaccess,
.
, httpd.conf, -
(.htaccess),
. - .htaccess
,
.
.htaccess, AllowOverride.
httpd.conf AllowOverride None
/usr/local/www/data. ,
.htaccess . ,
None AllowOverride ( /usr/ local/www/data)
. 26.2 (, AllowOverride AuthConfig Limit).

498

4. FreeBSD

26.2 Allow/Override

.htaccess

AllowOverride Options

Options

AllowOverride Filelnfo

, , AddType ErrorDocument

AllowOverride AuthConfig

, , Require Auth*

AllowOverride Limit

, , Allow, Deny Order

AllowOverride All

Options Apache.
, ExecCGI [ CGI-),
Includes ( ) MultiViews ( ].
. Options . http:// httpd.
apache. org/docs/mod/core.html#options.

httpd.conf, ( ). .htaccess Web- (


http://httpd.apache.org/docs/).
httpd.conf
( /home). ,
, , , HTTP/
1.1 (DELETE, COPY MOVE), , :
#
# UserDir. ,
# .
#
#<Directory /home/*/public_html>
#
AllowOverride Filelnfo AuthConfig Limit
#
Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
#
<Limit GET POST OPTIONS PROPFIND>
#
Order allow,deny
#
Allow from all
#
</Limit>
#
<LimitExcept GET POST OPTIONS PROPFIND>
#
Order deny,allow
#
Deny from all
#
</LimitExcept>
#</Directory>

, AllowOverride .htaccess Filelnfo, AuthConfig Limit, Options


.

, Web-
public htm! http://some.host.com/~user/ ,

26. Web-

499

/home/user/public_html. ,
index.html, Apache , . ( Microsoft
Default.htm)
. Directory!ndex . Apache
.

HTTP
Apache .
httpd ( ps grep):
# ps -waux I grep httpd
root
220
0.0
2.0
4436 2456
??
Ss
Sat02PM
0:02.79
/usr/local/sbin/httpd
nobody
303
0.0
2.0
4496 2548
??
I
Sat02PM
0:00.01
/usr/local/sbin/httpd
nobody
304
0.0
2.0
4460 2452
??
I
Sat02PM
0:00.00
/usr/local/sbin/httpd
nobody
305
0.0 2.0 4460 2452
?? I
Sat02PM 0:00.00
/usr/local/sbin/httpd
nobody
306
0.0
2.0
4460 2452
??
I
Sat02PM 0:00.00
/usr/local/sbin/httpd
nobody
307
0.0 2.0 4460 2452
??
I
Sat02PM 0:00.00
/usr/local/sbin/httpd
nobody 13963 0.0 2.0
4468 2468
?? I
SatlOPM 0:00.00
/usr/local/sbin/httpd

, Apache , (master) ( root)


80 ( nobody,
). , . ,
, Web-,
root,
,
root. "" CGI-
, .
,
httpd, ,
, . :
, ,
HUP.
,
.
, ,
ps, grep kill. , Apache ,
: apachectl, /usr/ local/sbin
( ). apachectl
Apache :

500

4. FreeBSD

# apachectl start
/usr/local/sbin/apachectl start: httpd started
# apachectl stop
/usr/local/sbin/apachectl stop: httpd stopped

/usr/local/etc/apache
. apachectl :
# apachectl restart
/usr/local/sbin/apachectl restart: httpd restarted

restart apachectl
kill -HUP httpd: (
);
. Apache
(, , ),
"" , SIGHUP
SIGUSR1.
. , .
# apachectl graceful
/usr/local/sbin/apachectl graceful: httpd gracefully restarted

apachectl configtest.
Apache ( , ) /usr/local/etc/apache ,
start. : ,
. ,
restart graceful: apachectl configtest
.
, .
restart
graceful:
# apachectl graceful
/usr/local/sbin/apachectl graceful: configuration broken, ignoring restart
/usr/local/sbin/apachectl graceful: (run 'apachectl configtest' for details)

Apache , apachectl restart apachectl


graceful .


Web-, , .

xo/IP- .
.

26. Web-

501


, ,
IP-
. (httpd.conf) (
) .htaccess ,
, ( ).
,
.htaccess , .
, (Allow, Deny Order)
/usr/local/www/data ( ,
<Directory>), AllowOverride Limit.
Apache , Allow Deny,
.
,
, .htaccess :
Order
Deny
Allow
Allow
Allow
Allow
Allow

deny,allow
from all
from 64.41.131.102
from stripes.somewhere.com
from nowhere. com
from 10.5.100
from 10.67.22.211/255.255.255.0

, .
: ,
. , ,
:
Order allow,deny
Allow from all
Deny from 133t.hacker.com
Deny from 192.168

( httpd.conf), <Directory> <Location>.


( ),
<Files> <FilesMatch>,
.
<Files "*.jpg">
Order deny,allow
Deny from all
Allow
</Files>

from

64.41.131.102

FilesMatch .
, ,gif, .jpg, .jpeg
.png:
<FilesMatch "\ .(gif|jpe?g|png)$">
Order deny,allow
Deny from all
Allow from 64.41.131.102
</FilesMatch>

502

4. FreeBSD

, <Directory> <Location>
.htaccess .
<Limit>, (limit , ),
.
, . ,
GET POST, .
<LimitExcept>, , ,
.
,
/home.


.
(, ),
IP-.
.
Apache ,
/etc/master.passwd .
,
. FreeBSD
,
, Apache Web-
Web-.
(, -
), .
,
.

.htaccess ( httpd.conf),
<Directory>, <Location> <Files>,
.
,
Apache. :
AuthType Basic AuthName "Restricted
Area" AuthUserFile
/usr/local/www/.htpasswd Require validuser

, .
( ) . :
AuthType. Basic Digest.
Basic.
AuthName. . (, "Enter username for

26. Web-

503

'Restricted Area' at www.somewhere.com" " '


' www.somewhere.com"), ,
. . , .
AuthUserFile, AuthDBUserFile AuthDBMUserFile. ,
/ .
, . , AuthUserFile, db
dbm, ( ), AuthDBUserFile AuthDBMUserFile, .
,
db/dbm, .
AuthGroupFile, AuthDBGroupFile AuthDBMGroupFile.
, AuthUserFile.
AuthUserFile, , . ,
, AuthUserFile ,
, .
Require. Apache, . valid-user ( AuthUserFile;
), user <username> <username>...
( ) group <groupname> <groupname>... ( ).


apachectl configtest , Apache. , , AuthUserFile.
htpasswd, FreeBSD /usr/
local/bin :
htpasswd - /usr/local/www/.htpasswd frank

- . htpasswd,
, . , , , . , - :
htpasswd -b /usr/local/www/.htpasswd joe Prld3L4ndz

-. htpasswd
MD5, crypt(),
. man apachectl.

504

4. FreeBSD

,
Web- [nobody], . -
.htpasswd
. , ,
Web-, .. /usr/local/www/data -
publicjitml. Web , /usr/local/www. , ,
!


.
, , ,
.
db dbm
AuthDBUserFile AuthDBMUserFile. ,
- , /usr/local/bin/dbmmanage:
# dbmmanage /usr/local/www/.htpwddb adduser frank
New password:
Re-type new password:
User frank added with password encrypted to NtMDxy6jwyW7A using crypt

db- /usr/local/www/.htpwddb,
AuthDBUserFile.
dbm-.
man dbmmanage.


(AuthGroupFile) .
, :
mygroup: frank joe alice
, , .
,
.
dbmmanage,
, , ( /etc/group),
, , , . AuthGroupFile
, AuthDBUserFile, .
,
.



: .
Satisfy:
Allow from 64.41.131.102
Require valid-user Satisfy
all

26. Web-

505

Satisfy all ,
Allow Require. , , -,
Allow, -, ,
.
Satisfy any , ,
Allow.
, Web- ,
.


Web .
Apache. , www.mystore.com
www.frankspage.com DNS IP-, Apache
( ,
ServerName).
, HTTP/1.0 .
,
IP- ( IP, Ethernet-).
IP-, , Web-,
Web-. ,
IP-
IP-.
/1.1 .
Host: ,
, , Internet. ,
Host: .
.
IP-, ,
Web- Apache.
httpd.conf
, , Apache.
ServerName
URL- 301.
, ,
Host: .
.
, stripes.somewhere.com.
ServerName.
NameVirtualHost * ( " "),
<VirtualHost *>:

506

4. FreeBSD

NameVirtualHost *
<VirtualHost *>
ServerName www.somewhere.com
DocumentRoot /usr/local/www/data
ServerAdmin webmaster3somewhere.com
ErrorLog logs/www.somewhere.com-error_log
CustomLog logs/www.somewhere.com-access_log common
</VirtualHost>
<VirtualHost *>
ServerName www.frankspage.com
ServerAlias frankspage.com
DocumentRoot /home/frank/public_html
ServerAdmin frank@frankspage.com
ErrorLog logs/www.frankspage.com-error_log
CustomLog logs/www.frankspage.com-access_log common
</VirtualHost>

<VirtualHost> ServerName .
DocumentRoot ,
, a ErrorLog CustomLog log-
. ServerAlias
. <VirtualHost> .
, , ,
(stripes.somewhere.com) , IP- , <VirtualHost>,
.
:
NameVirtualHost *
<VirtualHost *>
ServerName stripes.somewhere.com
</VirtualHost>
<VirtualHost *>
ServerName www.somewhere.com
ServerAlias *.somewhere.com
DocumentRoot /usr/local/www/data
ServerAdmin webmaster@somewhere.com
ErrorLog logs/www.somewhere.com-error_log
CustomLog logs/www.somewhere.com-access_log common
</VirtualHost>
<VirtualHost *>
ServerName www.frankspage.com
ServerAlias frankspage.com
DocumentRoot /home/frank/public_html
ServerAdmin frank@frankspage.com
ErrorLog logs/www.frankspage.com-error_log
CustomLog logs/www.frankspage.com-access_log common
</VirtualHost>

: IP <VirtualHost>.
http://httpd.apache.org/docs/vhosts/.

26. Web-

507

Apache
Apache .
.
Apache ,
(dynamic shared objects, DSO),
.


, Apache, httpd
-1:
# httpd -I Compiled-in
modules:
http_core.
mod_so.
suexec:
/usr/local/sbin/suexec

disabled;

invalid

wrapper

, Core mod_so.
Core Apache,
, a mod_so DSO,
, Apache,
.

suexec . Apache
setuid (
]. suexec . http://httpd.apache.org/docs/
suexec.html. 29 CGIwrap suexec.


httpd, .
, httpd.conf.
- ,
Apache. Apache
http://httpd.apache.org/docs/mod/.
: LoadModuIe ( httpd) AddModule ( ). httpd.conf, ,
LoadModuIe AddModule Apache,
/usr/local/libexec/apache. .
, .
.


Apache ,
.

508

4. FreeBSD

, Apache,
. Apache
. ,
mod_perl, Apache
Perl, CGI- ,
- CGI . mod_php4, Apache
PHP- ( - UNIX-
ASP). /usr/ports/www 34
Apache. mod_.

apxs
, DSO , , ,
Apache , ""
. "" (- ,
Apache), .
Apache
, .
apxs, APache eXtenSion ( Apache). , /usr/local/sbin, , ,
DSO, (
mod_so), , httpd.
Apache : apxs
.so,
LoadModule, .
, apxs .
. ,
( ),
/usr/ports/www make. apxs.
Apache,
. ,
.
.
mod_perl
raodjerl. Perl
CGI-, Perl
Apache. HTTP-
CGI- Perl, Apache
, .
mod_perl Perl Apache.

Perl, Apache . ,

26. Web-

509

, Apache,
. CGI-, ,
.
mod_perl http://
perl.apache.org.

mod_python
Python Perl mod_python, Apache Python, mod_perl Perl.
Python Apache ,
CGI- .
mod_python www.modpython.org.

mod_php
PHP, UNIX,
Apache mod_php3 mod_php4.
Apache php-,
.
mod_php4 httpd.conf ,
php- phps-.
mod_php4 Web- www.php.net.
, Apache.
Apache , FreeBSD
HTTP-.


Apache -
, HTML-
. (server-side includes)
,
HTML- -
.
HTML (parsed
HTML). HTML-, Apache
,
. :
<!#command attribute=value attribute=value ... -->

, command include, exec, config, echo ..


attribute=value ( )
( ) .

510

4. FreeBSD

, Apache
httpd.conf (
.htaccess):
AddType text/html .shtml
AddHandler server-parsed .shtml

Includes <Directory> <Location> (


.htaccess), Web-:
Options +Includes

AddType MIME, -
, /usr/local/etc/apache/mime.types, a AddHandler
(
, ).
shtml ( HTML-,
).

, html- shtml . HTML-. html , .shtml.


html- htm- .

:
<! echo var="HTTP_USER_AGENT"--> , .
, CGI-.
<!--#set var="e-mail" value="me@somewhere.com""> -- e-mail me@somewhere.com .
<!~#include virtual="/toolbar.html"> /toolbar.html. ,
, , . ( !)
<!--#config timefmt="%A %B %d, %Y">
, .
, date. . man date.
<!--#flastmod file="index.shtml"--> index.shtml. config timefmt.
<!--# cgi="/cgi-bin/counter"--> CGI- counter .
shtml- , - ,
. HTML, . , ,
. , Apache -

26. Web-

511

. , AddType
AddHandler Web-.

, index.html.
Directorylndex :
Directorylndex index.php index.php3 index.html index.shtml
Apache ,
( Options Indexes ), .
:

Options +MultiViews
Directorylndex index INDEX
MultiViews Apache , ( ) , a Directorylndex ,
index.* ( ). .
, index.htm, index.HTM, INDEX.HTML ..

, :
CGI-,
http://httpd.apache.org/docs/howto/ssi.html.

CGI
Web- HTML-. . Web- ( , , )
. CGI, Common
Gateway Interface ( ).
CGI -, Web-, HTML-
,
. CGI- Perl, ,
, ,
Apache (nobody). Apache Web-. , CGI-,
HTML-, , Sendmail,
()
HTML-. ,
- Perl.

CGI Apache
CGI- Apache. , , httpd.conf ScriptAlias, CGI-
( Web-):

512

4. FreeBSD

ScriptAlias /cgi-bin/ "/usr/local/www/cgi-bin/"

, httpd.conf , Apache,
cgi-bin , CGI, , ,
CGI-. -
, 500 (Server Error), ..
CGI. ScriptAlias . CGI-
(, /usr/local/www/cgi-bin/)
Web-.
, nobody.
Web-. ,
CGI- .
.

, /cgi-bin/ .
, . CGI Apache (,
script.cgi] ScriptAlias (, /cgi-bin/), -
( , /cgi-bin/script.cgi]
301 .

CGI-
Options ExecCGI ,
<Directory> <Location>. CGI-
public_html.
(, .cgi) .
cgi-, :
<Directory /home/*/public_html>
Options +ExecCGI
AddHandler cgi-script .cgi
</Directory>

CGI- ( ScriptAlias
) - ,
500 (Server Error).
log- Apache.
blah Perl /usr/local/www/cgi-bin:
# tail /var/log/httpd-error.log
syntax error at /usr/local/www/cgi-bin/blah line 3, at EOF
Execution of /usr/local/www/cgi-bin/blah aborted due to compilation
errors.
[Tue May 22 22:06:26 2001] [error] [client 64.2.43.44] Premature end of
script headers: /usr/local/www/cgi-bin/blah

Perl. ,
.
Apache , ,
- HTTP-, , Content-type: (
CGI-). , ,
CGI-, .

26. Web-

513

CGI-
, CGI- , URL ,
(=), -
(&). (STDIN).
CGI- Perl,
. :
Perl, Web-, , a
CGI ,
. Perl CGI-,
.
Perl ( 21)
.
HTML- ( ,
, , ..)
, . CGI- Perl
HTML-:
<FORM NAME="myform" METHOD="POST" ACTION="/ogi-bin/post2me">

, CGI post2me. Perl,


. , ,
(
):
read(STDIN, $buffer, $ENV{ ' CONTENT_LENGTH ' }) ;
@pairs = split (/&/, $buf fer) ; foreach $pair
(gpairs) {
($name, $value) = split(/=/, $pair) ;
$value =- tr/+/ /;
$value =~ s/%([a-fA-FO-9] [a-fA-FO-9] ) /pack("C" , hex($l) ) /eg;
$value =~ s/~!/ ~!/g;
$FORM{$name} = $value;

, .
. , CGl-npo
HTML- , ,
HTML-, , - ,
. http nobody ( -
), . , , .
HTML-, -
.
,
%FORM. , e-mail
$FORM{'e-maiI'}.

514

4. FreeBSD

HTML-.
: HTML- , -
, URL,
.
Content-type:, MIME (
, ),
, :
print "Content-type: text/html\n\n";

, ,
HTML-. , text/ plain.
() Location: URL:
print "Location: http://www.somewhereelse.com/path/to/file.html\n\n";

, , , -
URL.
CGI- , HTTP- -
. : HTTP_REFERER (URL

),
HTTP_USER_AGENT
(
),
REMOTE_HOST ( ) ..
printenv, Apache (
/usr/local/www/cgi-bin). URL
http://www.somewhere.com/cgi-bin/printenv, , , IP FreeBSD-. Perl
%ENV, , $ENV{ 'REMOTE_HOST'}.
CGI- Perl, HTML (name, e-mail comments),
. ,
26.1, - sendcomments.cgi.
26.1 CGI- Perl
#!/usr/bin/perl
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
Spairs = split(/S/, $buffer); foreach $pair
(Spairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-FO-9][a-fA-FO-9])/pack("C", hex($l))/eg;
$value =~ a/~!/ ~!/g;
$ FORM {$ name} = $value; }
print "Content-type: text/html\n\n";
open (MAIL,"| /usr/sbin/sendmail -oi -t") ;
print MAIL "From: $FORM{'name'} <$FORM{'e-mail1}>\n";
print MAIL "To: you\@your.hostname.com\n";

26. Web-

515

print MAIL "Subject: Form output\n\n";


print MAIL "$FORM{ 'name' } , from $ENV{ ' REMOTE_HOST ' } ($ENV{ ' REMOTE_ADDR' }) ,
has sent you the following comment:\n\n";
print MAIL "$FORM{'comment'}\n";
close (MAIL) ;
print qqA<HTML>\n<HEAD>\n<TITLE>Thank you!</TITLEX/HEAD>\nA;
print qqA<BODYXH3>Thank you!</H3>\nThanks for your comments! </H3>\n</
BODY>\n</HTML>A;

,
- : ( @
).
, , ,
, ,
- .
CGI- HTML POST.
URL CGI, ( %FORM, ). URL :
http://www.somewhere.com/cgi-bin/sysinfo?frank+3

URL sysinfo /cgi-bin/. , , (query string). @ARGV.


(+). sysinfo frank $ARGV[0], 3 $ARGV[1].

Perl QUERY STRING,


$EIMV{ QUERY STRING'}

27

FTP-

FTP
FTP
FTP-
-
FTP

FTP-

27. FTP-

517

FreeBSD FTP-,
, .
. FreeBSD-
, . FTP, , .
,
FTP. .

FTP
FTP HTTP .
,
:
Web- http://, ftp://.
,
. . 27.1
.
27.1 FTP HTTP

FTP

HTTP

(Dual connection)

(Single connection)


( MIME)


(mkdir, rm, rename ..)

FTP HTTP : FTP


. ,
,
. (,
HTTP , , .. ,
"" .) FTP
. , :
(control
connection ),
(data connection ). FTP-
. 27.1.

518

4. FreeBSD

27.1

FTP


.

FTP- ( ftp, FreeBSD)


FTP- 21- . . (, Is get
picturel.gif), TCP-,
,
, . . , FTP, 27.1.
27.1 FTP- __________________________________
# ftp spots.somewhere.com
Connected to spots.somewhere.com.
220 spots.somewhere.com FTP server (Version 6.00LS) ready.
Name (spots.somewhere.com:frank):
331 Password required for frank.
Password:
230 User frank logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd mydir
250 CWD command successful.

ftp> Is

150 Opening ASCII mode data connection for '/bin/Is'.


total 484
-rw-rr 1 frank
frank
43175 Apr
8 01:14 addresses.txt
-rw-rr 1 frank frank
100523 Apr
8 01:14 contents.html
-rw-rr 1 frank
frank
37864 Apr
8 01:14 directions
-rw-rr 1 frank frank
37308 Apr
8 01:14 lk_logo.gif
-rw-rr 1 frank frank
52427 Apr
8 01:12 picturel.gif
-rw-rr-- 1 frank frank
18648 Apr 24 13:04 picture2.jpg
-rw-rr 1 frank
frank
175325 Apr
8 01:14 resume.html
226 Transfer complete.
ftp> get picturel.gif
local: picturel.gif remote: picturel.gif
150 Opening BINARY mode data connection for 'picturel.gif' (52427 bytes).
100% |**************************************************| 52427
00:00 ETA
226 Transfer complete.
52427 bytes received in 4.99 seconds (10.25 KB/s)
ftp> quit
221 Goodbye.


, Telnet-.
HTTP, , , Apache
HTTP, FTP , FTP-.

27. FTP-

519

FTP- Telnet.
FTP, ( ) FTP (anonymous FTP), .
F3T , : Is, cd, mkdir, pwd .. , .
led. , , FTP-.
put ( ), get ( ), mput ( ) mget ( ). (, RETR, STOR, CWD
LIST), -,
, HTTP. . man ftpd.

FTP : ASCII ( ,
- , , .. CR/LF DOS/Windows, CR Macintosh
LF UNIX); Binary () ( ). FTP- , ,
. ASCII Binary
. bin asc
, , HTML Perl, ASCII.
. ,
Perl, -UNI-, .
, . ASCII .

FTP-, FreeBSD ,
BSD- ftpd. inetd, telnetd Qpopper,
. ,
, (, WU-FTPD
ProFTPD). ,
.
. -
FreeBSD.

FTP
FTP,
FTP- ,
. /etc ,
, -

520

4. FreeBSD

. FTP-, .
FTP, FTP
( Apache), .
/var/ftp ,
, .

-
, ,
FTP ,
. ls.
, FTP-.
FTP- -,
. -,
anonymous ( ftp) (- ,
) .
"" FTP: /var/ftp, - ftp (
).

. chroot
, /var/ftp.
( ) , /var/ftp. ,
, cd
/usr/local
, . , cd /pub,
/var/ftp/pub.
, ,
/etc/ftpchroot.

FTP-
FTP ,
/etc, /var/ftp/etc.
, FTP,
/var/ftp.
/etc, FTP-.
/etc/ftpusers. " " ,
FTP. FTP .
/etc/ftpchroot. , ( , ),
.

27. FTP-

521

/etc/ftphosts. , Apache (. 26).


/etc/ftpwelcome. . , , .
/etc/ftpmotd. (Message Of The Day - " "), .
/etc/shells. 12.
, , ,
. , bin, tty nobody,
.
/etc, , FTP-.
. /var/ftp
/, ,
/bin, /etc. FTP- ,
/bin/Is /bin/date .
,
/var/ftp/bin.
/var/ftp .
, "" (, ,
/var/ftp/etc ).
/var/ftp/bin. Is date. FTP-, , (
) /bin/Is /bin/date . .
/var/ftp/etc/passwd, /var/ftp/etc/group. /var/ftp/bin, /etc/passwd /etc/group.
. FTP-
/var/ftp,
/var/ftp.
root ,
, , . , /var/ftp/etc/passwd, ,
.
/var/ftp/etc/ftpmotd. /etc/ftpmotd,
. , /etc/ftpmotd.
/var/ftp/pub. /pub, . /pub .

522

4. FreeBSD

/var/ftp/incoming.
(sticky bit) (1777). ,
. ,
: .
!
, FTP-cep /etc/inetd.conf. , ftpd
inetd , inetd .
ps , :
# ps -waux | grep inetd
root
1640
0.0
0.6
inetd -Ww

1048

780

??

Ss

ThuO8PM

0:00.15

inetd , ,
/etc/rc.conf. inetd_enable="NO" .
/etc/inetd.conf , ftpd :
ftp

stream

tcp

nowait

root

/usr/libexec/ftpd

ftpd -1

, inetd
( killall -HUP inetd). ,
(ftp localhost). ,
. , . , inetd.

-
FTP ,
. (, Web-), ,
. , , ( )
, ,
. 29, : Telnet SSH,
HTTP Secure HTTP, a POPS IMAP . FTP ,
(, sftp sftpd ), FTP ,
. ,
, 29. , FTP
.
,
FTP . . /etc/ftpusers /etc/
shells. , /var/run/nologin, ,
.

27. FTP-

523

/etc/ftpusers
FTP- /etc/ftpusers,
FreeBSD
(operator, bin, tty ..). , a
ftpd , .
/etc/ftpusers .
. ftpd
,
- . FTP-
, :
# ftp

localhost

Connected to localhost.somewhere.com.
220 stripes.somewhere.com FTP server (Version 6.00LS) ready.
Name (localhost:frank):
530 User frank access denied.
ftp: Login failed.
ftp>

, access denied [ )
.
, -
.

/etc/ftpusers .
@, , users. ,
.

/etc/shells
/etc/ftpusers ftpd ,
/etc/shells.
, - access denied.
FTP ,
/sbin/nologin.
12. account not available (
) .

/var/run/nologin
FTP /etc/inetd.conf
nologin
/var/run. ftpd ,
:
#

ftp

localhost

Connected to localhost.somewhere.com.
530 System not available.
ftp>

524

4. FreeBSD

( ) touch
/var/run/nologin. FTP-,
(rm /var/run/nologin).

FTP
FTP .
sysinstall. /stand/sysinstall,
Configure Networking. Anon FTP
. Anonymous FTP Configuration,
. 27.2.
, , FreeBSD-.
UID, Group Comment , ftp.
FTP : ftp
, /etc/ftpchroot,
ftp ( anonymous)
/var/ftp.

27.2

FTP.

, (, UID, 14, incoming, ). ftp


/var/ftp.
/stand/sysinstall FTP
, , :
/var/ftp.
ftp.
ftp /etc/ftpusers (,
).
, incoming ,
755 ( , root).
, 1777: chmod 1777 /var/ftp/incoming.

27. FTP-

525


"" IP-,
FTP-. /etc/
ftphosts, FreeBSD (
).
,
, .
, (
/etc/ftphosts) . 27.2.
27.2 /etc/ftphosts

Hostname IP- . ,

FTP Host:,
/1.1, FTP
IP- , ,
, ftpd
IP-.
.
User

,
ftp
FTP .
,
/var/ftp/etc
/var/ftp/bin.

Statfile

,
FTP .

/var/log/ftpd

Welcome

,
FTP-.

/etc/ftpwelcome

MOTD

, .

/etc/ftpmotd

/etc/ftphosts.
(-), .
64.41.131.106
frank
/home/frank/welcome2
ftp2.somewhere.com ftp2
64.41.131.107

ftp3

/var/log/ftpd-frank

/home/frank/welcome
/etc/ftpd2welcome

/var/log/ftpd-3
-

FTP
FTP-. : WU-FTP ProFTPD
.

526

4. FreeBSD

WU-FTPD
(Washington University)

WUarchive, WU-FTPD
FTP- . Linux
UNIX. ftpd,
FreeBSD. ,
ftpd (, ,
, ). WUFTPD ,
FreeBSD.
WU-FTPD (/usr/ports/ftp/wu-ftpd).
ftpd , ftp
/etc/inetd.conf :
ftp
stream
stream tcp

tcp
nowait
nowait root

root
/usr/local/libexec/ftpd
ftpd -1 #ftp
/usr/libexec/ftpd
ftpd -1

WU-FTPD /usr/local/libexec/ftpd,
, man ftpd .
-MI,
man-: man -M /usr/local/man ftpd

WU-FTPD Web- http://


www.wu-ftpd.org.

ProFTPD
ProFTPD FTP-,
, Apache.
, httpd.conf ( 26),
Apache. ,
Apache, .
,
Apache. (/usr/ports/ftp/ pro ftpd).
ProFTPD , ,
Apache, , inetd.
inetd, ftp ,
/usr/local/libexec/proftpd:
ftp
stream

stream tcp
tcp
nowait

nowait root
/usr/local/libexec/proftpd
root
/usr/libexec/ftpd
ftpd -1

proftpd #ftp

ProFTPD http://www.proftpd.org
.

28

Internet

?
NAT FreeBSD
NAT



Internet
Donee

528

4. FreeBSD

22, NAT
(network address translation ). 23
,
.
FreeBSD .
.
.

?
, , .
. , ,
.

. ,
.
, .

, . .
28.1 , -
.
28.1.
.

, 28.1, , lion, cheetah, tiger puma, ""


, - .
wolf, bear, fox lynx ""
. , . -
, .
.
, . . 28.2 ,
.
28.2.

28. Internet

529


- . (
, , . 23.)
, ? - -
, , , ""
-. .
"" .
, ,
, . .
, , cheetah
lynx. , cheetah
lynx. lynx cheetah
simba, - . simba "" lynx, ,
lynx
( falcon). lynx.
. ( ), , , .
,
, . -
, .
. , ? , ,
? .
.
. Internet.
"", . ,
.
.
, . , , lion
cheetah ( - ),
. ,
, .
,
Internet, , Internet.
, (
). ,
. "",
,
. , ,
. ,
Internet.

530

4. FreeBSD

?
,
, : "".
" " ""
-.
simba falcon .
,
. , , .
; .
, "
" "" .
,
Internet .

NAT?
NAT Network Address Translation (
) Internet
IP-. ,
NAT NAT
.
Internet, NAT. NAT ""
IP- Internet
IP- ( , IP-, NAT).
IP- ( NAT). NAT
,
IP-.
:
IP-. IP- .
IP-, . NAT
IP- .
Internet , ..

Internet.
,
, Internet .

FreeBSD.
Internet
.

NAT FreeBSD
Internet,
. , Internet.
. 28.3.

28. Internet

531

,
Internet .
,
NAT.
28.3.

. simba
Internet . ,

lion, tiger, cheetah puma,
Internet simba

. ,
, Internet.
Ethernet (, edO).
. "" ,
. Internet. Internet
edO
. ,
Internet, edO,
Internet. ,
,
.


, ,
. Internet ,
, , .
( Internet) ,
FreeBSD ,
.
. ,
Sysinstall. ,

. .
/etc/rc.conf :
gateway_enable="YES"

,
.
IP-,
. ,
simba . ,

532

4. FreeBSD

, , ,
.
.

, ,
, Internet. , 23,
( Internet
ADSL ).
Internet , 24,
.

, , Internet
IP-.
IP-.
Internet (NAT).

NAT
Internet
(User ) (Kernel ).
Internet ,
NAT User ,
.

Internet ,
.
NAT .
,



FreeBSD
NAT, .
-nat .
, ( .
24).
Windows, Macintosh .
. " " .


Internet

Internet (ADSL, , Tl, OC3)
.
NAT (natd), .

28. Internet

533

, . , , . :
options IPFIREWALL
options
IPDIVERT

,
, , .
, ,

" " 29.
, - ,
.
, 17,
.
, natd.

natd
natd
Sysinstall, , /etc/rc.conf. , ,
.
/etc/rc.conf :
natd_enable="YES"
natd_interface="pppO"

natd_interface ,
Internet , .
Ethernet (
ADSL, , 1 )
, .
natd , .
,
natd.
rc.conf,
. .


/etc/rc.conf
:
firewall_enable="YES"


29. , .
, /etc/rc.conf :
firewall_type="/usr/local/etc/firewall.conf"

534

4. FreeBSD

, /etc/rc.conf, .
/usr/local/etc/firewall.conf,
( , ,
, . 29).
, /usr/local/etc/
firewall.conf :
add divert natd all from any to any via edO add
allow all from any to any

, ,
, .
, , root.
chmod 600 /usr/local/etc/firewall.conf.

,
,
. . .
" " 29, .

, ,
natd . . . .
.




. Windows, Macintosh, FreeBSD Linux.
: ,
,
.
, , ,
.

Windows 95/98
Windows 95 98,
My Computer, Control
Panel , , Network.
, . 28.4.

28. Internet

535

TCP/IP, Properties.
TCP/IP.
Gateway, , . 28.5.

28.4 Network
Configuration Windows 98. Windows 95
Windows ME

28.5.
Gate-way
Windows 98

IP- New gateway, . (


, IP- 64.41.131.72.)
Add, (Installed
gateways). . .
, . Windows 95
98 , ,
. Windows ME
.
Internet Windows.

Mac OS Mac OS X
Macintosh
FreeBSD, Windows-, TCP/IP
.
Mac OS (
9), TCP/IP, . 28.6,
Manually () Configure:, .
IP- Router address:.
.
.
Mac OS X System Preferences Network, . 28.7. Mac OS 9, Manually
Configure:

536

4. FreeBSD

IP- Router:. Save . .

28.6.

TCP/IP OS 9

28.7.

TCP/IP OSX


Ethernet, AirPort .
.

FreeBSD
FreeBSD,
/etc/rc.conf:
defaultrouter="64.41.131.162"

, IP- IP-
FreeBSD, .
, .

28. Internet 537

,
, root:
route add default 64.41.131.162

Linux
- Linux Linux FreeBSD
. , . , .

Linux
. Linux,
.

Red Hat Linux


Red Hat Linux /etc/sysconfig/network.
FreeBSD,
:
GATEWAY=64.41.131.162

IP- IP-
FreeBSD, .
, , ,
GATEWAY .
Red Hat Linux , .
,
, root:
route

add default gw

64.41.131.162

Slackware Linux
Slackware Linux
/etc/rc.inetl. , .
FreeBSD,
:
GATEWAY="64.41.131.162"
IP- IP-
FreeBSD, .
, , ,
GATEWAY .
Slackware Linux , .
,
, root:
route add default gw 64.41.131.162

538

4. FreeBSD


Internet
,
, . ,
, .
.
Internet .
Internet .
FreeBSD .
, FreeBSD
.
. 28.1 ,
FreeBSD, ,
.
28.1. ,
FreeBSD

Aironet 4500/4800 802.11

device an

AMD Am79C930

device awi

Xircom CNU/Netware Airsurfer

device cnw

Lucent WaveLan 802.11

device wi

Lucent WaveLan ( ISA)

device wl

cnw wl,
GENERIC. , , cnw wl, (
,
).
, 17, .
, , .


. , simba
Internet . . 28.8
.
lion, tiger, cheetah puma simba
Internet. ,

28. Internet

539

simba
Internet. ,

. , ,
, ,
.

28.8.
simba


Internet


, . 28.9. simba
,
falcon
.
28.9.

. simba


, falcon,

, , simba Internet ,
falcon. , simba
. ,
simba, , ,
falcon, .
, falcon, .
, 205.211.117.. , falcon
IP- 169.151.116.121. simba ,
falcon, /etc/rc.conf.
defaultroute="212.214.Ill.59"
static_routes="falcon"
falcon="-net
205.211.117.0
169.151.116.121"

540

4. FreeBSD

IP- 212.214.111.59
simba. , simba ,
, .
212.214.111.59 Internet, simba.
. ,
, . simba,
, 205.211.117.0,
169.151.116.121. IP- falcon . , , falcon,
205.211.117.. , simba , falcon,
212.214.111.59. , ,
simba ,
, .
, . , , , .
, root:
route

add

-net

205.211.117.0

169.151.116.121


, .. , . ,
Internet. , ,
simba Internet Internet.
falcon Internet simba.
Internet.
, , Internet .
. .
,
. , , .
FreeBSD .
FreeBSD routed. ,
RIP (Routing Information Protocol
). RIP , , routed.
FreeBSD gated zebra
net .
FreeBSD . 15.
.
.

28. Internet

541

,
. , (, Internet).
.


(DMZ)

(DMZ), .
, (, Web-)
IP-,
NAT. .
Internet, ,
NAT, , NAT. , IP-, (Demilitarized Zone DMZ}. DMZ .
29.

29



,

[OpenSSH)
[ IMAP]
- < Apache

[securelevel]


[DOS]

29.

543

, ,
. ,
, , Windows, UNIX- FreeBSD. He ,
, , .. ,
. . ,
, FreeBSD
.
Internet .
"" ("rootkit") , , , ,
. ,
, . ,
.
.
root. , , ( " ")
. , (
last ps), ,
.
. , , ( ), , ( root) .
. ,
,
.
FreeBSD, , .
, ,
,
. " " -- . , ,
.


, , -
.
, , , ,
, ..

544

4. FreeBSD

" Internet". , ( ). ,
( ,
Internet ), , ,
,
.
" ". , Internet
, .
,

. ,
.
" ". ,
, : , ,
(
, ), ,
.
(, ). ,
,
, ,
.
, " " (,
Web- ), Internet,
.
" ".
, , .


. , , ( ,
chroot ), . , Web-
.
, ,
,
. :

29.

545

() ;
, () ;
;
SMTP;
;
.

FreeBSD
. ,
, .

SMTP
Internet, .
25.


,
. ,
FreeBSD ,
, ( ).
,
.
, , ,
"password" , ,
. , ,
, - . ,
, , " ", ..
. .
.
passwd ,
, passwd, .
, , ,
.
,
.


Crack
( , )
, "".
passwd ,
. 18
2-53

546

4. FreeBSD

, , passwd,
. FreeBSD
passwd
, .
, , ,
, .
Crack,
/usr/ports/security/ crack.
"", .
Crack " " (
), "" :
, , ..
, ,

.
Crack (
. 15), ,
/usr/local/crack, ,
root.
,
/usr/local/crack Crack (
, ):
#

./Crack -fmt bad /etc/master.passwd

Crack .
/etc/master.passwd, ,
Reporter
./Reporter -quiet

-----

passwords

cracked

as

of

Sun

Jan

14

12:17:41

EST

2001

------

979693112:Guessed frank [frank] Frank Jones [/etc/master.passwd /bin/tcsh]


979693187:Guessed joe [password] Joe User [/etc/master.passwd /usr/local/
bin/bash]

----- done ----- , . .


Frank frank, Joe password.
, .
,
.
Crack,
:
# make tidy
# rm run/F-merged

FreeBSD , , passwd
, -

29. 547
Crack. , Crack,
/usr/ports/security/cracklib. Linux cracklib
(pluggable authentication module )
, FreeBSD (. man pam],
FreeBSD cracklib
. ,

cracklib passwd, , ,
http://www.kearneys.ca/~brent/FreeBSD/passwd42.html.


FreeBSD .
,
.
FreeBSD, /etc/login.conf.

(, ,
, ,
,
man login.conf).
"" ,
chfn ( ).
, default
:
default:\
:passwd_format=md5:\
:copyright=/etc/COPYRIGHT:\

:welcome=/etc/motd:\
:setenv=MAIL=/var/mail/$,BLOCKSIZE=K,FTP_PASSIVE_MODE=YES:\

:path=/sbin /bin /usr/sbin /usr/bin /usr/games /usr/local/


sbin /usr/local/bin /usr/XHR6/bin ~/bin:\
:nologin=/var/run/nologin:\
:cputime=unlimited:\

:datasize=unlimited:\
:stacksize=unlimited: \

:memorylocked=unlimited:\
:memoryuse=unlimited: \

: filesize=unlimited:\
:coredumpsize=unlimited:\
: openfiles=unlimited:\
:maxproc=unlimited: \
:sbsize=unlimited: \

:priority=0:\
:ignoretimeS:\
:umask=022:

(\) "" ,
, .
default , passwordtime.
, , :

548

4. FreeBSD

default:\
:passwordime=90d:\
:passwd_format=md5:\
:copyright=/etc/COPYRIGHT:\
:welcome=/etc/motd:\

90 . , 2 (2 ), 6w (6 )
24h (24 ). , /etc/login.conf ,
- ( /etc/mail,
25), cap_mkdb :
# cap_mkdb /etc/login.conf

,
90 ,
. , passwordtime , passwd
/etc/
master.passwd:
frank:$l$LXZkCuzD$7Oa8LyRf5jYOb.XrXiB3d.:1060:100::999066364:0::/home/frank:/
^bin/tcsh

login.conf .
minpasswordlen:
:minpasswordlen=8:\
8 .



, 123 ChangeThis.
,
.
, .
(, ),
. md5
:
# md5 -s "asdsad"
MD5
("asdsad")
=

503778522671892129806

(,
b5b0377) ,
, passwd , .
Perl, MD5
rand ( ).

29.

549

S/Key
,
, ,
: ,
.
(key),

Java, . http://www.cs.umd.edu/~harry/jotp/src.html. ( FreeBSD
MD4.)
,
SSH Telnet ( SSH ).

,
"" ("challenge" phrase) ,
( ),
.
.
.

S/Key ,
. S/Key,
keyinit,

, ,
.

, , Frank UNIX, S/Key. (


, , SSH),
keyinit S/Key:
# keyinit
Adding frank:
Reminder-Only use this method if you are directly connected.
If you are using telnet or rlogin exit with no password and use
keyinit -s. Enter secret
password: Again secret
password:
ID frank
HELM TAB

s/key is
DRY TRIM

99

st28077 COL

APT

Frank (,
Telnet), keyinit -s. -s
keyinit . Frank
[
S/Key UNIX)
. ,
, . -s
Frank key ,

550

4. FreeBSD

Windows, Macintosh UNIX ,


keyinit s/key access password: (
-s].

Frank keyinit
S/Key,
/etc/skeykeys, /etc/
skey.access ( ) :
deny user frank

/etc/skey.access FreeBSD,
UNIX,
S/Key. skey.access ,
permit (
S/Key, UNIX) deny ( S/Key),
. ,
man skey.access,
, , ,
. ,
Frank
S/Key, UNIX.
Frank
Telnet :
# telnet
Trying
Escape

stripes.somewhere.com
64.41.131.102... Connected

to

stripes.somewhere.com.

character is `^}`.

FreeBSD/1386

(stripes.somewhere.com) (ttyp2)

login: frank s/key 99


st28077 Password:

Frank key ( )
. , : (99 ;
, 99 , keyinit
) "" ( , st28077 ,
keyinit). Frank
S/Key,
:
# key 99 st28077
Reminder - Do not use this program while logged in via telnet or rlogin.
Enter secret password:
COL APT HELM TAB DRY TRIM

Frank ,
. ,
( ).
Frank S/Key
98, . ,

29.

551

. Frank keyinit ,
99, ,
. (,
/etc/skey.access, deny permit
S/Key.)

Frank , key
-. ,
:
# key -n 5 50 st28077
Reminder Do not use this program while logged in via telnet or rlogin.
Enter secret password:
41:
42:
43:
44:
45:

SHOT
CHOW
DOCK
WALE
GIFT

YOU BIEN GIN JUDD AS


AVIS DOES EMIT FLAM WORK
ATE ANN HAS JOCK OAT
AWL ELK LETS AWK WALE
BERT ROD GRIN YANG EAST

S/Key su,
root .
S/Key ,
/etc/skeykeys, /etc/
skey.access.

Kerberos
Kerberos. Athena
Kerberos
"" ("tickets") Telnet, FTP, POP3 NFS
. ,
, Kerberos ,
Kerberos. FreeBSD
Kerberos, ,
Kerberos , .
Kerberos
.
, , . ,
, Kerberos
. ,
, UNIX.
Kerberos
, Windows
2000 Kerberos ( ),
.
FreeBSD.
Kerberos FreeBSD,
. kerberos_server_enable="YES" /etc/rc.conf

552

4. FreeBSD

, Kerberos.
,
/etc/pam.conf
, , : login auth sufficient
pam_kerberos!V.so try_first_pass
Kerberos
man kerberos FreeBSD
(http://www.freebsd.org/handbook).

,

, (
Telnet, HTTP) (
), ,
, , -
, .
,
Internet ,
, . -
"", ,
- . ,
?
. , (,
), . ,
" " ("security through obscurity")
, , ,
, .
. ,
, ,
. , ,
.

tcpdump

,
, ,
, .
Ethernet "" ("promiscuous
mode"), , , ,
( 22).

.
.

29. 553

FreeBSD tcpdump,
/usr/sbin.
(Permission denied) /dev/bpfO
( ). (root).
tcpdump
TCP/IP (
EtherPeek WildPackets), , Crack,
, ,
, ,
.

tcpdump ,
. GENERIC
, .
, , , ,

. tcpdump
,
.

tcpdump
. , ,

TCP/IP .
Telnet (TCP- 23):
# tcpdump -x port 23 tcpdump:
listening on fxpO
20:14:19.076941
w044.Z064002043.sjc-ca.dsl.cnc.net.54109
>
w012.z064002043.sjc-ca.dsl.cnc.net.telnet:
S
1972342903:1972342903(0) win
32768 <mss 1460,,wscale 0,,,timestamp 465710 0> (DF) [tos 0x10]
4510 003 e44b 4000 4006 8024 4002 2b2c 4002 2bOc d35d 0017 758f
9077 0000 0000 a002 8000 OOlb 0000 0204 05b4 0103 0300 0101 080a 0007
12 0000 0000 20:14:19.077050
w012.z064002043.sjc-ca.dsl . cnc.net. telnet
> w044.Z064002043.sjc-ca.dsl.cnc.net.54109:
S 1734674412:1734674412(0) ack
1972342904 win 17520 <mss 1460> (DF)
4500 002c c9c2 4000 4006 9acd 4002 2bOc 4002
22 0017 d35d 6765 07ec 758f 9078 6012 4470
349c 0000 0204 05b4
20:14:19.677472
w044.Z064002043.sjc-ca.dsl.cnc.net.54109
>
w012.z064002043.sjc-ca.dsl.cnc.net.telnet: . ack 195 win 33580 (DF)
[tos 0x10]
4510 0028 e458 4000 4006 802b 4002 2b2c 4002
2bOc d35d 0017 758f 910a 6765 08af 5010 832c Oc49
0000 5555 5555 5555
^
134 packets received by filter
0 packets dropped by kernel

tcpdump "", (
-) , -

554

4. FreeBSD

, , .
. ,
, Telnet.
, ,
EtherPeek.
, tcpdump EtherPeek
. , IMAP, FTP HTTP,
Finger Syslog.
.
, .
, .
,
FreeBSD. , ,
.

(OpenSSH)
, Telnet
rlogin, , ,
. FreeBSD SSH (Secure Shell
), Telnet rlogin,

,
. OpenSSH,
OpenBSD, FreeBSD.
SSH 22 , sshd
( Apache) . SSH,
/etc/rc.conf ( )
( sshd):
sshd_enable="YES"

SSH Telnet. ssh


telnet :
#

ssh

stripes.somewhere.com

Ssh , ,
.
:
# ssh stripes.somewhere.com -1 frank
# ssh
frank@stripes.somewhere.com

ssh
.
Telnet, .
FreeBSD, Linux, UNIX Mac OS X
.

29.

555

Windows
Mac OS .
SSH ,
, Telnet, SSH.
Windows SecureCRT ( Van Dyke, http://www.vandyke.com)
SSH ( SSH Communications Security, http://www.ssh.com), Mac
NiftyTelnet/SSH MacSSH. Win-dows
, .
SSH
Telnet. , , ,
, SSH.
, ,
,
SSH . ,
Telnet
SSH. Telnet, telnetd
/etc/inetd.conf:
Stelnet stream top nowait root /usr/libexec/telnetd telnetd
inetd: # killall -HUP inetd

SSH : SSH1 SSH2. FreeBSD


, SSH1
, SSH2. SSH1,
/etc/ssh/ssh_config:
Protocol 2

, , SSH
SSH2. SSH1, , .

(
IMAP)
, , Telnet, (
).
, , , ,

, (
).
SSH Telnet,
.
25 qpopper
FreeBSD SSL (Secure Sockets Layer )
. -

556

4. FreeBSD

IMAP-UW.
SSL IMAP-UW ,
25. , -
(, qpopper), IMAP-UW.
. IMAP-UW http://www.washington.edu/imap/.
IMAP,
SSL SSL ,
stunnel.
( /usr/ports/security/stunnel)
SSL . ,
, .

(/usr/local/etc/rc.d/stunnel.sh.sample) 993 (
) 995 ( ),
, /etc/services.

stunnel.sh.sample stunnel.sh, 11.


.sample ,
[ .pern].

stunnel ,
qpopper IMAP-UW. stunnel
/usr/local/etc/stunnel.pem.
(993 143
995 110 ) .
,
SSL . , Microsoft
Outlook, ,
.
SSL
, . , stunnel
, SSL,
. ,
, /etc/inetd.conf.
, IPFW (
),
, localhost.

-
FTP, 27,
.
, . FTP
, Telnet, , ,

29. 557

Web-, , ,
. , .
, FTP SSH. SSH ( , ), FTP . FTP
SSH: SSH ,
/usr/libexec/sftp-server . FTP
FTP, .
FreeBSD FTP
sftp, OpenSSH. Windows FTP, FreeBSD,
SSH Communications Security. Mac OS FTP.
scp.
, ,
r ( . man rep man scp),
SSH. SSH,
NiftyTelnet/SSH c, .
scp
SSH, :
# scp file.txt stripes:
frank@stripes's password:
file.txt
100% |*****************************|

511

00:00

(:),
, . , .
, -.

Apache
HTTP. HTTP
,
, . ,

.
HTTP
SSL, ,
Apache - ,
SSL . ,
Apache SSL,
: Apache-SSL mod_ssl.
OpenSSL FreeBSD,
.

558

4. FreeBSD

HTTP .
HTTP SSL .
( Web-
,
, ],
.
Web .
,
. :
, .

Apache-SSL
"" Apache, Apache-SSL Apache Group,
mod_ssl.
, - .
Apache-SSL -
.
Apache-SSL httpsd, httpd. ,
httpd HTTP 80,
httpsd 443. , ,
Apache, SSL.
Apache-SSL (
/usr/ports/www/apachel3-ssl), Web- http://
www.apache-ssl.org.

Apache mod_ssl
SSL HTTP
Apache-SSL, mod_ssl Apache,
OpenSSL Apache
. , Apache-SSL,
. ,
apache 13-modssl , httpd,
apache13, ,
SSL:
<IfDefine SSL> Listen 80
Listen 443 </IfDefine>

Apache mod_ssl , mod_perl,


mod_php .., /usr/ports/www. mod_ssl
, ,
, Apache-SSL.
.
Apache mod_ssl /usr/ports/www/ apachel3modssl. Web- http://www.modssl.org.

29.

559

Web-
, Apache-SSL Apache mod_ssl,
Web- , . ,
Apache-SSL ,
httpd HTTP, ,
httpsd 443. ,
, httpsdctl, Apache-SSL,
apachectl Apache, httpsd.conf
/usr/local/etc/apache, httpd.conf. Apache
mod_ssl
, 26.
( apachel3-ssl, apache 13-modssl)
Apache, , HTML, .
Apache-SSL Apache.
mod_ssl ,
Apache, .
OpenSSL Web-,
, ,
.
(
, ), ,

. ,
.
,
(Security Information) , ,
.
,
.

CGI

Apache. He
( , )
, ,
.
Apache nobody ( ,
, )
nobody CGI- , CGI-
-, nobody.
, . , CGI-
,
. -

560

4. FreeBSD

, .
CGI-
. ,
,
Apache nobody.
Apache -"",
CGI- , (
) ,
nobody. suexec,
Apache.
, CGIWrap, (Nathan Neulinger).

CGI
CGIwrap
CGIWrap, /usr/
ports/www/cgiwrap, : CGI CGI- ,
.
, CGI- ,
, nobody. ,
,
, Web-.
CGI- ,
. CGI-, root,
, , ,
,
.
CGIWrap . , , -
, ,
CGI, ,
.
CGI ,
,
CGI, .
CGIWrap
cgiwrap ( ) cgi-bin
, /usr/Iocal/www/cgi-bin. CGIWrap Apache,
suexec, ,
URL :
http://www.somewhere.com/cgi-bin/cgiwrap/frank/myscript.cgi

:
<!#include

virtual="/ogi-bin/cgiwrap/frank/myscript.cgi">

myscript.cgi /home/frank/
public_html/cgi-bin. CGI-

29. 561
public_html/cgi-bin. , .
CGI- CGIWrap,
CGI
DocumentRoot-, , ,
, Options +ExecCGI.
Web- CGIWrap
http://cgiwrap.unixtools.org/.


(securelevel)
FreeBSD , -1
3, kern_securelevel /etc/rc.conf.
,
, ,
,
, IPFW
( , ).
17, securelevel
.
man securelevel.
FreeBSD
.
/stand/sysinstall, "Configure", "Security".
: Low,
Medium, High Extreme.
sendmail, sshd inetd . . 29.1
/etc/rc.conf:
29.1.

/etc/rc.conf

Low

sendmail_enable="YES"
sshd_enable="YES"
portmap_enable="YES"
inetd_enable="YES"

Medium

sendmail_enable="YES"
sshd_enable="YES"
inetd_enable="YES"

High

kern_securelevel="1"
kern_securelevel_enable="YES"
sendmail_enable="YES"
sshd_enable="YES"
portmap_enable="NO"

562

4. FreeBSD

/etc/rc.conf

nfs_server_enable="NO"
inetd_enable="NO"
Extreme

kern_securelevel="2"
kern_secureleveLenable="YES"
sendmail_enable="NO"
sshd_enable="NO"
portmap_enable="NO"
nfs_server_enable="NO"
inetd enable="NO"

, "Extreme"
. securelevel 2,
( )
,
, mount amount (
, amd, ). , inetd,
sendmail, sshd, NFS .
"High" . securelevel 1,
, .
sendmail sshd , , "Extreme",
.
,
/etc/rc.conf, .
29.1 , ,
. .
, ;
, . ,
.


, , ,
, ,
Internet. ,
" " ("script kiddies"), ,
, ,
. ,
, .
, IPFW, FreeBSD,
.
,
, .
,
. -

29.

563

; .

"" , , , ,
.
Internet.
. -,
, ( ,
). -, ,
,
. IPFW , ;
FreeBSD ,
, . . 29.1
, FreeBSD
(. 28),
(LAN), " " (DMZ) (WAN).
29.1.

LAN, DMZ WAN

" " ,
, . IP-
( 22)
Internet, ,
Web-, ,
Internet.
DMZ ,
. , ,
.
.


IPFW GENERIC. ,
,
17: IPFIREWALL, IPFIREWALL_VERBOSE
IPFIREWALL_VERBOSE_LIMIT=10. IPFW
,
/etc/rc.network.
, /etc/rc.conf:

564

4. FreeBSD

firewall_enable="YES"
firewall_type="open"

, (firewall_type="open"),
IPFW 65535 (
), IP-. ,
IPFW ,
, , , .

IPFW ,
. IPFW ,
,
, - .

open , IP-
(), . ,
, ,
, , .
. , ,
, .
/etc/rc.conf
/etc/netstart ( !).
:
Kernel firewall module loaded
Flushed all rules.
00100 allow ip from any to any via loO
00200 deny ip from any to 127.0.0.0/8
00300 deny ip from 127.0.0.0/8 to any
65000 allow ip from any to any
Firewall rules loaded, starting divert daemons:.

, IPFW , kldstat:
# kldstat
Id Refs Address
4
3 OxcOlOOOOO
5
1 OxcOeeeOOO
6
1 OxcOfl9000

Size
355be4
6000
12000

Name
kernel
ipfw.ko
linux.ko

ipfw,
, IPFW.

NATD Internet,
28, , NATD
IPDIVERT. . 28.

29.

565

IPFW

ipfw. ,
; (, deny), ,
(, tcp), ,
from to. , , TCP,
badhost.com, deny tcp from badhost.com to any, a
:
# ipfw add deny tcp from badhost.com to any

.
(, 255.255.255.0),
CIDR (, /24).
, , .. IP . ,
, :
# ipfw add deny all from evil.isp.com/16 to www.somewhere.com 80

,
allow, , :
# ipfw add allow all from goodhost.evil.isp.com to
~*www. somewhere. com 8 0

, IPFW . , 100 , ,
, add ipfw.
. ipfw -a list:
# ipfw -a list
00100

allow ip
00200
0
0 deny ip
00300
0
0 deny ip
00400
0
0 deny tcp
00500
0
0 ipfw add
www.somewhere.com 80
00600
0
0 ipfw add
www.somewhere.com 80
65000
1214 79688 allow ip
65535
1
40 deny ip

from any to any via loO


from any to
127.0.0.0/8
from 127.0.0.0/8 to any
from badhost.com to any
deny all from evil.isp.com/16 to
allow all from goodhost.evil.isp.com to
from any to any
from any to any

. 65535, ,
, ,
. ,
allow,
,
, .
,
, . ,
.
/etc/rc.conf .
, . 29.2.
-

566

4. FreeBSD

,
/etc/rc.firewall.
29.2.

open

closed

IP,

client

simple

unknown

He ,
65535

< >

(I)

"" IPFW, client simple.


, , .
;
/etc/firewall.conf. ,
ipfw:
add deny
add deny
add allow
add 65000

tcp
all
all

from badhost.com to any


from evil.isp.com/16 to www.somewhere.com 80
from goodhost.evil.isp.com
to
www.somewhere.com

allow

all

from

any

to

80

any

( firewall_type) /etc/rc.conf:
firewall_type="/etc/firewall.conf"
/etc/netstart
/etc/ firewall.conf 100, 200, 300 .. allow
all 65000 ,
. , .
IPFW
man ipfw FreeBSD Handbook
http://www.freebsd.org/ handbook.


,
.
, "rootkit" ,
.
,
. ,
.
.

29.

567

PortSentry
PortSentry, Psionic Software, ,
, ,
-
, ,
. , PortSentry
, " "
IPFW,
. PortSentry TCP-, UDP-;
,
, ,
, .
, PortSentry
(/usr/ports/security/portsentry).
portsentry /usr/local/bin,
/usr/local/etc/portsentry.conf.
PortSentry
.
,
PortSentry. , TCP_PORTS
UDP_PORTS. ;
,
.
, , ,
,
. , ("
"), .
, ,
. . ,
! , 143
, 143 .
, 143 .
.
.
: IPFW ( ,
) (black-hole routes) (
IPFW ).
, KILL_ROUTE ,
PortSentry .
, IPFW, ,
/sbin/ipfw, :
# , FreeBSD (
# ),
# .
KILL ROUTE="/sbin/ipfw add 1 deny all from $TARGET$ :255.255.255 .255 to any"

568

4. FreeBSD

IPFW , , ,
, ,
IPFW:
# FreeBSD ( .)
KILL_ROUTE="route add -net $TARGET$ -netmask 255.255.255.255 127.0.0.1 ~ blackhole"

PortSentry .
PortSentry
. ,
29.1 ( - portsentry.sh).
,
/usr/local/etc/rc.d, PortSentry .
29.1. PortSentry.
#!/bin/sh
PORTSENTRY="/usr/local/bin/portsentry"
case

"$1" in start)
${PORTSENTRY} -tcp && echo " Starting PortSentry TCP mode..."
${PORTSENTRY} -udp && echo " Starting PortSentry UDP mode..."
; ;
stop)
killall 'basename ${PORTSENTRY}
; ;
*)
echo ""
echo "Usage: 'basename $0'
echo " "
;;

start

stop }

"

esac

PortSentry sockstat ,
: # sockstat
USER
root
root
root
root
root
root

COMMAND PID
portsent 2432
portsent2432
portsent2432
portsent2432
portsent2432
portsent2432

FD PROTO
0 udp4
1 udp4
2 udp4
3 udp4
4 udp4
5 udp4

LOCAL
*: 1
*:7
*:9
*:69
*:161
*:162

ADDRESSFOREIGN
* *
* *
* *
* *
* *
* *

ADDRESS

,
, , /usr/
local/etc/portsentry.blocked.tcp TCP
/usr/local/etc/portsentry.blocked.udp UDP. ,
PortSentry , .
,
. -

29.

569

PortSentry. ,
IPFW, , ,
,
.

IPFW KILL_ROUTE
ipfw -a list:
# ipfw
00001

-a

list
1

44

deny

ip

from

209.237.26.165

to

any


netstat -rn:
# netstat -rn
Routing tables
Internet:
Destination
. . .

Gateway

209.237.26.165/32 127.0.0.1 UGScB

Flags
0 0

Refs

Use

Netif Expire

loO

["black-hole" route], .

/var/log/messages , ,
PortSentry:
Jun 2 23:50:56 stripes portsentry[2430]: attackalert: Connect from host:
209.237.26.165/209.237.26.165 to TCP port: 1
Jun 2 23:50:56 stripes portsentry[2430]: attackalert: Host 209.237.26.165
has been blocked via wrappers with string: "ALL: 209.237.26.165"
Jun 2 23:50:56 stripes portsentry[2430]: attackalert: Host 209.237.26.165
has been blocked via dropped route using command: "/sbin/ipfw add 1 deny
all from 209.237.26.165:255.255.255.255 to any"
PortSentry Logcheck (
/usr/ports/security/logcheck]
.

IPFW, PortSentry.
, , FreeBSD,
, , Telnet 1,
, . ,
.
,
ipfw delete 1 route delete <I->/32.
[, ) PortSentry, IP- /usr/local/etc/ portsentry.
ignore.

/etc/hosts.allow
/etc/hosts.allow .

570

4. FreeBSD

PortSentry. ,
IP- ,
. /etc/hosts.allow,
,
:
sendmail
sendmail

sendmail
sendmail
sendmail
sendmail

: localhost : allow
:
.nice.guy.exanple.com : allow

.evil.craclcer.example.com

:
:
:

231.21.15.0/255.255.255.0 : deny
12.124.231. : deny
ALL : allow

deny

IPFW , .
: (
), IP- (
, ). (
, ), :
, , DNS,
IP-. IP-
, . "" ,
,
. , , , ,
"".
/etc/hosts.allow , ,
"allow" "deny". ,
,

( , , ).
. fingerd
:
fingerd

: ALL \
: spawn (echo Finger. | \
/usr/bin/mail -s "tcpd\ : %u@%h[%a] fingered me!" root) & \
: deny

%u, %h %
man 5 hosts_access man hosts_options.

Tripwire

. , ,
. , ,
, .
, .
Tripwire,
/usr/ports/security/tripwire.
,
,

29.

571

. (,
sshd ,
Tripwire .
, .
Tripwire
"" make install
/var/adm/tcheck. -,
Tripwire, ,
.
, , , .
FreeBSD .
make install,
TRIPWIRE_FLOPPY=YES make
install:
# make install TRIPWIRE_FLOPPY=YES
### 3:
###
### :
###
./databases/tw.db_stripes.somewhere.com.
###
He
###
!

###
###
(Tripwire
###
'/var/adm/tcheck/databases'.)
#

/dev/rfdOc: 2880 sectors in 80 cylinders of 2 tracks, 18


1.4MB in 5 cyl groups (16 c/g, 0.28MB/g, 32 i/g)
super-block backups (for fsck -b #) at:
32, 632, 1184, 1784, 2336
mount /dev/fdOc /mnt
#
# .

sectors

Tripwire, a
tripwire, twcheck gunzip tw.config ,
.
tripwire
, , 14.
tripwire , ,
/var/adm/tw.config, ""
. , , ,
/usr/sbin/ sshd:
# tripwire
...
### Phase 3: Creating file information database
### Phase 4: Searching for inconsistencies
###
###
Total files scanned:
16803
###
Files added:
0

572

4. FreeBSD

###
###
###
###
###
###
###
changed:
###Phase

###

### Attr
### ======

Files deleted:
Files changed:

14321

After applying rules:


Changes discarded:
14320
Changes remaining:
1
-r-xr-xr-x root 197940 (null) /usr/sbin/sshd
5: Generating observed/expected pairs for changed files
Observed (what it is)
Expected (what it should be)
======================== ============================

/usr/sbin/sshd
st__mtime: Sun Jun 3 00:55:51 2001 Sat Apr 28 21:17:19 2001
st_ctime: Sun Jun 3 00:55:51 2001 Sat Apr 28 21:17:19 2001

,
Tripwire. ,
sshd. , Tripwire,
Tripwire, .
-update:
# tripwire -update /usr/sbin/sshd

,
( /var/adm/tcheck/ databases)
. ;
gzip Tripwire:
#
#
#
#

gzip databases/tw.db_stripes.somewhere.com
mount /dev/fdO /floppy
cp databases/tw.db_stripes.somewhere.com /floppy
umount /floppy


Tripwire
(air gap] , ,
. ,
,
. , ,
, ,
"" ,
. ,
.
"" , .
, , .
: ,
. (
, ,
).
, - CD-R
, , " " ,
. , .

29.

573

,
,
100 .
,
. ,
.
Tripwire PortSentry
,
. top,
.
, , .
,
.
/tmp /var/tmp, ,
setuid , .
/var/log;
, ,
. ,
.
, , .

/dew.
,
"rootkits" . , FreeBSD
DEVFS ,
, .

, ,
, , , .
, ,
, .
; ,
. " " ,
,
.
, .
1. . ,
, ,
. , , , ,
.
2. , /var/cron/tabs /etc/crontab;
atq ,
. , n
, "" ,
.

574

4. FreeBSD

3. , .
- , , ,
. . ,
.
4. /var/log , , , ,
. ,
, , ,
.
5. , Web-
(National Infrastructure Protection Center NIPC):
http://www.nipc.gov (
, ),
. ,
. "-"
("script kiddies") , ,
, . .
6. Web-, , /usr/local . , FreeBSD " " .
Tripwire, ,
, " ",
/usr/local.
7. ,
, .
. ; ,
NIPC .

(DoS)
,

. (Denial of Service
DoS).
. ,
,
. ,
.

29.

575

, , IPFW, PortSentry .
; ,
,
. , .
,
,
.
. , ping (ICMP)
, ,
. , DDoS,
,
, ,
.

.
. , ,
, ,
, .



DoS Apache, Sendmail ,
"" .
, ,
.
, , , ,

.
, -
.
Apache MaxClients 150,
.
,
CGI , Apache
, , ,
HTML-.
,
Telnet SSH, Apache (apachectl stop) .
, HTTP IP-
, IPFW deny from
Apache. , MaxClients,
.

576

4. FreeBSD

Sendmail: MaxDaemonChildren,
. ,
/etc/mail/sendmail.cf (make restart).
, Sendmail "",
12 .

,
, Sendmail
.
, , , (
, ), /etc/
login.conf ,
.
, nobody
Apache, ,
, chfn.
login.conf:
baduser:\
:cputime=30m:\
:openfiles=24:\
:maxproc=32:\
:memoryuse=l6m:\
:tc=default:

cap_mkdb /etc/login.conf
.


" " .
, ,
. , ping ( "smurf")
ping (
),
, .
ping.
,
( ) .
UDP- echo ,
"-",
echo ( FreeBSD ).

. smurf , ,
ping. -

29.

577

FreeBSD, icmp_bmcastecho="NO"
/etc/defaults/rc.conf ,
.
GENERIC ICMP_BANDLIM,
ICMP- (
), .


,
, .
,
, .
(secure co-location facilities)
Internet.
,
,
.
BIOS, .
, ,
, root
. ,
/etc/ttys, "", .. ,
:
console

none

unknown

off

insecure

CD-ROM
. ,
, ,
, . :
.


FreeBSD.
, ,

Internet.
(
FreeBSD, ), .

man security
(Matthew Dillon),
man security
,

578

4. FreeBSD

. ,
FreeBSD Handbook.


freebsd-security@freebsd.org.
majordomo@freebsd.org subscribe freebsd-security
.
. ,
.
,
UNIX , Bugtraq.
, Internet, ,
FreeBSD. Bugtraq http://
www.securityfocus.com, .

FreeBSD
(security advisories)
FreeBSD (FreeBSD Security Officer) freebsd-announce@freebsd.org
freebsd-security@freebsd.org .
http://www.freebsd.org/security/.

: FreeBSD
, FreeBSD, .
, ,
. freebsd-security@freebsd.org,
.

(. 15).
FreeBSD, ,
(-STABLE -CURRENT). ,
.
, .
make world. , , 18.

Web-
FreeBSD, http://www.freebsd.org/security/,
, FreeBSD .
,
.
FreeBSD Security How-To (http://people.freebsd.org/~jkb/howto.html)
FreeBSD.
, , ,
.

29.

579

CERT (http://www.cert.org) Internet



. CERT
. ,
.
SecurityFocus , Bugtraq.
, :
.

. FreeBSD,

.
http://www.securityfocus.com.

/etc/rc.firewall : " Internet"


(Firewalls & Internet Security) (William R. Cheswick)
(Steven M. Bellowin) , "
Internet" (Building Internet Firewalls, 2nd Edition) (Brent Chapman)
(Elizabeth Zwicky)
.
SecurityFocus "Library" ("").

30

BIND

BIND [namecl.conf]

30.

581

, 22 23,
(DNS) Internet ;
IP- . FreeBSD
.
FreeBSD ,
, ,
.

. Web-,
, ,
, - "", . DNS, , . , DNS, , ,
.
DNS. , .
FreeBSD
.
DNS . UNIX,
Internet,
BIND, Internet Software Consortium (ISC).

BIND
BIND ( Berkeley Internet Name Domain)
- (named), ,
, . BIND FreeBSD,
.


(DNS) ,
Internet . " ",
Internet
, Network Solutions, Inc.
. (, somewhere.com)
, , com, org, net ..
, (.),
. (
top-level domains TLD) ,
, DNS Internet. ,
DNS somewhere.com
(, nsl.somewhere.com). ""
DNS . ,
Network Solutions, ,
. "
"

582

4. FreeBSD

: Network Solutions
.
DNS, ,
TCP/IP,
, . 30.1.
, DNS , .
, .

DNS. ( NS),
. DNS,
, . , , DNS DNS, .

30.1.


DNS,

DNS,

DNS
, . ,
DNS
, Internet. , , ,
DNS DNS
. DNS "" . .

BIND IP-
, DNS. , com. (.), somewhere.com. , com.
, , , ! , ; .
cluster.somewhere.com. , . , . DNS,
IP-.

30.

583

DNS, IP- ,

. DNS IP-
ARPAnet ( . 22)
, DNS CCC.BBB.AAA.inaddr.arpa. IP-, ,
.in-addr.arpa. , 64.41.131.* 131.41.64.inaddr.arpa.
, ,
, IP-
( ). , ,
.
DNS; .

BIND
BIND FreeBSD,

. , , ,
.
/usr/sbin/named. . 53,
DNS.
/usr/sbin/ndc. . , , .
/etc/namedb.
BIND, , (
).
/etc/namedb/named.conf. BIND.
BIND "",
.


BIND FreeBSD .
,
FreeBSD, /etc/rc.conf:
named_enable="YES"

, named
. ndc:
# ndc start
new pid is 12717

. BIND.

/etc/resolv.conf
nameserver, (127.0.0.1)

584

4. FreeBSD

. DNS
. , : search
somewhere.com nameserver 127.0. 0. 1 nameserver
64.41.131.167

BIND ""
27, ( )
, "",
, , ,
. FTP
" " ("chroot jail").
,

. BIND ,
"" ("sandbox"), "".
, , .
"" sandbox
/etc/namedb named ,
. , named ( ,
BIND ),
. /etc/named/
sandbox ,
bind:
# chown -R bind:bind /etc/namedb/sandbox
# chmod -R 750 /etc/namedb/sandbox

/etc /var/run sandbox.


/etc/localtime /etc/namedb/sandbox/etc.
/var/run, localtime
.
# mkdir /etc/namedb/sandbox/etc
# /etc/localtime /etc/namedb/sandbox/etc
# mkdir -p /etc/namedb/sandbox/var/run

, /etc/rc.conf:
named_flags="-u bind

-g bind

-t

/etc/namedb/sandbox"

: named ndc (
) "",
-. :
# ndc - /etc/namedb/sandbox/var/run/ndc start

, named ,
sandbox.

BIND (named.conf)
, ,
, ,

30.

585

.

.
/etc/namedb/named.conf ,
.
, BIND 8 ( FreeBSD
; , , BIND 9)
,
( 4 ). BIND 8,
BIND 4, ,
. 30. 1
named.conf,
.
30.1. /et c/named b/named .conf /*
*

BIND 8 */

logging {
category
category

>;

lame-servers {
cname { null;

null;
};

};

options {
directory "/etc/namedb" ; } ;
zone "somewhere.com" {
type master;
file " somewhere . com" ; };
zone "131.41. 64. in-addr.arpa" {
type master;
file "131 . 41 . 64 .in-addr.arpa" ; {;
zone

"elsewhere.com" {
type slave;
file
"slave/elsewhere . com" ;
masters { 113.125.2.145; }; };
zone " . " {
type hint;
file "named. boot" ;
};
zone "0.0 .127. in-addr.arpa" {
type master;

file

"localhost.rev"; );

zone "O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.O.IP6. INT" {


type master; file "localhost.rev";
} ;

, (
"") , -

586

4. FreeBSD

({}).
named.conf. options, controls,
logging zone.
named.conf ;
(//), : /*
*/.
( #).
named.conf, FreeBSD, , 30.1, .
, .
named.conf - (
) named
ndc:
# ndc
Reload

reload
initiated.


. 30.1 , ,
(forwarder) "" ,
, DNS. (,
, .)
FreeBSD,
, Internet.
DNS-,
( /etc/namedb/named.root).
.
.
DNS-, ,
:
# nslookup www.freebsd.org ns.somewhere.com
Server: ns.somewhere.com
Address: 64.41.131.172
Non-authoritative
answer:
Name: freefall.freebsd.org
Address: 216.136.204.21 Aliases:
www.freebsd.org

FreeBSD
, . (
) "" ,
(
). . 30.2 DNS-
. ,
.
DNS
,
.

30.

587

DNS-, , . , , , DNS,
, DSL . Internet
DNS . . ,
.

30.2.
DNS

,


DNS
DNS

,
127.0.0.1 forwarders options IP-
(127.0.0.1, , ) /* */ .
/*
forwarders {
127.0.0.1;

*/

};

named , . forward only options,


named . DNS- ,
,
. forward only,
.


, FreeBSD.
somewhere.com:

588

4. FreeBSD

zone "somewhere.com" {
type master;

file

"somewhere.com"; };

( , ), type,
( ), ,
. , ,
.
type master, slave, stub, forward hint.
master () slave ();
, .
master ,
, ,
Internet. ,
DNS ,
.
(slave) ; .
DNS. :
zone "elsewhere.com"
type slave;

file
"slave/elsewhere.com";
masters { 113.125.2.145; }; };

masters (
), .
, . file
,
named .
elsewhere.com /etc/namedb/slave.
() ().

ndc reload,
BIND -
file .
, ndc reload
ndc reload
.


named.conf,
.
stub. stub , ,
NS ,
DNS- .

30.

589

forward. forward
. zone
forwarders, options. .
hint. hint , /etc/
namedb/named.root. , , "" BIND, ,
, .

DNS
BIND
(Access Control List ACL). ACL acl,
.
, ; , ACL
ACL. .
any. .
. .
localhost. IP- .
localnets. , .
IP- (,
111.112.113.114), CIDR (, 111.112.113/24),
(1111.112.113.114, " 111.112.113.114")
key ( ). ACL,
, ,
. ,
, , .
.
named.conf , , . acl named.conf,
options. :
acl

"my_list" {
localhost;
localnets;
another_list;
!132.112.14.124;
132.112.14/24; };

590

4. FreeBSD

) options. :
allow-query { __; ... };. , DNS. allow-query zone allow-query
options. , .
allow-transfer { __; ... };. ,
. allow-transfer zone
allow-transfer options.
, .
allow-recursion { __; ... };. , . , .
blackhole { __; ... };. ,
. .
, ,
my_list. ,
somewhere.com, my_list
, ,
. :
options {
directory "/etc/namedb"
allow-query { my_list;

}; };

zone "somewhere.com" {
type master; file
"somewhere.com";
allow-query { my_list; 64.2.43/24; };
allow-transfer { 64.2.43.167; 123.15.221.3;

};


IP-
.
BIND, .
( Master Zone File,
, Master File) ,
. ""
BIND . , ()
,
.

30.

591

, 30.2,
. ,
(;) .
30.2. 5omewhere.com.
$TTL

3600

somewhere.com.

IN

SOA

; DNS
@
@
;
localhost
nsl
ns2
mail
@

stripes.somewhere.com.
root.somewhere.com.
20010610
;
Serial
10800
;
Refresh
3600
; Retry
604800
; Expire
86400 )
; Minimum TTL
IN NS
IN NS

IN
IN
IN
IN
IN

A
A
A
A
A

stripes.somewhere.com.
spots.somewhere.com.

127.0.0.1
64.41.131.162
64.41.131.163
64.41.131.167
64.41.131.162

;
www
IN CNAME
ftp
IN CNAME

@
www.somewhere.com.

; MX

IN MX 10

mail.somewhere.com.

,
, . 30.2
:
STTL;
SOA (Start-of-Authority);
NS ( );
();
CNAME ( Canonical Name),
;
MX (Mail Exchanger).
, (Resource
Record RR),
" " ("origin"). .

e. .
($).
, .
SORIGIN.

592

4. FreeBSD

SORIGIN. : SORIGIN < > [<>]


SORIGIN .
www; www
, SORIGIN somewhere.com.,
www.somewhere.com. ( ).
SORIGIN , ,
, zone,
. ,
"", ..
SORIGIN. ,
$ORIGIN com.
$ORIGIN somewhere
www

IN CNAME

stripes

:
www.somewhere.com.

IN CNAME stripes.somewhere.com.

SINCLUDE. : SINCLUDE < > [< >] [<>]


SINCLUDE
,
SINCLUDE. SORIGIN
< >, .
STTL. : STTL < > [<>]
STTL (Time-to-Live TTL)
, .
,
BIND (..
). (Resource Record RR), TTL
. , 30.2, (
IN ). STTL (3600 ), .
SGENERATE. : SGENERATE <> < > <> < > [<>]
SGENERATE ,
, . ,
, IP-
.
<>. : - -/.
1.
< ,
. $ . < > , SORIGIN.
, - 0.

<>. PTR, CNAME NS.

30.

593

< , < >, .


SGENERATE
$ORIGIN 0.0.192.in-addr.arpa.
$GENERATE 1-2
N8
ns$.somewhere.com.
$GENERATE 1-127 $ CNAME $.0

BIND :
..0.192.in-addr.arpa.
.0.0.192.in-addr.arpa.
1.0.0.192.in-addr.arpa.
2. 0.0.192.in-addr.arpa.

NS
NS
CNAME
CNAME

127.0.0.192.in-addr.arpa.

CNAME

nsl.somewhere.com.
ns2.somewhere.com.
1.0.0.0.192.in-addr.arpa.
2 . 0 . 0.0.192.in-addr.arpa.
127.0.0.0.192.in-addr.arpa.

SOA
(Resource Record) .
Start-of-Authority (SOA). ,
.
. .
30.2. SOA:
somewhere.com. IN SOA stripes.somewhere.com. root.somewhere.com. (
2001061000

10800

3600

604800

86400 )

SOA, , :
<>

[<

>]

[<>]

<>

<>

<> ,
SORIGIN. ( ).
< > , STTL, . IN ( "Internet")
. BIND ,
. in zone named.conf,
, .
<> : IP-,
. SOA, , .
(stripes.somewhere.com). , @
. .
(root@somewhere.com) root.somewhere.com. BIND .

@ ,
@ .
SORIGIIM, BIND .
, @ ;
, www.@ .

594

4. FreeBSD

.
, ,
, . ,
Internet.
. BIND . , BIND, .
NN; , .
, .

ndc reload ,
BIND , , . .
.

. ( ) ,
.

, .
. , ,
( ).
.
( ),
.
. ( ),
" " ( ).

NS
30.2 (Name
Server - NS):
@
@

DNS

IN NSstripes.somewhere.com.
IN NS spots.somewhere.com.

DNS,
. , @
$ORIGIN (somewhere.com.)
(, ).
NS , . ,
cluster.somewhere.com., DNS-
(ns.cluster.somewhere.com). NS

30.

595

, IP- , :
cluster

IN NS ns.cluster.somewhere.com.

, cluster , BIND
SORIGIN (somewhere.com.).


() IP-.
:
;
looalhost
IN
stripes
IN
spots
IN
mail
IN
@
IN

A
A
A
A
A

127.0.0.1
64.41.131.162
64.41.131.163
64.41.131.167
64.41.131.162

.
SORIGIN,
mail.somewhere.com 64.41.131.167. @
, somewhere.com 64.41.131.162.
, , ,
( CNAME).

CNAME
(Canonical Name CNAME)
. , 30.2, :
;

www
IN CNAME
ftp
IN CNAME

@
www.somewhere.com.

www ( $ORIGIN www.somewhere.com.)


@, somewhere.com. (IP-
).
CNAME ,
IP-. CNAME, ,
, . CNAME
IP.

MX
Mail Exchanger (MX) ,
. Sendmail (
) MX
. MX
host:
# host somecompany.com
somecompany.com has address 207.114.98.18
somecompany.com mail is handled (pri=100) by mail.uu.net
somecompany.com mail is handled (pri=5) by mx-1.somecompany.com

,
,
-

596

4. FreeBSD

SMTP.
, :
; MX
@

IN MX

10

mail.somewhere.com.

MX IP-. ,
, MX,
( CNAME]. , MX ,
!

PTR
(PTR) CNAME,
DNS (, 131.41.64.in-addr.arpa)
IP- .
DNS 30.3.
DNS ,
PTR IP- . , .

DNS
DNS, I31.41.64.in-addr.arpa,
IP-.
named.conf,
, DNS. 30.3
DNS.
30.3. DNS 131.41.64.inaddr.arpa
$TTL

3600

131.41.64.in-addr.arpa.

@
@

164
165
167

IN NS
IN NS

IN SOA stripes.somewhere.com. root.somewhere.com.


2001061000
;
10800
;
3600
;
604800
;

86400 )
;

stripes.somewhere.com.
spots.somewhere.com.

IN PTR stripes.somewhere.com.
IN PTR spots.somewhere.com.
IN PTR mail.somewhere.com.

, CNAMEN PTR.
, PTR, IP-. MX,
MX IP-.

30.

597

localhost
localhost
(0.0.127.in-addr.arpa). /etc/namedb , . make-localhost;
(PROTO.localhost.rev)
.
, sh:
# sh make-localhost
Enter your domain

name:

somewhere.com

, localhost.rev, ,
30.4 ( . , .).
30.4. localhost.rev
From: @(#)localhost.rev 5.1 (Berkeley) 6/30/90 $FreeBSD:
src/etc/namedb/PROTO.localhost.rev,v 1.6 2000/01/10 15:31:40 peter
Exp $
;
/etc/namedb.
$TTL
@

'make-localhost1 ;

3600
IN

SOA

stripes.somewhere.com. root.stripes.somewhere.com.
20010612
;
3600
;
900
;
3600000
;
3600 )
; IN
NS
stripes.somewhere.com. 1
IN
PTR localhost.somewhere.com.

, DNS!

,
. ,
DNS
.
,
:
,
.
,
.
,
named.conf zone, ,
. 30.5.

598

4. FreeBSD

30.5. /etc/namedb/named.conf
/*
* BIND 8 */
logging {
category lame-servers { null; }
category cname { null; } ; };
options {
directory "/etc/namedb";
};
zone

};
zone

"." {
type hint;

file "named.boot" ;
"0.0.127.in-addr.arpa" in { type
master; file "localhost.rev";

};
zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT" {
type master; file "localhost.rev";

" " , , . ""


.
DNS .
,
. DNS,
.

31


(NFS)

NFS

NFS

NFS

[amd]

600

4. FreeBSD

NFS (Network Filesystem) UNIX. Windows Mac OS


,
,
. NFS
, , ,
.
FreeBSD
/ NFS, ..
, UNIX,
, Internet.

NFS
Windows NetBIOS, a Mac OS
AppleTalk. ;
,
.
NFS , -,
, ,
NFS.
, ,
.
NFS ,
, ,
.
Windows Mac OS
( " " - - "shares")
. "" ,
,
"" . NFS . , NFS ,
, . ,
.
NFS, , . ,
IP-
, NIS Kerberos.
NFS , , , ,
Internet , .
-.
NetBIOS AppleTalk "" ""
.
FreeBSD, NFS ,
. NFS ,

31. [NFS]

601

. 9.
,
. NFS
.
- NFS , . ,
UNIX, ,
NFS,
,
. . 31.1 .
( )
,
(, ). NFS
NIS ( ) .
,
NFS. FreeBSD NFS,
CD-ROM NFS Sysinstall.

31.1.

,
NFS

, NFS
UDP, TCP. 22,
UDP ,
TCP, , , . ,

UDP,
, NFS
UDP. ,
TCP, , . NFS
, TCP
,
. NFS
, . UDP
,
, ,
.

NFS, , -

602

4. FreeBSD

, , ,
TCP. NFS,
TCP, , NFS . NFS
TCP
, ,
TCP ,
UDP.

UDP ,
NFS .
TCP ,
. ,
NFS.

NFS ,
Internet
, .
NFS .
,
(VPN).
FreeBSD
NFS, NFS, , .
,
NFS.
NFS, .

NFS
FreeBSD NFS
/etc/rc.conf:
nfs_server_enable="YES"

, portmap_enable "YES" (
, ). portmap
NFS, NFS- ,
. UDP ""
, , NFS 2049,
RPC ( ) , . RPC portmap.
, portmap ,
NFS Internet, .
. 29.
nfs_server_enable , FreeBSD
- (, , portmap)
/etc/exports, , NFS.
.

31. [NFS]

603

NFS (nfsd)
NFS, sshd httpd,
nfsd. nfsd (
); NFS,
. NFS
.
nfs_server_flags /etc/rc.d:
nfs_server_flags="-u

-t

-n

4"

- ;
NFS.
-t -u nfsd ,
TCP, UDP. . , -h
64.41.131.102 , NFS
64.41.131.102. ( IP- .)
.
UDP , nfsd, IP-
, ,
.
-h. , ,
"", "" .
"" IP-, NFS
. NFS
:
nfs_server_flags="-u

-t

-n

-h

64.41.131.102

-h

64.41.131.116"

NFS
IPFW:
ipfw add deny udp from any to

64.41.131.10

nfsd

IPFW . 29.

NFS (mountd)
nfsd , NFS,
NFS ( TCP 2049).
mountd, .
nfsd ,
nfs_server_enable "YES".
mountd NFS
nfsd. NFS, /etc/exports;
, NFS
/etc/exports HUP mountd.
mountd .
/etc/defaults/rc.conf, /etc/rc.conf, :
mountd_flags="-r"

604

4. FreeBSD

-r mountd ,
, , NFS. -1
NFS, -n
NFS Windows,
UNIX.

/etc/exports
/etc/exports ,
NFS, , .
/etc/exports ,
nfsd mountd .
/etc/exports
man exports. ,
( ),
( IP-, , ),
. ,
/home
:
/home

-alldirs

, -alldirs ,
(, /usr /home).
.
,
, :
/usr2 -ro -alldirs stripes.somewhere.com spots.somewhere.com 64.41.131.165

, /etc/netgroup.
:

_ (, , ) (, , ) . . .
, desktops, ( sol,
luna terra), :
desktops

(sol,,)

(luna,,)

(terra,,)

:
developers

(,frank,)

(,bob,)

(,alice,)

netgroup
/etc/exports, NFS
.

NFS
.
(,
NIS Kerberos),
. 1045
bill,
1045 john,

31. [NFS]

605

, , "" .
, ,
, .
-maproot=< > -maproot=< > ,

root . ,
NFS 64.41.131 ,
frank :
/

-maproot=frank

-network

64.41.131

-mask

255.255.255.0

/etc/exports
mountd. , /var/run/mountd.pid:
#

kill

-HUP

'cat

/var/run/mountd.pid'

.
. NFS
, -
,
. :
/home/frank 64.41.131.102
/home/joe 64.41.131.102
:
/home/frank

/home/joe

64.41.131.102


showmount. , /etc/
exports :
# showmount -e
Exports
list on
/usr
/home/frank
/home/joe
/

localhost:
Everyone
64.41.131.102
64.41.131.102
64.41.131.0

NFS
NFS .
, ,
root ( portmap , ):
# portmap

# nfsd -u -t -n 4

# mountd -r

showmount -e, , NFS.

606

4. FreeBSD

NFS
FreeBSD
NFS , .

NFS .
NFS
.
NFS /etc/
rc.conf:
nfs_client_enable="YES"
/ NFS, nfsiod, NFS ,
. /etc/rc.network
, NFS ( ).

/ NFS (nfsiod)
nfsiod NFS,
. NFS ,
" " " "
.
nfsd, nfsiod, NFS
. nfsiod ( 4),
nfs_client_flags /etc/rc.conf:
nf s_client_flags="-n 4"

nfsiod .
:
# nfsiod -n 4


NFS mount_nfs,
mount -t nfs ( 9). , :
, :
# mount nfs spots:/home /home2

.
df:
# df
Filesystem
/dev/adOsla
/dev/adOslf
/dev/adOsle
proofs
spots:/home

IK-blocks
992239
26704179
9924475
4
9924475

Used
54353
4872963
1642343
4
1642343

Avail
858507
19694882
7488174
0
7488174

Capacity Mounted
6% /
20% /home
18% /usr
100% /proc
18% /home2

on

/homeZ, /home
NFS,

31. [NFS]

607

, .
,
umount:
# umount /home2

NFS ,
umount!
"device busy".

NFS ; man mount_nfs.


-, TCP
UDP ( ), -s - <->,

( "" ).
# mount_nfs -s - 60 spots:/home /home2

- - i, .
NFS ,
( , Is)
, Ctrl+C . -i
, Ctrl+C ( )
, .

,
NFS /etc/fstab ,
. , mount_nfs, Options,
:
# Device
spots:/home

Mountpoint
/home2

FStype
nfs

Options
Dump
rw,-T,-i,noauto

Pass#

NFS
mount:
# mount /home2



, /etc/fstab,
, 9,
noauto.
NFS , /etc/fstab,
. .
, NFS
,
,
. NFS
(,

-

608

4. FreeBSD

),
,
.
, noauto /etc/fstab,
. ,
NFS . -b.
# Device
spots:/home

Mountpoint
/home2

FStype
nfs

Options
rw,-b

Dump

Pass#

-b , mount , , ,
, .
-b,
,
. , /etc/
fstab, 60 :
# mount /home2
NFS Portmap:
RFC:

Port

mount__nf s:

immediately

Cannot

mapper

failure

mount

RPC:

Unable

spots: /home,

to

send

backgrounding

:
NFS Portmap: RPC: RPC;

mount_nfs: spots:/home,

mount_nfs ,
.
, NFS ,
. ,
NFS ,

.

(amd)
, amd, NFS
. NFS (
) , ,
, .
FreeBSD amd.
/etc/rc.conf:
amd_enable="YES"

amd ,
amd_flags,
/host /net,

31. [NFS]

609

amd. , :
# amd -a /.amd_mnt -1 syslog /host /etc/amd.map /net /etc/amd.map

amd cd
/host . .
# cd /host
# 1s

, ,
NFS :
# Is
home

stripes

, , /host stripes,
home, , stripes:/home.
/host,
. /host/stripes/home
/home2, . df
:
# df
Filesystem
1K-blocks
stripes:/home
9924475
/.amd_mnt/stripes/host/home

Used
1642345

Avail
7488172

Capacity
18%

Mounted

on

, NFS, ,
.amd_mnt . , amd .


NFS, /host /net:
# In -s /host/stripes/home /home2

/home2 stripes:/home
, . .

amd, ,
/etc/amd.conf.
FreeBSD; .
man amd.conf.

32


Microsoft; Windows

Samba
SMB/CIFS
Samba
Samba
Samba
smbfs

32. Microsoft Windows

611

NFS UNIX, UNIX (


) .
NFS .
Windows Mac OS
. , NFS
"",
.

Windows. FreeBSD
-
Windows , FreeBSD
, Windows. SMB, Server
Message Block, , Common Internet File System (CIFS),
.
SMB/CIFS
FreeBSD. , Samba,
FreeBSD -
Windows ,
Windows.

Samba
Samba ,
(Andrew Tridgell),
UNIX. Samba UNIX- (,
FreeBSD)
Windows, ,
NT ,
. ,
Windows NT/2000.
smbfs, (
FreeBSD Windows),
, FreeBSD
Windows , Windows-.
Web- Samba http://www.samba.org,
- .

SMB/CIFS
SMB, , 1985
IBM, Microsoft
Intel,
. , , .
-,

612

4. FreeBSD

Windows . SMB , MS-DOS, Windows,


OS/2 Linux, Windows Microsoft.
SMB CIFS ,
IPX, NetBEUI, Banyan VINES DECnet. ""
, IP ( 22),
TCP/IP.
SMB NetBIOS
(Network Basic Input/Output System /,
RFC 1001 1002) IP, TCP,
UDP.
Windows.

SMB , NFS, , (browsing).


Windows (Network Neighborhood)
SMB.
, " " ("master browser")
( SMB)
. " "
("browse list") .
, (. . 32.1),
" NetBIOS", .. , Windows
15 . Windows NetBIOS ,
, .
( FreeBSD) NetBIOS ,
15 .
NetBIOS
DNS, NetBIOS-
, IP- ( NetBIOS
IP). Samba SMB, .
32.1. Windows,

FreeBSD, Samba

32. Microsoft Windows

613

NetBIOS
LAN; NetBIOS ,
.
Windows WINS (Windows Internet Name Service
Internet Windows), .

,
SMB .
IP- .
(, )
/.
,
( ,
).

( ) (
). " " ""
Windows. ,
,
. ,
, .
Samba ,
" " ( )
( ). ,
.


Macintosh AppleTalk
Samba SMB/
CIFS Windows. Macintosh
AppleTalk , IP.

AppleTalk ,
FreeBSD.
, AppleTalk UNIX-, netatalk; .
,
SourceForge
.
AppleTalk netatalk
/usr/ports/net/netatalk. netatalk-asun , (Adrian Sun)
netatalk, .
, AppleTalk
.

614

4. FreeBSD

netatalk
NETATALK . . 17.
netatalk
- ;
.dist.
,
.
Macintosh AppleShare Chooser
( Connect to Server Mac OS X), . 32.2.
32.2. Mac OS Chooser,

- netatalk,

AppleShare

netatalk
( Linux-,
) Web- netatalk
http://netatalk.sourceforge.net/.

Samba
Samba /usr/ports/net/
samba .
15.
Samba : ( /usr/local/sbin), ( /usr/local/bin), ( /usr/local/share)
, /usr/local/etc.
;
,
. ( /usr/local/etc/codepages),
Windows UNIX.
smb.conf.default,
smb.conf. /usr/local/
etc/rc.d/samba.sh.sample samba.sh.
Samba
smb.conf,
, :
# workgroup = NT, , REDHAT4 workgroup
= MYGROUP

32. Microsoft Windows

615

Samba .
, samba.sh start:
# /usr/local/etc/rc.d/saniba.sh
Samba#

start


, Samba. "" ,
, /usr/local/etc/rc.d,
echo .
rc.d, .

smbd nmbd
samba.sh ,
: smbd nmbd:
# ps
root

root

-waux | grep mbd


3855 0.0 1.5 2368
/usr/local/sbin/smbd
3857 0.0 1.2 1940
/usr/local/sbin/nmbd

1816 ?? Is 2:43PM 0:00.00


-D
1496 ?? Ss 2:43PM 0:00.02
-D

smbd , ,
SMB/CIFS Windows, ,
, .. NFS, SMB
; smbd
,
. -D , smbd
, TCP 139.
smbd nmbd, NetBIOS.
( Windows FreeBSD
, . 32.1.
NetBIOS, . Windows \\<> ,
IP-
NetBIOS. IP- ,
SMB , nmbd. -
DNS ( ,
), ARP (
,
).

smb.conf SWAT
Samba /usr/Iocal/etc/smb.conf,
. , # ;,
; smb.conf.default ( )

616

4. FreeBSD

# , ; -
.
smb.conf.default.
,
( man smb.conf),
. , ,
smb.conf,
. SWAT, Samba Web Administration Tool (
Samba Web), . 32.3.

32.3. SWAT,

Samba Web

SWAT Samba Samba Web. smb.conf


. , Web
, . SWAT
,
/etc/master.passwd.
Samba , ,
(localhost, -Windows),
. ,
. SWAT,
.
SWAT (localhost). .
, . smb.conf root.

32. Microsoft Windows

617

SWAT,
root, ( )
HTTP- SWAT.
,
.
"" (, smbowner) smb.conf ( chown). SWAT,
, root. He

, . ,
, Samba. .

SWAT, , /etc/services
(901 , TCP):
swat

901/tcp

/etc/inetd.conf:
swat stream top nowait root /usr/local/sbin/swat swat

, inetd:
# killall -HUP inetd

SWAT

URL
http://stripes.somewhere.com: 901, Samba
localhost. .
SWAT (root,
).
SWAT
, ;
. SWAT
,
smb.conf, ,
. 32.3. , ,
Samba,
.
SWAT
smb.conf
,
Samba smb.conf,
SWAT.



smb.conf.default. ,
smb.conf, Samba:

618

4. FreeBSD

# /usr/local/etc/rc.d/samba.sh stop
# /usr/local/etc/rc.d/samba.sh start

smb.conf =====
Share Definitions =====.
, , ,
. smb.conf [global], . , , Apache,
httpd.conf ( 26).

man smb.conf
.
HTML, , ,
. HTNL
http://samba.org/samba/docs/man/ smb.conf.5.html.

, :
[my-public]
comment = path =
/usr/local/share/samba-stuff public = y es
writeable = yes print able = no write
list = @staff

my-public
. UNIX- staff,
. write list,
. , writeable = yes read only = no.
[homes];
, Samba Windows
. ( .)
[homes]
comment =
browseable


= no writeable = yes

(browseable = no), , , .
,
Samba, ( UNIX
) .
.

35. Microsoft Windows

619


[homes], [printers] ,
. FreeBSD , /etc/printcap, Samba. FreeBSD /etc/printcap 16.
, [printers] :
[printers]
comment = path
= /var/spool/samba browseable
= no
# public = yes, 'guest'
quest

ok

no

writeable = no
printable = yes

, ,
.
, . , public
guest ok,
guest ok yes,
public = yes.
Samba 2.2.0 ,
(printing RPCs) Windows 2000/NT, , .
. Web- Samba.


Samba ,
.
- Windows: LAN Manager (LANMAN), Windows NT/2000, Windows
95/98/Me Windows for Workgroups,
- ,
.
Samba :
.
, security:
#
#

.
. . security_level.txt.
security = user



/. ,
, /
- . , .

. Windows, Windows
,
Samba UNIX (

620

4. FreeBSD

UNIX). , Windows-
Harris Windows-, Network
Neighborhood ( ) Samba,
(
\\STRIPES\IPC$), UNIX-
harris.

Windows NT/2000 , ,
. Windows 95/98/ ,
.

Samba /usr/
local/private/smbpasswd, /etc/master.passwd , UNIX.
Samba /etc/master.passwd
Samba /usr/local/private/smbpasswd,
LANMAN Windows NT ( )
16 X,
.
, . smbpasswd.
passwd, Samba,
, root (
, , ).
# smbpasswd harris
New SMB password:
Retype new SMB password:
Password changed for user

harris.

Windows 95 NT . , UNIX. Windows 95 Windows NT, service pack 3,


, .
Windows NT/2000, Windows 98/,
Samba. . (
/usr/local/share/doc/samba/textdocs/ENCRYPTION.txt,
. . Win95.txt WinNT.txt
.)
#
#
#

. ,
, ENCRYPTION.txt, Win95.txt WinNT.txt
Samba. He ,

# .
encrypt passwords = yes

, ,
, .
Samba, /usr/local/private/smbpasswd,
, , , -

32. Microsoft Windows

621

. ,
smbpasswd,
( root) Samba,
/etc/master.passwd
. smbpasswd , master.passwd,
!

Windows UNIX,
Windows ,
UNIX. , ,
/usr/local/etc/smbusers.map
:
< unix> = < win-l> [< win-2> . . . ]
, [global] smb.conf : username
map = /usr/local/etc/smbusers.map
Windows
UNIX, .



Samba /,
. , IP-
smb.conf ( hosts allow).


, .
, (public = yes),
, , (,
[homes]) /,
.
.
/usr/local/share/doc/samba/textdocs/security_level.txt.


Samba, ,
, .
,
UNIX .
, Samba,
,
.
, guest
account smb.conf:
# ,
# guest.
# /etc/passwd, "nobody".
guest account = pcguest

pcguest (
)
adduser.

622

4. FreeBSD

chfn.
ftp ( sysinstall,
FTP-)
Samba. FTP- . 27.
Windows,
Samba, ,
guest ok public yes.
.
guest only = yes, ,
.

Samba
Samba /var/log
.
1og.<>:
# 1s

-1

/var/log/log.*

-rw-r--r-- 1 root wheel 468


Jun 9 12:42 /var/log/log.gaming-pc rw-r--r-- 1 root wheel 2343 Jun 9 14:49 /var/log/log.nmb -rw-r--r-1 root wheel 1606 Jun 9 14:44 /var/log/log.smb

log.nmb log.smb nmbd


smbd, . , (, ), log.< >. ,
, /var/log.
, log file smb.conf:
#
#

Samba

;
log file = /var/log/log.%m

, SMB
log.smb.
max log size,
50 .
. Samba ,
.old,
. .old .
# ( ).
max log size = 50

Samba
smb.conf ,
, . , %u.
path = /usr/local/share/user-files/%u.

32. Microsoft Windows

623

harris /usr/local/share/user-files/harris
path.
:
%u ;
%g %u;
%S , ;
% , %u;
%h Internet- , Samba;
% Internet- ;
%L NetBIOS Samba. , ; , , " ";
%m NetBIOS ;
%I IP- ;
% ;
%$(envvar) envvar.

man smb.conf.

Samba
Samba . man samba;
.
.
smbclient. FTP,
SMB Windows.
testparm. ,
smb.conf; apachectl configtest Apache.
testprns. , /etc/
printcap, Samba.
smbstatus. Samba. SWAT,
, , Web-.
nmblookup. NetBIOS, Windows,
SMB, .
make_smbcodepage.
SMB Samba.
smbd, nmbd
smbpasswd. .

624

4. FreeBSD

Samba
Samba
2.0.9; Samba 2.2.0,
, , , ,
, , /usr/ports/ net/samba.
2.2.0 Windows,
Windows 2000, Windows UNIX. .
Windows NT/2000
Samba, .
(Access Control Lists ACLs) Windows
NT/2000 UNIX, Windows-.
Windows NT/2000.
Microsoft (Microsoft Distributed
File System DPS) DFS Windows.
http://
www.samba.org.

smbfs
8MB .
Samba FreeBSD
8MB, ,
SMB, .
smbfs,
/usr/ports/net/smbfs.
smbfs Linux ; FreeBSD ,
,
. smbfs FreeBSD
smbfs.ko /modules mount_smbfs /sbin,
mount_*, 9.
smbfs
man mount_smbfs.
/usr/local/etc/nsmb.conf.sample
nsmb.conf, /usr/local/etc/rc.d/smbfs.sh.sample smbfs.sh. SMB
smbfs,
smbfs, /etc/fstab, .
8MB smbfs,
mount_smbfs . -I IP-,
( //<>@< NetIOS>/< >) . ,

32. Microsoft Windows

625

public Windows- gaming-pc


/smb/public :
#

mount_smbfs

-I

64.41.131.139

//guest@gaming-pc/public

/smb/public

. ,
; ,
.

smbfs.ko
mount_smbfs. , ,
/boot/loader.conf:
smbfs_load="YES" .

SMB /etc/fstab,
:
//guest@gaming-pc/public /smb/public smbfs rw,noauto 0

/usr/local/etc/rc.d/smbfs.sh FreeBSD.

33

DHCP

DHCP
DHCP
DHCP
DHCP
clhclient
DHCP
dhcpd

33. DHCP

627

DHCP ( Dynamic Host Configuration Protocol,


) ,
IP-, , ,
, DHCP.

DHCP
DHCP ,
.
FreeBSD dhclient,
FreeBSD DHCP. ,
DHCP, dhclient,
68. UDP.
DHCP, 68
. , ,
IP-, .

67, UDP. IP-
, ,
DHCP.
, DHCP, 67
. , .

IP-
DHCP IP- .
. DHCP. ,
, .
IP- :
DHCP,
. ,
, DHCP .
IP- . IP-. , ,
,
IP-, .. . IP-
. , IP-
.

DHCP
DHCP
IP-.
.

628

4. FreeBSD

. DHCP IP-.
IP-, , .
DHCP.
. ( )
. DHCP,
.
.
, DHCP .
DHCP ,
. , ,
. , , .
,
IP- .
IP-. , , . DHCP IP- .
, IP- , .
, IP-.
, IP- , IP-, . DHCP , IP- , ,
.
, 10 15 , ,
, DHCP, , .
DHCP, ,
, ,
. ,
DHCP , 10 15
. DHCP
, DHCP
.

33. DHCP

629


DHCP
FreeBSD
DHCP, Berkeley Packet
Filter ( ).
GENERIC, ,
, .
Berkeley Packet Filter ,
:
device

bpf

, .
, .
17.

Berkeley Packet Filter . bpf .


, ,
. root,
, .
, DHCP,
, ,
bpf.

DHCP
, DHCP ,
. sysinstall.
.
sysinstall.

DHCP sysinstall
FreeBSD yes
, DHCP .
FreeBSD ,
DHCP sysinstall.
2. root sysinstall
sysinstall.
3. Configure. , sysinstall

.
Enter.
4. Configuration Networking.
Network Services Menu (. . 33.1).
5. Interfaces , .

630

4. FreeBSD

5. , , (. . 33.2).

33.1. Network Services Menu


sysinstall

33.2.
.
,

6. No
IPv6.
7. Yes

DHCP.

DHCP dhclient,
.
DHCP,
,
.
, , DHCP.
(
), sysinstall
, DHCP .

DHCP

DHCP ,
/etc/rc.conf. ifconfig
, DHCP. ,
Ethernet edO, /etc/rc.conf
:
ifconfig_edO="DHCP"

DHCP ,
edO,
.
/etc/rc.conf -
, , ,
, IP-.

, #,
.

33. DHCP

631

/etc/rc.conf ,
DHCP .

dhclient
dhclient DHCP.
, , DHCP.
dhclient
, /etc/rc.conf.
dhclient, /etc/rc.conf ifconfig,
DHCP :
dhcp_flags =""

dhclient. . 33.1 .
33.1. dhclient

-d

dhclient ,
.

/etc/rc.conf.

-cf _ dhclient
/sbin/dhclient-script. cf dhclient.
, .
-If _

dhclient
/var/db/dhclient.leases. -If
dhclient . ,
.

-pf _ dhclient
(PID) /var/run/dhclient.pid. -pf
, .
-q

dhclient .
.

-I

dhclient IP-.
, dhclient 2.

/sbin/dhclient-script
dhclient,
. ;
, .

632

4. FreeBSD

/etc/dhclient.conf
dhclient,
, .
dhclient, . dhclient
,
, .
, . . 33.2
.
33.2. dhclient.conf

timeout n

,
dhclient
DHCP,
. 60 .

retry n

,
dhclient
DHCP, .
.

select-timeout n

DHCP.

. --
(, IP-,
,
, IP-).
,
dhclient
.

reboot n

dhclient IP, .
, IP-.
, dhclient
, , IP, , .
10 .

request


DHCP-.
dhcp-options.

require


DHCP-. ,
.

dhcp-options.

default

DHCP
, .

dhcp-options.

33. DHCP

633

supersede
, DHCP .

dhcp-options.
reject

, DHCP IP, .

, /etc/dhclient.conf,
.
dhclient.conf.
DHCP, DHCP,
dhcp-options.
, /etc/
dhclient.conf, dhclient
.

DHCP
FreeBSD DHCP.
FreeBSD
DHCP. isc-dhcp3
net .
. 15.
, dhcpconf,
FreeBSD net ,
DHCP FreeBSD.
isc-dhcp3 /usr/local/etc/ rc.d
isc-dhcpd.sh.sample. DHCP.
DHCP. dhcpd
dhcpd.
/usr/local/etc/rc.d, ,
. , dhcpd.
, DHCP , root.
DHCP:
/usr/local/etc/rc.d/dhcpd

start

DHCP:
/usr/local/etc/rc.d/dhcpd

stop

, DHCP:
/usr/local/etc/rc.d/dhcp

restart

DHCP .

634

4. FreeBSD

dhcpd
DHCP, dhcpd, /usr/Iocal/
etc. dhcpd dhcpd.conf.sample.
dhcpd.conf:
dhcpconf. dhcpd, dhcpconf.
dhcp.conf, dhcpconf, , .

dhcpconf
dhcpconf
,
DHCP. ,
dhcpconf
root. About, . Enter
. .
33,3 dhcpconf
33.3 dhcpconf.
, .
, Enter Tab.
(Common)
,
IP-.
,
.
Enter, . .
33.4
Common.

, , 33,4 IP- ,
.

. ,
.
IP- . ,
, IP , .
600 (10 ),
7200 (120 ). -

33. DHCP

635

, ,
, IP- .
, ,
<> Enter. .


IP-
(IP-, ). . DHCP Configurator. . 33.5 (Fixed-host Entries).

33.5.
, IP-

. 33.3 .

33.3.

New entry hostname

,
IP-. ,
,
(Common) .

New entry HW address ,


IP-.
New entry IP address

IP-,
.

Enter,
.
, <>, . ,
Enter. , Enter, <>, .


, IP-, .
Subnet . . 33.6
.
. 33.4 .

636

4. FreeBSD

33.6.

Subnet, no

Fixed-host entries,

33.4.

New range subnet

,
IP-.

New range start IP IP-, DHCP,


IP-.
New range end IP

IP-, DHCP,
IP-.

, IP- Enter,
. .
IP-
, IP-. ,
IP- .
,
<> Enter, .

, , ,
22.


DHCP Configurator <Save> Enter.
/etc/dhcpd.conf .
, ,
DHCP.
dhcpd dhcpd.conf,
, dhcpd.conf.

X-Window


X-Winclow

34


X-Window

3.3.6 4.x

SuperProbe
X-Window
xf86config
XF86Config

X-Winclow

.xinitrc

X-Winclow
xdm

34. X-Window

639

FreeBSD XFree86
3.3.6. .
XFree86 4.1 .

3,3,6 4.x
XFree86 4.1.
XFree86 4.1 XFree86 3.3.6, 4.1
-, . packages/ xll
XFree86-4.1.0_4.tgz. . 15,
, XFree86 4.1
. root :
# mount /cdrom
# cd /cdrom/packages/xll
# pkg_add -v XFree86-4.1. 0_4.tgz

.
. ,
, /etc/make.conf, , XFree86 4
XFree86 3. /etc/make.conf
( , ) :
XFREE86_VERSION= 4

Xwrapper. , , XFree86 root,


.
Xwrapper.
Xwrapper FreeBSD.
Internet. Xwrapper
/usr/ports/xl I/wrapper.
15. Xwrapper.
:
f cd /usr/ports/xll/wrapper
# make
( )
# make install
( ) #

, /etc/XF86Config,
. rm /etc/XF86Config.
XFree86 4.1.

SuperProbe
SuperProbe
, , ..
SuperProbe , -

640

5. X-Window

.
, , .
-Window.

, SuperProbe "" . ,
, . SuperProbe
root.

SuperProbe,
( , SuperProbe, ).
""
, .
Ctrl+C . SuperProbe
. :
First video: Super-VGA
Chipset: Matrox (chipset unknown) (PCI Probed)
Signature data: 50 (please report)
RAMDAC: Generic 8-bit pseudo-color DAC
(with 6-bit wide lookup tables (or in 6-bit mode))

, SuperProbe,
X-Window.
SuperProbe .
-verbose.
. man- ,
.

X-Window
xfSGconfig
,
, .
XWindow.

.

, ,
, .

xfSGconfig XfS6Config.
XFSGConfig, ,
. /etc/X11/
XFSGConfig. , , /etc/X11/XF86Config.bak. ,
,
.

34. X-Window

641

, root.
xf86config Enter. :
XF86Config, .
XF86Config /usr/XHR6/etc/Xll /etc/ X11.
XF86Conig XFree86.
VGA 640x480.
, .
XF86Conig
.
, ,
, ,
. SuperProbe.
Enter, Ctrl-C.

, , .
, xfSGconfig.
. ,
Enter .
Ctrl+C .


xf86config :
. :
1.
2.
3.
4.
5.
6.
7.
8.
9.

Microsoft compatible (2-button protocol)


Mouse Systems (3-button protocol)
Bus Mouse
PS/2 Mouse
Logitech Mouse (serial, old type, Logitech protocol)
Logitech MouseMan (Microsoft compatible)
MM Series
MM HitTablet
Microsoft IntelliMouse

, , 1,
, , 1 2.
:
, 1 (
) 2.
2,
(. ClearDTR/ClearRTS).
:

, Enter.
:
9- , . 1, 2, 5 6.
1 2, Logitech 1
6. 5 Logitech.

642

5. X-Window

, PS/2.
4. , Microsoft,
PS/2, 4. " Microsoft" .
FreeBSD , ,
, 4 ( , PS/2).
Enter, :
,
.
' ' ' n' .
?

, ,
, . -Window
. ,
. .
, :
, , ,
/dev/ttyOO. , /dev/mouse,
Enter.
Mouse device:

, /dev/mouse,
. . 34.1 .
34.1

PS/2 ( )

/dev/psmO

/dev/cuaaO

/dev/cuaa1

/dev/cuaa2

/dev/cuaa3

Bus mouse

/dev/mseO

Enter.


:
,
. , 1 (Generic 101-key PC)
2
3
4
5

Generic
Generic
Generic
Generic

101-key
102-key
104-key
105-key

PC
(Intl) PC
PC
(Intl) PC

34. X-Window
7
8
9
10
11

643

Dell 101-key PC
Everex STEPnote
Keytronic FlexPro
Microsoft Natural
Northgate OmniKey 101
17
Winbook Model XP5
18
Japanese 106-key
19
PC-98xx Series
20
Brazilian ABNT2
21
HP Internet
22
Logitech iTouch
23
Logitech Cordless Desktop Pro
24
Compaq Internet
25
Microsoft Natural Pro

, .
Enter . ,
Enter .
, 1 Enter. :
' us'
, Enter

, Enter .
'' 'n' .
( ,
..)?

, .
( ), .
, , , Caps Lock Ctrl (
Emacs) .
Enter. , ,
Enter .


,
. :
:
.
.
.
, /usr/XHR6/lib/Xll/
doc/Monitors.
Enter Ctrl-C

Enter ,
:
.
,
, .

644

5. X-Window

,
. ,
.
;

4
56

10
11

1
31.5; Standard VGA, 640x480 8 60 Hz
2
31.5 - 35.1; Super VGA, 800x600 @ 56 Hz
3
31.5, 35.5; 8514 Compatible, 1024x768 @ 87 Hz interlaced (no 800x600)
31.5, 35.15, 35.5; Super VGA, 1024x768 @ 87 Hz interlaced, 800x600 @
Hz
5
31.5 - 37.9; Extended Super VGA, 800x600 @ 60 Hz, 640x480 @ 72 Hz
6
31.5 - 48.5; Non-interlaced SVGA, 1024x768 @ 60 Hz, 800x600 @ 72 Hz
7
31.5 - 57.0; High Frequency SVGA, 1024x768 @ 70 Hz
8
31.5 - 64.3; Monitor that can do 1280x1024 @ 60 Hz
9
31.5 - 79.0; Monitor that can do 1280x1024 @ 74 Hz
31.5 - 82.0; Monitor that can do 1280x1024 @ 76 Hz
Enter your own horizontal sync range
(1-11):

,
, .
, , .

,
, 11 .
, /usr/XllR6/lib/Xll/doc/Monitors.
, ,
. . :
Section "Monitor"
Identifier "ELSA GDM-17E40"
VendorName "ELSA GmbH"
ModelName "GDM-17E40"
Bandwidth 135
HorizSync 29-82
VertRefresh 50-150
ModeLine "640x480" 25 640 664 760 800 480 491 493 525
ModeLine "640x480" 31 640 664 704 832 480 489 492 520
ModeLine "800x600x32" 45 800 820 904 964 600 601 604 621
ModeLine "1024x768x16" 78.7 1024 1044 1140 1264 768 770 773 796
ModeLine "1152x875" 135 1152 1416 1456 1664 875 875 877 906
ModeLine "1152x900" 135 1152 1400 1440 1648
900 901 905 935
ModeLine "1280xl024i" 80 1280 1296 1512 1568 1024 1025 1037 1165
interlace
ModeLine "1280x1024" 110 1280 1328 1512 1712 1024 1025 1028 1054
ModeLine "1280x1024" 135 1280 1312 1456 1712 1024 1027 1030 1064
EndSection

Section EndSection
.
.
: Identifier, VendorName ModelName.
, .
.

34. X-Window

645

: HorizSync VertRefresh. ,
, .
11 .
,
Monitors, , ,
.
Enter :
.
,
, .
(, 87 , 43 ) .
1
2
3
4
5

50-70
50-90
50-100
40-150

:

, , . Enter.
:
. Enter .
.
:

XF86Config,
. Enter, .


. Enter
, :
0
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17

2 the Max MAXColor S3 Trio64V+


2-the-Max MAXColor 6000
3DLabs Oxygen GMX
928Movie
ASX (generic)
ALG-5434
2010
ASUS SDexplorer
ASUS PCI-AV264CT
ASUS PCI-V264CT
ASUS Video Magic PCI
V864
ASUS Video Magic PCI
VT64
AT25 Alliance AT3D
AT3D Alliance AT3D
ATI 3D Pro Turbo
ATI 3D Pro Turbo PC2TV
ATI 3D Xpression
ATI 3D Xpression*

S3 Trio64V+
ET6000
PERMEDIA 2
S3 928
AGX-014/15/16
CL-GD5434
Voodo Banshee
RIVA128
ati
ati
S3 864
S3 Trio64
ati
ati
ati
ati

646

5. X-Window

.
Enter,
q.

, .
Enter. Enter .
, q. He
, - ,
. , . ,
Enter. , :
:
Identifier: Matrox Millennium G400
Chipset:
mgag400
Driver:
mga
Do NOT probe clocks or use any Clocks line.
Enter Ctrl- .

Enter , Ctrl+C . xf86config .


, :
.
"Device" XF86Conig.
, .
, -,
. ,
(, ATI Mach64
1024 SVGA),
, .
:
1
2
3
4
5
6

256
512
1024
2048
4096
Other
:

, , , , , 6
. . , 1024, 1000 .
. 34.2 .

34. X-Window

647

34.2

8192

16

16384

32

32768

64

65536

128

131072

Amount of memory in Kbytes ( )


Enter.
: ,
. Enter
( ).
Matrox Millennium G400.
.
:

, /. . ,
Enter.
, ,
.


,
. , :
( ).
, ,
. :
"640x480" "800x600" "1024x768" "1280x1024" for 8-bit
"640x480" "800x600" "1024x768" "1280x1024" for 16-bit
"640x480" "800x600" "1024x768" "1280x1024" for 24-bit
, -
, .

1
2
3

8- (256 )
16- (32/64 )
24- (16 )
.

, ,
X-Window 640x480,
. 17- ,
1024x768 . 19- 21-
, 1024x768. 15- ,
1024x768, , 800x600. 14-

648

5. X-Window

1024x768 ,
800x600 640x480.
. , ,
. ,
. 16-
24- . 8- 16--
. , ,
:
8- (256 ), , 16.
16-, 24- , ( ) , .
, , . Enter.
, 24- , 3
.
:
1
2
3
4
5
6
7
8
9

"640x400"
"640x480"
"800x600"
"1024x768"
"1280x1024"
"320x200"
"320x240"
"400x300"
"1152x864"
"1600x1200"
"1800x1400"
"512x384"

, .
, 432 "1024x768" "800x600" "640x480",
1024x768.

, , X-Window
. , 1024x768, 4.
,
. ,
, . ,
1024x768, 800x600 , , 640x480,
432.
.
Windows Macintosh, ,
FreeBSD. . -

34. X-Window

649

Enter.
:
( ),
, . " "
.
, .

'' 'n' .
, , ?

,
.
.
. ,
(640x480 ).
, n
().
, .
Enter.
,
. :
( ).
, ,
. :
"640x480" "800x600" "1024x768" "1280x1024" for 8-bit
"640x480" "800x600" "1024x768" "1280x1024" for 16-bit
"1024x768" for 24-bit
, -
, .
1
2
3
4

8- (256 )
16- (32/64 . )
24- (16 . )
.

, 24-
1024x768.
,
.
, .
4 .
:
, :
1
2
3
4

1 bit ... 1 ()
4 bits ... 4 (16 )
8 bits ... 8 (256 )
16 bits ... - 16 (65536 )

650

5. -Window
5

24 bits ... 24 (16 )

Enter ... .

Enter.



:
XF86Config. ,
.
/etc/Xll/XF86Config?

XF86Config. XF86Config
, .
xf86config :
. 'startx'.
XF86Config ,
(, /etc/Xll).
Ctrl, alt ' + ' .
Ctrl, alt backspace (
, ).
/usr/Xl11R6/lib/
Xll/doc/README.Config.

.
" X-Window".


,
:
, :
1
2
3
4
5

1 ()
4 (16 )
4 (256 )
16 (65536 )
24 (16 )

Enter.
:
XF86Config. ,
.
/etc/Xll/XF86Conig?

XF86Config. XF86Config
, .
xf86config :
. 'startx'.
XF86Config ,
(, /etc/Xll).
Ctrl, alt ' +' .

34. X-Window

651

Ctrl, alt backspace


( ,
).
/usr/XHR6/lib/
XI1/doc/README.Config.

X-Window 640x480.
,
XF86Config. .

XFSGConfig
FreeBSD, XWindow .
X-Window /etc/Xll XF86Config.
/ xf86cfg ( X-Window
) xf86config ( X-Window
). X-Window
.
, . , .
X-Window xf86config,
(, ). ,
,
, xf86config.
XF86Config, ,
. /etc/Xll/ XF86Config,
, /etc/Xll/XF86Config.bak.
(. 7, , FreeBSD).

, FreeBSD ( , UNIX) .
[xfSBconfig]
(XFSGConfig]. , .

XFSGConfig
XF86Config . .
Section, .
EndSection. , . (#)
. XF86Config:
Section "Module"
# DBE.
Load

"dbe"

652

5. X-Window

#
# XFree86-DGA .
Subsection
"extmod"
Option
"omit xfree86-dga"
#
# DGA extension
EndSubSection
# Typel FreeType
Load
"typel"
Load
"freetype"
# GLX
#
Load
"glx"
EndSection

, , . XF86Config
. Module , . , # This loads the Typel and
FreeType font modules ( Typel FreeType) .
Load Adobe Type 1, freetype,
X-Window
TrueType.
, . SubSection, ,
EndSubSection. , .
XF86Config.

"Modules"
,
, , . -, X-Window. , . ,
. , TrueType,
X. Load "freetype" .
Load .
, TrueType:
Load "freetype"

"Files"
X-Window PATH. ,
.
, , , ,
, X-Window, .
FontPath,

34. X-Window

653

. , Adobe
1:
FontPath

"/usr/XllR6/lib/Xll/fonts/Typel/"


Adobe Type 1. X-Window .
. ,
Adobe Type 1 Typel.
, , .

"ServerFlags"
, X-Window.
, xf86config,
. .
Option,
. , ,
- Ctrl+Alt+ Backspace:
Option "DontZap"

( ,
X-Window .)
.

Option "NoTrapSignals"
, X-Window
. .
X-Window.
, -. , .
Xfree86 .

Option "DontZap"
-
Ctrl+Alt+Backspace. ,
X-Window , .
.
, .

Option "DontZoom"
Ctrl+Alt+keypad+ Ctrl+Alt+keypad-. , .
,
.

654

5. X-Window

Option "DisableVidModeExtension"
-
xvidtune. ,
, xvidtune, . ,
, xvidtune . .
, xf86config,
.
, , , xf86config.
. - ,
XF86Config.

Option "AllowMouseOpenFail"
, -
- ,
.
.
X-Window - , .

Option "BlankTime" "n"


n . ,
10 .

Option "StandbyTime "n"


(standby) n .
, 20 .
, DPMS. , XF86Config,
( ),
DPMS.

Option "SuspendTime" "n"


(suspend mode)
n . , 30
.
, DPMS. , XF86Config.
, DPMS.

Option "OffTime" "n"


n . , 40 .
, DPMS. , XF86Config.
, DPMS.

34. X-Window

655

Option "NoPM"
, .
, .
,
, .
, ,
. , man-
XF86Config.

"InputDevice"
.
InputDevice. :
( - ).
InputDevice .
Identifier. ,
. -Window , ,
.
Driver. .
"keyboard" "mouse";
"microtouch", "touch screen".
InputDevice .

: .

InputDevice :
Section "InputDevice"
Identifier
Driver

"Keyboardl"
"Keyboard"

Option "Protocol"
, "standard". , .

Option "AutoRepeat" "x "


; ,
;
.
500 30 .

Option "XkbRules" "xfreeSB"


, .
"xfree86".
-98 , "xfree98".

656

5. X-Window

Option "XkbModel" "pe104"


Windows 104 ,
"104", 101 - "pclOl". .
, .
Option "XkbLayout" "us"
"us". -98, "nec/jp".
Option "XkbOptions" "ctrhswapcaps"
, Caps Lock Ctrl,
Ctrl Caps Lock. Emacs (
Emacs Ctrl) ,
UNIX- Ctrl Caps Lock.
, .

InputDevice :
Section "InputDevice"
#
Identifier
"Mousel"
Driver
"mouse"

.
Option "Protocol" "protocol"
protocol , . , - .
Auto, -
. . :
Auto, Microsoft, MouseSystems, MMSeries, Logitech, MouseMan, MMHitTab, GlidePoint,
IntelliMouse, ThinkingMouse, AceCad, PS/2, ImPS/2, ExplorerPS/2, ThinkingMousePS/2,
MouseManPlusPS/2, GlidePointPS/2, NetMousePS/2, NetScrollPS/ 2, BusMouse, SysMouse,
WSMouse, USB, Xqueue.
:
Logitech Logitech.
Logitech, Microsoft MouseMan.
PS/2 PS/2, ,
.
- ,
PS/2.

34. X-Window

657

Auto ,
.
Option "Device" "devicename"
, .
, - .
. 34.3 , .
34.3

PS/2 ( )

/dev/psmO

/dev/cuaaO

/dev/cuaa1

/dev/cuaa2

/dev/cuaa3

Bus mouse

/dev/mseO

devicename .
Option "Buttons" "n"
.
.
n . 2 3,
5. ,
.
Option "EmulateSButtons"
.
, XWindow .
.
Option "EmulateSTimeout" "n"
EmulateSButtons, , ,
X-Window ,
. ,
, - , n
.
, EmulateSButtons , EmulateSTimeout
50 .
.

658

5. X-Window

"Monitor"
.
Identifier, ,
. .
. .

HorizSync
, .
:
. , (
). , HorizSync 44-76 ,
44 76 .
. ,
.
. ,
, , , "HorizSync
31.5, 35.2".
.
, , , "HorizSync 15-25, 30-50".
VertRefresh
.
,
, HorizSync.

HorizSync VertRefresh, , , .
. Web .

Monitor ,
. man- XF86Config.

"Device"
. , Identifier,
.
Driver . ,
NVIDIA TNT2 :
Driver "nv"

,
xf86config ( ),
, XF86Config. - -

34. X-Window

659

,
www.xfree86.org/current/Status.html.
VideoRam,
. , , 16 RAM,
:
VideoRam 16384
. ,
1024 .
. 34.2.
,
.
XF86Config.
, Web- http://www.xfree86.Org/4.0.2/index.html
, ,
, .

, .
Vesa. cynep-VGA.
,
X-Window, , .
, , .

"Screen"
Screen (..
), -.
Identifier, . XF86Conflg
. ,
ServerLayout .
.

Device "devicename"
,
, devicename ( ) ,
Identifier .
Monitor "monitorname"
, . Monitorname
( ) ( Identifier).
DefaultDepth "n"
, .
n 8, 16 24 ( , ).

660

5. X-Window


XF86Config.
() .

"Display"
display ,
.
,
- .
display.
Depth,
, . , :
Subsection "Display"
Depth
24

.
: Modes,
. ,
Ctrl+Alt+keypad+
Ctrl+Alt+keypad-.
:
Modes "1024x768" "800x600" "640x480"


1024x768. Ctrl+Alt+keypad+ Ctrl+Alt+keypad-
800x600 640x480.
-Window , . ,
800x600, 1024x768.
, X-Window \f86config.
.
Virtual resolution
, "Virtual 1024x768". , .
, "
" ( ).
man-
XF86Config.

"ServerLayOut"
ServerLayout . ,
, .
ServerLayout , , -.

34. X-Window

661

Identifier, . , , ServerLayout:

Screen "screenname"
, .
screenname , Identifier ServerLayout.
InputDevice "keyboardname" "CoreKeyboard"
, ServerLayout. keyboardname ,
.
CoreKeyboard .
InputDevice "mousename" "CorePointer"
. ,
ServerLayout. CorePointer .
ServerLayout.
, ,
, .
,
XF86Config, . , man- XF86Config.

X-Window
xf86config /
XF86Config , -.
X-Window startx. ,
,
, .
, .
X-Window ,
, XF86Config , .

X-Window , /
, ,
Ctrl+Alt+Backspace X-.
, ,
( , -
). -, /
XFSBConfig ( xfSBconfig].
.

startx ,
( ,

662

5. X-Window

), , ,
. -
Ctrl+Alt+Backspace. .
/
.
.xinitrc ,
.

.xinitrc
.xinitrc XWindow, , ,
. .


4, 5 6 , , GNOME (Gnome
Desktop Environment). Gnome ,
.
: Blackbox WindowMaker.
FreeBSD ( xll-wm). 15
, FreeBSD.
. 34.1 34.2 Blackbox WindowMaker.
Blackbox . , , .

34.1 Blackbox .
.

34. X-Window

663

34.2 WindowMaker ,
NextStep.

WindowMaker - "" (
) . ,
: , , .

.xinitrc, Gnome.
.xinitrc .
, .
,
-Window, . WindowMaker :
wmaker
Blackbox:
blackbox

.
X-Window, Gnome
.
.
Blackbox WindowMaker, Web- http://
blackbox.alug.org www.windowmaker.org.
, Web-
www.xwinman.org.


, X-Window
- , .xinitrc
&, .
a
.

664

5. X-Window

.xinitrc, X- -
Blackbox.
xterm &
xclock &
blackbox


WindowMaker Gnome
. (, FVWM wm2) . .xinitrc.


X-Window ,
.
xsetroot
bitmap. /usr/XHR6/
lib/Xll/rgb.txt. :
xsetroot -solid ForestGreen

X- .
,
.xinitrc . ,
twin:
xsetroot -solid ForestGreen & twin

, rgb.txt. ,
.
bitmap-, xsetroot
. man- xsetroot.
, . 34.3.


X-Window , .
FreeBSD
xv. . xv
. 34.4.

34.3




xsetroot.

34. X-Window

665

xv

, GIF, JPEG
BMP,
.

xv Window:
xv -root -quit /home/foobar/images/
myimage.jpg

myimage.jpg (.. ).
xv,
.
-Window,
.xinitrc
:

34.4 xv

-Window.
,
.

xv -root -quit /home/foobar/images/myimage.jpg twm

xv: -max ; -maxspect


.


, X-Window (, GIMP).
X-Window . Adobe Type 1 TrueType. ,
Windows, Macintosh Xfree86.
Internet ,
1 TrueType.
.

XFSGConfig
, , , XF86Config
, .
XF86Config "
XF86Config".
/etc/Xll/XF86Config Load Modules. : Adobe Type 1:
Load "typel"
TrueType:
Load "freetype"

666

5. X-Window

:
Section "Modules"
, , files ,
.
XF86Config FontPath.
TrueType, FontPath
, :
FontPath

"/usr/XllR6/lib/Xll/fonts/TrueType/"


( root):
mkdir /usr/XllR6/lib/Xll/fonts/TrueType

TrueType.
, . , 1 /usr/XllR6/lib/Xll/fonts/Typel, a
TrueType /usr/XHR6/lib/Xl I/fonts/TrueType.
, :
chmod 444 _

(, .
8).
, .
TrueType ttmkfdir.
FreeBSD ( xll-fonts). Adobe Type 1 typelinst. . , , 15.
, .
TrueType:
ttmkfdir > fonts.scale

Adobe Type 1:
typelinst

>

fonts.scale

mkfontdir,

. ( 1 TrueType) -.
:
mkfontdir -e /usr/XHR6/lib/font/encodings

X-Window .

34. X-Window

667

ttmkfdir
( typelinst) mkfontdir.

XWindow
X-Window ,
() . ,
,
. Telnet SSH, .
, . X-Window
. , .
, ,
X-Window . , , , . XWindow : ,
. , X-Window
, . , -
, , . , ,
, -. , .
,
X-Window-, -. . - FreeBSD,
Linux, Solaris Mac OS X. ,
UNIX-. - Windows,
-, FreeBSD.
. Xfree86
Windows, - Windows-.
- . . ( !)
xhost.

xhost

xhost , , .
xhost . :
bash$ xhost
access control enabled, only authorized clients can connect
bash$

668

5. X-Window


, (authorization list). , ..
.
lion,
. :
bash$ xhost +lion
lion being added to access control list
bash$

xhost :
access control enabled, only authorized clients can connect
INET:lion.samplenet.org

lion -Window
.
( !) ,
lion, .
, .
xhost . ( )
.
xhost ,
,
.
:
bash$ xhost -lion
lion being removed from access control list
bash$

lion
.
xhost ,
. , ,
- ,
:
bash$ xhost +
access control disabled, clients can connect from any host
bash$

xhost -.
:
access control enabled, only authorized clients can connect

xhost ,
,
, xhost: 6000 6063 (. 29].

, . -

34. X-Window

669

Telnet, SSH rlogin (


rlogin ).

-, Windows,
Telnet SSH, .
Windows Telnet -,
, .


DISPLAY
. Telnet, SSH
rlogin.
( , simba):
bash$ DISPLAY=simba:0; export DISPLAY bash$
xcalc & .

bourne (.. bourne, korn


bash). tcsh, :
% setenv DISPLAY simba:0

xcalc,
.
DISPLAY :
DISPLAY=_ : #: #

# 0, #, , ,
.

Telnet SSH, .
xterm .


,
. ,
xhost, .
.
Xsecurity. ( .)

xdm
xdm X-Window.
, ,
. Windows NT/2000.

670

5. X-Window

xdm,
.xsession. .xinitrc xdm.
, . .xsession
(&). :
maker &
xterm
&

WindowMaker xterm.
, , .xinitrc, .xsession , .
xdm .
, ,
X-Window .
/usr/local/etc/rc.d:
#!/bin/sh
case "$1" in
start)
echo "**************************************************" echo "*
Starting the XDM login manager. Please wait... *" echo
"**************************************************" xdm
;;
*)

: #
;;

esac

, xdm
.
xdm ,
. man- xdm.

. 673

FreeBSD.
:
, ..
,
.
FreeBSD.

cd _

_. ( 8)

Is

.
: -I ( ), - (
) -F (, ). ( 8)

_ _ _ _. ,
, .
-r ( )
-i (
). ( 8)
mv _ _ .
, ,
. -r
( ) -i (

).
. ( 8)
rmdir _

_, . ( 8)

touch _


, ( ). ( 8)

mkdir _

. ( 8)

In 1 2

2, 1 (
Windows). ( 8)

mount _

_ ,

.,
. ( 9)

umount _

,
_,
. ( 9)

,
mod [_]

_. ( 10)

chown
_


_ . ( 10)

chgrp _ _

_. ( 10)

674

6.

passwd

.
root ,
. ( 10)

adduser

,
. ( 10)

rmuser

,
. ( 10)

vipw

/etc/master.passwd.
. ( 10)


grep [] _

_ .
( 8)

more _

. ( 8)

less _

.
less more, . ( 8)

cat _

, cat
. ( 8)

we _

,
. ( 8)

diff 1 2

/ 2
. ( 8)

fmt _

_ ,
.
STDOUT. ( 8)

cut [] _


_.
STDOUT. ( 8)

head _

10 . ( 8)

tail _

10 . ( 8)

sort _


. STDOUT.
( 8)

cal

. ( 8)

date

. root
. ( 8)

man

.
( 8)

vi

vi.
, . ( 7)

FreeBSD Easy Editor.


, . ( 7)

. 675

,
ps

, .
: -I ( ), - (
) - ( , ,
). ( 14)

top


.
. ( 14)

kill n

n.

. ( 14)

killall _

_ ,
. ,
,
.
. ( 14)

at


. ( 14)

crontab _


. _ crontab
.( 14)

shutdown

. ( 4)

halt

. ( 4)

reboot

. ( 4)

Ipr

. ( 16)

Iprm n

n .

.. ( 16)

Ipq

.
( 16)

.
( 16)


pkg_jnfo

, ,

pkg_add _

. ( 15)

pkg_delete _

. ( 15)

make

,
. ( 15)

make install

, ,
. ,
. ( 15)

. ( 15)

676

G.

make deinstall

,
. , ,
. ( 15)

make clean

,
, ,
, , . ( 15)

make distclean

,
, ,
. ( 15)

.profile

,
Bourne (sh, ksh bash). ( 12)

.login

,
csh tcsh. ( 12)

.cshrc

,
csh tcsh.
, ,
. ( 12)

.bashrc

bash.
,
, . ( 12)

/etc/csh.login


csh tcsh,
.( 12)

/etc/profile


Bourne (sh, ksh, bash),
. ( 12)

.forward

(forwarding) .
( 25)

.xinitrc

, X-Window. ( 34)

/etc/re.conf

,
FreeBSD. ( 11)

/etc/X11/XF86Config

X-Window.
( 34)



, X-Wintlow

678

6.

, FreeBSD, a
, X-Window.


:
# Intel 386sx
# 4
, :
# Intel 486DX2/66
# 32
# 1 ( -Window)
( ). ,
.
-Window, (
:
# 1024x768
# SVGA (. ) 1
#


, FreeBSD.
( SCSI)
MFM RLL (WD1003)
IDE (WD1007)

FreeBSD UDMA EIDE-,


.

SCSI-
, SCSI- (, SoundBlaster
SCSI-) , Adaptec.
, , .
.
Adaptec:
EISA SCSI- 174

EISA/VLB/PCI SCSI- 274/284/2920/294/2950/3940/3950


(Narrow/Wide/Twin)
SCSI- AIC-7850, AIC-7860, AIC-7880, AIC-789X
ISA SCSI- 1510 ( )

. 679

ISA SCSI- 152


AIC-6260 AIC-6360, SCSI- 152 SoundBlaster
AdvanSys:
SCSI- AdvanSys.
AMI:
AMI FastDisk,
BusLogic MultiMaster
Bus Logic:
- MultiMaster "W", -948, -958, -9580
- MultiMaster "", -946, -956, BT-956CD, -445,
-747, -757, BT-757CD, -545, BT-540CF
- MultiMaster "S", BT-445S, BT-747S, BT-747D, BT-757S,
BT-757D, BT-545S, BT-542D, -742, -542
- MultiMaster "", -742, -542
Compaq:
Intelligent Disk Array: IDA, 1DA-2, IAES, SMART, SMART-2/E, Smart-2/P,
SMART-2SL; Integrated Array; and Smart Arrays 3200, 3100ES, 221, 4200, 4200, 4250ES
DPT:
SmartCACHE Plus, SmartCACHE III, SmartRAID III,
SmartCACHE IV SmartRAID IV SCSI/RAID. DPT SmartRAID/CACHE V
. , SCSI RAID- DPT PM3754U216M.
DTC:
EISA SCSI- 1542
SymBios ( NCR):
PCI SCSI- 53810, 53810, 53815, 53820, 53825, 53860, 53875,
53C875j, 53885 53896, ASUS SC-200; Data Technology DTC3130 ( ); Diamond FirePort (); NCR cards (); SymBios cards (); Tekram DC390W,
390U 390F; Tyan S1365
QLogic:
SCSI- Fiber- 1020, 1040, 1040 2100

FreeBSD SCSI-1 SCSI-1I. CD-RW


WORM-, FreeBSD, .
, cdrecord
FreeBSD.

CD-ROM
, ATAPI SCSI

680

6.

Matsushita/Panasonic (Creative Labs SoundBlaster) ( 562/563)


Sony


Adaptec:
Duralink PCI- Fast Ethernet Adaptec AIC-6195 Fast Ethernet,
:
ANA-62011 64-, , 10/100baseTX
ANA-62022 64-, , 10/100baseTX ANA62044 64-, , 10/100baseTX ANA-69011
32-, , 10/100baseTX ANA-62020 64-,
, lOObaseFX
Allied-Telesyn:
1700 RE2000
Alteon Networks:
Alteon Networks PCI Gigabit Ethernet Tigon 1
Tigon 2, Alteon AceNIC (Tigon 1 2), 3Com 3c985-SX (Tigon 1 2), Netgear
GA620 (Tigon 2), Silicon Graphics Gigabit Ethernet, DEC/Compaq EtherWORKS 1000, NEC
Gigabit Ethernet
AMD:
PCnet/PCI (79c970 53974 79974)
RealTek:
8129/8139 Fast Ethernet, :
Allied-Telesyn AT2550 Allied-Telesyn AT2500TX Genius
GF100TXR (RTL8139) NDC Communications NE100TX-E
OvisLink LEF-8129TX OvisLink LEF-8139TX Netronix Inc. EA1210 NetEther 10/100 KTX-9130TX 10/100 Fast Ethernet
Accton "Cheetah" EN1207D (MPX 5030/5038; RealTek 8139) SMC
EZ Card 10/100 PCI 1211-TX
Lite-On:
98713, 98713A, 98715 98725 Fast Ethernet, :
LinkSys EtherFast LNE100TX NetGear FA310-TX Rev. Dl Matrox FastNIC 10/100
Kingston KNE110TX

Macronix:
98713, 98713, 98715, 98715 98725 Fast Ethernet,
:
NDC Communications SFA100A (9871 ) CNet
120 (98713 9871 ) CNet
(98715) SVEC PN102TX (98713)
Macronix/Lite-On:
PNIC II LC82C115 Fast Ethernet, LinkSys EtherFast
LNE100TX 2

Winbond:
W89C840F Fast Ethernet, Trendware TE100-PCIE

Via Technologies:
VT3043 "Rhine I" VT86C100A "Rhine II" Fast Ethernet,
Hawking Technologies PN102TX D-Link DFE-530TX
Silicon Integrated Systems:
SiS 900 SiS 7016 PCI Fast Ethernet
Sundance Technologies:
ST201 PCI Fast Ethernet, D-Link DFE-550TX
SysKonnect:
SK-984x PCI Gigabit Ethernet, :
SK-9841 lOOObaseLX (, , ) SK9842 lOOObaseSX (, , ) SK-9843
lOOObaseLX (, , ) SK-9844
lOOObaseSX (, , ).
Texas Instruments:
ThunderLAN PCI, :
Compaq Netelligent 10, 10/100, 10/100 Proliant, 10/100 Dual-Port, 10/100 TX Embedded
UTP, 10 PCI UTP/Coax, and 10/100 TX UTP
Compaq NetFlex , Integrated w/BNC
Olicom OC-2135/2138, OC-2325, OC-2326 10/100 TX UTP
Racore 8165 10/100baseTX 8148 lObaseT/lOObaseTX/lOObaseFX
ADMTek:
PCI Fast Ethernet AL981 AN985
ASIX Electronics:
PCI AX88140A, Alfa Inc. GFC2204 CNet ProllOB

681

682

6.

DEC:
EtherWORKS III (DE203, DE204 DE205)
EtherWORKS II (DE200, DE201, DE202 DE422)
DC21040, DC21041 DC21140 (SMC Etherpower 8432T,
DE245 ..)
FDDI (DEFPA/DEFEA)
Efficient:
ENI-155pATMPCI
FORE:
-200 ATM PCI
Fujitsu:
MB86960A/MB86965A

HP:
PC Lan+ ( : 27247 27252)

Intel:
EtherExpress ISA ( - )
EtherExpress Pro/10
EtherExpress Pro/100B PCI Fast Ethernet
Isolan:
AT 4141-0 (16-)
Isolink:
4110(8-)

Novell:
NE1000, NE2000 NE2100
PCI, NE2000, :
RealTek 8029
NetVin 5000
Winbond W89C940
Surecom NE-34
VIAVT86C926
3Com:
3C501
3C503 Etherlink II 3C505
Etherlink/+ 3C507 Etherlink
16/TP 3C509 3C579
3C589 (PCMCIA)
3C590/592/595/900/905/905B/905C PCI and EISA (Fast) Etherlink III / (Fast) Etherlink XL

683

980/980 Fast Etherlink XL


3CSOHO100-TX OfficeConnect
Toshiba:
Ethernet- Toshiba
PCMCIA:
PCMCIA Ethernet- IBM National Semiconductor

USB
USB-
USB-
USB- USB
USB-


16550 UART (Midi) ( ,
, )
Advance Asound 100, 110 Logic ALS120
Aureal Vortexl/Vortex2 Vortex Advantage

Creative Labs SB 16, SB32, SB W (64 Gold), Vibral6, SB PCI
( ), SB Live! ( )
, SoundBlaster
Creative Labs SB Midi Port ( ), SB OPL3 Synthesizer
( )
Crystal Semiconductor CS461x/462x Audio Accelerator; Midi-
CS461x
Crystal Semiconductor CS428x
CS4237, CS4236, CS4232, CS4231 (ISA)
ENSONIQ AudioPCI ES1370/1371
ESS ES1868, ES1869, ES1879, ES1888
Gravis UltraSound PnP, MAX
NeoMagic 256AV/ZX (PCI)
OPTi931 (ISA)
Midi-, OSS ( )
Trident 4DWave DX/NX (PCI)
Yahama OPL-SAx (ISA)


4- AST, IRQ 8 ARNET, IRQ
ARNET ( Digiboard) Sync 570/i 4 Boca BB1004 ( ) 6 Boca IOAT66 ( ) 8 Boca BB1008 ( )

684

16- Boca BB2016 ( )


Cyclades Cyclom-y
4- SmartIO CI-104J
4- STB, IRQ
SDL Communications RISCom/8
SDL Communications
RISCom/N2 N2pci
Specialix SI/XIO/SX (S'IHOST2.x)
( , JET) ; ISA, EISA
PCI
: EasylO, EasyConnection 8/32 & 8/64, ONboard
4/16 Brumby
Connectix QuickCam
Matrox Meteor Video
Creative Labs Video Spigot
Cortex 1
Brooktree Bt848
Bt878
CD-R HP4020, 6020, Philips CDD2000/CDD2660 Plasmon
Bus-
PS/2

-10
GPIB Transputer
Genius Mustek
( ;
)
PCMCIA- ISA- Lucent Technologies WaveLAN/IEEE
802.11 (2 /) - (6 /), (NCR
WaveLAN/IEEE 802.11, Cabletron RoamAbout 802.11 DS)

, XWindow
, XFree86
. Web- XFree86.
, , , .
2 the Max MAXColor S3 Trio64V+
3DLabs Oxygen GMX
928Movie
AGX (generic)
ALG-5434
ASUS 3Dexplorer
ASUS PCI-AV264CT

ASUS PCI-V264CT
ASUS Video Magic PCI V864
ASUS Video Magic PCI VT64
AT25
AT3D
ATI 3D Pro Turbo
ATI 3D Pro Turbo PC2TV
ATI 3D Xpression
ATI 3D Xpression+
ATI 3D Xpression+ PC2TV
ATI 8514 Ultra ( VGA)
ATI All-in-Wonder
ATI All-in-Wonder Pro
ATI Graphics Pro Turbo
ATI Graphics Pro Turbo 1600
ATI Graphics Pro Turbo AT&T 20C408 RAMDAC
ATI Graphics Pro Turbo I68860 RAMDAC
ATI Graphics Pro Turbo I68860 RAMDAC
ATI Graphics Pro Turbo I68860 RAMDAC
ATI Graphics Pro Turbo I68875 RAMDAC
ATI Graphics Pro Turbo 8398 RAMDAC
ATI Graphics Pro Turbo STG1702 RAMDAC
ATI Graphics Pro Turbo STG1703 RAMDAC
ATI Graphics Pro Turbo TLC34075 RAMDAC
ATI Graphics Ultra
ATI Graphics Ultra Pro
ATI Graphics Xpression
ATI Graphics Xpression I68860 RAMDAC
ATI Graphics Xpression I68860 RAMDAC
ATI Graphics Xpression I68860 RAMDAC
ATI Graphics Xpression I68875 RAMDAC
ATI Graphics Xpression AT&T 20C408 RAMDAC
ATI Graphics Xpression CH8398 RAMDAC
ATI Graphics Xpression Mach64 CT (264CT)
ATI Graphics Xpression STG1702 RAMDAC
ATI Graphics Xpression STG1703 RAMDAC
ATI Graphics Xpression TLC34075 RAMDAC
ATI Mach32
ATI Mach64
ATI Mach64 3D RAGE II
ATI Mach64 3D RAGE II+DVD
ATI Mach64 3D Rage IIC
ATI Mach64 3D Rage Pro
ATI Mach64 CT (264CT), Internal RAMDAC

685

686

6.

ATI Mach64 GT (264GT), 3D RAGE, Int


ATI Mach64 VT (264VT), Internal RAMDAC
ATI Mach64 AT&T 20C408 RAMDAC
ATI Mach64 I68860 RAMDAC
ATI Mach64 I68860 RAMDAC
ATI Mach64 I68860 RAMDAC
ATI Mach64 I68875 RAMDAC
ATI Mach64 8398 RAMDAC
ATI Mach64 IBM RGBS 14 RAMDAC
ATI Mach64 Internal RAMDAC
ATI Mach64 STG1702 RAMDAC
ATI Mach64 STG1703 RAMDAC
ATI Mach64 TLC34075 RAMDAC
ATI Pro Turbo+PC2TV, 3D Rage II+DVD
ATI Ultra Plus
ATI Video Xpression
ATI Video Xpression+
ATI WinBoost
ATI Win Boost AT&T 20C408 RAMDAC
ATI WinBoost I68860 RAMDAC
ATI WinBoost I68860 RAMDAC
ATI WinBoost I68860 RAMDAC
ATI WinBoost I68875 RAMDAC
ATI WinBoost 8398 RAMDAC
ATI WinBoost Mach64 CT (264CT)
ATI WinBoost STG1702 RAMDAC
ATI WinBoost STG1703 RAMDAC
ATI WinBoost TLC34075 RAMDAC
ATI WinCharger
ATI WinCharger AT&T 20C408 RAMDAC
ATI WinCharger I68860 RAMDAC
ATI WinCharger I68860 RAMDAC
ATI WinCharger I68860 RAMDAC
ATI WinCharger I68875 RAMDAC
ATI WinCharger 8398 RAMDAC
ATI WinCharger Mach64 CT (264CT)
ATI WinCharger STG1702 RAMDAC
ATI WinCharger STG1703 RAMDAC
ATI WinCharger TLC34075 RAMDAC
ATI Win Turbo
ATI WinTurbo AT&T 20C408 RAMDAC
ATI WinTurbo I68860 RAMDAC
ATI WinTurbo I68860 RAMDAC
ATI WinTurbo I68860 RAMDAC

ATI WinTurbo ATI68875 RAMDAC


ATI WinTurbo 8398 RAMDAC
ATI WinTurbo Mach64 CT (264CT)
ATI WinTurbo STG1702 RAMDAC
ATI WinTurbo STG1703 RAMDAC
ATI WinTurbo TLC34075 RAMDAC
ATI Wonder SVGA
ATI Xpert 98
ATI Xpert XL
ATI Xpert@Play PCI and AGP, 3D Rage Pro
ATI Xpert@Play 98
ATI Xpert@Work, 3D Rage Pro
ATI, Intel Maui MU440EX
ATrendATC-2165A
AccelStar Permedia II AGP
Actix GE32+ 2MB
Actix GE32i
Actix GE64
Actix ProStar
Actix ProStar 64
Actix Ultra
Acumos AVGA3
Alliance ProMotion 6422
Ark Logic'ARK1000PV (generic)
Ark Logic ARK1000VL (generic)
Ark Logic ARK2000MT (generic)
Ark Logic ARK2000PV (generic)
Avance Logic 2101
Avance Logic 2228
Avance Logic 2301
Avance Logic 2302
Avance Logic 2308
Avance Logic 2401
Binar Graphics AnyView
Boca Vortex (Sierra RAMDAC)
COMPAQ Armada 7380DMT
COMPAQ Armada 7730MT
California Graphics SunTracer 6000
Canopus Co
Canopus Total-3D
Cardex Challenger (Pro)
Cardex Cobra
Cardex Trio64
Cardex Trio64Pro

687

688

6.

Chips & Technologies CT64200


Chips & Technologies CT64300
Chips & Technologies CT65520
Chips & Technologies CT65525
Chips & Technologies CT65530
Chips & Technologies CT65535
Chips & Technologies CT65540
Chips & Technologies CT65545
Chips & Technologies CT65546
Chips & Technologies CT65548
Chips & Technologies CT65550
Chips & Technologies CT65554
Chips & Technologies CT65555
Chips & Technologies CT68554
Chips & Technologies CT69000
Cirrus Logic GD542x
Cirrus Logic GD543x
Cirrus Logic GD5446 (noname card) 1MB upg
Cirrus Logic GD544x
Cirrus Logic GD5462
Cirrus Logic GD5464
Cirrus Logic GD5465
Cirrus Logic GD5480
Cirrus Logic GD62xx (laptop)
Cirrus Logic GD64xx (laptop)
Cirrus Logic GD754x (laptop)
Colorgraphic Dual Lightning
Creative Blaster Exxtreme
Creative Labs 3D Blaster PCI (Verite 1000)
Creative Labs Graphics Blaster 3D
Creative Labs Graphics Blaster Eclipse (OEM Model CT6510) XF86_SVGA
Creative Labs Graphics Blaster MA201
Creative Labs Graphics Blaster MA202
Creative Labs Graphics Blaster MA302
Creative Labs Graphics Blaster MA334
DFI-WG1000
DFI-WG5000
DFI-WG6000
DSV3325
DSV3326
DataExpert DSV3325
DataExpert DSV3365
Dell S3 805
Dell onboard ET4000

Diamond Edge 3D
Diamond Fire GL 1000
Diamond Fire GL 1000 PRO
Diamond Fire GL 3000
Diamond Multimedia Stealth 3D 2000
Diamond Multimedia Stealth 3D 2000 PRO
Diamond SpeedStar (Plus)
Diamond SpeedStar 24
Diamond SpeedStar 24X ( )
Diamond SpeedStar 64
Diamond SpeedStar A50
Diamond SpeedStar HiColor
Diamond SpeedStar Pro ( SE)
Diamond SpeedStar Pro 1100
Diamond SpeedStar Pro SE (CL-GD5430/5434)
Diamond SpeedStar64 Graphics 2000/2200
Diamond Stealth 24
Diamond Stealth 32
Diamond Stealth 3D 2000
Diamond Stealth 3D 2000 PRO
Diamond Stealth 3D 3000
Diamond Stealth 3D 4000
Diamond Stealth 64 DRAM SE
Diamond Stealth 64 DRAM S3 SDAC
Diamond Stealth 64 DRAM S3 Trio64
Diamond Stealth 64 VRAM
Diamond Stealth 64 Video VRAM (TI RAMDAC)
Diamond Stealth II S220
Diamond Stealth Pro
Diamond Stealth VRAM
Diamond Stealth Video 2500
Diamond Stealth Video DRAM
Diamond Stealth64 Graphics 2001
Diamond Stealth64 Graphics 2xxO (864 + SDAC)
Diamond Stealth64 Graphics 2xxO (Trio64)
Diamond Stealth64 Video 2001 (2121/2201)
Diamond Stealth64 Video 2120/2200
Diamond Stealth64 Video 3200
Diamond Stealth64 Video 3240/3400 (IBM RAMDAC)
Diamond Stealth64 Video 3240/3400 (TI RAMDAC)
Diamond Viper 330
Diamond Viper 550
Diamond Viper PCI 2MB
Diamond Viper Pro Video

689

690

6.

Diamond Viper VLB 2MB


Digital 24-plane TGA (ZLXp-E2)
Digital 24-plane+3D TGA (ZLXp-E3)
Digital 8-plane TGA (UDB/Multia)
Digital 8-plane TGA (ZLXp-El)
EIZO (VRAM)
ELSA ERAZOR II
ELSA GLoria Synergy
ELSAGLoria-L
ELSA GLoria-L/MX
ELSA GLoria-S
ELSA GLoria-XL
ELSA Gloria-4
ELSA Gloria-8
ELSA VICTORY ERAZOR
ELSA Victory 3D
ELSA Victory 3DX
ELSA WINNER 1000/T2D
ELSA Winner 1000 R3D
ELSA Winner 1000AVI ( AT&T 20C409)
ELSA Winner 1000AVI ( SDAC)
ELSA Winner 1000ISA
ELSA Winner 1000PRO S3 SDAC
ELSA Winner 1000PRO STG1700 AT&T RAMDAC
ELSA Winner 1000PRO/X
ELSA Winner 1000TRIO
ELSA Winner 1000TRIO/V
ELSA Winner 1000TwinBus
ELSA Winner 1000VL
ELSA Winner 2000
ELSA Winner 2000/Office
ELSA Winner 2000AVI
ELSA Winner 2000AVI/3D
ELSA Winner 2000PRO-2
ELSA Winner 2000PRO-4
ELSA Winner 2000PRO/X-2
ELSA Winner 2000PRO/X-4
ELSA Winner 2000PRO/X-8
ELSA Winner 3000
ELSA Winner 3000-L-42
ELSA Winner 3000-M-22
ELSA Winner 3000-S
EPSON CardPC ()
ET3000 (generic)

4000 (generic)
4000 W32i, W32p (generic)
ET4000/W32 (generic)
ET6000 (generic)
ET6100 (generic)
ExpertColor DSV3325
ExpertColor DSV3365
, VGA
Genoa 5400
Genoa 8500VL(-28)
Genoa 8900 Phantom 32i
Genoa Phantom 64i S3 SDAC
Genoa VideoBlitz III AV
Hercules Dynamite
Hercules Dynamite 128/Video
Hercules Dynamite Power
Hercules Dynamite Pro
Hercules Graphite HG210
Hercules Graphite Power
Hercules Graphite Pro
Hercules Graphite Terminator 64
Hercules Graphite Terminator 64/DRAM
Hercules Graphite Terminator Pro 64
Hercules Stingray
Hercules Stingray 128 3D
Hercules Stingray 64/V ICS5342
Hercules Stingray 64/V ZoomDAC
Hercules Stingray Pro
Hercules Stingray Pro/V
Hercules Terminator 3D/DX
Hercules Terminator 64/3 D
Hercules Terminator 64/Video
Hercules Thriller3D
Integral FlashPoint
Intel 5430
Interay PMC Viper
JAX 8241
Jaton Video-58P
Jaton Video-70P
Jazz Multimedia G-Force 128
LeadTek WinFast 3D S600
LeadTek WinFast 3D S680
LeadTek WinFast S200
LeadTek WinFast S430

691

692

6.

LeadTek WinFast S510


Leadtek WinFast 2300
MELCO WGP-VG4S
MELCO WGP-VX8
MSI MS-4417
Matrox Comet
Matrox Marvel II
Matrox Millennium 2/4/8MB
Matrox Millennium (MGA)
Matrox Millennium G200 4/8/16MB
Matrox Millennium G200 SD 4/8/16MB
Matrox Millennium II 4/8/16MB
Matrox Millennium II AGP
Matrox Mystique
Matrox Mystique G200 4/8/16MB
Matrox Productiva G100 4/8MB
MediaGX
MediaVision Proaxcel 128
Mirage Z-128
Miro Crystal 10SD GenDAC
Miro Crystal 12SD
Miro Crystal 16S
Miro Crystal 20SD PCI S3 SDAC
Miro Crystal 20SD VLB S3 SDAC (BIOS 3)
Miro Crystal 20SD ICD2061A (BIOS 2)
Miro Crystal 20SD ICS2494 (BIOS 1)
Miro Crystal 20SV
Miro Crystal 22SD
Miro Crystal 40SV
Miro Crystal 80SV
Miro Crystal 8S
Miro Crystal DVD
Miro miroCRYSTAL VRX
Miro miroMedia 3D
Miro Miro Video 20TD
Miro Video 20SV
Neomagic
Number Nine FX Motion 331
Number Nine FX Motion 332
Number Nine FX Motion 531
Number Nine FX Motion 771
Number Nine FX Vision 330
Number Nine GXE Level 10/11/12
Number Nine GXE Level 14/16

Number Nine GXE64


Number Nine GXE64 Pro
Number Nine GXE64 S3 Trio64
Number Nine Imagine I-128 (2-8MB)
Number Nine Imagine I-128 Series 2 (2-4MB)
Number Nine Imagine-128-T2R
Number Nine Revolution 3D AGP (4-8MB SGRAM)
Number Nine Visual 9FX Reality 332
Oak 87 ISA (generic)
Oak 87 VLB (generic)
Oak ISA Card (generic)
Ocean (octek) VL-VGA-1000
OctekAVGA-20
Octek Combo-26
Octek Combo-28
Octek VL-VGA-26
Octek VL-VGA-28
Orchid Celsius (AT&T RAMDAC)
Orchid Celsius (Sierra RAMDAC)
Orchid Fahrenheit 1280
Orchid Fahrenheit VA
Orchid Fahrenheit-1280+
Orchid Kelvin 64
Orchid Kelvin 64 VLB Rev A
Orchid Kelvin 64 VLB Rev
Orchid P9000 VLB
Orchid Technology Fahrenheit Video 3D
PC-Chips M567 Mainboard
Paradise Accelerator Value
Paradise/WD 90CXX
PixelView Combo TV 3D AGP (Prolink)
PixelView Combo TV Pro (Prolink)
R1VATNT
R1VA128
Rendition Verite 1000
Rendition Verite 2x00
Revolution 3D (T2R)
S3 801/805 (generic)
S3 801/805 20490 RAMDAC
S3 801/805 20490 RAMDAC ICD2061A
S3 801/805 Chrontel 8391
S3 801/805 S3 GenDAC
S3 801/805 SC1148{ 2,3,4} RAMDAC
S3 801/805 SC1148{ 5,7,9} RAMDAC

693

694

6.

S3 864 (generic)
S3 864 ATT 20C498 21498
S3 864 SDAC (86C716)
S3 864 STG1703
S3 868 (generic)
S3 868 ATT 20C409
S3 868 ATT 20C498 21498
S3 868 SDAC (86C716)
S3 86260 (generic)
S3 86280 (generic)
S3 86325 (generic)
S3 86357 (generic)
S3 86C365 (Trio3D)
S3 86C375 (generic)
S3 86C385 (generic)
S3 86C391 (SavageSD)
S3 86C764 (generic)
S3 86C765 (generic)
S3 86C775 (generic)
S3 86C785 (generic)
S3 86C801 (generic)
S3 86C805 (generic)
S3 86C864 (generic)
S3 86C868 (generic)
S3 86C911 (generic)
S3 86C924 (generic)
S3 86C928 (generic)
S3 86C964 (generic)
S3 86C968 (generic)
S3 86C988 (generic)
S3 86CM65
S3 911/924 (generic)
S3 924 SC1148 DAC
S3 928 (generic)
S3 964 (generic)
S3 968 (generic)
S3 Aurora64V+ (generic)
S3 Savage3D
S3 Trio32 (generic)
S3 Trio3D
S3 Trio64 (generic)
S3 Trio64V+ (generic)
S3 Trio64V2 (generic)
S3 Trio64V2/DX (generic)

S3 Trio64V2/GX (generic)
S3 ViRGE (generic)
S3 ViRGE ( S3V)
S3 ViRGE/DX (generic)
S3 ViRGE/GX (generic)
S3 ViRGE/GX2 (generic)
S3 ViRGE/MX (generic)
S3 ViRGE/MX+ (generic)
S3 ViRGE/VX (generic)
S3 Vision864 (generic)
S3 Vision868 (generic)
S3 Vision964 (generic)
S3 Vision968 (generic)
SHARP 9080
SHARP 9090
SNI PC5H W32
SNI Scenic W32
SPEA Mercury 64
SPEA Mirage
SPEA/V7 Mercury
SPEA/V7 Mirage P64
SPEA/V7 Mirage P64 S3 Trio64
SPEA/V7 Mirage VEGA Plus
SPEA/V7 ShowTime Plus
STB Horizon
STB Horizon Video
STB LightSpeed
STB LightSpeed 128
STB MVP-2
STB MVP-2 PCI
STB MVP-2X
STB MVP-4 PCI
STB MVP-4X
STB Nitro (64)
STB Nitro 3D
STB Nitro 64 Video
STB Pegasus
STB Powergraph 64
STB Powergraph 64 Video
STB Powergraph X-24
STB Systems Powergraph 3D
STB Systems Velocity 3D
STB Velocity 128
STB Velocity 64 Video

695

696

6.

STB nvidia 128


SiS 3D PRO AGP
SiS 5597
SiS 5598
SiS 6326
SiS SG86C201
SiS SG86C205
SiS SG86C215
SiS SG86C225
Sierra Screaming 3D
Sigma Concorde
Sigma Legend
Spider Black Widow
Spider Black Widow Plus
Spider Tarantula 64
Spider VLB Plus
Tech Works Thunderbolt
Tech works Ultimate 3D
Toshiba Tecra 540CDT
Toshiba Tecra 550CDT
Toshiba Tecra 750CDT
Toshiba Tecra 750DVD
Trident 3DImage975 (generic)
Trident 3DImage975 AGP (generic)
Trident 3DImage985 (generic)
Trident 8900/9000 (generic)
Trident 8900D (generic)
Trident Cyber 9382 (generic)
Trident Cyber 9385 (generic)
Trident Cyber 9388 (generic)
Trident Cyber 9397 (generic)
Trident TGUI9400CXi (generic)
Trident TGU19420DGi (generic)
Trident TGUI9430DGi (generic)
Trident TGUI9440 (generic)
Trident TGUI9660 (generic)
Trident TGUI9680 (generic)
Trident TGUI9682 (generic)
Trident TGUI9685 (generic)
Trident TVGA 8800BR
Trident TVGA 8800CS
Trident TVGA9200CXr (generic)
, VGA
VI720

VL-41
VidTech FastMax P20
VideoLogic GrafixStar 300
VideoLogic GrafixStar 400
VideoLogic GrafixStar 500
VideoLogic GrafixStar 550
VideoLogic GrafixStar 560 (PCI/AGP)
VideoLogic GrafixStar 600
VideoLogic GrafixStar 700
ViewTop PCI
WD 90C24 (laptop)
WD 90C24A or 90C24A2 (laptop)
Weitek P9100 (generic)
WinFast 3D S600
WinFast 3D S600
WinFast S200
WinFast S430
WinFast S510
XGA-1 ( ISA)
XGA-2 ( ISA)

697

699

(
) ( ).


, , .

, . .
, -. ,
. .
, , FTP , ASCII-.
, . BIOS.
, , DOS,
DOS Windows. .

Probing Devices
( )
IDE Zip Jaz.
, . , FreeBSD,
.

CD-,
, CD-ROM
CD-.
CD-ROM
.
CD-ROM
.


FreeBSD , . DOS . , FreeBSD
.
pfdisk, .
pfdisk DOS . FreeBSD .

700 6.

Micron
Micron PCI BIOS . PCI- . , plug-and-play
BIOS.

3Com PCI Micron


PCI BIOS, Micron. plug-and-play BIOS.

SCSI- HP Netserver

SCSI- EISA
PCI. SCSI- EISA 11, PCI. UserConfig ( ). ,
, .
UserConfig, :
eisa 12 quit

FreeBSD
. ,
:
options

EISA_SLOTS=12

ATI Mach64
, ATI Mach64
. UserConfig sioO, siol, sio2 sio3.
.
, /usr/src/sys/i386/isa/sio.c.
28 . .
( , , 17).

, FreeBSD,

,
, . ,
, ,
UserConfig .

701

UserConfig .
:
Kernel Configuration Menu Skip
kernel configuration and continue with installation.
Start kernel configuration in full screen Visual mode.
Start kernel configuration in CLI mode.
Here you have the chance to go into kernel configuration mode, making
any changes which may be necessary to properly adjust the kernel to
match your hardware configuration.
If you are installing FreeBSD for the first time, select Visual Mode
(press Down-Arrow then ENTER).
If you need to do more specialized kernel configuration and are an
experienced FreeBSD user, select CLI mode.
If you are certain that you do not need to configure your kernel then
simply press ENTER or Q now.

.
.

,
.

FreeBSD
Missing Operating System (
)
, FreeBSD
. :
DOS-
DOS. FreeBSD
, .
pfdisk.exe,
-, ,
FreeBSD.
, .

FreeBSD "F?"
.
. .

FreeBSD Read
Error ( )
-,
. . .

702

6.

FreeBSD ,
Windows
: FreeBSD,
- Windows (, fdisk /mbr
) . , .
CD- .
Sysinstall, Configure Fdisk (.
2). , ,
Fdisk. , . Fdisk W, .
, ,
. Yes Enter.
, Master Boot Record.
.

FreeBSD ,

FreeBSD BIOS. , FreeBSD
64 RAM.

:
options

"MAXMEM=n"

n . ,
1024, 1000 . , 1048576 ,
1000000. , 1000, 1024 . , k = m * 1024 , m
. , 128 128 * 1024 = 131072 .
( , ,
17).

FreeBSD Device Not Configured


( )
CD-
. CD . , .
AT API CD-ROM
. CD-ROM .
SCSI- CD-ROM ,
, .
options SCSI_DELAY
. ( . 15000,
.. 15 .) (. 17).

703

Signal 11
illegal operation ( ) Windows.
, ,
. ,
, FreeBSD, .
. , ,
. RAM,
(,
), - .


top, ps
(world)
(kernel). , make world,
. :
, make
world.
, ,
(
17).
, (world). ( 18 , make world.)
, ,
(. 18), , .

root
root, .
.

ok
boot -s,
. , , Enter.
root:
#

mount -u/ Enter.


-. mount -
. root passwd root. .
.
shutdown - now.
.

, FreeBSD
, BSD pyue
Internet

. 705

FreeBSD . FreeBSD,
. .

,
FreeBSD
Web-
www.freebsd.org
Web- FreeBSD. , , .

www.freebsddiary.org
(FAQS)
"how-to" . ,
, FreeBSD
"FreeBSD Pets" ( FreeBSD). FreeBSD
, .

www.freebsdzine.org
, ,
FreeBSD. FreeBSD .

www.freshports.org
,
FreeBSD.

www.freebsdmall.com
, FreeBSD. -, , , , , , FreeBSD. ,
FreeBSD.


.
- ,
majordomo@freebsd.org :
subscribe -

, :
unsubscribe -

706

6.

.
(). ,
100 .



. , ,
( ). .

freebsd-advocacy
FreeBSD ""
.

freebsd-announce
, FreeBSD.
.

freebsd-arch
.

freebsd-bugs
FreeBSD. ,
, GNATS,
( ). http://www.freebsd.org/ sendpr.html. -.

freebsd-chat
( ) FreeBSD .

freebsd-commit
, FreeBSD, . .

freebsd-config
FreeBSD (,
, , , Sysinstall).
.

freebsd-current
CURRENT FreeBSD, . ,
make world ,
, .
CURRENT,

707

. ,
"how-to" . ,
CURRENT. , , freebsd-questions.

freebsd-isp
Internet, FreeBSD.
, .

freebsd-jobs
FreeBSD ,
. ,
"help wanted" ( ).

freebsd-newbies
, FreeBSD. ,
, .
FreeBSD .
freebsd-questions, freebsd-newbies.

freebsd-policy
, FreeBSD. .

freebsd-questions
FreeBSD.
, . ,
: " pppd . ?" . ,
, log-, .. ,
, . , , ,
. , .
, .
, .

freebsd-stable
, STABLE
FreeBSD. CURRENT,
STABLE, .
,
, STABLE , CURRENT, . , .

708 6.

freebsd-security-notifications
. ,
.


,
, , FreeBSD, FreeBSD .. ,
.

http://www.freebsd.org/doc/en_US.ISO_8859-I/books/handbook/
eresources.html#ERESOURCES-MAIL.

USENET,
FreeBSD
, FreeBSD. USENET:
.unix.bsd.freebsd.announce
comp.unix.bsd.freebsd.misc

IRC
IRC, FreeBSD.
, FreeBSD. , FreeBSD:
EFNet: #freebsdhelp
Undernet: #freebsd
, , , ,
. .
, IRC

.
, , .
- , ( , ), , , . ,
, , .

, BSD
, BSD,
FreeBSD. FreeBSD
BSD, .

. 709

Web-
www.daemonnews.org
, BSD.
"how-to". "Source
Wars".

www.bsdtoday.com
, BSD.

www.maximumbsd.com
BSD,
.

USENET
USENET ,
BSD:
comp.bugs.4bsd
.bugs.4bsd.ucb-fi\es
comp.unix.bsd

Internet
Internet,
FreeBSD. ,
, .

Web-
www.slashdot.org
News for nerds. Stuff that matters. (" . ,
") .

.
slashdot ,
.

www.xfree86.org
XFree86,
- X-Window,
FreeBSD.

www.gnu.org
GNU (
GNU's Not UNIX, "GNU UNIX"). ,
FreeBSD (, GCC, GAWK,
EMACS, 77), GNU.
,
.

710

6.

www.gnome.org
Gnome Desktop Environment (
GNOME). , , Gnome.

www.kde.org
Gnome. D, .

www.apache.org
Web- Apache, Web- . Web-
FreeBSD.

www.mysql.com
SQL , FreeBSD.
, ..
MySQL.

www.postgresql.org
SQL,
FreeBSD. , MySQL,
.

www.php.net
, Web-.
Active Server Pages (ASP),
.

www.perl.com
Perl, FreeBSD.

www.python.org
Python,
Perl.

www.sendmail.org
Sendmail, FreeBSD.

www.postfix.org
, Sendmail. Postfix
Sendmail. Sendmail, .

USENET
USENET , FreeBSD :

. 711

UNIX

comp.unix
comp.unix.questions
comp.unix.admin
comp.unix.programmer
comp.unix.shell
comp.unix.user-friendly
.security.unix
.sources.unix
.unix.advocacy
.unix.misc

, X-Window

comp.windows.x.i386unix
comp.windows.x
.windows.x.apps
comp.windows.x.announce
comp.windows.x.intrinsics
comp.windows.x.motif
comp.windows.x.pex
comp.emulators.ms-windows.wine

466

427
427
552
245
397

574
" " 576

/ 83
431
195
184
532, 544, 562
533
563
533
533

191
602
98
525
253

76, 83, 207


wheel 189

528
541, 563

279
DHCP 633
dhcpd 636
gated 540
inetd 617

Ipd 305
mountd 603
NAT 532
natd 533
NFS 603
PortSentry 568
pppd 452
named 581, 586
nmbd 615
smbd 615
sshd 572
zebra 540
608
/ 606
541
603
287
507
592
581, 613
434
421
420

152
185
181

3
84
84, 208

CNAME 595
MX 596

NS 594
PTR 596
SOA 593
543, 555
- 556
577
543


578
Apache 557
555
577
582
forward 589
master 588
588

196
setgid 196
196
43
184
425
Perl 391
66, 141, 222
Bourne (sh) 141
Bourne Again Shell (bash) 143
C(csh) 142
Korn (ksh pdksh) 142, 266 sh
141

Tcsh(tcsh) 143
531 Ethernet
531
163
592

417
418
418
170, 183
260

abort 319
429
at 282
awk 161
cd 149
chfn 204
chmod 195, 534
chown 617
chroot 544
cp 149
cut 160

df 169, 606
disable 321
dmesg 180
down 321
du 170
egrep 158
expr 246
fgrep 158
fmt 161
getfacl 198
grep 158
hostname 444
ifconfig 441
kill 277
In 152
Ipc 319
Ipd 314
Ipq 317
Ipr 314
Iprm 317
Is 147
mount 171
mount_nfs 606
mv 150
printenv 236
printf 248
pwd 149
renice 278
restart 322
rm 151
rmdir 151
rmuser 203
route 443
Script-Fu 125
sed 161
setfacl 198
shift 252
sockstat 568
sort 159
status 319
stop 319
su 551
topq 322
touch 152
tr 159
umount 172
unalias 233

713

714

up 322
we 157
420
239
620
208
419

395
AND/OR 250

422, 576
530, 539
540
528
540
198
268, 394

95
224
154
551
328
131
407
mod_perl 558
mod_php 558
mod_ssl 558, 559
Perl 408
422
130


push( ) 396
( ) 396
shift( ) 396
unshift( ) 396

bash 235
235
59
438
83
147, 226

51
222
399
208

=- 402
break 253
case 258
continue 253
elif 256
false 253
if 255
options 590
true 253
zone 593
die 404
my 407
402
395
395
402
402
395
395
402
254
395
404

305
473

613, 293
293
293
97
533
natdjnterface 533
545
root 189
549
545
547
243
237


236
- 162
531
262
634
185
450
246
420

root 543
daemon 307
FreeBSD 294
466
528, 530

$ 396
@ 396

Cap_mkdb 548
chat 454
Crack 545, 546
dhclient 627, 630, 631
dhcpconf 633, 634
fdisk 363
GIMP 123
gzip 572
keyinit 549
Mutt 138

perl 394
Reporter 546
sftp 557
showmount 605
SSH 554
sysctl 383
Sysinstall 531, 601
sysinstall 363, 629
tcpdump 553
tripwire 571
uuencode uudecode 138
xsetroot 664
Xwrapper 639
612

ARP 429
DHCP 627

FTP 135
NetBIOS 600
UDP 601
POPS 476

local() 406
207
233
189

613
BSD 361
286
UFS 197
400
116
116
vi 118
191

83
51

Apache 494, 558, 575


NFS 600, 602
602
509
559
430
600
242
153
- 259
381

Apache-SSL 558
BIND 582, 583

CGIWrap 560
Kerberos 551
Samba 611
622
623
614
622

SWAT 615

Tripwire 570

715

716

581
581
285
395
148
361
245

578
197
296
287
515
182
216
CGI 559, 631
/sbin/dhclient-script 631
86
209, 211
86

376
mime 109
53, 171, 169

203
619
621
619
235
vpO 177

dd 44
gunzip 571
make 224
perldoc 408
ping 448

pkg_add 287
pkg_create 287
pkg_delete 287
pkgjnfo 287
pkg_update 287
pkg_version 287
ps 275
restore 386
tcpdump 552

top 272

tripwire 571 twcheck


571 xhost 668
621

fstab 178
.htaccess 501
.xinitrc 662
/bin/test! 223
/etc/csh.cshrc 230
/etc/csh.login 230
/etc/diskcheckd.conf 181
/etc/dhclient.conf 632
/etc/fstab 178
/etc/exports 604
/etc/fstab 607
/etc/ftpusers 523
/etc/group 205
/etc/hosts.allow 569
/etc/login.conf 547
/etc/master.passwd 203
/etc/netstart 445, 564
/etc/passwd 203
/etc/printcap 312
/etc/profile 232
/etc/re 212
/etc/rc.conf
183, 211, 445, 534, 536, 539, 564
/etc/resolv.conf 449
/etc/shells 225, 523
/etc/skeykeys 551
/etc/syslog.conf 218
/etc/ttys 209
/usr/bin/perl 391
/usr/lib/perl5 407
/usr/local/crack 546
/usr/local/etc 214
/usr/local/lib/perl5 407
/usr/ports/www/cgiwrap 560
/var/db/pkg 287, 298
/var/run/nologin 523
/var/spool 306
localhost 597
592
591

583, 590
dhcpd 634
450
596
333
590
264
smbfs 611, 624
124
311
263
X
419
556

249
for 251
until 250
while 249

430, 528, 537


NAT 530
530
538

209, 328, 561


328
562


a2ps 308
AbiWord 110
Access Control lists 197
adduser 201
alias 233
AND/OR 259
ARP 429
associative array 397
awk 161
Balsa 137
bash 143
BIOS (Basic Input/Output Services) 83
bootO 83, 207
bootl 84, 207
boot2 84, 208

bootstrapping process 207


Bourne 240
bridges 422
cd 149
CGI 511
CGI- 560
chgrp 193
chmod 534
chsh 227
CIDR (Classless Inter-Domain Routing) 431
clean 86
cnw 538
committers 375
conversion filters 311
crontab 280
Crossover Cables 418
CVSup 344
DHCP 435
dial-on-demand 456
diamond operator 404
diskcheckd 181
disklabei 208
dmesg 209, 330
dot- 148
dump 179, 385
dynamic linking 287
echo 262
edquota 184
errors.txt 73
escape- 156
F.D. 0 STDIN 264
F.D. 1 STDOUT 264
F.D. 2 STDERR 264

fdimage.exe 43
Fetchmail 483
fi 255
File Manager 99
FIPS 73
for 398
foreach 398
fsck 179, 209
FTP 135, 517
FTP- 520
FTP- 520
gedit 114

717

718

GENERIC 329
getopts 270
getty 87
Gnome 105
Gnome Control Center 108
Gnome File Manager 106
GQview 126
grace period 185
grep 158
halt 93
hard limit 185
hard link 152
home directory 189
home- 147
ICMP 425
ifconfig 426
IMAP 481
inetd 216
IP- 426
IP- 627
627
IP- 447
IP- 427
kern.flp 43
kernel 209
less 157
LINT 333
loader 208
login shell 226
Iptcontrol 306
Ismod 208
Lynx 135
- 428
Mail Transfer Agent 466
Mail User Agent 466
mailq 473
maintainer 297
make world 340
Makefile 296
man 144
Master Boot Record 207
master boot record 76
maximum permissions mask 198
mergemaster 345, 351
microkernel architecture 328

more 157
mount 171
Mount point 53
mpg123 133
msfroot.flp 43
MTU 442
NAT 427, 528, 530

netmask 430
NFS 600
package manager 224
PAP- - 455
partitions 174
patches 373
pdksh 142
persistent connection 456
Pine 137
ping 448
pkg_add 287
PortSentry 566
POST (Power On Self Test) 83
Post Office Protocol 476
PPP 532
532
preen 178
print queue 305
printf 241
ProFTPD 526
qpopper 477
query string 515
Red Hat Linux 537
537
relaying 474
resource configuration 209
Resource Configuration script 209
restorrb.exe 73
root 88
routers 422
Sawfish 109
Sawfish Configurator 112
sed 161, 234
sh 141
shadow passwords 376
shared library 286
shell 222
shutdown 91

719

Simple Mail Transfer Protocol 464


single-user mode 208
Slackware Linux 537
537
slices 174, 207, 361
smb.conf 615
SMB/CIFS 611
SMTP 464
soft limit 185
soft links, symbolic links 153
Soft Updates 181
split( ) 397
StarOffice 127
StarOffice Explorer 129
static linking 287
STDIN 244
STDOUT 241
Straight-through 418
strict mode 407
stty 234
switch 420
synchronous writes 381
sysinstall 438



Spiki &
Byzyka.

:
byzyka@pochta.ru

syslogd 218
TCP 423
TCP/IP 425
UDP 424
UFS (Universal File System) 166
UFS Extensions 197
umass 177
UNIX File System 166
upgrade kit 302
uudecode 138
uuencode 138
vi 227
Web- 578
while 398
wl 538
WU-FTPD 526
xdm 669
XF86Config 651
xf86config 640
XMMS 133
xv 664
xvidtune 64

Вам также может понравиться