FreeBSD. Администрирование: Искусство достижения равновесия

Эксперты в области операционных систем и системного администрирования написали эту книгу для тех, кому нужна надежная се

325 110 20MB

Russian Pages 716 Year 2003

Report DMCA / Copyright

DOWNLOAD PDF FILE

Recommend Papers

FreeBSD. Администрирование: Искусство достижения равновесия

  • Similar Topics
  • Art
  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Citation preview

1.

: FreeBSD................................................................. 31

1. 2. 3.

FreeBSD................................................................................. 32 FreeBSD ................................................................................... 41 ...................................................................... 71

2.

FreeBSD .............................................................. 81

4. 5. 6. 7. 8.

FreeBSD..............................................................82 Gnome.................................................................................94 Gnome.......................................................................... 101 ........................................................................ 113 ................................................... 140

3.

FreeBSD................................................... 164

9. 10. 11. 12. 13.

FreeBSD .................................................................... 165 .................................................. 187 ..................................... 206 ................................................ 221

14.

,

................................................................................................. 238 , ............................................ 271

15. .......................................................................................................284 .................................................................................................... 304 ....................................................................... 327 FreeBSD.............................................................................337 ..............................................354 FreeBSD........................................ 368

16. 17. 18. 19. 20. 21. Perl...........................................................................................................390

4. FreeBSD 22. 23. 24. 25.

.......................................................... 411 ................................................................412 .......................................................436 .........................................451 E-mal ………………………………………….…463

6 26. 27. 28. 29. 30. 31. 32.

WebFTP-

....................................................489 ....................................................516 Internet.................................................527 ......................................................................................542 ...................................................................580 (NFS) ...................................................599 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. 1.

: FreeBSD.................................................... 31

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 FreeBSDUNIX... 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.

Boot-

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

2. 4.

FreeBSD ................................................. 81

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 WebStarOffice ....................................................................... 128 StarOffice…………………………………………………128

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

-

,

10.

............................................................................................... 173 Windows/MS-DOS.......................................... 174 Linux ................................................................. 175 CD-ROM ............................................................................................................ 176 .............................................................. 176 ........................................................... 177 ......................................................................................... 177 /etc/fstab ............................................................................................ 177 fsck ................................................................................................................ 179 ........................................ 181 fsck ........................................... 181 ................................................................................. 183 .............................................................. 184

,

.......................................... 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 r n ....................................................................................................................279 crontab ........................................................................................280 crontab..........................................................281

14 r n

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

15. .......................................................................................................... 284

Web-

FreeBSD ................................................................................................................ 285 ..................................................................286 .........................................287 .............................................................................................................289 sysinstall................................................................................289 pkg_add ..............................................................................291 ..............................................................................................................293 ..........................................................................................................293 ..............................................................................................................293 FreeBSD ...................................................................................................294 FreeBSD ...........................................................................................296 ..........................................................................................................297 ..............................................................................298 ..............................................................................................................298 ? ........................................................................299 .............................................................................300 , ........................................................................................................ 301 , ................................. 301 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.

"

21. Perl

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

Perl......................... 390

Perl?................................................................................................................... 391 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 22.

................................................ 411

............................................................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 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 , kernel

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 IMAPIMAP-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 NFS /

/etc/exports...................................................... 604 ..................................................................... 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 SCSIHP 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

. , Web-

Web-

Web-

........................................................ 704

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

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

(Michael Urban),

, FreeBSD, Linux

UNIX, — Center.

, , ,

Java,

Solaris. Lion Research

, , Web.

Perl . FreeBSD

, (Bryan Tiemann) -Caltech. -

,

.

,

,

,

. Macintosh,

(Tim Hicks) —

Solaris 8

AIX 4.1

FreeBSD, .

HomeSide Leading, Inc. UNIX. .

HP-UX 10.10 Sybase

Oracle.

11.00,

-

, .

,

,

,

,

, Research Center

Lion

. .Э

,

,

.

,

.

.

Sams Publishing, , — ,

,

,

-

. . FreeBSD.

-

. FreeBSD

FreeBSD

.

,

, ,

. Lion Research Center . ,

,

(www.lionresearch.org)

, ,

,

-

. ,

-

,

,

-

.

,

, -

, , TLK-L lionking.org

. . ,

,

.

,

,

?

, -

, IBM? ?

, Microsoft

Microsoft ,

? Linux?

,

2001

IBM

— . ,—

20 Internet

,

.

. Internet-

,

,

. Internet-

UNIX . Linux.

, .

Microsoft

Linux

.

, . ,

,

UNIX. ,

UNIX;

,

, UNIX,

,

Linux —

,

, . GPL, GNU General Public License, ,

, . ,

. GPL,

. .

, . ,

. .

,

GPL

:

, . GPL.

,

,

, . , . .

, .

.

, , . FreeBSD (Berkeley Software Design) — . , -

, , BSD,

28

,

,

BSD , GPL. Microsoft

. , Apple ( NeXTSTEP,

NeXT)

BSD Mac OS X. Linux, FreeBSD.

FreeBSD # ,

BSD

BSD-

,

,

FreeBSD

,

Linux .

15%

,

, FreeBSD

. . FreeBSD Linux. .

, . Linux : Linux —

Linux .

FreeBSD UNIX. "

-

-

"

, a FreeBSD — , -

. Linux, . . FreeBSD —

,

,

-

.

UNIX, UNIX Linux ?

,

, "

". UNIX, a ? ,

, Windows, Microsoft?

FreeBSD

. FreeBSD

1997

,

, Linux, a Hotmail ( Solaris, . ( 2000 Microsoft Hotmail Windows 2000, , FreeBSD ; Linux , RealPlayer StarOffice. .

FreeBSD ,

Linux.

FreeBSD

,

NetBSD, OpenBSD

.

2.2.2. Yahoo! Microsoft) , FreeBSD

-

.) . .

-

FreeBSD Mac OS X; FreeBSD

Linux, ,

Linux, ,

-

29

, Linux . FreeBSD,

, —

,

-

,

,

Microsoft.

Linux . FreeBSD .

-

GPL

,

BSD,

: OpenBSD

, , a NetBSD Intel x86,

(

PowerPC,

Sega Dreamcast). FreeBSD

; .

, Web-

,

Internet. FreeBSD ,

, ,

.

: ,

. , .

, ,

.

, ,

FreeBSD .

. , -

, ,

FreeBSD,



.

: : FreeBSD.

1.

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 — Linux • simpledemo.pl —

Perl, FreeBSD ( (

• sendcomments.cgi — • portsentry.sh — , • StarOffice 5.2 —

.

20); Perl,

-

21); CGIPostSentry (

FreeBSD. ,

.

Perl ( .

. 26); PortSentry 29); Sun Linux, , .

-

1

: FreeBSD

Fre BSD ► FreeBSD ► ►

1

FreeBSD

◀ ◀ ◀ ◀ ◀ ◀

FreeBSD FreeBSD? FreeBSD UNIX UNIX FreeBSD FreeBSD

1.

FreeBSD — x86 Alpha, PowerPC.

FreeBSD

UNIX.

33

Intel Spare FreeBSD, .

FreeBSD , .

,

FreeBSD, , FreeBSD — .

,

, FreeBSD ,

,

.

, FreeBSD .

. • ,

50

: Netcraft (www.netcraft.com),

47 WebFreeBSD.

FreeBSD. 1133 !

№1

, FreeBSD : Sony; Yahoo!; The Apache Project freesoftware.com — FTP. . , ,





,

-

. . •

. :

, Web-

,

FreeBSD

-

,

.

FreeBSD? FreeBSD

, . FreeBSD . FreeBSD

486

,

.

"

"

Warner Brothers

FreeBSD.

FreeBSD, ,

:

34

1.

: FreeBSD



. Samba (

.

32) -

, Windows. • Web-

, FreeBSD (Primary Domain Controller) , FreeBSD . , FreeBSD —

. WebInternet.



.



, DNS-

FreeBSD 486NAT. , DNS,

Windows. -

. ,

Internet

.



. SQL,

, .

,

FreeBSD

Oracle. . FreeBSD



,

-

. .

FreeBSD — ,

FreeBSD,

. WebHTML, , , Web-



.

-

: .

, .

WebWebCGI, . FreeBSD

,

, Web-

. • • ,

,

. FreeBSD Web. FreeBSD, . , ,

. -

. •

. FreeBSD

.

1.

FreeBSD

FreeBSD UNIX, UNIX, (

30 .

35

-

!)

-

FreeBSD UNIX UNIX (Ken Thompson) UNIX. UNIX



Bell Laboratories AT&T. (Dennis Ritchie) .

60-

AT&T Bell

Laboratories Multics. ,

. ,

,

. DEC PDP-7 .

1969 Research Center

Bell Labs

,

Computing Science .

UNIX. DEC PDP-7,

-

, UNIX DEC PDP-11.

: 1973 ,

UNIX

.

UNIX — . . ,

, , ,

, UNIX .

UNIX

.

BSD AT&T

( .

).

AT&T

UNIX

80%

. UNIX, Computer Systems Research Group. Bell Labs . (Bill Joy). UNIX. Berkeley Software Distribution, , , — vi shell).

, UNIX ,

, — ,

1975 -

BSD. (

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. ,

.

FreeBSD — FreeBSD

, Intel x86.

UNIXUNIX

. ,

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 ?

,

. , UNIX .

30

, —

,

. ,

UNIX KISS (Keep It Simple, Stupid).

UNIX

, .

UNIX

-

BSD.

, :

1.

FreeBSD 37

, ,

.

-

,

UNIX.

: • • • •

,

(Doug Mcllory) 8).

(pipe)

(piping). " UNIX (

Bell Labs.

"

.

,

,

. ,

Doe,

John~505

Doe,

Jane~121

Bar,

Foo~501

, (~).

Some Any Some

(

e-mail),

. . :

[email protected] [email protected] Street~Anytown~NY

50

500

[email protected]



. 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

Windows 2000

-

Linux.

FreeBSD

Microsoft

, . Windows 2000

,

-

, .

, Windows 2000

,

, , Windows 2000

.

. "

" ,

(

:

)

, "

. FreeBSD



"

Windows 2000? . — . FreeBSD

Windows 2000 ; ,

-

. .

Windows 2000

, . • Windows 2000 .

FreeBSD

. , . .





FreeBSD

-

, FreeBSD, , .

Windows 2000,

. ,

. FreeBSD

-

1.

FreeBSD

39

, . FreeBSD



FreeBSD . -

. ,

FreeBSD , Windows, Macintosh ,

, .

, -

Windows 2000

,

Windows.

,

WindowsWindows. •

-

, . . -

,

.

,

,

,

,

.

Linux

FreeBSD Linux

.

.

-

Linux —

UNIX.

FreeBSD,

,

.

Jnux

.

FreeBSD

, .

Linux

,

FreeBSD

,

"FreeBSD,

, Linux.

,

Linux. •

FreeBSD

Linux

• FreeBSD . Linux. , , , Linux FreeBSD

FreeBSD Linux: Linux 30. FreeBSD . Linux . . , Slackware Linux BSD. Debian Linux — Sys V, a Red Hat Sys V, , Sys V. , Linux . , ; Linux — , , Linux, , , , Linux, . Linux. , , . , , . ,

40

1.

: FreeBSD



Linux. FreeBSD

. ,

Linux.

, ,

. FreeBSD

,

Linux FreeBSD,

. , ,

,

Linux.

:

, ,

.

FreeBSD FreeBSD

.

.

-

UNIX, . , -

. : Microsoft

. WebWindows 2000

, . "

".

2

FreeBSD

► ► ► Sysinstall ► ►

o Sysinstall



► ► ► Sysinstall ► FreeBSD ► FreeBSD



ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

42

FreeBSD, .

:

,

,

-

.

,

CD20

,

.

-

,

. ,

. ,

,

,

,

.

, (

,

3).

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɍɛɟɞɢɬɟɫɶ ɜ ɬɨɦ, ɱɬɨ ɪɚɫɩɨɥɚɝɚɟɬɟ ɞɨɫɬɚɬɨɱɧɵɦ ɜɪɟɦɟɧɟɦ, ɱɬɨɛɵ ɫɩɨɤɨɣɧɨ ɢ ɧɟ ɬɨɪɨɩɹɫɶ ɜɵɩɨɥɧɢɬɶ ɜɫɟ ɧɟɨɛɯɨɞɢɦɵɟ ɨɩɟɪɚɰɢɢ.

ɋɈȼȿɌ ɋɟɣɱɚɫ ɫɚɦɨɟ ɜɪɟɦɹ ɩɪɨɫɦɨɬɪɟɬɶ ɩɪɢɥɨɠɟɧɢɟ Ȼ, ɝɞɟ ɞɚɧ ɫɩɢɫɨɤ ɨɛɨɪɭɞɨɜɚɧɢɹ, ɩɨɞɞɟɪɠɢɜɚɟɦɨɝɨ FreeBSD. He ɢɦɟɟɬ ɫɦɵɫɥɚ ɩɪɨɞɨɥɠɚɬɶ ɭɫɬɚɧɨɜɤɭ, ɟɫɥɢ ɨɛɧɚɪɭɠɢɬɫɹ, ɱɬɨ ɛɨɥɶɲɚɹ ɱɚɫɬɶ ɜɚɲɢɯ ɚɩɩɚɪɚɬɧɵɯ ɫɪɟɞɫɬɜ ɧɟ ɩɨɞɞɟɪɠɢɜɚɟɬɫɹ ɫɢɫɬɟɦɨɣ FreeBSD.

ɉɪɨɜɟɪɤɚ ɨɛɨɪɭɞɨɜɚɧɢɹ ,

,

,

.

,

: • •

,

. X-Window

;

. • •

, (serial, ps/2

,

IRQ bus) ,



.

. .

,

,

,

IRQ. •

: IP; IP-

DNS-

;

;

;

;

( . .

). -

, Microsoft Windows,

Control Panel.

ɋɨɡɞɚɧɢɟ ɡɚɝɪɭɡɨɱɧɵɯ ɞɢɫɤɟɬ CD-

FreeBSD, CD-

,

.

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

FreeBSD

43

-

(

,

),

(boot disks). floppies CD-

. FTPreleases/5.0-RELEASE/floppies. msfroot.flp. Windows, FreeBSD/tools.

CDftp.freebsd.org.

, /pub/FreeBSD/ kern.flp DOS /pub/

fdimage.exe,

ȼɨɡɦɨɠɧɨ, ɜɵ ɫɦɨɠɟɬɟ ɛɵɫɬɪɟɟ ɡɚɝɪɭɡɢɬɶ ɧɭɠɧɵɟ ɮɚɣɥɵ ɫ ɨɞɧɨɝɨ ɢɡ ɡɟɪɤɚɥɶɧɵɯ ɫɟɪɜɟɪɨɜ ftp.freebsd.org. ȼ ɛɨɥɶɲɢɧɫɬɜɟ ɫɥɭɱɚɟɜ, ɡɚ ftp ɫɪɚɡɭ ɠɟ ɫɥɟɞɭɟɬ ɱɢɫɥɨ (ɧɚɩɪɢɦɟɪ, ftp1.freebsd.org ɢɥɢ ftp2.freebsd.org). ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɡɟɪɤɚɥ ɦɨɠɟɬ ɡɧɚɱɢɬɟɥɶɧɨ ɭɫɤɨɪɢɬɶ ɫɤɚɱɢɜɚɧɢɟ ɮɚɣɥɨɜ.

1,44

.

ɉɊɂɆȿɑȺɇɂȿ

Ɏɚɣɥɵ, ɫɨɞɟɪɠɚɳɢɟ ɢɦɢɞɠɢ ɡɚɝɪɭɡɨɱɧɵɯ ɞɢɫɤɨɜ ɧɟɥɶɡɹ ɩɪɨɫɬɨ ɫɤɨɩɢɪɨɜɚɬɶ ɧɚ ɝɢɛɤɢɣ ɞɢɫɤ. Ɉɧɢ ɞɨɥɠɧɵ ɛɵɬɶ ɡɚɩɢɫɚɧɵ ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɫɩɟɰɢɚɥɶɧɵɯ ɦɟɬɨɞɨɜ, ɨɩɢɫɚɧɧɵɯ ɧɢɠɟ.

ɋɈȼȿɌ

ɉɨɥɶɡɭɣɬɟɫɶ ɧɨɜɵɦɢ ɞɢɫɤɚɦɢ ɞɥɹ ɫɨɡɞɚɧɢɹ ɡɚɝɪɭɡɨɱɧɵɯ ɞɢɫɤɟɬ, ɩɨɫɤɨɥɶɤɭ ɭɬɢɥɢɬɵ ɡɚɩɢɫɵɜɚɸɬ ɧɚ ɞɢɫɤɢ ɧɟɨɛɪɚɛɨɬɚɧɧɵɟ ɞɚɧɧɵɟ, ɧɟ ɩɪɢɧɢɦɚɹ ɜɨ ɜɧɢɦɚɧɢɟ ɢɯ ɮɨɪɦɚɬ. ȿɫɥɢ ɧɚ ɞɢɫɤɟ ɛɭɞɟɬ ɞɟɮɟɤɬɧɵɣ ɫɟɤɬɨɪ, ɩɪɢ ɭɫɬɚɧɨɜɤɟ ɫɢɫɬɟɦɵ ɷɬɨ ɦɨɠɟɬ ɜɵɡɜɚɬɶ ɩɪɚɤɬɢɱɟɫɤɢ ɧɟ ɪɟɲɚɟɦɵɟ ɩɪɨɛɥɟɦɵ.

ɋɨɡɞɚɧɢɟ ɡɚɝɪɭɡɨɱɧɵɯ ɞɢɫɤɟɬ ɜ DOS ɢɥɢ Windows Windows, DOS. DOS, DOS

CD-

,

Windows, , CD-



D:\TOOLS\FDIMAGE.EXE



D:\FLOPPIES\BOOT.FLP



D:\FLOPPIES\MFSROOT.FLP

,

D: —

.

:

CD-

DOS,

. . CD

CDfloppy-

.

CD-

.

DOS

CD-

( .

D:),

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

44

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

,

-

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

:

CD, fdimage.exe, boot.flp ,

msfroot.flp temp

DOS

-

,

:

:\>cd temp :\ > fdimage boot.flp a:

: :\

> fdimage msfroot.flp a:

ɋɨɡɞɚɧɢɟ ɡɚɝɪɭɡɨɱɧɵɯ ɞɢɫɤɨɜ ɧɚ ɞɪɭɝɨɣ FreeBSD-ɢɥɢ UNIX-ɫɢɫɬɟɦɟ FreeBSDboot.flp

(

fdimage.exe

UNIXmsfroot.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

45

FreeBSD/1386 bootstrap loader, Revision 0.8 ([email protected], 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 UserConfig, Kernel Configuration Menu

щ я

я

Enter. :

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 , ,

Sysinstall. 2.1.

Ɋɢɫɭɧɨɤ 2.1

Sysinstall.

FreeBSD -

46

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

ɇɚɜɢɝɚɰɢɹ ɩɨ Sysinstall ,

Sysinstall, .

,

2.1.

2.1 ɋɬɪɟɥɤɚ ɜɜɟɪɯ

ɉɟɪɟɯɨɞ ɤ ɩɪɟɞɵɞɭɳɟɣ ɨɩɰɢɢ ɦɟɧɸ.

ɋɬɪɟɥɤɚ ɜɧɢɡ

ɉɟɪɟɯɨɞ ɤ ɫɥɟɞɭɸɳɟɣ ɨɩɰɢɢ ɦɟɧɸ.

ɋɬɪɟɥɤɢ ɜɥɟɜɨ/ɜɩɪɚɜɨ

ɉɟɪɟɤɥɸɱɟɧɢɟ ɦɟɠɞɭ ɜɚɪɢɚɧɬɚɦɢ ɜɵɛɨɪɚ, ɜɧɢɡɭ ɷɤɪɚɧɚ. Ɍɚɤ, ɜ ɨɫɧɨɜɧɨɦ ɦɟɧɸ ɤɥɚɜɢɲɢ ɜɥɟɜɨ ɢ ɜɩɪɚɜɨ ɩɟɪɟɤɥɸɱɚɸɬ

ɨɩɰɢɢ

Select ɢ Exit Install. Ʉɥɚɜɢɲɚ ɩɪɨɛɟɥ

ȼ ɦɟɧɸ, ɝɞɟ ɜɨɡɦɨɠɟɧ ɜɵɛɨɪ ɦɧɨɝɨɱɢɫɥɟɧɧɵɯ ɨɩɰɢɣ, ɩɪɨɛɟɥ ɢɧɨɝɞɚ ɫɥɭɠɢɬ ɞɥɹ ɜɵɛɨɪɚ ɬɟɤɭɳɟɣ ɨɩɰɢɢ.

Ʉɥɚɜɢɲɚ ɬɚɛɭɥɹɰɢɢ

Ɋɚɛɨɬɚɟɬ ɬɚɤ ɠɟ, ɤɚɤ ɢ ɤɭɪɫɨɪɧɵɟ ɤɥɚɜɢɲɢ ɜɥɟɜɨ/ɜɩɪɚɜɨ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɞɥɹ ɩɟɪɟɯɨɞɚ ɦɟɠɞɭ ɩɨɥɹɦɢ, ɬɚɦ, ɝɞɟ ɧɟɨɛɯɨɞɢɦɨ ɜɜɨɞɢɬɶ ɢɧɮɨɪɦɚɰɢɸ.

, Sysinstall Standard DOS.

. -

. Enter , Enter

Usage. .

: •

, FreeBSD.



, ,

FreeBSD.

ɉɊȿȾɈɋɌȿɊȿɀȿɇɂȿ ɋɨɡɞɚɧɢɟ ɪɚɡɞɟɥɨɜ ɢ ɩɨɞɤɥɸɱɟɧɢɟ ɤɚɬɚɥɨɝɨɜ — ɷɬɨ ɨɞɧɚ ɢɡ ɬɟɯ ɨɛɥɚɫɬɟɣ, ɝɞɟ ɥɸɛɚɹ ɨɲɢɛɤɚ ɦɨɠɟɬ ɜɵɡɜɚɬɶ ɩɨɬɟɪɸ ɜɫɟɯ ɞɚɧɧɵɯ ɧɚ ɠɟɫɬɤɨɦ ɞɢɫɤɟ. ȿɫɥɢ ɧɚ ɠɟɫɬɤɨɦ ɞɢɫɤɟ ɯɪɚɧɢɬɫɹ ɰɟɧɧɚɹ ɢɧɮɨɪɦɚɰɢɹ, ɫɧɚɱɚɥɚ ɭɛɟɞɢɬɟɫɶ, ɱɬɨ ɫ ɧɟɟ ɫɞɟɥɚɧɚ ɪɟɡɟɪɜɧɚɹ ɤɨɩɢɹ. ȿɫɥɢ FreeBSD ɛɭɞɟɬ ɭɫɬɚɧɚɜɥɢɜɚɬɶɫɹ ɧɚ ɦɚɲɢɧɭ ɫ ɭɠɟ ɭɫɬɚɧɨɜɥɟɧɧɨɣ ɨɩɟɪɚɰɢɨɧɧɨɣ ɫɢɫɬɟɦɨɣ, ɩɪɟɞɜɚɪɢɬɟɥɶɧɨ ɩɪɨɱɬɢɬɟ ɝɥɚɜɭ 3.

ȼɵɛɨɪ ɠɟɫɬɤɢɯ ɞɢɫɤɨɜ , 2.2.

,

-

2.

FreeBSD

47

2.2 .

2.2

,

,

. 2.2

adO

-

.

IDEWindows

.

, DOS,

. a d1

-

.

, daO

,

, primary-

slave.

daO

SCSISCSI-

.

,

Windows

DOS,

da2

da3

. d a1

SCSI-

.

fd

ad2 , FreeBSD

ad3,



; ,

. . ,

.

,

,

FreeBSD.

-

, . , .

,

,

,

.

Enter

.

FreeBSD

, ,

, Boot-

.

, Boot-

. ,

. .

FreeBSD , Boot,

.

,

. FreeBSD, ɧɨɫɬɶ

-

ɭɫɬɚɧɨɜɢɬɶ

Boot-ɦɟɧɟɞɠɟɪ

, . ɧɚ

ɩɟɪɜɨɦ

ɞɢɫɤɟ.

ȿɫɥɢ

FreeBSD ɷɬɨɝɨ

ɧɟ

ɫɞɟɥɚɬɶ,

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

48

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 D = Delete Slice = Change Type

G = set Drive Geometry Z = Toggle Size Units

=Create Slice S = Set Bootable

U = Undo All Changes

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 FreeBSD,

165,

, Q

Flags.

. ɉɊɂɆȿɑȺɇɂȿ ȼ ɨɬɥɢɱɢɟ ɨɬ Linux, ɜ ɫɢɫɬɟɦɟ FreeBSD ɧɚ ɨɞɧɨɦ ɞɢɫɤɟ ɨɛɵɱɧɨ ɧɟ ɫɨɡɞɚɟɬɫɹ ɧɟɫɤɨɥɶɤɨ ɪɚɡɞɟɥɨɜ. ɑɬɨɛɵ ɫɨɡɞɚɬɶ ɨɬɞɟɥɶɧɵɟ ɪɚɡɞɟɥɵ ɞɥɹ ɪɚɡɧɵɯ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ, ɢɫɩɨɥɶɡɭɣɬɟ Disk Label Editor.

,

-

BSD

fdisk

.

Disk Label Editor. .

Enter —

FreeBSD

( ,

,

,

.

Disk Label Editor , FreeBSD.

),

:

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

50

FreeBSD Disklabel Editor Disk: adl Disk: adO

Partition name: ad1s1 Partition name: adOs1

Part

Mount

----

-----

The = N = =

Free: 30033360 blocks (14664MB) Free: 39882528 blocks (19473MB)

Size Newfs ----

-----

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

,

. ,

, /tmp

root (

).

-

Auto Defaults /var. , /var /tmp ,

,

-

. FreeBSD? :

root

.

swap.

-



root

. root

, .

FreeBSD —

. —

.

UNIX, .

,

, , ,

.

,

,

. , . . , — root. ,

,

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

51

.

root . , . DoS).

root, -

,

(

,

,

.

,

.

,

. , ; Web. Syslogd

, , (

,

,

log-

,

) , . (

,

,

,

,

), ,

tmp. ,

,

. —

. .

,

-

. , .

,

, . :

root (/),

— — /var ,

swap,

— /var.

/usr

(/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 root (/) Disk Label Editor

/boot, .

-

,

.

. (

.

. 2.3).

Ɋɢɫɭɧɨɤ 2.3

.

,

100

root. ,

100 .

,

Enter. FS A filesystem, root, Enter. (mount point) . Enter.

. ,

. Mount point — /, -

, :

FreeBSD Disklabel Editor

Disk: adl

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

Disk: adO Part -----

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

Mount

Size Newfs Part Mount

-----

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

/

100MB UFS Y

adOsla

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.

, ,

FreeBSD

adlsla ( );

-

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

54

/;

— 100

;

— swap.

(UFS).

FreeBSD

Ɋɚɡɞɟɥ swap FreeBSD —

: ,

-

. .

, ,

, swap — . .

swap

. •

.

swap ,



. swap

, . :

,

swap? ,

2-4

-

. .

. 256

, .

, 128-256

,

-

,

,

1:1. 512

,

,

256

,

,

-

. .

-

. , "

.

" (kernel panic).

,

. ,

, kernel ?

swap. , . ,

panic ,

: •

. , )

(

-

,

.



, ,

,

-

swap, . swan.

, ,

swap, -

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

55



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 M S A

(upper or lower case): = Mount pt. = Toggle SoftUpdates = Auto Defaults

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

FreeBSD, .

,

/home

Ɂɚɦɟɬɤɢ ɨ SoftUpdates Soft Updates 9, S

5.0 FreeBSD, Disk Label Editor. , Soft Updates

, Soft Updates . , .

-

56

1.

: FreeBCD

SoftUpdates , UFS+S). , Q

(

+S . -

W, ,

.

,

.

ȼɵɛɨɪ ɬɢɩɚ ɭɫɬɚɧɨɜɤɢ ,

( . X-Window

,

. 2.4) ,

,

Develloper. ,

cvsup. ,

,

-

All. ,

cvsup

. —

All.

2.4 .

ɉɊɂɆȿɑȺɇɂȿ cvsup — ɷɬɨ ɫɢɫɬɟɦɚ, ɩɨɡɜɨɥɹɸɳɚɹ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɩɨɞɞɟɪɠɢɜɚɬɶ ɨɩɟɪɚɰɢɨɧɧɭɸ ɫɢɫɬɟɦɭ FreeBSD ɜ ɚɤɬɭɚɥɶɧɨɦ ɫɨɫɬɨɹɧɢɢ ɢ ɜɧɨɫɢɬɶ ɢɡɦɟɧɟɧɢɹ, ɤɨɬɨɪɵɟ ɫɞɟɥɚɧɵ ɜ ɫɢɫɬɟɦɟ ɫ ɦɨɦɟɧɬɚ ɩɨɫɥɟɞɧɟɝɨ ɡɚɩɭɫɤɚ cvsup. Ʌɸɛɵɟ ɢɡɦɟɧɟɧɢɹ ɚɜɬɨɦɚɬɢɱɟɫɤɢ ɡɚɝɪɭɠɚɸɬɫɹ ɫ ɫɟɪɜɟɪɚ ɢ ɩɪɢɦɟɧɹɸɬɫɹ ɤ ɢɫɯɨɞɧɨɦɭ ɤɨɞɭ FreeBSD. ɗɬɨɬ ɩɪɨɰɟɫɫ ɜɵɩɨɥɧɹɟɬɫɹ ɛɵɫɬɪɨ, ɩɨɫɤɨɥɶɤɭ cvsup ɡɚɝɪɭɠɚɟɬ ɬɨɥɶɤɨ ɢɡɦɟɧɟɧɢɹ (ɫɦ. ɝɥɚɜɭ 18).

,

. ,

All, FreeBSD. . ,

, ,

"

,

,

". Enter.

.

Enter.

Exit

ȼɵɛɨɪ ɦɟɬɨɞɚ ɭɫɬɚɧɨɜɤɢ (

.

. 2.5).

57

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

2.5

,

CD(

.

,

,

-

; ),

3,.

. Enter.

CD-

,

CD-ROM :

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. ,

, Ethernet-

Enter.

,

-

, -

. ,

IPv6. IPv6).

,

No ( DHCP-

DHCP-

,

-

, .

FreeBSD .

,

No.

-

. 22 23. ( . . 2.7).

-

2.6 2.7 .

.

. 2.5

.

2.5 . ɉɨɥɟ

Ɉɩɢɫɚɧɢɟ Ɉɫɧɨɜɧɵɟ ɫɟɬɟɜɵɟ ɨɩɰɢɢ ɞɥɹ ɞɚɧɧɨɣ ɫɢɫɬɟɦɵ (ɜ

Host

Domain

, simba.samplenet.org).

(samplenet.org).

IPv4 Gateway

А

Name Server

IP-

Internet. DNS-

.

ɋɟɬɟɜɵɟ ɩɚɪɚɦɟɬɪɵ ɞɚɧɧɨɣ ɫɢɫɬɟɦɵ IPv4 Address

IP-

Netmask

М

Extra Options to ifconfig

ifconfig

59

2. У

FreeBSD

Enter

.

,

. ,

n , .

Sysinstall

: •

? , Internet, FTP-



. .,

Yes. (

,

FTP)? •

NFSNFS

Yes. .

FTP? NFS.

No.

, (

.

-

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 Linux?). Yes mini Linux filesystem /usr, , Linux. Yes. , , StarOffice Linux.

compatibility?" ( Sysinstall , , ,

ɉɊɂɆȿɑȺɇɂȿ ɉɪɨɝɪɚɦɦɵ Linux ɜ ɫɢɫɬɟɦɟ FreeBSD ɜɵɩɨɥɧɹɸɬɫɹ ɧɟ ɱɟɪɟɡ ɷɦɭɥɹɬɨɪ, ɚ ɩɨɞɞɟɪɠɢɜɚɸɬɫɹ ɧɚ ɭɪɨɜɧɟ ɹɞɪɚ. ɉɨɷɬɨɦɭ Linux-ɩɪɨɝɪɚɦɦɵ ɜɨ FreeBSD ɪɚɛɨɬɚɸɬ ɬɚɤɠɟ ɛɵɫɬɪɨ, ɤɚɤ ɢ ɜ Linux. Ɇɚɥɨ ɬɨɝɨ, ɧɟɤɨɬɨɪɵɟ ɩɪɢɥɨɠɟɧɢɹ ɪɚɛɨɬɚɸɬ ɜ ɫɢɫɬɟɦɟ FreeBSD ɞɚɠɟ ɛɵɫɬɪɟɟ, ɱɟɦ ɜ ɫɚɦɨɣ Linux!

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɦɵɲɢ FreeBSD "

,

" .

USB-

,

. (

, .

Yes,

. 2.9).

2.9 .

,

. . .

.

— )

- low (

).

high (

X-Widow , Flags

-3 -

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.

, .

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

62 ,

, . 2.12. ,

Enter.

-

, . 2.13.

.

Sysmouse . /dev/sysEnter. -

mouse , (

2.12 Э

"Apply"

.

) .

Enter, -

.

, ,

. .

, ,

, Emulate3Buttons. 2.13 Э

Keyboard

, (

"Generic 101-key PC". (Enhanced Windows keyboard), Window ,

.

.

. -

. 2.14). 104 .

,

.

X,

. , . Card

(

.

, .2.15).

, XF86Setup

-

63

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

-

, . -

,

. , , "Detailed Setup" (

.

34, "Monitor", .

-Window). , -

2.14

.

ȼɇɂɆȺɇɂȿ! C ɧɚɫɬɪɨɣɤɨɣ ɦɨɧɢɬɨɪɚ ɫɥɟɞɭɟɬ ɛɵɬɶ ɨɫɨɛɟɧɧɨ ɜɧɢɦɚɬɟɥɶɧɵɦ, ɩɨɫɤɨɥɶɤɭ ɧɟɩɪɚɜɢɥɶɧɚɹ ɭɫɬɚɧɨɜɤɚ ɟɝɨ ɬɟɯɧɢɱɟɫɤɢɯ ɯɚɪɚɤɬɟɪɢɫɬɢɤ ɦɨɠɟɬ ɩɨɜɥɟɱɶ ɡɚ ɫɨɛɨɣ ɩɨɪɱɭ ɨɛɨɪɭɞɨɜɚɧɢɹ. ɇɟ ɭɤɚɡɵɜɚɣɬɟ ɬɢɩ ɦɨɧɢɬɨɪɚ, ɱɚɫɬɨɬɚ ɝɨɪɢɡɨɧɬɚɥɶɧɨɣ ɪɚɡɜɟɪɬɤɢ ɤɨɬɨɪɨɝɨ ɜɵɯɨɞɢɬ ɡɚ ɩɪɟɞɟɥɵ ɜɨɡɦɨɠɧɨɫɬɟɣ ɜɚɲɟɝɨ ɦɨɧɢɬɨɪɚ. ȼ ɫɥɭɱɚɟ ɫɨɦɧɟɧɢɣ ɜɵɛɢɪɚɣɬɟ ɛɨɥɟɟ ɤɨɧɫɟɪɜɚɬɢɜɧɵɣ ɜɚɪɢɚɧɬ.

, . 2.16. 2.1

.

-

. . . X-Window 17. 151421-

1024x768. ,

.

15-

800x600.

-Window 800x600,

, — 640x480. 1024x768.

,

19-

. X-Window (

). ,

:

64

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

• 8256

-

.

, . • 1664 • 2416,7

.

.

. .

-

. • 3216,7

2.16 .

,

.

,

3,

24-

. "done" -

.

.

"X". ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ȿɫɥɢ ɷɤɪɚɧ ɜɟɪɧɭɥɫɹ ɤ ɫɜɨɟɦɭ ɨɛɵɱɧɨɦɭ ɫɨɫɬɨɹɧɢɸ, ɧɨ ɢɦɟɟɬ ɤɚɤɨɣ-ɬɨ ɢɫɤɚɠɟɧɧɵɣ ɢ ɫɬɪɚɧɧɵɣ ɜɢɞ, ɢ/ɢɥɢ ɜɵ ɭɫɥɵɲɚɥɢ ɜɵɫɨɤɢɣ ɜɨɸɳɢɣ ɡɜɭɤ, ɢɫɯɨɞɹɳɢɣ ɨɬ ɦɨɧɢɬɨɪɚ, ɇȿɆȿȾɅȿɇɇɈ ɜɵɤɥɸɱɢɬɟ ɦɨɧɢɬɨɪ ɢɥɢ ɨɞɧɨɜɪɟɦɟɧɧɨ ɧɚɠɦɢɬɟ ɤɨɦɛɢɧɚɰɢɸ ɤɥɚɜɢɲ CTRL-ALT-BACKSPACE ɞɥɹ ɭɧɢɱɬɨɠɟɧɢɹ ɏ-ɫɟɪɜɟɪɚ. Ɉɛɚ ɫɢɝɧɚɥɚ ɭɤɚɡɵɜɚɸɬ ɧɚ ɬɨ, ɱɬɨ ɱɚɫɬɨɬɵ ɨɛɧɨɜɥɟɧɢɹ ɦɨɧɢɬɨɪɚ ɛɵɥɢ ɡɚɜɵɲɟɧɵ, ɢ ɫɬɪɨɱɧɵɣ ɬɪɚɧɫɮɨɪɦɚɬɨɪ ɝɨɬɨɜ ɜɡɥɟɬɟɬɶ ɧɚ ɜɨɡɞɭɯ.

,

( ,

),

,

,

, , CTRL-ALT-BACKS

.

X-

. got a running X server!" ,

"Congratulations. You've .

xvidtune

xvidtune xvidtune

"

" ,

/ :

.

,

-

65

Ƚɥɚɜɚ 2. ɍɫɬɚɧɨɜɤɚ FreeBSD

Ɋɢɫɭɧɨɤ 2.17 xvidtune.

: Ɍɚɛɥɢɰɚ 2.6 Ʉɥɚɜɢɲɢ ɭɩɪɚɜɥɟɧɢɹ xvidtune. Left, Right, Up ɢ Down

ɉɟɪɟɦɟɳɟɧɢɟ ɢɡɨɛɪɚɠɟɧɢɹ ɧɚ ɷɤɪɚɧɟ ɜ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɯ ɧɚɩɪɚɜɥɟɧɢɹɯ.

Wider (ɲɢɪɟ), Narrower ɋɨɨɬɜɟɬɫɬɜɭɸɳɟɟ ɢɡɦɟɧɟɧɢɟ ɢɡɨɛɪɚɠɟɧɢɹ ɧɚ ɷɤɪɚɧɟ, (ɭɠɟ), Shorter (ɤɨɪɨɱɟ), Taller (ɜɵɲɟ) ȼɵɯɨɞ ɢɡ xvidtune.

Quit Apply

ɉɪɢɦɟɧɟɧɢɟ ɢɡɦɟɧɟɧɢɣ ɤ ɬɟɤɭɳɟɦɭ ɜɢɞɟɨɪɟɠɢɦɭ.

Auto

ȼ ɚɤɬɢɜɧɨɦ ɫɨɫɬɨɹɧɢɢ ɢɡɦɟɧɟɧɢɹ ɜɧɨɫɹɬɫɹ ɧɟɡɚɦɟɞɥɢɬɟɥɶɧɨ, ɛɟɡ ɧɚɠɚɬɢɹ ɤɥɚɜɢɲɢ "Apply". ɗɬɨ ɩɨɡɜɨɥɹɟɬ ɜɢɞɟɬɶ ɪɟɡɭɥɶɬɚɬɵ ɩɪɟɞɩɪɢɧɢɦɚɟɦɵɯ ɞɟɣɫɬɜɢɣ ɜ ɪɟɚɥɶɧɨɦ ɜɪɟɦɟɧɢ.

Test

ɉɪɨɜɟɪɤɚ ɞɢɫɩɥɟɹ ɫ ɭɱɟɬɨɦ ɜɧɟɫɟɧɧɵɯ ɢɡɦɟɧɟɧɢɣ. ɇɚɱɚɥɶɧɵɣ ɷɤɪɚɧ ɛɭɞɟɬ ɜɨɫɫɬɚɧɨɜɥɟɧ ɱɟɪɟɡ ɧɟɫɤɨɥɶɤɨ ɫɟɤɭɧɞ. ɉɪɢ ɩɚɪɚɥɥɟɥɶɧɨɣ ɚɤɬɢɜɢɡɚɰɢɢ Auto ɧɟ ɞɟɣɫɬɜɭɟɬ.

Restore

ȼɨɫɫɬɚɧɚɜɥɢɜɚɟɬ ɩɟɪɜɨɧɚɱɚɥɶɧɵɟ ɩɚɪɚɦɟɬɪɵ.

Fetch

ɋɨɯɪɚɧɹɟɬ ɬɟɤɭɳɢɟ ɩɚɪɚɦɟɬɪɵ ɏ-ɫɟɪɜɟɪɚ. ȼɨɫɩɨɥɶɡɭɣɬɟɫɶ ɮɭɧɤɰɢɟɣ Restore ɞɥɹ ɜɨɫɫɬɚɧɨɜɥɟɧɢɹ ɩɚɪɚɦɟɬɪɨɜ, ɚɤɬɢɜɧɵɯ ɧɚ ɦɨɦɟɧɬ ɜɵɛɨɪɚ Fetch.

Show

Ɉɬɨɛɪɚɠɚɟɬ ɬɟɤɭɳɢɣ ɦɨɞɟɥɢ ɢɡ ɮɚɣɥɚ XF86Config ɜ ɫɬɚɧɞɚɪɬɧɵɣ ɜɵɜɨɞ ɞɚɧɧɵɯ (ɛɨɥɟɟ ɞɟɬɚɥɶɧɚɹ ɢɧɮɨɪɦɚɰɢɹ — ɜ ɝɥɚɜɟ 34).

Next, Prev

Ɏɭɧɤɰɢɹ ɩɟɪɟɤɥɸɱɟɧɢɹ ɧɚ ɫɥɟɞɭɸɳɢɣ ɢɥɢ ɩɪɟɞɵɞɭɳɢɣ ɜɢɞɟɨɪɟɠɢɦ, ɫɨɨɬɜɟɬɫɬɜɟɧɧɨ (ɩɪɢ ɭɫɥɨɜɢɢ, ɱɬɨ ɜɵɛɪɚɧɨ ɧɟɫɤɨɥɶɤɨ ɪɚɡɪɟɲɟɧɢɣ).

,

-

xvidtune ,

. ,

Apply xvidtune.

Quit xvistune

Yes

XF86Setup Save Configuration and Exit. 'X' .

-

66

ɑɚɫɬɶ 1. Ɂɧɚɤɨɦɶɬɟɫɶ: FreeBSD

ȼɵɛɨɪ ɪɚɛɨɱɟɝɨ ɫɬɨɥɚ ɩɨ ɭɦɨɥɱɚɧɢɸ ,

Sysinstall. ,

. , Enter. X-Window Microsoft Windows, ' Linux, X-Window, -

, . FreeBSD ,

. .

, . 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 — SDGnome. 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). Enter. Sysinstall

.

Install, .

-

Ⱦɨɛɚɜɥɟɧɢɟ ɩɨɥɶɡɨɜɚɬɟɥɹ .

.

Yes

-

,

,

root

root .

-

.

,

, . , User .

(

.

, . 2.20).

. 2.19,

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. ,

, Exit.

. 2.20.

ɍɫɬɚɧɨɜɤɚ ɩɚɪɨɥɹ 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) , root.

. Amnesiac.

, »

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 shutdown -h now. FreeBSD

. /sbin/ "System halted". -

. , FreeBSD.

, , (clean). .

-

3

► FIPS ►

FreeBSD

FIPS ►

► Boot-

FreeBSD ► FreeBSD

LILO ► ►

72

1.

: FreeBSD

FreeBSD

,

,

.

,

FreeBSD Windows.

, , .

FreeBSD Linux.

,

, (FTP).

(NFS)

-

,

, FreeBSD

. , :

,

,

,

.

. .

,

.



,

,

,

,

.

,

, -

,

Zip

-

Jaz, .(



, . —

.

.)

, .



,

,

(

,

). . ,

-

FreeBSD. : •

.

-

. •

, Partition Magic.



. Partition Magic. FIPS.

, ,

FreeBSD. .

,

Partition Magic,

FIPS

.

,

-

73

3.

FreeBSD FIPS —

, DOS

DOS. ,

.

FreeBSD. , DOS (FAT16 FAT32). FIPS - NTFS (Windows NT/ 2000), EXT2FS

FIPS , (Linux)

FIPS

HPFS (OS/2). FIPS

,

: • FIPS

DOS — Windows 95 OSR2 Windows 98, ,

,

.

. •

. FIPS

,

, -

.

Scandisk FIPS

Scandisk DOS

,

Windows

.

. FIPS . -

,

.

,

"

"

. .

FIPS FIPS

CDTOOLS RESTORRB.EXE ERRORS.TXT. FTPFreeBSD ftp.freebsd.org /pub/FreeBSD/tools/fips.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

FIPS.EXE. FIPS .

FIPS restorrb.exe

74

1.

Volume label

: FreeBSD (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

0

0|

00h|

0

0

0|

0|

0|

0

Checking root sector . . . OK Press any Key

, , 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

,

. Press any Key. FIPS , :

75

3.

Media descriptor byte: f8h Sectors per FAT: 200 Sectors per track: 32 Drive heads: 13 Hidden sectors: 32 Numb r 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 -t

tips

.

,

fips -t .

,

Scandisk

.

, . .

, ,

76

1.

: FreeBSD

,

FreeBSD 1024

,

. 1024

root

,

. .

root DOS

Windows

,

, DOS

D. FreeBSD.

1024 —

Windows

D , 30

,

/boot.

. DOS

Windows

FreeBSD. Windows (

DOS) ,

,

-

(master boot record). DOS Windows .

FreeBSD, FreeBSD,

FreeBSD DOS, Windows 95/98/ FreeBSD ,

DOS, Windows 95, Windows 98 FreeBSD

(boot manager), . .

Windows Me , .

FreeBSD FreeBSD FreeBSD,

Linux, LILO — Linux Boot-

MBR.

Boot-

Linux, a FreeBSD.

FreeBSD boot-

FreeBSD

. bootOcfg. .

bootOcfg . bootOcfg boot, . 3.1)

Linux

, MBR.

FreeBSD boot-

. ,

.

( boot-

:

.

77

3.

3.1 -v

boot.

Boot0cfg

-b image

image — /boot/bootO.

-d drive

drive

. ,

BIOS

0x80 -f file

— .

0x81

file —

. .

, .

MBR ,

.

,

.

:

3.2

boot-

packet

BIOS

, int 0x13 1024 , ,

bootOcfg CHS

. .

,

BIOS

. noupdate

Boot-

MBR , MBR. noupdate

. , boot-

MBR.

bootOcfg

n—

-s,

1

.

-t n;

5, n

ticks

( 18,2 ticks).

FreeBSD

LILO

Linux

FreeBSD, /etc/ lilo.conf Linux

.

Linux LILO,

: other=/dev/hda2 table=/dev/hda label=FreeBSD

,

,

-

. LILO .

root

.

,

-

lilo.

,

FreeBSD FTP-

NFS-

, .

78

1.

: FreeBSD

FreeBSD

FTP FreeBSD

FTP-

.

, Internet. ,

,

.

, anonymous. FreeBSD .

FTPFTP-

(

,

FreeBSD FTP-

FreeBSD, FTP-

.

, ), .

sysinstall ( ,

.

.3.1) . 3.2.

Options

Enter,

3.1

sysinstall FreeBSD.

3.2 Options.

FTP Username

.

,

FTP. ,

sysinstall.

Q

,

,

Enter. Enter.

79

3.

FTP 2, (Choose Installation Media). (

.

. 3.3). .

(

.

FTP3.4 samplenet.org,

FTPFreeBSD

3.3 FTP-

,

FreeBSD.

3.4 FTP-

.

3.5 .

lion, /FreeBSD. ( . . 3.5).

FreeBSD, . 3.4) FreeBSD.

80

1.

: FreeBSD

2. , 2.

,

,

2. ,

.

NFS NFS , NFS-

(Network File System). ,

FreeBSD.

NFS NFS. NFSFreeBSD. -install/FreeBSD.

, 3.6

lion,

3.6

NFS.

( 2. , 2.

. 3.5). -

2

FreeBSD

FreeBSD ► Gnome ► Gnome ► ► ►

4

FreeBSD



FreeBSD

◀ BIOS ◀

◀ ◀ ◀

init FreeBSD



X-Window



Gnome

◀ ◀ ◀

X-Winclow FreeBSD FreeBSD

83

4.

FreeBSD

FreeBSD ,

X-Window. Gnome.

FreeBSD FreeBSD, ,

. FreeBSD.

BIOS 86

FreeBSD, Alpha

Intel.

FreeBSD

,

.

BIOS (Basic Input/Output Services —

/

)

, .

,

BIOS

.

POST , POST (Power On Self Test —

).

BIOS

, n ,

,

.

BIOS

,

.



BIOS.

, ,

CD-

.

. .

,

, BIOS —

. bootO.

,

bootO BIOS

0 .

Record,

MBR).

,

0 ,

MBR,

512

, ,

. bootO:

(Master Boot .

84

2.

FreeBSD

Fl

DOS

F2 F3

FreeBSD Drive 1

Default: F2

, ( ,

,

).

bootO .

FreeBSD, . bootl.

,

bootl bootl bootO, boot2.

. 512

.



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 [email protected]:/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 AMD Features=Ox80000800

. psmO: irq 12 on atkbdcO psmO: model Generic PS/2 mouse, device ID 0 fdcO: at port Ox3f0-0x3f5,0x3f7 ↪ 2 on isaO fdcO: FIFO enabled, 8 bytes threshold fdO: on fdcO drive 0

irq

PS/2. .

— fdcO,

on

— fdO.

, unknown: unknown: unknown: unknown: unknown: unknown:

388- ~

38

sbcO

SoundBlaster AWE 64 ,

.

drq

psmO.

sbcO: -«Creative SB AWE64> at port Ox220-0x22f, 0x330-0x331, irq 5 drq 1,5 on isaO pcm1:

6

sbcO — .





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

assign assign assign assign assign assign

FreeBSD. Plug and Play,

resources resources resources resources resources resources

, ,

.

.

adO: 19473MB [39566/16/63] at ataO-master UDMA33 adl: 14664MB [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 ( clean

FreeBSD

).

,

. , clean. .

init, — init init ,

, ,

,

fsck;

. Windows was not properly shut down ( fsck

,

, Scandisk Your system ) Windows.

fsck

,

, ,

. ,

clean

. /etc/fstab

init ,

mount at boot. .

fsck 9.

fsck

,

,

init (run control scripts, rc , init , ( ,

, /etc

scripts), /user/local/etc/rc.d init Web-

/etc/defaults.

, .). config.sys, autoexec.bat, system.ini

,

Windows. ,

init

;

, ,

FreeBSD /usr/local/ etc/re.d,

/etc/re.local Web-

. . /etc/re.local.

87

4.

FreeBSD

BSD .

. .

SYS V,

BSD SYS V, — rc.conf

BYS V

SYS V UNIX, init , .

BSD —

,

. BSD

.

getty

,

inittab, ,

,

Login ( getty.

init ). , getty, — xdm, X-Window. . ,

,

/etc/ttys

, getty. ,

getty . getty

/etc/ttys.

,

— 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

8

15:17:26

1994 All CDT

rights 2001

bash$

, ,

,

-

88

2.

FreeBSD

(Last Login). .

, , ,

. , Sat Sept 15 14:05:29, -

— ,

,

.

( .[

, root —

passwd) ?)



(

).



1

FreeBSD

.

. ,

,

root. — #.

root ,

, ], root,

%

$ ( ).

> ( (#] .

, : Login incorrect login:

. , .

.



, ,

,

. . .

login:

X-Window X-Window, X-Window.

startx,

Gnome ,

( ,

,

.

Gnome, 2), . 4.1.

89

4.

FreeBSD

4.1

,

Gnome.

Windows

Macintosh?

.

,

1.

, Start — Programs Windows. URL-

2.

. 4.1: Gnome. Web-

-

,

FTP,

-

. . 3. 4. 5.

Gnome. .

. -

. 6.

, .

-

, .

7.

.

Gnome-PIM, ,

, .

90

2.

FreeBSD

8.

Web-

9.

.

.

10.

.

11.

.

12.

.

13.

Gnome —

14.

Start (

)

Windows.

Gnome.

15.

,

.

16. 17.

Gnome. Gnome. 18. Gnome.

19.

Web-

.

Netscape Navigator.

. 20.

. Gnome , ,

. 6.

Gnome "

34,

,

" . Gnome -

, .

ToolTips ,

.

"

",

.

X-Window Gnome •

:

Gnome

, (



-

!).

Desktop



Log Out.

Gnome Log Out.

Gnome (

) :

.

,

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

- , (

)

.

.

.

now . (

shutdown , +n,

92

2.

FreeBSD

).

yymmddhhmm, . — , mm — mm — . . , shutdown, " ,

) ,

, dd —

, hh —

( 24,

, , .

", .

10 . ,

10-

. # shutdown -h +10 Hard disk needs to be replaced

.

shutdown .

10

, :

*** System shutdown message from [email protected] *** 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.

, •

: TERM,

init .



init

/etc/re.shutdown ,



TERM .

, •

. ,

,

-

, TERM,

KILL,

.

, sync



.

, •

clean. .

,

,

shutdown .

,

-

93

4.

FreeBSD

root (

root,

su). , , , shutdown

Enter.

su root.

,

: -h

now

, System halted Please press any

key

to

:

reboot

.

halt

reboot : halt

.

reboot,

. rc.shutdown, .

,

. shutdown. DOS / Ctrl+Alt+Delete. ,

,

Windows, FreeBSD ,

, FreeBSD -

, .

, reboot. .

11 Ctrl+Alt+Delete

,

5

Gnome



◀ Gnome ◀ ◀

Gnome

◀ ◀ ◀ ◀

Gnome

95

5.

Gnome

(Window Managers) X-Window

-

. . X-

"

"; .

, ,

-Window.

Gnome . 5.1

X,

Gnome.

-

. , . , Gnome.

,

Gnome .

Gnome

Sawfish. Gnome (

Enlightenment).

,

,

,

IceWM

,

6. ,

X-Window. Linux)

UNIX Gnome

( D .

,

Sun Microsystems, Hewlett-Packard D ,

5.1

-

Gnome.

, FreeBSD Gnome UNIX,

IBM. 7.

96

Ч

2.

FreeBSD

,

,

;

, .

-

.

ȿɫɥɢ ɩɢɤɬɨɝɪɚɦɦɵ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɨɬɫɭɬɫɬɜɭɸɬ ɢ ɳɟɥɱɨɤ ɩɪɚɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɧɟ ɩɪɢɜɨɞɢɬ ɤ ɤɚɤɨɦɭ-ɥɢɛɨ ɜɢɞɢɦɨɦɭ ɷɮɮɟɤɬɭ, ɬɨ, ɜɟɪɨɹɬɧɨ, ɜɨ ɜɪɟɦɹ ɢɧɫɬɚɥɥɹɰɢɢ ɜɵ ɧɟ ɭɫɬɚɧɨɜɢɥɢ gnomemc

Gnome Gnome

,

,



,

. :

,

Gnome -

. ( ,

Gnome) Windows. Gnome) ,

Start ( . .

, .

,

.

,

, ,

5.2

Gnome.

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,

workspace. . • , (

) ). .

, , , Move workspace right (

Insert -

Move workspace left -

99

Ƚɥɚɜɚ 5. Ɋɚɛɨɬɚ ɜ ɫɪɟɞɟ Gnome

, Merge with next ( ).

Workspaces, 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 ( [

) ,

.

Move to trash Delete .

Windows.

Manager

, File Manager

. "

"

.

-

)

Delete

, ,

,

File m ,

6

Gnome

► Gnome ► ► Gnome File Manager ► Gnome Control Center ► Sawfish ►

102

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

Ⱦɨɛɚɜɥɟɧɢɟ ɧɨɜɵɯ ɩɢɤɬɨɝɪɚɦɦ ɧɚ ɪɚɛɨɱɢɣ ɫɬɨɥ . , Gnome File Manager. , . , .

Link

. , New. .

-

6.1. Ɍɚɛɥɢɰɚ 6.1 Ʉɨɦɚɧɞɵ ɫɨɡɞɚɧɢɹ ɧɨɜɵɯ ɷɥɟɦɟɧɬɨɜ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ Ɉɬɤɪɵɜɚɟɬ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɧɨɜɨɟ ɨɤɧɨ ɫ ɤɨɦɚɧɞɧɨɣ ɫɬɪɨɤɨɣ. Directory

Terminal

ɋɨɡɞɚɟɬ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɧɨɜɵɣ ɤɚɬɚɥɨɝ. ɋɨɡɞɚɟɬ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɹɪɥɵɤ ɞɥɹ Web-ɫɚɣɬɚ. ɉɪɢ ɞɜɨɣɧɨɦ ɳɟɥɱɤɟ ɧɚ ɷɬɨɦ ɹɪɥɵɤɟ ɩɪɨɢɫɯɨɞɢɬ ɡɚɩɭɫɤ ɛɪɚɭɡɟɪɚ Netscape ɢ ɡɚɝɪɭɡɤɚ ɭɤɚɡɚɧɧɨɣ Web-ɫɬɪɚɧɢɱɤɢ.

URL link

ɋɨɡɞɚɟɬ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɢɤɨɧɤɭ ɞɥɹ ɡɚɩɭɫɤɚ ɩɪɨɝɪɚɦɦɵ.

Launcher

ɋɨɡɞɚɧɢɟ ɧɚ ɪɚɛɨɱɟɦ ɫɬɨɥɟ ɩɢɤɬɨɝɪɚɦɦ ɞɥɹ ɡɚɩɭɫɤɚ ɩɪɨɝɪɚɦɦ . Gnome File Manager

-

,

, .

, -

, — New,

Link. ,

— -

Launcher. .

,

.

,

.

,

, —

. FreeBSD . . 6.1

,

-

. ,

, ).

xcalc (

(

),

. 1. Name —

, .

.

Ƚɥɚɜɚ 6. ɇɚɫɬɪɨɣɤɚ ɫɪɟɞɵ Gnome

1 03

Ɋɢɫɭɧɨɤ 6.1 .

3 4

Comment — Command —

,

.

,

. — xcalc.

5



,

,

. Run in Terminal —

6

Application. ,

.

,

.

. ,

No Icon. Gnome /usr/XHR6/share/gnome/pixmaps.

7

xcalc -

Advanced — (

, ,

).

ɇɚɫɬɪɨɣɤɚ ɩɚɧɟɥɢ Gnome Gnome, , Properties, Panel

Panel Properties.

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 Gnome

Edit Menus.

. 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.



, .

, ,

, ),

unexpectedly" ( . .

Reload, ,

,

"The applet appears to have died ,

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. Manager.

Gnome File

(~). 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)

-

, .

Ɋɚɛɨɬɚ ɫ Gnome Control Center Gnome Control Center ( Windows Control Panel (

). Gnome.

Gnome Control Center,

, .

ɂɡɦɟɧɟɧɢɟ ɮɨɧɚ ɪɚɛɨɱɟɝɨ ɫɬɨɥɚ , Gnome Control Center

. (

.

. Background

. 6.5). ,

. Gnome ,

6.5 .

BMP, JPEG, GIF, PNG

.

Ƚɥɚɜɚ 6. ɇɚɫɬɪɨɣɤɚ ɫɪɟɞɵ Gnome

Gnome Theme Selector,

( . ,

6.6).

1 09

, 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 .

FreeBSD,

Microsoft Word ,

-

110

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

Word.

,

AbiWord

,

.

6.7. .

ɉɪɨɝɪɚɦɦɚ Abiword ɢɦɟɟɬɫɹ ɜ ɤɨɥɥɟɤɰɢɢ ɩɨɪɬɨɜ ɨɩɟɪɚɰɢɨɧɧɨɣ ɫɢɫɬɟɦɵ FreeBSD ɜ ɤɚɬɚɥɨɝɟ "editors". Ȼɨɥɟɟ ɩɨɞɪɨɛɧɚɹ ɢɧɮɨɪɦɚɰɢɹ ɢɦɟɟɬɫɹ ɜ ɝɥɚɜɟ 15.

Word, : , mime, (

.

(AbiWord). . 6.8), , Microsoft Word.

ɉɊɂɆȿɑȺɇɂȿ

? , , . Gnome File Manager Word mime Gnome

Mime — ɷɬɨ ɫɨɤɪɚɳɟɧɢɟ ɨɬ multipurpose Internet mail extensions (ɦɧɨɝɨɰɟɥɟɜɵɟ ɩɨɱɬɨɜɵɟ ɪɚɫɲɢɪɟɧɢɹ ɫɟɬɢ Internet). ɋɬɚɧɞɚɪɬ mime ɩɟɪɜɨɧɚɱɚɥɶɧɨ ɛɵɥ ɪɚɡɪɚɛɨɬɚɧ ɞɥɹ ɩɟɪɟɞɚɱɢ ɩɨ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɟ ɮɚɣɥɨɜ, ɚ ɧɟ ɩɪɨɫɬɨ ɬɟɤɫɬɚ. ɉɨɡɞɧɟɟ ɨɧ ɛɵɥ ɪɚɫɩɪɨɫɬɪɚɧɟɧ ɢ ɧɚ WWW. Ʉɨɝɞɚ ɜɵ ɩɨɫɟɳɚɟɬɟ Web-ɫɬɪɚɧɢɰɭ, ɫɟɪɜɟɪ ɫɧɚɱɚɥɚ ɩɨɫɵɥɚɟɬ ɜɚɦ ɡɚɝɨɥɨɜɨɤ, ɢɧɮɨɪɦɢɪɭɸɳɢɣ ɛɪɚɭɡɟɪ ɨ ɬɨɦ, ɤɚɤɨɝɨ ɬɢɩɚ ɞɨɤɭɦɟɧɬ ɨɧ ɫɨɛɢɪɚɟɬɫɹ ɜɚɦ ɨɬɩɪɚɜɥɹɬɶ. ɂɧɮɨɪɦɚɰɢɹ ɜ ɷɬɨɦ ɡɚɝɨɥɨɜɤɟ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɬɢɩ mime. ɋ ɟɝɨ ɩɨɦɨɳɶɸ ɛɪɚɭɡɟɪ ɨɩɪɟɞɟɥɹɟɬ, ɤɚɤ ɨɛɪɚɛɨɬɚɬɶ ɞɨɤɭɦɟɧɬ, ɤɨɬɨɪɵɣ ɨɧ ɫɟɣɱɚɫ ɩɨɥɭɱɢɬ [ɨɬɨɛɪɚɡɢɬɶ ɜ ɨɤɧɟ ɛɪɚɭɡɟɪɚ, ɨɬɤɪɵɬɶ ɜɧɟɲɧɟɟ ɩɪɢɥɨɠɟɧɢɟ ɞɥɹ ɨɛɪɚɛɨɬɤɢ ɞɨɤɭɦɟɧɬɚ ɢɥɢ ɫɝɪɭɡɢɬɶ ɞɨɤɭɦɟɧɬ ɧɚ ɞɢɫɤ). Ɇɧɨɝɢɟ ɬɢɩɵ ɮɚɣɥɨɜ ɢɦɟɸɬ ɫɬɚɧɞɚɪɬɧɵɟ ɧɚɡɜɚɧɢɹ ɬɢɩɨɜ mime, ɤɨɬɨɪɵɟ ɯɪɚɧɹɬɫɹ ɜ ɫɚɦɢɯ ɮɚɣɥɚɯ ɢ ɢɡɜɟɫɬɧɵ ɛɪɚɭɡɟɪɚɦ ɢ ɩɨɱɬɨɜɵɦ ɤɥɢɟɧɬɚɦ. ɉɨɞɪɨɛɧɚɹ ɢɧɮɨɪɦɚɰɢɹ ɨ ɬɢɩɚɯ mime ɢɦɟɟɬɫɹ ɜ ɞɨɤɭɦɟɧɬɚɯ RFC 2045 ɢ 2046.

-

Ƚɥɚɜɚ 6. ɇɚɫɬɪɨɣɤɚ ɫɪɟɞɵ Gnome

111

6.8 mime .

Gnome .

, Internet mime, , assignments/media-types/media-types. , Microsoft Word application/msword. "Add" Regular Expression , , mime. mime . Edit. . 6.10 Edit.

6.9 Microsoft Word.

mime

mime, , http://www.isi.edu/in-notes/iana/ , mime mime, ( . . 6.9). . ,

mime

6.10 mime



Word.

112

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

Open, View

Edit

abiword %f.

%f

, .

. Ч

Ⱥɪɝɭɦɟɧɬ — ɷɬɨ ɩɚɪɚɦɟɬɪ, ɤɨɬɨɪɵɣ ɩɟɪɟɞɚɟɬɫɹ ɜ ɩɪɨɝɪɚɦɦɭ ɢ ɢɧɮɨɪɦɢɪɭɟɬ ɟɟ ɨ ɬɨɦ, ɫ ɤɚɤɢɦɢ ɞɚɧɧɵɦɢ ɨɧɚ ɞɨɥɠɧɚ ɪɚɛɨɬɚɬɶ. ɇɚɩɪɢɦɟɪ, ɜ ɞɚɧɧɨɦ ɫɥɭɱɚɟ ɩɚɪɚɦɟɬɪ %f ɫɨɞɟɪɠɢɬ ɢɦɹ ɮɚɣɥɚ, ɜɵɛɪɚɧɧɨɝɨ ɜ ɨɤɧɟ ɦɟɧɟɞɠɟɪɚ ɮɚɣɥɨɜ. ɗɬɨ ɢɦɹ ɜ ɤɚɱɟɫɬɜɟ ɚɪɝɭɦɟɧɬɚ ɩɟɪɟɞɚɟɬɫɹ ɜ ɩɪɨɝɪɚɦɦɭ abiword, ɩɨɷɬɨɦɭ ɨɧɚ ɜɵɡɵɜɚɟɬɫɹ ɤɨɦɚɧɞɨɣ abiword filename ɢ ɨɬɤɪɵɜɚɟɬ ɮɚɣɥ ɫ ɢɦɟɧɟɦ filename ɞɥɹ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ.

. abiword

, Select application .

Word

-

ɇɚɫɬɪɨɣɤɚ ɩɚɪɚɦɟɬɪɨɜ ɦɟɧɟɞɠɟɪɚ ɨɤɨɧ Sawfish Gnome Control Center. Configurator. ,

Sawfish 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.

7

► ► StarOffice ► ► ►

114

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

FreeBSD

,

,

Linux. .

,

,

.

Ɋɚɛɨɬɚ ɫ ɬɟɤɫɬɨɦ , ,

.

, . ,

, . : •

. ,

. , , .(

11.) .

• .



13

21 FreeBSD; . HTML. Web.

. Web-

Web,

, Web-

. (what you see is what you get — . • .

,

WYSIWYG ,

) ,

-

LayTeX,

. ,

X-Window, Windows Macintosh. .

, FreeBSD,

Ɍɟɤɫɬɨɜɵɣ ɪɟɞɚɤɬɨɪ gedit gedit — Gnome.

,

, Notepad

, gedit

Windows

, ,

gedit editors.

. 7.1

,

. Notepad. FreeBSD, gedit.

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

115

Ɋɢɫɭɧɨɤ 7.1 gedit.

, Edit

.

File

,

-

,

.

.

ɋɦɟɧɧɵɟ ɦɨɞɭɥɢ gedit

, .

-

-

,

Plug-ins gedit

. .

-

. Browse

-

Lynx,

Browse

Web-

. ,

-

. ,

, .

Diff ,

Diff ,

. ,

,

,

,

-

.

E-mail -

E-mail . Shell Output

Shell Output .

-

116

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

, ,

Directory

/,

command — ls -1.

Enter shell -l

ls .

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 7.2

Enter. .

я

7.

117

7.3 7.2

.

.

7.2

.

Tabs to spaces

.

, . ,

(

Python

Case-sensitive search

FORTRAN).

.

, .

Margins observed

, . .

, .

, . Auto paragraph format

.

, — .

, , Margins

observed.

Margins observed .

Eightbit characters ( )

.

8ASCII.

,

.

Info window

. menu/help.

,

. Emacs key bindings

. ,

Emacs.

,

. Right margin

,

. 80-

16 bit characters

,

.

1616-

( ).

8-

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 ( , insert (

i

, -

). . ).

,

.

,

open ( ,

,

). vi

, . insert,

. , . ; .

, ,

-

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

119

, Escape.

vi

-

. vi , .

,

Page Up / Page Down. ,

.

, . ,

Escape h, . -

. j, k

,

1 ,

,

,

, : 1— h— j . k .

• • • •

. . ,

.

kaif,

— . .

7.3 vi

,

h

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜɥɟɜɨ ɧɚ ɨɞɢɧ ɫɢɦɜɨɥ.

j

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜɧɢɡ ɧɚ ɨɞɢɧ ɫɢɦɜɨɥ.

k

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜɜɟɪɯ ɧɚ ɨɞɢɧ ɫɢɦɜɨɥ.

I

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜɩɪɚɜɨ ɧɚ ɨɞɢɧ ɫɢɦɜɨɥ.

w

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜɩɟɪɟɞ ɧɚ ɨɞɧɨ ɫɥɨɜɨ.

b

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɧɚɡɚɞ ɧɚ ɨɞɧɨ ɫɥɨɜɨ.

ɟ

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɤɨɧɟɰ ɫɥɟɞɭɸɳɟɝɨ ɫɥɨɜɚ.

Ɉ

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɧɚɱɚɥɨ ɫɬɪɨɤɢ.

$

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɤɨɧɟɰ ɫɬɪɨɤɢ.

)

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɧɚɱɚɥɨ ɫɥɟɞɭɸɳɟɝɨ ɩɪɟɞɥɨɠɟɧɢɹ.

(

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɧɚɱɚɥɨ ɩɪɟɞɵɞɭɳɟɝɨ ɩɪɟɞɥɨɠɟɧɢɹ.

}

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɧɚɱɚɥɨ ɫɥɟɞɭɸɳɟɝɨ ɚɛɡɚɰɚ.

{

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɜ ɧɚɱɚɥɨ ɩɪɟɞɵɞɭɳɟɝɨ ɚɛɡɚɰɚ.

G

ɉɟɪɟɦɟɳɚɟɬ kɭɪɫɨɪ ɜ ɤɨɧɟɰ ɬɟɤɭɳɟɝɨ ɞɨɤɭɦɟɧɬɚ.

7.3

120

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

^

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɤ ɩɟɪɜɨɦɭ ɫɢɦɜɨɥɭ ɫɬɪɨɤɢ, ɧɟ ɹɜɥɹɸɳɟɦɭɫɹ ɩɪɨɛɟɥɨɦ.

ɇ

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɧɚ ɩɟɪɜɭɸ ɫɬɪɨɤɭ ɧɚ ɷɤɪɚɧɟ.

L

ɉɟɪɟɦɟɳɚɟɬ ɤɭɪɫɨɪ ɧɚ ɩɨɫɥɟɞɧɸɸ ɫɬɪɨɤɭ ɧɚ ɷɤɪɚɧɟ.

, 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

7.5 vi.

vi. , Ɍɚɛɥɢɰɚ 7.5 Ʉɨɦɚɧɞɵ ɪɟɞɚɤɬɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ ɜ ɪɟɞɚɤɬɨɪɟ vi D

ɍɞɚɥɹɟɬ ɬɟɤɫɬ ɨɬ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ ɞɨ ɤɨɧɰɚ ɫɬɪɨɤɢ,

dd

ɍɞɚɥɹɟɬ ɜɫɸ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɰɟɥɢɤɨɦ.

ndd

Ɂɞɟɫɶ n — ɱɢɫɥɨ ɭɞɚɥɹɟɦɵɯ ɫɬɪɨɤ. ɇɚɩɪɢɦɟɪ, ɤɨɦɚɧɞɚ 5dd ɭɞɚɥɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɢ ɱɟɬɵɪɟ ɫɬɪɨɤɢ, ɫɥɟɞɭɸɳɢɟ ɡɚ ɧɟɣ. Ɂɞɟɫɶ ɫ — ɫɢɦɜɨɥ. ɗɬɚ ɤɨɦɚɧɞɚ ɡɚɦɟɧɹɟɬ ɫɢɦɜɨɥ ɜ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ ɫɢɦɜɨɥɨɦ, ɤɨɬɨɪɵɣ ɭɤɚɡɚɧ ɡɚ r.

R

Ɍɟɤɫɬ, ɜɜɨɞɢɦɵɣ ɩɨɫɥɟ ɷɬɨɣ ɤɨɦɚɧɞɵ, ɡɚɦɟɳɚɟɬ ɬɟɤɭɳɢɣ ɬɟɤɫɬ, ɧɚɱɢɧɚɹ ɫ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ. ɗɬɨɬ ɪɟɠɢɦ ɞɟɣɫɬɜɭɟɬ ɞɨ ɬɟɯ ɩɨɪ, ɩɨɤɚ ɧɟ ɛɭɞɟɬ ɧɚɠɚɬɚ ɤɥɚɜɢɲɚ Escape, ɜɨɡɜɪɚɳɚɸɳɚɹ ɪɟɞɚɤɬɨɪ ɜ ɤɨɦɚɧɞɧɵɣ ɪɟɠɢɦ.

S

ɍɞɚɥɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɢ ɧɚɱɢɧɚɟɬ ɜɜɨɞ ɬɟɤɫɬɚ ɧɚ ɧɨɜɨɣ ɩɭɫɬɨɣ ɫɬɪɨɤɟ.

ɯ

ɍɞɚɥɹɟɬ ɫɢɦɜɨɥ ɜ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ ɢ ɫɞɜɢɝɚɟɬ ɫɥɟɞɭɸɳɢɟ ɡɚ ɧɢɦ ɫɢɦɜɨɥɵ ɜɥɟɜɨ.

X

ɍɞɚɥɹɟɬ ɫɢɦɜɨɥ ɩɟɪɟɞ ɤɭɪɫɨɪɨɦ ɢ ɫɞɜɢɝɚɟɬ ɫɥɟɞɭɸɳɢɟ ɡɚ ɧɢɦ ɫɢɦɜɨɥɵ ɜɥɟɜɨ. Ɂɚɦɟɧɹɟɬ ɛɭɤɜɭ ɧɚ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ ɬɨɣ ɠɟ ɛɭɤɜɨɣ ɞɪɭɝɨɝɨ ɪɟɝɢɫɬɪɚ.

J

Ɉɛɴɟɞɢɧɹɟɬ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ ɫ ɩɪɟɞɵɞɭɳɟɣ.

Ɉɩɟɪɚɰɢɢ ɧɚɞ ɮɚɣɥɚɦɢ ɢ ɜɵɯɨɞ ɢɡ ɪɟɞɚɤɬɨɪɚ 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/

:%s/

2 1/

2

Ɂɚɦɟɧɹɟɬ ɜ ɬɟɤɭɳɟɣ ɫɬɪɨɤɟ ɤɚɠɞɨɟ ɫɨɜɩɚɞɟɧɢɟ ɲɚɛɥɨɧɚ 1 ɧɚ ɲɚɛɥɨɧ2. Ɂɚɦɟɧɹɟɬ ɜ ɮɚɣɥɟ ɤɚɠɞɨɟ ɫɨɜɩɚɞɟɧɢɟ ɲɚɛɥɨɧɚ 1 ɧɚ

,

vi ( —

vi yank — 7.8

.

2.

).

,

,

-

yank.

7.8

Yank

vi

yw

ɉɨɦɟɳɚɟɬ ɜ ɛɭɮɟɪ ɫɥɨɜɨ, ɧɚ ɤɨɬɨɪɨɦ ɜ ɞɚɧɧɵɣ ɦɨɦɟɧɬ ɧɚɯɨɞɢɬɫɹ ɤɭɪɫɨɪ.

ɭ$

ɉɨɦɟɳɚɟɬ ɜ ɛɭɮɟɪ ɬɟɤɫɬ ɨɬ ɬɟɤɭɳɟɣ ɩɨɡɢɰɢɢ ɤɭɪɫɨɪɚ ɞɨ ɤɨɧɰɚ ɞɚɧɧɨɣ ɫɬɪɨɤɢ,

ɭɭ

ɉɨɦɟɳɚɟɬ ɜ ɛɭɮɟɪ ɜɫɸ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ.

nɭɭ

Ɂɞɟɫɶ n — ɱɢɫɥɨ ɫɬɪɨɤ, ɡɚɧɨɫɢɦɵɯ ɜ ɛɭɮɟɪ. ɇɚɩɪɢɦɟɪ, ɤɨɦɚɧɞɚ 5ɭɭ ɩɨɦɟɳɚɟɬ ɜ ɛɭɮɟɪ ɬɟɤɭɳɭɸ ɫɬɪɨɤɭ, ɚ ɬɚɤɠɟ ɱɟɬɵɪɟ ɫɬɪɨɤɢ, ɫɥɟɞɭɸɳɢɟ ɡɚ ɧɟɣ.

,

-

. .

. ,

. ,

.

,

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

123

ɉɊȿȾɈɋɌȿɊȿɀȿɇɂȿ Ɋɟɞɚɤɬɨɪ vi ɯɪɚɧɢɬ ɜ ɛɭɮɟɪɟ ɬɟɤɫɬ ɬɨɥɶɤɨ ɫɚɦɨɣ ɩɨɫɥɟɞɧɟɣ ɨɩɟɪɚɰɢɢ ɤɨɩɢɪɨɜɚɧɢɹ ɬɟɤɫɬɚ ɜ ɛɭɮɟɪ ɢɥɢ ɭɞɚɥɟɧɢɹ. Ⱦɪɭɝɢɦɢ ɫɥɨɜɚɦɢ, ɟɫɥɢ ɜɵ ɜɵɩɨɥɧɢɥɢ ɤɨɦɚɧɞɭ dd, ɱɬɨɛɵ ɭɞɚɥɢɬɶ ɫɬɪɨɤɭ ɬɟɤɫɬɚ, ɚ ɩɨɬɨɦ ɜɵɩɨɥɧɢɥɢ ɤɨɦɚɧɞɭ ɭɭ, ɱɬɨɛɵ ɫɤɨɩɢɪɨɜɚɬɶ ɫɬɪɨɤɭ ɬɟɤɫɬɚ, ɬɨ ɜ ɛɭɮɟɪɟ ɬɟɤɫɬ, ɫ ɤɨɬɨɪɵɦ ɨɩɟɪɢɪɨɜɚɥɚ ɤɨɦɚɧɞɚ dd, ɛɭɞɟɬ ɡɚɦɟɳɟɧ ɬɟɤɫɬɨɦ ɨɩɟɪɚɰɢɢ ɭɭ- ɗɬɨ ɨɡɧɚɱɚɟɬ, ɱɬɨ ɬɟɤɫɬ ɢɡ ɨɩɟɪɚɰɢɢ dd ɛɭɞɟɬ ɩɨɬɟɪɹɧ, ɬ.ɟ. ɨɩɟɪɚɰɢɸ ɭɞɚɥɟɧɢɹ ɨɬɦɟɧɢɬɶ ɛɭɞɟɬ ɧɟɜɨɡɦɨɠɧɨ.

Ƚɪɚɮɢɤɚ ɢ ɢɡɨɛɪɚɠɟɧɢɹ ,

-

FreeBSD. Gimp ,

Xfig. FreeBSD.

,

ɉɪɨɝɪɚɦɦɚ GIMP GIMP —

The GNU Image Manipulation Program. ,

-

.

Adobe Photoshop, GIMP

. GIMP

-

, PNG, PCX TIFF, GIMP FreeBSD. , gimp Run.

BMP, GIF, JPEG,

PostScript. graphics GIMP

, X-Window

-

7.4

. 7.4 GIMP. GIMP.

,

File

Load Image,

Ctr+O.

. .

,

, . GIMP

,

, !

,

. 7.5

GIMP.

GIMP GIMP . Acquire ( Shot (

File, ). ).

Screen

124

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

7.5 GIMP

GIMP

,

-

GIMP . — . (

: Indexed ( 256 ).

)

, RGB (16,7

Grayscale ,

), ; ,



Image, a

Mode. ,

, ,

Image

. Colors.

-

, RGB Web-

Indexed ( .

Grayscale. ),

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. 1

ȼɵɞɟɥɟɧɢɟ ɩɪɹɦɨɭɝɨɥɶɧɨɣ ɨɛɥɚɫɬɢ. ɍɞɟɪɠɢɜɚɣɬɟ ɥɟɜɭɸ ɤɧɨɩɤɭ ɜ ɧɚɠɚɬɨɦ ɩɨɥɨɠɟɧɢɢ ɢ ɩɟɪɟɦɟɳɚɣɬɟ ɭɤɚɡɚɬɟɥɶ ɦɵɲɢ ɩɨ ɢɡɨɛɪɚɠɟɧɢɸ.

2

ȼɵɞɟɥɟɧɢɟ ɨɜɚɥɶɧɨɣ ɨɛɥɚɫɬɢ. ɍɞɟɪɠɢɜɚɣɬɟ ɥɟɜɭɸ ɤɧɨɩɤɭ ɦɵɲɢ ɜ ɧɚɠɚɬɨɦ ɩɨɥɨɠɟɧɢɢ ɢ ɩɟɪɟɦɟɳɚɚɣɬɟ ɭɤɚɡɚɬɟɥɶ ɦɵɲɢ ɩɨ ɢɡɨɛɪɚɠɟɧɢɸ.

6

ȼɵɞɟɥɟɧɢɟ ɩɪɨɢɡɜɨɥɶɧɨɣ ɨɛɥɚɫɬɢ. ɍɞɟɪɠɢɜɚɣɬɟ ɥɟɜɭɸ ɤɧɨɩɤɭ ɦɵɲɢ ɜ ɧɚɠɚɬɨɦ ɩɨɥɨɠɟɧɢɢ ɢ, ɩɟɪɟɬɚɫɤɢɜɚɹ ɭɤɚɡɚɬɟɥɶ ɦɵɲɢ ɩɨ ɢɡɨɛɪɚɠɟɧɢɸ, ɜɵɞɟɥɹɣɬɟ ɬɪɟɛɭɟɦɭɸ ɨɛɥɚɫɬɶ ɩɪɨɢɡɜɨɥɶɧɨɣ ɮɨɪɦɵ.

7

ȼɨɥɲɟɛɧɚɹ ɩɚɥɨɱɤɚ. ɓɟɥɱɨɤ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɩɪɢɜɨɞɢɬ ɤ ɬɨɦɭ, ɱɬɨ ɢɧɫɬɪɭɦɟɧɬ ɜɵɞɟɥɹɟɬ ɫɦɟɠɧɵɟ ɫ ɞɚɧɧɨɣ ɬɨɱɤɨɣ ɨɛɥɚɫɬɢ, ɢɦɟɸɳɢɟ ɩɨɯɨɠɢɣ ɰɜɟɬ.

5

Ʉɪɢɜɚɹ Ȼɟɡɶɟ. Ⱦɚɧɧɵɣ ɢɧɫɬɪɭɦɟɧɬ ɩɨɡɜɨɥɹɟɬ ɜɵɞɟɥɹɬɶ ɨɛɥɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ ɫ ɩɨɦɨɳɶɸ ɤɪɢɜɨɣ Ȼɟɡɶɟ.

12

ɂɧɬɟɥɥɟɤɬɭɚɥɶɧɵɟ ɧɨɠɧɢɰɵ. ɗɬɨɬ ɢɧɫɬɪɭɦɟɧɬ ɩɨɡɜɨɥɹɟɬ ɜɵɞɟɥɹɬɶ ɧɚ ɢɡɨɛɪɚɠɟɧɢɢ ɨɛɥɚɫɬɢ ɪɚɡɥɢɱɧɨɣ ɮɨɪɦɵ.

13

ɉɟɪɟɦɟɳɟɧɢɟ. ɉɨɡɜɨɥɹɟɬ ɩɟɪɟɦɟɳɚɬɶ ɫɥɨɢ, ɚ ɬɚɤɠɟ ɱɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ, ɜɵɞɟɥɟɧɧɵɟ ɫ ɩɨɦɨɳɶɸ ɨɞɧɨɝɨ ɢɡ ɢɧɫɬɪɭɦɟɧɬɨɜ ɜɵɞɟɥɟɧɢɹ.

14

Ɇɚɫɲɬɚɛ ɢɡɨɛɪɚɠɟɧɢɹ. ɉɪɢ ɳɟɥɱɤɟ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɦɵɲɢ ɢɡɨɛɪɚɠɟɧɢɟ ɭɜɟɥɢɱɢɜɚɟɬɫɹ. ȿɫɥɢ ɜɨ ɜɪɟɦɹ ɳɟɥɱɤɚ ɥɟɜɨɣ ɤɧɨɩɤɨɣ ɭɞɟɪɠɢɜɚɬɶ ɜ ɧɚɠɚɬɨɦ ɩɨɥɨɠɟɧɢɢ ɤɥɚɜɢɲɭ Ctrl, ɬɨ ɢɡɨɛɪɚɠɟɧɢɟ ɭɦɟɧɶɲɢɬɫɹ.

15

ɂɧɫɬɪɭɦɟɧɬɵ ɤɚɞɪɢɪɨɜɚɧɢɹ. ɉɨɡɜɨɥɹɸɬ ɜɵɪɟɡɚɬɶ ɱɚɫɬɶ ɢɡɨɛɪɚɠɟɧɢɹ, ɚ ɬɚɤɠɟ ɢɡɦɟɧɢɬɶ ɟɝɨ ɪɚɡɦɟɪ.

16

ȼɪɚɳɟɧɢɟ ɢ ɩɟɪɫɩɟɤɬɢɜɚ. ɋ ɩɨɦɨɳɶɸ ɷɬɨɝɨ ɢɧɫɬɪɭɦɟɧɬɚ ɧɚ ɢɡɨɛɪɚɠɟɧɢɟ ɧɚɤɥɚɞɵɜɚɟɬɫɹ ɫɟɬɤɚ. ɉɟɪɟɬɚɫɤɢɜɚɹ ɷɬɭ ɫɟɬɤɭ ɦɨɠɧɨ ɜɪɚɳɚɬɶ ɢɡɨɛɪɚɠɟɧɢɟ.

11

ɉɟɪɟɜɨɪɨɬ. ɉɪɢ ɳɟɥɱɤɟ ɧɚ ɢɡɨɛɪɚɠɟɧɢɢ ɞɚɧɧɵɣ ɢɧɫɬɪɭɦɟɧɬ ɩɟɪɟɜɨɪɚɱɢɜɚɟɬ ɢɡɨɛɪɚɠɟɧɢɟ, ɞɚɜɚɹ, ɩɪɟɢɦɭɳɟɫɬɜɟɧɧɨ, ɟɝɨ ɡɟɪɤɚɥɶɧɨɟ ɨɬɪɚɠɟɧɢɟ.

126

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD



Ɍɟɤɫɬ. Ⱦɚɧɧɵɣ ɢɧɫɬɪɭɦɟɧɬ ɨɬɤɪɵɜɚɟɬ ɞɢɚɥɨɝɨɜɨɟ ɨɤɧɨ, ɩɨɡɜɨɥɹɸɳɟɟ ɞɨɛɚɜɥɹɬɶ ɤ ɢɡɨɛɪɚɠɟɧɢɸ ɬɟɤɫɬ. Ɇɨɠɧɨ ɦɟɧɹɬɶ ɬɢɩ ɲɪɢɮɬɚ, ɟɝɨ ɪɚɡɦɟɪ ɢ ɬ.ɞ.



ɉɢɩɟɬɤɚ. ȿɫɥɢ ɳɟɥɤɧɭɬɶ ɧɚ ɷɬɨɦ ɢɧɫɬɪɭɦɟɧɬɟ, ɚ ɡɚɬɟɦ ɝɞɟ-ɧɢɛɭɞɶ ɧɚ ɢɡɨɛɪɚɠɟɧɢɢ, ɬɨ ɰɜɟɬ ɞɚɧɧɨɣ ɬɨɱɤɢ ɫɬɚɧɟɬ ɰɜɟɬɨɦ ɩɟɪɟɞɧɟɝɨ ɩɥɚɧɚ.



Ɂɚɥɢɜɤɚ. ȿɫɥɢ ɳɟɥɤɧɭɬɶ ɧɚ ɤɚɤɨɣ-ɧɢɛɭɞɶ ɨɛɥɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ, ɬɨ ɩɪɨɢɡɨɣɞɟɬ ɡɚɥɢɜɤɚ ɷɬɨɣ ɨɛɥɚɫɬɢ ɥɢɛɨ ɰɜɟɬɨɦ ɩɟɪɟɞɧɟɝɨ ɩɥɚɧɚ, ɥɢɛɨ ɰɜɟɬɨɦ ɮɨɧɚ, ɥɢɛɨ ɜ ɫɨɨɬɜɟɬɫɬɜɢɢ ɫ ɲɚɛɥɨɧɨɦ. Ⱦɜɨɣɧɨɣ ɳɟɥɱɨɤ ɩɨɡɜɨɥɹɟɬ ɢɡɦɟɧɢɬɶ ɤɨɧɮɢɝɭɪɚɰɢɸ ɢɧɫɬɪɭɦɟɧɬɚ.



Ƚɪɚɞɢɟɧɬ. ɉɨɡɜɨɥɹɟɬ ɫɨɡɞɚɜɚɬɶ ɰɜɟɬɨɜɵɟ ɩɟɪɟɯɨɞɵ. ɉɨ ɭɦɨɥɱɚɧɢɸ ɨɫɭɳɟɫɬɜɥɹɟɬɫɹ ɩɟɪɟɯɨɞ ɨɬ ɰɜɟɬɚ ɩɟɪɟɞɧɟɝɨ ɩɥɚɧɚ ɤ ɰɜɟɬɭ ɮɨɧɚ.



Ʉɚɪɚɧɞɚɲ. Ʉɨɝɞɚ ɥɟɜɚɹ ɤɧɨɩɤɚ ɦɵɲɢ ɭɞɟɪɠɢɜɚɟɬɫɹ ɜ ɧɚɠɚɬɨɦ ɩɨɥɨɠɟɧɢɢ, ɷɬɨɬ ɢɧɫɬɪɭɦɟɧɬ ɪɢɫɭɟɬ ɪɟɡɤɢɟ, ɱɟɬɤɢɟ ɥɢɧɢɢ.



Ʉɢɫɬɶ. Ɋɢɫɭɟɬ ɦɟɧɟɟ ɪɟɡɤɢɦɢ, ɱɟɦ ɤɚɪɚɧɞɚɲ, ɛɨɥɟɟ ɪɚɫɩɥɵɜɱɚɬɵɦɢ ɦɚɡɤɚɦɢ.



Ʌɚɫɬɢɤ. ɗɬɨɬ ɢɧɫɬɪɭɦɟɧɬ ɫɬɢɪɚɟɬ ɜɵɛɪɚɧɧɵɟ ɨɛɥɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ ɢ ɡɚɦɟɧɹɟɬ ɢɯ ɰɜɟɬɨɦ ɮɨɧɚ.



Ⱥɷɪɨɝɪɚɮ.



ɒɬɚɦɩ. ɗɬɨ ɢɧɫɬɪɭɦɟɧɬ ɞɥɹ ɤɥɨɧɢɪɨɜɚɧɢɹ. Ɇɨɠɧɨ ɜɵɞɟɥɢɬɶ ɨɩɪɟɞɟɥɟɧɧɭɸ ɨɛɥɚɫɬɶ ɢɡɨɛɪɚɠɟɧɢɹ, ɚ ɡɚɬɟɦ ɫɤɨɩɢɪɨɜɚɬɶ ɟɟ ɜ ɞɪɭɝɨɟ ɦɟɫɬɨ. ɂɫɩɨɥɶɡɭɟɬɫɹ ɞɥɹ ɪɟɬɭɲɢɪɨɜɚɧɢɹ.



Ɋɚɡɦɵɬɨɫɬɶ/Ɋɟɡɤɨɫɬɶ. ȿɫɥɢ ɩɪɨɜɟɫɬɢ ɞɚɧɧɵɦ ɢɧɫɬɪɭɦɟɧɬɨɦ ɩɨ ɤɚɤɨɣ-ɧɢɛɭɞɶ ɨɛɥɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ, ɬɨ ɷɬɚ ɨɛɥɚɫɬɶ ɫɬɚɧɟɬ ɥɢɛɨ ɛɨɥɟɟ ɪɚɡɦɵɬɨɣ, ɥɢɛɨ, ɧɚɨɛɨɪɨɬ, ɛɨɥɟɟ ɪɟɡɤɨɣ.



ɑɟɪɧɢɥɶɧɚɹ ɪɭɱɤɚ. Ⱦɚɧɧɵɣ ɢɧɫɬɪɭɦɟɧɬ ɪɢɫɭɟɬ ɩɨɞɨɛɧɨ ɱɟɪɧɢɥɶɧɨɣ ɪɭɱɤɟ.



Ɉɫɜɟɬɥɢɬɟɥɶ. ȿɫɥɢ ɩɪɨɜɟɫɬɢ ɷɬɢɦ ɢɧɫɬɪɭɦɟɧɬɨɦ ɩɨ ɤɚɤɨɣ-ɧɢɛɭɞɶ ɨɛɥɚɫɬɢ ɢɡɨɛɪɚɠɟɧɢɹ, ɬɨ ɨɧɚ ɫɬɚɧɟɬ ɛɨɥɟɟ ɫɜɟɬɥɨɣ.



ɉɚɥɟɰ (Smudge tool). Ⱦɚɧɧɵɣ ɢɧɫɬɪɭɦɟɧɬ ɪɢɫɭɟɬ ɲɢɪɨɤɢɦɢ ɦɚɡɤɚɦɢ, ɫɨɡɞɚɜɚɹ ɷɮɮɟɤɬ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɚɤɜɚɪɟɥɶɧɵɯ ɤɪɚɫɨɤ.



ɂɡɦɟɪɢɬɟɥɶɧɵɣ ɢɧɫɬɪɭɦɟɧɬ. ɗɬɨɬ ɢɧɫɬɪɭɦɟɧɬ ɫɥɭɠɢɬ ɞɥɹ ɢɡɦɟɪɟɧɢɹ ɪɚɫɫɬɨɹɧɢɣ ɢ ɭɝɥɨɜ ɧɚ ɢɡɨɛɪɚɠɟɧɢɢ.

GIMP , 100

86

, 168

,

200

40

, .

GQview GQview —

Gnome.

-

FreeBSD

graphics .

GQview –

. GQview

, ,

X.

, .

gqview

-

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

GQview.

127

:

,

,

,

.

, . ,

v

-

, , Start slideshow.

StarOffice StarOffice — ,

Sun Microsystems. StarOffice

Microsoft Office, Lotus SmartSuite , ,

. . ,

StarOffice

, HTMLeditors

Internet. , : , . StarOffice

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.

• .

7.6 StarOffice.

StarOffice : ,

-

128

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

• •

File, New File, New

. From Template (

).

ȼɫɬɪɨɟɧɧɵɣ Web-ɛɪɚɭɡɟɪ StarOffice WebFilename Web-

, URL

File Web-

Open; , StarOffice, ( .

. WebBack .

. 7.7).

WebForward.

Back

StarOffice Tools,

Forward,

Web.

Option, Web-

.

ɗɥɟɤɬɪɨɧɧɚɹ ɩɨɱɬɚ ɜ StarOffice StarOffice

. .

Tools, (

.

Options. (+)

, General,

, User Data

7.8). . -

StarOffice.

, ;

Ɋɢɫɭɧɨɤ 7.7

WebSams Publishing, StarOffice.

( ,

, ).

. .

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

129

, Contents

-

Include in update function

. messages from server

, Save document contents locally.

Remove ,

Internet. . ,

,

Yes.

7.8

StarOffice. ,

.

, SMTP.

Outbox. .

,

Reply to

, Server

,

Sender.

. Properties,

-

. , ,

, StarOffice,

.

StarOffice

. : • •

StarOffice

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



New Mail.

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

, : ). -

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

130

ɋɩɪɚɜɨɱɧɚɹ ɢɧɮɨɪɦɚɰɢɹ ɜ 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: at port Ox220-0x22f,0x330-0x331,Ox388-0x38b irq 5 drq

1,5 on isaO pcml: on sbcO

,

FreeBSD ,

AWE 64; FreeBSD

, www.opensound.com. 4Front Technologies, device pcm . - 17.

SoundBlaster . , 4Front Technologies.

-

,

FreeBSD 4.4 ,

, ,

.

/dev

root

:

./MAKEDEV sndO

FreeBSD 5.0

DEVFS .

Ɇɢɤɲɟɪ , FreeBSD

.

X

, Mixer Mixer Mixer Mixer Mixer Mixer Mixer Mixer Mixer Mixer Mixer

vol bass treble synth pcm speaker line mic cd igain ogain

mixer.

: 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)

( .

, ,

-

2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

Ч

132



.

,

-

:

• Mixer vol — • Mixer pcm — . , • Mixer synth — MIDI.

. , .wav, Real Audio

. . .

• Mixer cd — • Mixer line —

,

, -

.

, .

• Mixer igain —

.

• Mixer ogain —

. ,



. 90%,

cd

-

mixer, ,

, ,

-

,

: mixer cd 90

, , 100%

. 80%

,

,

:

mixer cd 100:80

75%.

.

, ,

.

,

,

. mixerset.

/usr/local/etc/rc.d , :

,

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.

,



home-

.login. 12.

.

Ƚɥɚɜɚ 7. Ɋɚɛɨɬɚ ɫ ɩɪɢɥɨɠɟɧɢɹɦɢ

133

,

,—

.profile .

.login

-

.

,

:

mixer vol 80:80 mixer cd 50:50 mixer p n 90:90

, .

root, , , .

ȼɨɫɩɪɨɢɡɜɟɞɟɧɢɟ ɮɚɣɥɨɜ ɆɊɁ ɫ ɩɨɦɨɳɶɸ XMMS FreeBSD XMMS — UNIX.

Winamp, audio XMMS xmms. X,

. 7.10 XMMS

. FreeBSD FreeBSD. -

, Run.

XMMS. (skins) Winamp. . Winamp

home-

.xmms/Skins

-

.

-

XMMS; Options

Skin Browser.

-

,

. 7.10

XMMS , Winamp, Skins,

-

www.xmms.org/skins.html XMMS. .xmms/ . XMMS tar .tar.gz. UNIX.

-

XMMS .

audio

-

FreeBSD.

ȼɨɫɩɪɨɢɡɜɟɞɟɧɢɟ ɆɊɁ-ɮɚɣɥɨɜ ɫ ɩɨɦɨɳɶɸ ɬɪɞ123 X-Window, ,

-

,

. audio

FreeBSD.

mpg!23.

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

134

mpg123 filename —

mpg123 filename, . mpg123 *.mp3 .m . . . . , —

, (

.

. 8).

, , ,

-Z -@, mpg123 . .

-

,

man mpg123.

Ɇɢɤɲɟɪɵ ɞɥɹ ɫɢɫɬɟɦɵ X-Window audio . Run.

xmixer, xmixer

FreeBSD. —

X

xmixer Athena (

xmixer ).

xmixer —

xgmixer. ,

FreeBSD ,

xmixer, GTK. , ,

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 ,

,

,

JavaLynx Lynx

. ,

ALT, . man lynx.

,

FTP FTP —

File Transfer Protocol (

). -

.

FTP-

ftp

,

X

, 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. anonymous. Enter,

,

, FTP anonymous :

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). FTP-

7.10 .

Ɍɚɛɥɢɰɚ 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. -Window, .

FTP -

ftp

ɉɪɢɥɨɠɟɧɢɹ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ — FreeBSD

Internet. .

, X-Window. Balsa

Balsa — mail balsa.

FreeBSD).

Gnome ( ,

Balsa ,

, . Balsa

-

www.balsa.net. Pine Pine —

-

,

.

, . Pine

FreeBSD.

7.11

Pine.

. 7.11

mail Pine.

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

138

Pine

. , .

, ,

,

Pine

,

Pine

.

-

, . ɉɊȿȾɈɋɌȿɊȿɀȿɇɂȿ

Ɉɬɤɪɵɜɚɬɶ ɥɸɛɭɸ ɷɥɟɤɬɪɨɧɧɭɸ ɩɨɱɬɭ, ɛɭɞɭɱɢ ɡɚɪɟɝɢɫɬɪɢɪɨɜɚɧɧɵɦ ɤɚɤ root, — ɩɥɨɯɚɹ ɢɞɟɹ, ɚ ɜ ɫɥɭɱɚɟ Pine — ɨɫɨɛɟɧɧɨ. ɗɬɨ ɫɜɹɡɚɧɨ ɫ ɩɪɢɪɨɞɨɣ ɧɟɤɨɬɨɪɵɯ ɩɨɬɟɧɰɢɚɥɶɧɵɯ ɛɪɟɲɟɣ ɜ ɡɚɳɢɬɟ Pine. ɉɨɱɬɭ ɩɨɥɶɡɨɜɚɬɟɥɹ root ɫɥɟɞɭɟɬ ɩɟɪɟɫɵɥɚɬɶ ɧɚ ɢɦɹ ɩɪɨɫɬɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɹ, ɚ ɡɚɬɟɦ ɱɢɬɚɬɶ ɷɥɟɤɬɪɨɧɧɭɸ ɩɨɱɬɭ, ɢɫɩɨɥɶɡɭɹ ɭɱɟɬɧɭɸ ɡɚɩɢɫɶ ɷɬɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɹ. ɉɨɞɪɨɛɧɟɟ ɨ ɪɚɛɨɬɟ ɫ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɨɣ ɦɨɠɧɨ ɩɨɱɢɬɚɬɶ ɜ ɝɥɚɜɟ 25.

Mutt Mutt —

-

,

.

mail . "

.

",

Mutt ) Pine ( Mutt

Elm). Mutt —

, ,

Mutt — www.mutt.org — , .

,

uuencode

FreeBSD. Mutt — , Elm ( , . . . -

uudecode uuencode

, uuencode -

uudecode. .

.

.

, ,

, .

, :

begin 644 gunzip.exe M35HZ `4D`````.16_____ /6 `````.`,4( '````$Q: .3'_\ 8X&W@ 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, ,

. , .

-

8

Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ ◀ Ɉɫɧɨɜɵ ɪɚɛɨɬɵ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ ◀ Ɍɢɩɵ ɞɨɫɬɭɩɧɵɯ ɤɨɦɚɧɞɧɵɯ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɜ ◀ ȼɵȻɨɪ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ◀ ɉɨɥɭɱɟɧɢɟ ɫɩɪɚɜɤɢ ◀ ɉɪɨɫɬɟɣɲɢɟ ɫɩɨɫɨɛɵ ɪɚȻɨɬɵ ɫ ɮɚɣɥɚɦɢ ɜ ɤɨɦɚɧɞɧɨɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɟ ◀ Ʉɨɦɚɧɞɵ ɨɛɪɚɛɨɬɤɢ ɬɟɤɫɬɨɜɵɯ ɮɚɣɥɨɜ ◀ Ʉɨɧɜɟɣɟɪɵ ɢ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɟ ɜɜɨɞɚ-ɜɵɜɨɞɚ. ◀ ɉɨɩɨɥɧɟɧɢɟ ɤɨɦɚɧɞɧɨɣ ɫɬɪɨɤɢ ɢ ɪɟɞɚɤɬɢɪɨɜɚɧɢɟ ɢɫɬɨɪɢɢ ɤɨɦɚɧɞ

141

Ƚɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

X-Window ,

Gnome. FreeBSD . UNIX, —

-

, ,

, 30

.

,

FreeBSD,

.

Ɉɫɧɨɜɵ ɪɚɛɨɬɵ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ UNIX UNIX. , , . , Windows

Macintosh (

).

,

.1

,

,

,

.

,

, . 8.1. 17.

.

,

(

).

,

-

, .

Ɍɢɩɵ ɞɨɫɬɭɩɧɵɯ ɤɨɦɚɧɞɧɵɯ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɜ FreeBSD

, .

,

. :

-

, Bourne,

sh.

Ʉɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ Bourne (sh) Bourne (Steven Bourne) FreeBSD,

UNIX,

Bell Labs AT&T UNIX. -

142

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

,

POSIX, Bourne

,

,

,

,

--

,

Bourne.

Ʉɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ ɋ (csh) csh — Bourne,

BSD.

Berkeley, BSD.

, . csh

Bourne, ,

- :

.

-

,

Bourne. csh

,

.

, . Bourne:

Bourne ,

csh,

, .

,

,

csh,

. csh ,

.

-

,

.

Ʉɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ Korn (ksh ɢɥɢ pdksh) AT&T AT&T

Korn (David Korn). Korn

csh.

1986

Bourne.

, vi

, Korn Emacs ( . . ,

). -

,

, -

.

Korn UNIX. Korn: pdksh. ,

FreeBSD, 15. , ,

vi Emacs, UNIX, ), (

,

-

bash ( -

vi

,

, .

Korn

,

, -

-

.

Emacs ).

143

Ƚɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

Ʉɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ Bourne Again Shell (bash) Bourne Again Shell ( : Bourne Again Born Again — ) , (Free Software Foundation) (FSF). Linux. , , ,

Bourne Bourne bash n, ,

- , -

. UNIX.

bash ,

bash,

UNIX.

Ʉɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ Tcsh (tcsh) tcsh .( .)

"t" tcsh

TENEX

DEC PDP-10;

,

tcsh

, , tcsh bash, : "Are you sure you want to delete ALL files?"). , , bash. , , , , .

bash (

).

, ( tcsh — . , . Bourne,

Ʉɚɤɨɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ ɜɵɛɪɚɬɶ? , FreeBSD

? . ,

,

,

. ,

Korn, bash ,

bash,

rn

tcsh. ,

.

ɂɡɦɟɧɟɧɢɟ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ 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

# /bin/tcsh.

tcsh. tcsh. n.

# /usr/local/bin/ksh. # /usr/local/bin/bash.

bash. ,

bash .

12

-

bash

,

-

. ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ UNIX ɢ FreeBSD ɭɱɢɬɵɜɚɸɬ ɪɟɝɢɫɬɪ ɜ ɤɨɦɚɧɞɚɯ ɢ ɢɦɟɧɚɯ ɮɚɣɥɨɜ. ɉɨɷɬɨɦɭ Grep, grep ɢ greP — ɷɬɨ ɫ ɬɨɱɤɢ ɡɪɟɧɢɹ FreeBSD ɫɨɜɟɪɲɟɧɧɨ ɪɚɡɧɵɟ ɜɟɳɢ. ȿɫɥɢ ɜɵ, ɜɜɨɞɹ ɤɨɦɚɧɞɵ, ɩɨɥɭɱɚɟɬɟ ɫɨɨɛɳɟɧɢɟ ɨɛ ɨɲɢɛɤɟ: No such file or directory (ɇɟɬ ɬɚɤɨɝɨ ɮɚɣɥɚ ɢɥɢ ɤɚɬɚɥɨɝɚ), ɭɛɟɞɢɬɟɫɶ, ɱɬɨ ɤɨɦɚɧɞɚ ɜɜɟɞɟɧɚ ɜ ɩɪɚɜɢɥɶɧɨɦ ɪɟɝɢɫɬɪɟ.

ɉɨɥɭɱɟɧɢɟ ɫɩɪɚɜɤɢ ,

, .

-

FreeBSD

,

. man

. man.

,

_

man,

man ,

Page Up/Page Down.

ɉɨɢɫɤ ɫɬɪɚɧɢɰ ɫɩɪɚɜɨɱɧɵɯ ɪɭɤɨɜɨɞɫɬɜ ,

,

-k

, man -k search.

. 8.1.

man.

. ,

145

Ƚɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

8.1

man -k

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

S

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. ,

. no grep

,

man grep, ,

.

Ɋɟɡɸɦɟ ɤɨɦɚɧɞ , ( games). (

,

,

,

/usr/bin

-f ) /usr/games

.

man ,

, ,

:

$ man -f pom pom (6) — display the phase of the moon bash$

:

(6) ,

.

Ɋɚɡɞɟɥɵ ɫɩɪɚɜɨɱɧɵɯ ɪɭɤɨɜɨɞɫɬɜ , . 8.1.

/usr/

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 (ɂɧɬɟɪɮɟɣɫɵ ɹɞɪɚ)

ɂɧɮɨɪɦɚɰɢɹ ɞɥɹ ɩɪɨɝɪɚɦɦɢɫɬɨɜ ɨɛ ɢɧɬɟɪɮɟɣɫɟ ɹɞɪɚ ɧɚ ɋ.

. 1 ( man

, 5 ( , . .

crontab)

crontab crontab). crontab

1. 5,

man 5 crontab. , ,

-

-S .

ɉɪɨɫɬɟɣɲɢɟ ɫɩɨɫɨɛɵ ɪɚɛɨɬɵ ɫ ɮɚɣɥɚɦɢ ɜ ɤɨɦɚɧɞɧɨɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɟ MS-DOS, .

-

.

Ʉɚɤ ɫɢɫɬɟɦɚ FreeBSD ɯɪɚɧɢɬ ɮɚɣɥɵ , FreeBSD FreeBSD

. . . .

FreeBSD

-

147

ɝɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

.

. .

Windows Macintosh

Macintosh.

,

, Windows

FreeBSD —

.

DOS FreeBSD

.

Windows

,

,

-

. ,

.

-

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".

FreeBSD .bat.

, ,

, . .

FreeBSD .com.

Windows, .com, .exe ,

1 48

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

. -F

,

-

dot-

-

man ls. Is

-G, . ,

Is , . . - : $ ls -

,

.forward .hushlogin .addresshook .muttrc

.

.mailrc .mysql_history .rhosts .cshrc

.login .sh-history

..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 ɢ file2 ɜ ɤɚɬɚɥɨɝ "archive", ɪɚɫɩɨɥɨɠɟɧɧɵɣ ɜ

ɫɪ filel file 2 /archive

ɤɨɪɧɟɜɨɦ ɤɚɬɚɥɨɝɟ.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɉɨ ɭɦɨɥɱɚɧɢɸ ɤɨɦɚɧɞɚ ɫɪ ɩɟɪɟɡɚɩɢɫɵɜɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɫɭɳɟɫɬɜɭɸɳɟɝɨ ɮɚɣɥɚ ɫ ɢɦɟɧɟɦ, ɭɤɚɡɚɧɧɵɦ ɤɚɤ ɬɨɱɤɚ ɧɚɡɧɚɱɟɧɢɹ. ɇɚɩɪɢɦɟɪ, ɫɪ file1 file2 ɩɟɪɟɡɚɩɢɫɵɜɚɟɬ file2 ɮɚɣɥɨɦ filel, ɟɫɥɢ file2 ɭɠɟ ɫɭɳɟɫɬɜɭɟɬ. Ɉɩɰɢɹ -i (ɢɧɬɟɪɚɤɬɢɜɧɵɣ ɪɟɠɢɦ) ɡɚɫɬɚɜɥɹɟɬ ɤɨɦɚɧɞɭ ɫɪ ɡɚɩɪɚɲɢɜɚɬɶ ɩɨɞɬɜɟɪɠɞɟɧɢɟ ɧɚ ɩɟɪɟɡɚɩɢɫɶ ɮɚɣɥɚ.

, , $

-R dirl /dir2

, dir2.

, :

-R.

dir2 . ,

dir1 dir2,

dir1 dir1 , -

, ,

-

dir1, , dir1

-R ,

dir2. (

-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

.

.

,

, . 8.5.

-R. Ɍɚɛɥɢɰɚ 8.5

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɤɨɦɚɧɞɵ

rm file1

ɍɞɚɥɹɟɬ file1.

rm file1 file2

ɍɞɚɥɹɟɬ ɮɚɣɥɵ file1 ɢ file2.

rm -R dir1

ɍɞɚɥɹɟɬ ɤɚɬɚɥɨɝ dir1 ɢ ɜɫɟ, ɱɬɨ ɜ ɧɟɦ ɧɚɯɨɞɢɬɫɹ.

rm

(

)

,

rm,

. 8.6: Ɍɚɛɥɢɰɚ 8.6 Ɉɩɰɢɢ ɤɨɦɚɧɞɵ ɝɬ

-f

Ɂɚɫɬɚɜɥɹɟɬ rm ɩɪɨɢɡɜɟɫɬɢ ɭɞɚɥɟɧɢɟ, ɧɟ ɡɚɞɚɜɚɹ ɜɨɩɪɨɫɨɜ, ɞɚɠɟ ɟɫɥɢ ɮɚɣɥ ɩɪɟɞɧɚɡɧɚɱɟɧ ɬɨɥɶɤɨ ɞɥɹ ɱɬɟɧɢɹ. ɗɬɭ ɨɩɰɢɸ ɫɥɟɞɭɟɬ ɢɫɩɨɥɶɡɨɜɚɬɶ ɫ ɨɫɨɛɨɣ ɨɫɬɨɪɨɠɧɨɫɬɶɸ.

-i

Ɂɚɩɪɚɲɢɜɚɟɬ ɩɨɞɬɜɟɪɠɞɟɧɢɟ ɧɚ ɭɞɚɥɟɧɢɟ ɤɚɠɞɨɝɨ ɮɚɣɥɚ. ɉɨɥɟɡɧɨ ɩɪɢ ɢɫɩɨɥɶɡɨɜɚɧɢɢ rm ɫ ɫɢɦɜɨɥɚɦɢ-ɡɚɦɟɫɬɢɬɟɥɹɦɢ (ɨ ɧɢɯ ɞɚɥɟɟ) ɢɥɢ ɨɩɰɢɟɣ -R.



Ɍɪɢ ɪɚɡɚ ɩɟɪɟɡɚɩɢɫɵɜɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɮɚɣɥɚ ɫɥɭɱɚɣɧɨɣ ɩɨɫɥɟɞɨɜɚɬɟɥɶɧɨɫɬɶɸ ɛɚɣɬɨɜ ɞɥɹ ɟɝɨ ɩɨɥɧɨɝɨ ɮɢɡɢɱɟɫɤɨɝɨ ɭɞɚɥɟɧɢɹ. Ɍɚɤɢɦ ɨɛɪɚɡɨɦ, ɭɦɟɧɶɲɚɟɬɫɹ ɲɚɧɫ ɜɨɫɫɬɚɧɨɜɥɟɧɢɹ ɮɚɣɥɚ. ɗɬɭ ɨɩɰɢɸ ɢɫɩɨɥɶɡɭɸɬ ɞɥɹ ɭɞɚɥɟɧɢɹ ɨɫɨɛɨ ɜɚɠɧɵɯ ɮɚɣɥɨɜ.

-W

ɉɵɬɚɟɬɫɹ ɜɨɫɫɬɚɧɨɜɢɬɶ ɮɚɣɥ, ɭɞɚɥɟɧɧɵɣ ɤɨɦɚɧɞɨɣ rm.

ɍɞɚɥɟɧɢɟ ɤɚɬɚɥɨɝɨɜ rmdir. .

- ,

,

. ,

rm -R.

1 52

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

Ʉɨɦɚɧɞɚ touch :

touch

.

: • touch

_

,

,

_

. • touch

,

.

.

ɋɨɡɞɚɧɢɟ ɫɫɵɥɨɤ , FreeBSD .

-

.

:

links).

(hard links)

(soft

. , ),

(hard link) — (

.

. ,

. ln

.

:

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

filel.txt, /home/foo/documents/books/fbsd/ , , , vi , . Is -

, file1.txt. file1.txt

vi documents/books/fbsd/file1.txt. . :

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 ,

Windows.

symlinks) , .

,

.

$ 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] , filea, fileb filec. ɋɈȼȿɌ

filel, file2, file ,

ffle4. ,

, file[a-c]

ɉɪɢ ɪɚɛɨɬɟ ɫ ɞɢɚɩɚɡɨɧɚɦɢ ɫɢɦɜɨɥɨɜ ɜɚɠɧɨ ɩɨɦɧɢɬɶ, ɱɬɨ ɫɨɜɩɚɞɟɧɢɟ ɨɫɧɨɜɚɧɨ ɧɚ ASCII-ɤɨɞɟ ɫɢɦɜɨɥɚ. ɇɚɩɪɢɦɟɪ, file[A-b] ɫɨɜɩɚɞɚɟɬ ɧɟ ɬɨɥɶɤɨ ɫ fileA ɢ fileb, ɧɨ ɢ ɫ fileB, fileC ɢ ɬ.ɞ. ɞɨ fileZ. Ɍɚɤ ɩɪɨɢɫɯɨɞɢɬ ɩɨɬɨɦɭ, ɱɬɨ ɜ ɤɨɞɨɜɨɣ ɬɚɛɥɢɰɟ ɩɪɨɩɢɫɧɵɟ ɛɭɤɜɵ ɩɪɟɞɲɟɫɬɜɭɸɬ ɫɬɪɨɱɧɵɦ. ɉɨ-ɷɬɨɦɭ, ɤɨɝɞɚ ɞɢɚɩɚɡɨɧ ɧɚɱɢɧɚɟɬɫɹ ɫ ɩɪɨɩɢɫɧɨɣ ɛɭɤɜɵ ɢ ɡɚɤɚɧɱɢɜɚɟɬɫɹ ɫɬɪɨɱɧɨɣ, ɜ ɧɟɝɨ ɜɯɨɞɹɬ ɜɫɟ ɩɪɨɩɢɫɧɵɟ ɛɭɤɜɵ — ɨɬ ɭɤɚɡɚɧɧɨɣ ɞɨ Z.

, . file3

, fil [1234]*

,

file4 (

file1, file2, ,

). -

.

.

file3

, , file[!1234]* file4.

-

. filel, filel,

,

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ

ɉɪɢ ɢɫɩɨɥɶɡɨɜɚɧɢɢ ɫɢɦɜɨɥɨɜ-ɡɚɦɟɫɬɢɬɟɥɟɣ ɫ ɬɚɤɢɦɢ ɤɨɦɚɧɞɚɦɢ, ɤɚɤ 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 , File\\l.txt. ,

, . Filel.txt: No such file or directory. : rm -i

File 1. ,

rm File 1 : File 1. : rm -i "File 1". file"3".txt? file3.txt: No such file or directory. ,

, rm ffle"3".txt ,

(") :

file\"3\".txt. Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ, ɱɬɨ ɜɨ ɜɫɟɯ ɩɪɢɦɟɪɚɯ ɤɨɦɚɧɞɚ rm ɢɫɩɨɥɶɡɭɟɬɫɹ ɫ ɨɩɰɢɟɣ -i. ɗɬɨ ɫɥɟɞɭɟɬ ɫɱɢɬɚɬɶ ɯɨɪɨɲɟɣ ɩɪɢɜɵɱɤɨɣ, ɨɫɨɛɟɧɧɨ ɩɪɢ ɪɚɛɨɬɟ ɫ ɮɚɣɥɚɦɢ, ɢɦɟɸɳɢɦɢ ɧɟɫɬɚɧɞɚɪɬɧɵɟ ɢɦɟɧɚ. Ɍɚɤɢɦ ɨɛɪɚɡɨɦ, ɜɵ ɜɫɟɝɞɚ ɫɦɨɠɟɬɟ ɭɛɟɞɢɬɶɫɹ, ɱɬɨ ɤɨɦɚɧɞɚ ɜɵɩɨɥɧɹɟɬ ɢɦɟɧɧɨ ɬɨ ɞɟɣɫɬɜɢɟ, ɤɨɬɨɪɨɟ ɬɪɟɛɭɟɬɫɹ.

157

Ƚɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

? ( ). . $ find

.

, FreeBSD :

,

-

find,

-name "lostfile*"

, , ,

.

,

,

,

, NFS,

-

.

.

,

-

lostfile

-

,

, . ,

find .

, -

find

man find.

,

, locate, ,

, , .

.

-

, ,

, locate,

. (

). man locate.

-

Ʉɨɦɚɧɞɵ ɨɛɪɚɛɨɬɤɢ ɬɟɤɫɬɨɜɵɯ ɮɚɣɥɨɜ , UNIX,

AT&T FreeBSD

. UNIX

,

.

-

.

ɉɨɞɫɱɟɬ ɱɢɫɥɚ ɫɬɪɨɤ, ɫɥɨɜ ɢ ɫɢɦɜɨɥɨɜ , . ,

wc. , 1160

, $ wc fbu8mcu 1160 7823

, , 7823

51584

:

51584 fbu8mcu.html

,

we -l —

,

,

, -w —

- —

:

.

ɉɪɨɫɦɨɬɪ ɬɟɤɫɬɨɜɵɯ ɮɚɣɥɨɜ: ɭɬɢɥɢɬɵ more ɢ less , ,

less. ,

more (

).

less (

)

158

ɑɚɫɬɶ 2. ɂɫɩɨɥɶɡɨɜɚɧɢɟ FreeBSD

less ( .

more) ,

. ,

),

less (

. 8.9.

8.9

,

less

/pattern

Ɂɞɟɫɶ pattern ɡɚɞɚɟɬ ɲɚɛɥɨɧ ɩɨɢɫɤɚ ɫɬɪɨɤɢ ɜ ɮɚɣɥɟ.

ɉɊɈȻȿɅ ɢɥɢ f

ɉɪɨɤɪɭɱɢɜɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɧɚ ɨɞɢɧ ɷɤɪɚɧ ɜɩɟɪɟɞ. ȿɫɥɢ ɩɟɪɟɞ ɧɚɠɚɬɢɟɦ ɤɥɚɜɢɲɢ ɩɪɨɛɟɥ ɜɜɟɫɬɢ ɱɢɫɥɨ, less ɩɪɨɤɪɭɬɢɬ ɫɨɞɟɪɠɢɦɨɟ ɜɩɟɪɟɞ ɧɚ ɭɤɚɡɚɧɧɨɟ ɱɢɫɥɨ ɫɬɪɨɤ.

b

ɉɪɨɤɪɭɱɢɜɚɟɬ ɫɨɞɟɪɠɢɦɨɟ ɧɚ ɨɞɢɧ ɷɤɪɚɧ ɧɚɡɚɞ. ȿɫɥɢ ɩɟɪɟɞ ɧɚɠɚɬɢɟɦ b ɜɜɟɫɬɢ ɱɢɫɥɨ, less ɩɪɨɤɪɭɬɢɬ ɫɨɞɟɪɠɢɦɨɟ ɧɚɡɚɞ ɧɚ ɭɤɚɡɚɧɧɨɟ ɱɢɫɥɨ ɫɬɪɨɤ.

Ʉɥɚɜɢɲɢ ɤɭɪɫɨɪɚ "↑ " ɢ "↑ "

ɉɪɨɤɪɭɱɢɜɚɟɬ ɮɚɣɥ ɧɚ ɨɞɧɭ ɫɬɪɨɤɭ. Ɂɞɟɫɶ # ɨɛɨɡɧɚɱɚɟɬ ɱɢɫɥɨ. ȼɜɟɞɢɬɟ ɟɝɨ ɢ ɧɚɠɦɢɬɟ g. less ɩɪɨɤɪɭɬɢɬ ɮɚɣɥ ɞɨ ɭɤɚɡɚɧɧɨɣ ɜɚɦɢ ɫɬɪɨɤɢ.

#g

Ɂɞɟɫɶ # ɨɛɨɡɧɚɱɚɟɬ ɱɢɫɥɨ ɨɬ 0 ɞɨ 100. ɉɨ ɷɬɨɣ ɤɨɦɚɧɞɟ less ɩɪɨɤɪɭɱɢɜɚɟɬ ɮɚɣɥ ɞɨ ɬɨɣ ɱɚɫɬɢ, ɤɨɬɨɪɚɹ ɡɚɞɚɧɚ ɜ ɩɪɨɰɟɧɬɚɯ.

#%

.

less

,

,

(

2000

grep,

grep. ,

!).

ɉɨɢɫɤ ɩɨ ɲɚɛɥɨɧɭ : , egrep, .

fgrep, UNIX fgrep ,

grep),

,

fgrep ,

"fast grep" ( grep.

, grep.

cat.

textfile grep

:

$ grep cat textfile

, , , catnip, catbird, catfish cat.

cat, concatenate, , :

$ grep "

cat "

cat. .

,

textfile

159

Ƚɥɚɜɚ 8. Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɦ

grep: -i —

,- —

,

, -n — (

,

), -v — . egrep

, 13.

ɋɨɪɬɢɪɨɜɤɚ ɬɟɤɫɬɚ ɜ ɮɚɣɥɟ . /

-

,

.

sort. ASCII-

sort .

. 8.10. 8.10

sort

-d

ɋɨɪɬɢɪɨɜɤɚ ɜ ɫɬɢɥɟ "ɬɟɥɟɮɨɧɧɨɣ ɤɧɢɝɢ". ɂɝɧɨɪɢɪɭɸɬɫɹ ɜɫɟ ɫɢɦɜɨɥɵ, ɤɪɨɦɟ ɛɭɤɜ, ɰɢɮɪ ɢ ɬɢɪɟ.

-b

ɉɪɢ ɫɨɪɬɢɪɨɜɤɟ ɜ ɫɬɪɨɤɚɯ ɢɝɧɨɪɢɪɭɸɬɫɹ ɜɟɞɭɳɢɟ ɩɭɫɬɵɟ ɫɢɦɜɨɥɵ.

-f

ɉɪɢ ɫɨɪɬɢɪɨɜɤɟ ɫɬɪɨɱɧɵɟ ɛɭɤɜɵ (ɜɧɭɬɪɟɧɧɟ) ɩɪɟɨɛɪɚɡɭɸɬɫɹ ɜ ɩɪɨɩɢɫɧɵɟ (ɧɨ ɜ ɜɵɜɨɞɟ ɫɨɯɪɚɧɹɸɬɫɹ ɢɫɯɨɞɧɵɟ ɡɧɚɱɟɧɢɹ). Ɏɚɤɬɢɱɟɫɤɢ, ɷɬɚ ɨɩɰɢɹ ɨɬɤɥɸɱɚɟɬ ɭɱɟɬ ɪɟɝɢɫɬɪɚ.

-n

ɋɨɪɬɢɪɨɜɤɚ ɜ ɫɨɨɬɜɟɬɫɬɜɢɢ ɫ ɱɢɫɥɨɜɵɦ ɡɧɚɱɟɧɢɟɦ ɩɨɥɹ.

-t

Ɉɩɰɢɹ ɢɡɦɟɧɹɟɬ ɫɢɦɜɨɥ-ɪɚɡɞɟɥɢɬɟɥɶ ɩɨɥɟɣ. ɉɨ ɭɦɨɥɱɚɧɢɸ ɞɥɹ ɨɬɞɟɥɟɧɢɹ ɩɨɥɟɣ ɞɪɭɝ ɨɬ ɞɪɭɝɚ sort ɢɫɩɨɥɶɡɭɟɬ ɩɭɫɬɨɣ ɫɢɦɜɨɥ.

-u

ȿɫɥɢ ɜɨ ɜɯɨɞɧɵɯ ɞɚɧɧɵɯ ɩɪɢɫɭɬɫɬɜɭɸɬ ɨɞɢɧɚɤɨɜɵɟ ɫɬɪɨɤɢ, ɜ ɨɬɫɨɪɬɢɪɨɜɚɧɧɨɦ ɜɵɜɨɞɟ ɩɟɱɚɬɚɟɬɫɹ ɬɨɥɶɤɨ ɨɞɧɚ ɬɚɤɚɹ ɫɬɪɨɤɚ.



ȼɵɜɨɞ ɨɬɫɨɪɬɢɪɨɜɚɧɧɵɯ ɞɚɧɧɵɯ ɜ ɨɛɪɚɬɧɨɦ ɩɨɪɹɞɤɟ.



ȼɵɜɨɞɢɬ ɪɟɡɭɥɶɬɚɬ ɧɟ ɧɚ ɷɤɪɚɧ, ɚ ɜ ɮɚɣɥ, ɢɦɹ ɤɨɬɨɪɨɝɨ ɫɥɟɞɭɟɬ ɡɚ -ɨ. ɗɬɚ ɨɩɰɢɹ ɞɚɟɬ ɬɨɬ ɠɟ ɷɮɮɟɤɬ, ɱɬɨ ɢ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɟ ɜɵɜɨɞɚ ɜ ɮɚɣɥ (ɩɨɞɪɨɛɧɟɟ ɨ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɢ ɜɜɨɞɚ-ɜɵɜɨɞɚ ɪɚɫɫɤɚɡɚɧɨ ɞɚɥɟɟ ɜ ɷɬɨɣ ɝɥɚɜɟ).

,

-m, sort

, 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. ,

. filel $ tr -d

'AB '

tr file2:

< 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 (~). , /etc/passwd: $ cut -f 1 -d':' /etc/passwd frank bob alice joe simba lee

.

,

cut

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

,

.

, Web-

,

- :

,

log,

. . . ,

, awk.

sed

,

-

. 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, --

. ,

, filel, $

tr

tr, file2:

'a-z'

'A-Z'

(

,

. :

< filel > file2

,


,

,

.)

$ cut -fl -d'

' access.log | sort | uniq -

NCSA,

: | more log-

Web1,

: ,

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 !

(

Ctrl+D (tcsh).

,

)

$ has[Tab] basename bash

tcsh.

bashbug

Tab

:

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

showuploads.cgi*

. . 100

tcsh

). .

Enter. .

bash — ,

, .bash_history.

: tcsh — "

" . -

rm ~/.history .

-

, ,

, .

.history,

, ,

. rm ~/.bash_history,

3

Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD



Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD



ɉɨɥɶɡɨɜɚɬɟɥɢ, ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ



Ʉɨɧɮɢɝɭɪɚɰɢɹ ɫɢɫɬɟɦɵ ɢ ɫɬɚɪɬɨɜɵɟ ɫɢɟɧɚɪɢɢ

◀ ɇɚɫɬɪɨɣɤɚ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ◀ ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

ɧɚ

ɹɡɵɤɟ

ɤɨɦɚɧɞɧɨɝɨ

◀ Ɇɨɧɢɬɨɪɢɧɝ ɩɪɨɢɡɜɨɞɢɬɟɩɶɧɨɫɬɢ, ɭɩɪɚɜɥɟɧɢɟ ɩɪɨɰɟɫɫɚɦɢ ɢ ɚɜɬɨɦɚɬɢɡɚɰɢɹ ɡɚɞɚɧɢɣ ◀

ɍɫɬɚɧɨɜɤɚ ɞɨɩɨɥɧɢɬɟɥɶɧɨɝɨ ɩɪɨɝɪɚɦɦɧɨɝɨ ɨɛɟɫɩɟɱɟɧɢɹ



ɉɟɱɚɬɶ



Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ



ɉɨɞɞɟɪɠɤɚ FreeBSD



0 ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ



Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD



Ɉɫɧɨɜɵ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɹ ɧɚ ɹɡɵɤɟ Perl

9 Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

◀ ɋɬɪɭɤɬɭɪɚ ɤɚɬɚɥɨɝɨɜ FreeBSD ◀ Ɇɨɧɢɬɨɪɢɧɝ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɮɚɣɥɨɜɨɣ ɫɢɫɬɟɦɵ ◀ Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ FreeBSD ◀ Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɞɪɭɝɢɯ ɨɩɟɪɚɰɢɨɧɧɵɯ ɫɢɫɬɟɦ

ɫɢɫɬɟɦ

◀ Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ CD-ROM ɢ ɮɥɨɩɩɢ-ɞɢɫɤɨɜ ◀ ɉɨɧɢɦɚɧɢɟ ɮɚɣɥɚ /etc/fstab



ɉɪɨɜɟɪɤɚ ɢ ɜɨɫɫɬɚɧɨɜɥɟɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ ɫ ɩɨɦɨɲɶɸ ɭɬɢɥɢɬɵ fsck

◀ ɍɫɬɚɧɨɜɤɚ ɢ ɢɫɩɨɥɶɡɨɜɚɧɢɟ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɯ ɤɜɨɬ ɮɚɣɥɨɜɨɣ ɫɢɫɬɟɦɵ

166

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

, ,

FreeBSD, ,

. . FFS (BSD Fast File System, , UFS (Universal File System, UNIX).

FreeBSD BSD). BSD File System ( !

UNIX ) ,

, mount),

UFS

.

BSD

UFS,

,

"

BSD FFS — NetBSD

UNIX

,

(

-

,

FreeBSD). Linux, NTFS, a Windows 95/98/Me — VFAT. ,

" UFS FreeBSD.

, Mac OS X ( ,

FreeBSD, OpenBSD, , Darwin, Ext2FS, Windows NT .

ɉɊɂɆȿɑȺɇɂȿ Ȼɨɥɟɟ ɩɨɥɧɵɣ ɨɛɡɨɪ ɪɚɡɥɢɱɧɵɯ ɬɢɩɨɜ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ, ɫɭɳɟɫɬɜɭɸɳɢɯ ɜ ɫɨɜɪɟɦɟɧɧɨɦ ɤɨɦɩɶɸɬɟɪɧɨɦ ɦɢɪɟ, ɦɨɠɧɨ ɧɚɣɬɢ ɩɨ ɚɞɪɟɫɭ http://www.penguin.cz/~mhi/fs/.

FreeBSD ,

UNIX FreeBSD,

. ,

UNIX,

, (

.

FreeBSD UNIX Windows Macintosh, .

Linux, Solaris , FreeBSD UNIX, .

,

(

.

. 9.1).

-

. 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

, Linux, ,

: "

, ,

FreeBSD. -

UNIX.

, -

/usr/local".

FreeBSD — ( .

15). /var/lib,



FreeBSD

/etc,

, /usr/local/lib

,

/usr/local/etc.

-

,

/usr/local/etc, ,

/usr/

local/etc/rc.d. /etc/rc.d. FreeBSD, (

,

,

).

,

-

/usr/local ,

.

, . Linux

, , ,

, FreeBSD. , , /usr/bin/python,

, Solaris, FreeBSD , , Python ,

FreeBSD. —

Linux, FreeBSD, ,

,

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

,

.

/usr/bin/python, FreeBSD

man hier.

. Python Python,

169

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

Ɇɨɧɢɬɨɪɢɧɝ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɮɚɣɥɨɜɨɣ ɫɢɫɬɟɦɵ UNIX-

, (mount points). , :),

Windows, DOS

( .

ROM

:, D:

Windows/

,

CD.

:,

UNIX ,

. . Windows

: , UNIX

, , (

.

. 9.2).

9.2 FreeBSD (UNIX) Windows.

/dev/adO s1a FreeBSD

,

-

: -

(

).

, .

Mac OS

Windows ,

. .

FreeBSD

,

, ,

"

"

,

, -

.

Ʉɨɦɚɧɞɚ df df (disk free —

)— ;

-

170

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

(

df .

14).

-

,

.

df

: 1K-blocks 49583 4254901 19815 4

Filesystem /dev/adOsla /dev/adOslf /dev/adOsle proofs

Used 28427 1959405 12058 4

(slice)

Avail 17190 1955104 6172 0

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

on

(partition) . IDE (/dev/adO),

/usr

/var.

20

.

,

, /, . , a /var — ,

FreeBSD 50 /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 . ( (summary), .

, -d, ).

-

du,

,

, -s

: man du. .

-

,

.

: .

(quotas).

171

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ FreeBSD UNIX(/dev/adO)

, /dev/adl. (

-

.

(primary slave). /dev/daO . .)

SCSI (

19)

, . (

-

.)

Ʉɨɦɚɧɞɚ mount ,

,

, .

( /usr/home. He

df

du),

-



/usr

, .

(40

).

50 FreeBSD — /dev/adlsle (100 )

(

.

), /dev/adlslf (8

/dev/ad slg . /home 40. /usr/home, /usr/home , , mv /home

— , /home —

.) /home.old.

,

, rm /home. ( /home — ,

)

-

. ,

;

,

,

(union .)

.( filesystems), mkdir /home. . FreeBSD

:

/dev/adlslg # mount

/dev/adlslg

. 40-

mount /home

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

df: 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/acdO (slice mode)

/dev/adlsle, /dev/ad3sl —

, (dedicated mode).

,

.

19.

mount .

-f, ,

,

. -f. "

,

-

, , "

, . .

,

.

-

,

fsck ( ), options,

. (

.

),

-

, -

-

,

,

-r (

.

rdonly) mount

.

,

man mount.

Ʉɨɦɚɧɞɚ umount , umount ( #

umount

— "unmount"). :

/home,

/home

umount /dev/adlslg, a umount ,

. , -

. .

,

,

,

/usr .

,

/home ,

, mount :

/var,

. umount,

,

/home,

,

, . ! : Device busy (

173

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

).

: mount, . ;

cd /. umount

-f,

-

.

Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ ɞɪɭɝɢɯ ɨɩɟɪɚɰɢɨɧɧɵɯ ɫɢɫɬɟɦ FreeBSD. , , Linux, Windows 98 FreeBSD

, NT?

, . ,

. 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 , . , , . /sbin:

, , MSDOSFS),

mount_od9660* mount_devfs* mount_ext2fs* mount_fdesc* mount_kernfs* mount_linprocfs*

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

, ( , FreeBSD

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 mount_msdos.

FreeBSD. ,

MSDOSFS ,

, -W

-L,

, FAT32/VFAT. ISO 8859-1,

, ..

-

, root.

# mount_msdos /dev/adlsl /mnt

: , FreeBSD (partitions) BSD,

DOS (slices),

Linux

"

" (partitions) -

.

175

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

Windows 98

,

/dev/adlsl

,

, FreeBSD, ( /dev/adlslg). DOS (extended DOS partition), — Invalid argument ( ). DOS : /dev/adls5. MS-DOS UID/G1D , root;

,

-

5,

,

: ;

,

. . 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)

1

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:

Ф

К

FreeBSD) (sysid]. 131, FreeBSD — 165. К , я я /usr/src/sbin/i386/fdisk/fdisk.c.

[ Linux Ext2FS fdisk,

Ɇɨɧɬɢɪɨɜɚɧɢɟ ɢ ɞɟɦɨɧɬɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ CD-ROM ɢ ɮɥɨɩɩɢ-ɞɢɫɤɨɜ — CD-ROM CD9660, , MS-DOS.

,

.

CD-ROM FFS (

FreeBSD),

Ɇɨɧɬɢɪɨɜɚɧɢɟ ɤɨɦɩɚɤɬ-ɞɢɫɤɨɜ ɢ ɞɢɫɤɟɬ .

CD-ROM IDE

SCSI — . -

/dev/acdOc,

/dev/cdOc, , (dedicated mode).

"

"

ɋɈȼȿɌ Ɉ ɬɟɤɭɳɟɦ ɫɨɝɥɚɲɟɧɢɢ ɨɛ ɢɦɟɧɚɯ ɦɨɠɧɨ ɭɡɧɚɬɶ ɩɨ ɚɞɪɟɫɭ http://www.FreeBSD.org/ handbook/disks-naming, html. # mount_cd9660

/dev/acdOc

/cdrom

-

.

, — fdcO. -

fdO • •

fdl

mount /dev/fdO /floppy mount_msdos /dev/fdO /floppy

,

,

/dev/fdO; ,

ISA, .

177

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

:

-

,

CD-ROM

,

FreeBSD !

-

.

,

-

rdonly, ,

, — . CD-ROM rdonly,

-

-

!

Ⱦɟɦɨɧɬɢɪɨɜɚɧɢɟ ɤɨɦɩɚɤɬ-ɞɢɫɤɨɜ ɢ ɞɢɫɤɟɬ -

, ,

.

: Windows

.

Mac OS

-

, . FreeBSD (

UNIX

86)

-

,

, . CD-ROM

-

(

). ,

. ,

,

-

,

,

-

. ,

, ,

.

: -

(umount/cdrom)

(umount/floppy)

.

,

Ⱦɪɭɝɢɟ ɫɦɟɧɧɵɟ ɧɨɫɢɬɟɥɢ ,

, USB

DVD. FreeBSD Zip —

FireWire,

Zip Zip umass. ,

-

. . vpO, a USB, . —

.

ɉɨɧɢɦɚɧɢɟ ɮɚɣɥɚ /etc/fstab : ,

.

,

, ,

IDE,

178

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

NFS,

MS-DOS ? !

SCSI-

CD-ROM, — cat /etc/fstab:

/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

, :

-

, ,

, .

mount. . , ,

fstab

fstab — . : mount - . , preen (

fsck -p, . . clean (

),

, mount -a -t nonfs — /etc/fstab, NFS.

). , ,

. -

/etc/fstab, ,

mount;

:

# mount /home

fstab, UFS ( ,

/dev/adOslg #

.

, , FFS),

-

:

mount /floppy

, noauto, ,

! /cdrom CD-ROM noauto

,

/floppy .

mount, NFS,

-

-

. ,—

. fstab

mount,

.

, man mount

,

,

-

man mount_*,

. /etc/fstab — fsck ( .

"Pass#"; ). ,

, ,

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) "

,

(investigative mode). ,

" , (

fsck ,

. . ,

. man fsck), fsck

.

. ,

,

.

, ,

.

,

-

,

,

, . #.

fsck boot ,

reboot.

,

-

. ,

fsck

. ,

!

,

.

(single-user mode):

fsck, # shutdown +5

(multiuser mode)

.

,

,

,

.

-

. "

" ,

,

fsck. ,

,

dmesg (

root) , . fsck fsck -p /dev/adlslg) ( ) . fsck , , . , fstab .

( (

exit)

fsck /etc/fstab. ,

,

).

-

fsck ( .

181

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

,

-

,

!

ɀɭɪɧɚɥɶɧɵɟ ɮɚɣɥɨɜɵɟ ɫɢɫɬɟɦɵ ɢ ɦɹɝɤɨɟ ɨɛɧɨɜɥɟɧɢɟ . (logging)



,

-

.

fsck, —

, FreeBSD

. . —

(Soft Updates). , )—

logFreeBSD 5.0 ,

( ,

log-

.

,

.

,

:

-

, . FreeBSD 5.0 )

(

diskcheckd. ,

,

fsck .

,

man diskcheckd. syslogd (

11). ps:

diskcheckd # ps 251

| ??

grep diskcheckd Ss 0:00.28 diskcheckd:

/etc/diskcheckd.conf; , 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, . ,

(

, . : "/dev/adlslh on /mnt: Incorrect super

), mount 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

Ƚɥɚɜɚ 9. Ɏɚɣɥɨɜɚɹ ɫɢɫɬɟɦɚ FreeBSD

5963808,

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,

9371680,

9830432,

9437216,

9895968,

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,

,

- ),

, ).

( /etc/fstab

. groupquota. /dev/adOslg /dev/adOslf /dev/adOsle

YES ( )

userquota /

:. /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,

). EDITOR,

,

edquota, 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

816

. 2048

,

, -

,

, 8,

.

2048 .

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. ,

, ,

-

, 19,

.

FreeBSD, .

, ,

10 ɉɨɥɶɡɨɜɚɬɟɥɢ ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ

Ʉɨɧɰɟɩɰɢɹ ɩɨɩɶɡɨɜɚɬɟɥɟɣ u ɝɪɭɩɩ ► Ɂɚɱɟɦ ɧɭɠɧɵ ɝɪɭɩɩɵ? ► ȼɥɚɞɟɧɢɟ ɮɚɣɥɚɦɢ ► ɉɪɚɜɚ ɞɨɫɬɭɩɚ ɤ ɮɚɣɥɚɦ ɢ ɤɚɬɚɥɨɝɚɦ ► ɋɩɢɫɤɢ ɭɩɪɚɜɥɟɧɢɹ ɞɨɫɬɭɩɨɦ [ACL] ► Ⱦɨɛɚɜɩɟɧɢɟ ɢ ɭɞɚɥɟɧɢɟ ɭɱɟɬɧɵɯ ɡɚɩɢɫɟɣ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ►

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

188

. ,

-

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,

, ,

NT-

. FreeBSD

,

-

,

.

Ʉɨɧɰɟɩɰɢɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ɢ ɝɪɭɩɩ , UNIX),

.

FreeBSD ( :

-

Ƚɥɚɜɚ 10. ɉɨɥɶɡɨɜɚɬɟɥɢ, ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ

,

root. .

6 ,

(

189

root —

,

. Windows NT/2000) -

, ,

. -

, ,

.

Web26).

,

,

( ,

, -

,

. FreeBSD — root -

root —

,

(home directory). su. root — root ,

.

UNIX-

.

, .

root ,

, .

root (

29).

. .

-

. su , root,



:

wheel. wheel ,

su).

FreeBSD root ( 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. (

, )

"

" , wheel (

. man adduser. /etc/ group).

, root. ,

wheel: root, .

,

,

su. -

Ƚɥɚɜɚ 10. ɉɨɥɶɡɨɜɚɬɟɥɢ, ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ

,

,

191

,

,

(

.

. 10.2).

, . "

"

.

Ɋɢɫɭɧɨɤ 10.2

, .

ȼɥɚɞɟɧɢɟ ɮɚɣɥɚɦɢ .

UNIX

:

,

.

,

-

. ( 1s

- (

,

, . .

. -1 (

10.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

?

, .

drwxr-xr-x, —

(user), . ,

(others) — , :

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

(read), :

(write)

(execute).

(group)

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

7

21:44

for

tempfile

tempfile?

ɂɡɦɟɧɟɧɢɟ ɩɪɚɜ ɜɥɚɞɟɧɢɹ ɮɚɣɥɨɦ ɫ ɩɨɦɨɳɶɸ ɤɨɦɚɧɞɵ chown .

,

root: . chown (change owner —

): #

chown

bob

file.txt

file.txt ( ,

frank,

a frank

)

bob. ,

. :

chown #

bob

chown bob

/home/frank

,

,

10.1).

"." ( ".." 10.1

, /home/frank

.

. bob —

, ,

. ,

,

,

.

,

Ƚɥɚɜɚ 10. ɉɨɥɶɡɨɜɚɬɟɥɢ, ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ

193

. . 10.1.

ɋɈȼȿɌ

Ʉɚɠɞɵɣ ɚɞɦɢɧɢɫɬɪɚɬɨɪ ɞɨɥɠɟɧ ɡɧɚɬɶ ɩɨɥɟɡɧɭɸ ɨɩɰɢɸ ɤɨɦɚɧɞɵ chown: -R. Ɉɧɚ ɡɚɫɬɚɜɥɹɟɬ ɤɨɦɚɧɞɭ ɜɵɩɨɥɧɹɬɶɫɹ ɪɟɤɭɪɫɢɜɧɨ, ɬ.ɟ. ɞɥɹ ɬɟɤɭɳɟɝɨ ɤɚɬɚɥɨɝɚ, ɜɫɟɯ ɮɚɣɥɨɜ ɧɟɦ ɢ ɜɫɟɯ ɮɚɣɥɨɜ ɜɨ ɜɫɟɯ ɩɨɞɤɚɬɚɥɨɝɚɯ, ɧɚɯɨɞɹɳɢɯɫɹ ɧɢɠɟ ɜ ɢɟɪɚɪɯɢɢ. ɗɬɚ ɨɩɰɢɹ ɩɪɢɦɟɧɹɟɬɫɹ, ɧɚɩɪɢɦɟɪ, ɩɪɢ ɜɨɫɫɨɡɞɚɧɢɢ ɭɱɟɬɧɨɣ ɡɚɩɢɫɢ, ɤɨɝɞɚ ɧɟɨɛɯɨɞɢɦɨ ɢɡɦɟɧɢɬɶ ɩɪɚɜɚ ɜɥɚɞɟɧɢɹ ɜɫɟɦɢ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɦɢ ɮɚɣɥɚɦɢ: #

chown

-R bob

/home/frank

ɂɡɦɟɧɟɧɢɟ ɝɪɭɩɩɨɜɵɯ ɩɪɚɜ ɜɥɚɞɟɧɢɹ ɮɚɣɥɨɦ ɫ ɩɨɦɨɳɶɸ ɤɨɦɚɧɞɵ chgrp — chgrp.

chown , #

chgrp

users

.

:

contents.html

:

contents.html -rw-rw-r--

1 bob

users

2703 Dec 22

1998

, users FreeBSD ,

contents.html

, ,

bob

bob. :

-

bob.

:

bob, bob, bob

bob.

( .

, frank) . -

,

frank

chgrp —

chown; :

#

chown

bob.users

contents.html

bob

contents.html

users.

: #

chown

.users

chown,

chgrp

contents.html

.

-R,

ɉɪɚɜɚ ɞɨɫɬɭɩɚ ɤ ɮɚɣɥɚɦ ɢ ɤɚɬɚɥɨɝɚɦ 10.1. .

, ,

— d.

,

. ,

, • 4

:



( w—

ls); (

), ; 5

— -

, .

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD _____________________________________

194

, (d),

,

,

drwxr-xr-x

, .

:

, —

.

"

".

, . .

ȼɡɚɢɦɨɫɜɹɡɶ ɦɟɠɞɭ ɩɪɚɜɚɦɢ ɞɨɫɬɭɩɚ ɮɚɣɥɨɜ ɢ ɤɚɬɚɥɨɝɨɜ . 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 ɞɨɫɬɭɩ ɧɚ ɱɬɟɧɢɟ

,

"

" — 5,

"

"

-

6, " -- 7. , . 10.3.

,

.

"

-

Ɍɚɛɥɢɰɚ 10.3 ɉɪɚɜɚ ɞɨɫɬɭɩɚ ɜ ɱɢɫɥɟɧɧɨɣ ɮɨɪɦɟ 755

ɱɬɟɧɢɟ/ɡɚɩɢɫɶ/ɜɵɩɨɥɧɟɧɢɟ ɞɥɹ ɜɥɚɞɟɥɶɰɚ, ɱɬɟɧɢɟ/ɜɵɩɨɥɧɟɧɢɟ ɞɥɹ ɝɪɭɩɩɵ ɢ

644

ɱɬɟɧɢɟ/ɡɚɩɢɫɶ ɞɥɹ ɜɥɚɞɟɥɶɰɚ, ɬɨɥɶɤɨ ɱɬɟɧɢɟ ɞɥɹ ɝɪɭɩɩɵ ɢ ɨɫɬɚɥɶɧɵɯ

600

ɱɬɟɧɢɟ/ɡɚɩɢɫɶ ɞɥɹ ɜɥɚɞɟɥɶɰɚ, ɞɥɹ ɝɪɭɩɩɵ ɢ ɨɫɬɚɥɶɧɵɯ ɞɨɫɬɭɩɚ ɧɟɬ

ɨɫɬɚɥɶɧɵɯ

: #

chmod

755

testscript.sh

,

"

"

: .

-

,

6 7

.

0— 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) ,

5.0.

FreeBSD

. ,

, (maximum ACL. ACL

. permission

mask),

, UFS.

,

,

.

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɩɨɞɞɟɪɠɤɢ ACL ɜ ɹɞɪɟ ,

FreeBSD 5.0

(UFS Extensions)

UFS

. .

,

,

-

. , UFS Intel x86 i386/conf/GENERIC, ACL , options options options

. Alpha —

, - , /usr/src/sys/ /usr/src/sys/alpha/conf/GENERIC. :

UFS__EXTATTR UFS__EXTTR__AUTOSTART UFS__ACL

, .

,

.

,

,

,

17. ,

ACL.

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ ɞɥɹ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ACL , ,

extattrctl. .

,

ACL

/usr,

:

, .attribute/system: mkdir

ACL -

/usr/.attribute

extattrctl

root,

/usr/.attribute

/usr/.attribute/system

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

extattrctl initattr -p /usr 388 posixle.acl_access

/usr/

198

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

. (

):

extattrctl initattr -p /usr 388 posixle.acl_default ,

.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ Ɏɚɣɥɵ, ɫɨɡɞɚɜɚɟɦɵɟ ɩɪɟɞɵɞɭɳɢɦɢ ɤɨɦɚɧɞɚɦɢ, ɦɨɝɭɬ ɞɨɫɬɢɝɚɬɶ ɱɪɟɡɜɵɱɚɣɧɨ ɛɨɥɶɲɢɯ ɪɚɡɦɟɪɨɜ — ɞɨ ɧɟɫɤɨɥɶɤɢɯ ɝɢɝɚɛɚɣɬ ɧɚ ɛɨɥɶɲɢɯ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ. ɉɨɷɬɨɦɭ ɞɨ ɡɚɩɭɫɤɚ ɤɨɦɚɧɞ ɭɛɟɞɢ-ɬɟɫɶ, ɱɬɨ ɧɚ ɠɟɫɬɤɨɦ ɞɢɫɤɟ ɢɦɟɟɬɫɹ ɞɨɫɬɚɬɨɱɧɨ ɫɜɨɛɨɞɧɨɝɨ ɩɪɨɫɬɪɚɧɫɬɜɚ.

,

.

ACL

.

ɉɨɥɭɱɟɧɢɟ ɢɧɮɨɪɦɚɰɢɢ ɨ ɬɟɤɭɳɢɯ ɭɫɬɚɧɨɜɤɚɯ ACL ACL,

getfacl. ACL

-

acltest.txt getfacl acltest.txt

644 :

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

.



(

root). ,

. .

ɍɫɬɚɧɨɜɤɚ ɦɚɫɤɢ ɦɚɤɫɢɦɚɥɶɧɵɯ ɩɪɚɜ ɞɨɫɬɭɩɚ (

,

(maximum permissions mask) ),

,

-

ACL. ,

ACL

. ,

,

.

ACL,

, .

,

ACL :

setfacl. setfacl

action

permissions

action — acltest.txt

(

filename

, ACL, filename —

,

. .), permissions — . 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:: .

,

-m

,

ACLr

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

.

, . (

,

, -n.

), ,

, setfacl -n -m u:foobar:rw acltest.txt

ACL ACL

foobar, :

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



guest

visitors.

,

foobar, -n

Ƚɥɚɜɚ 10. ɉɨɥɶɡɨɜɚɬɟɥɢ, ɝɪɭɩɩɵ ɢ ɩɪɚɜɚ ɞɨɫɬɭɩɚ 201

, ,

.

Ɂɚɩɪɟɳɟɧɢɟ ɞɨɫɬɭɩɚ ɫ ɩɨɦɨɳɶɸ ACL ACL , -

, ACL

.

,

foobar,

:

setfacl -m u:foobar: acltest.txt

foobar

-

-

acltest.txt, . ACL

,

,

.

ɍɞɚɥɟɧɢɟ ɡɚɩɢɫɢ ɢɡ ACL -

ACL.

setfacl

,

-

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

ɍɞɚɥɟɧɢɟ ɜɫɟɯ ɡɚɩɢɫɟɣ ɢɡ ACL ACL

-b.

: setfacl -b

acltest.txt

ACL,

ACL getfacl setfacl.

,

Ⱦɨɛɚɜɥɟɧɢɟ ɢ ɭɞɚɥɟɧɢɟ ɭɱɟɬɧɵɯ ɡɚɩɢɫɟɣ ɩɨɥɶɡɨɜɚɬɟɥɟɣ , adduser adduser

, . adduser. Linux, root.

useradd,

.

-

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. -

— GID,

(UID ). .

. , UID

. . (

rmuser, ), 10.3 I rmuser j oe Matching password

rmuser ________________________________ entry:

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

adduser

10.3.

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:

matching password entry (

is

empty)

done.

)

,

.

.

Ɏɚɣɥɵ /etc/passwd ɢ /etc/master.passwd ,

UNIX,

/etc/passwd,

. (

).

(vi, pico,

, emacs

.). :

204

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

/etc/passwd, , root. . /etc/security/master.passwd. FreeBSD passwd , : , , , , , ", " "). /etc/passwd , /etc/passwd, root — , . FreeBSD /etc/passwd: joe:*:1008:1008:Joe

/etc/shadow, /etc/ master.passwd. , (:). - , ( , :" ", " 0644, a /etc/master.passwd —

0600. , /etc/master.passwd, MD5.

User:/home/joe:/bin/csh

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

. .

--

25

User:/home/joe:

, .

FreeBSD /etc/passwd

/etc/pwd.db db, .

/etc/master.passwd,

pwd_mkdb adduser/rmuser. chfn (change full name —

chfn, passwd .

) edquota,

9,

,

chfn — vi).

/etc/ spwd.db.

EDITOR ( -

, /etc/master.passwd .

-

,

pwd_mkdb -p /etc/master.passwd. FreeBSD-

master.passwd

,

/etc

: #

pwd_mkdb

-p

/etc/master.passwd.new

, master.passwd.new. /etc/master.passwd /etc/spwd.db /etc/passwd . pwd_mkdb /etc/passwd; . .

-

/etc , a /etc/ pwd.db, , /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,

-

, .

,

OS.

, (

, ,

"

Windows

Mac ,

")

. UNIX, Linux.

FreeBSD ,

,

fsck

, ,

LILO (

FreeBSD

Linux). (runlevel), ,

,

Linux. A boot, FreeBSD Linux Solaris. , , .

ɉɨɧɢɦɚɧɢɟ ɩɪɨɰɟɫɫɚ ɧɚɱɚɥɶɧɨɣ ɡɚɝɪɭɡɤɢ FreeBSD (bootstrapping process) FreeBSD . .

, , . -

,

BIOS ,

CMOS. IDE

, —

SCSI. .

,

. .

BIOS

(Master Boot Record) (MBR) . MBR



-

,

. .

512 ). 0 (bootO).



(.. . MBR

, MBR -

, . Fl FreeBSD F2

Linux

F3

??

Default:

Fl

.

,

,

. •

1 (bootl). (slice),

, bootO.

-

208

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

disklabel, ( boot2. , 2 (bootl).

#

19) .

boot l , ,

,

,

. FreeBSD (

,

, -

). (loader),

,

. #

(loader).

/boot. /boot/defaults/loader.conf /boot/loader.conf, .( /boot/loader.conf , /boot/defaults/loader.conf, /etc/rc.conf, .) 10 . , . , : (single-user mode) boot -s, 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, )

,

. ) ,

, Enter, — boot (

)

, ,

Ox4c)

? load ( ,

-

Ismod (

). ,

. man loader. ,

, FreeBSD: ,

. ,

Ƚɥɚɜɚ 1 1 . Ʉɨɧɮɢɝɭɪɚɰɢɹ ɫɢɫɬɟɦɵ ɢ ɫɬɚɪɬɨɜɵɟ ɫɰɟɧɚɪɢɢ 209



(resource configuration), . (kernel). ,

,

-

. .

dmesg, dmesg.

ɋɈȼȿɌ dmesg ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɞɨɜɨɥɶɧɨ ɩɪɢɦɢɬɢɜɧɨɟ ɫɪɟɞɫɬɜɨ, ɤɨɬɨɪɨɟ ɥɢɲɶ ɜɵɜɨɞɢɬ ɧɚ ɷɤɪɚɧ ɜɫɟ ɫɨɨɛɳɟɧɢɹ, ɧɚɤɨɩɥɟɧɧɵɟ ɜ ɩɪɨɰɟɫɫɟ ɡɚɝɪɭɡɤɢ ɫɢɫɬɟɦɵ. Ⱦɨɫɬɚɬɨɱɧɨ ɩɪɨɫɬɨ ɜɜɟɫɬɢ ɤɨɦɚɧɞɭ dmesg, ɢɥɢ dmesg I less ɞɥɹ ɛɨɥɟɟ ɭɞɨɛɧɨɝɨ ɱɬɟɧɢɹ.

,

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

• init. init, ). fstab, 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);

.

DNS,

/etc/ , ,

. , ; resolv.conf. ( ,

Sendmail,

Apache,

TCP/IP

23.) , .

-

, .

?

/etc/resolv.conf, Sendmail Apache . 127.0.0.1 (localhost) , init (NFS)

.

, FreeBSD-

, ;

,

, mount,

. mount -a -t nonfs . ,

,

9,

NFS ( ). NFS,

init /etc/re. /etc/fstab (

, NFS. ,

noauto) .

NFS, !

ɋɰɟɧɚɪɢɢ ɤɨɧɮɢɝɭɪɢɪɨɜɚɧɢɹ ɪɟɫɭɪɫɨɜ /etc, .

, ,

,

-

11.

211

FreeBSD -

. ,

,

. -

/etc

, . /etc/rc.conf. FreeBSD,

,

. 11.1.

11.1 config.

/etc/re /etc/rc.diskless1

init

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

init

. , ,

. /etc/

/etc/rc.conf 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

ATM-

re.network; WAN.

/etc/rc.firewall

re.network; ipfw.

/etc/rc.firewall6

re.networkG; ip6fw.

/etc/re.i386

,

86 (

,

).

/etc/re.shutdown /etc/re.suspend

.

init ,

.

/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/defaults/

/etc/rc.conf

, ,

rc.conf. . .)

(IP, , sendmail sshd. /etc/defaults/rc.conf,

,

. -

,

11.1. Ʌɢɫɬɢɧɝɟ 11.1 Ɏɪɚɝɦɟɧɬ ɮɚɣɥɚ /etc/defaults/rc.conf # named #s e c u r i t y . # named_enable=MNO"

sandbox, # # ( # #

named_program="named" named_flags="" #named_flags="-u

bind

, " ; ).

-g bind"

named,

. DNS-

man (

NO

)). named, . # #

named. 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

, , , /etc/rc (

init, YES.

,

"

" named). .

bind, , ,

).

(

-

,

mynamed.

( mynamed /etc/rc.conf

,

named), —

: named_program="mynamed" named_flags="-u bind -g

bind"

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

/etc/re* case ${

,

,

named_enable)

in

/etc/rc.network. :

, network_pass2 () echo

init:

{

-n

'Doing

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

additional

network

setup:' case

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

;; esac

,

rc.conf ; Doing additional network setup: -

named_* , ,

named, . ɉɊɂɆȿɑȺɇɂȿ

Ɉ ɫɨɡɞɚɧɢɢ ɫɰɟɧɚɪɢɟɜ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ɱɢɬɚɣɬɟ ɜ ɝɥɚɜɟ 13. ɗɬɨ ɩɨɦɨɠɟɬ ɜɚɦ ɜ ɞɚɥɶɧɟɣɲɟɦ ɩɪɢ ɢɡɭɱɟɧɢɢ ɫɰɟɧɚɪɢɟɜ ɤɨɧɮɢɝɭɪɢɪɨɜɚɧɢɹ ɪɟɫɭɪɫɨɜ.

, TCP/IP. FreeBSD /etc/rc.conf

,

/etc/rc.conf ,

,

.

11.2 :

-

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-

)

. ; . sysinstall (

/etc/rc.conf ). ),

,

,

(

,

/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 ( Configuration for Daemons — init /etc/re.*.

Resource ). ,

/usr/local/etc/rc.d ,

. apache.sh, mysql-server.sh ,

samba.sh. start ,

init

.sh, ,

,

-

,

stop;

,

start. ,

: # /usr/local/etc/rc.d/apache.sh

start

.sample ( . Apache,

, config (

-

, ,

).

, apache.sh,

.

,

;

,

Samba ,

. .sample), /usr/local/XHR6/etc

(

, -

,

samba.sh.sample).

, init. /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. rc.d -

,

init

.sh (

start ). man re: #!/bin/sh

-

#

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

/

-d

&&

foobar

echo

-n

'

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 , /etc,

.conf

— inetd,

.

. inetd . inetd telnet,

,

.

telnet-

, telnetd. 23, ,

inetd (

, telnetd -

. ), ,

/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

/ ɋɟɪɜɟɪ biff (ɭɜɟɞɨɦɥɟɧɢɟ

comsat

ɉɨɪɬ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

ɉɨɪɬ 25/ɌɋɊ

Qmail (ɚɥɶɬɟɪɧɚɬɢɜɚ SMTP-ɫɟɪɜɟɪɭ Sendmail)

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"

FreeBSD,

inetd .

/etc/inetd.conf, ,

,

cvs , .

Samba ,

. ,

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

218

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

( /usr/Iocal/libexec. /usr/local, .

,

,

) , ,

-

qpopper ( qpopper popper.

inetd. ),

: stream top

nowait root /usr/local/libexec/qpopper qpopper

.

. man

,

inetd

inetd 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, logsyslogd; 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 *

: notice,

, debug

err

,

, , /var/log/security, /var/log/maillog. log-

( . . ).

crit FreeBSD,

.( syslog.)

info /var/log/messages — ,

Linux, .

logsyslog.conf

,

,

Ƚɥɚɜɚ 11. Ʉɨɧɮɢɝɭɪɚɰɢɹ ɫɢɫɬɟɦɵ ɢ ɫɬɚɪɬɨɜɵɟ ɫɰɟɧɚɪɢɢ

err, notice emerg —

root, 11.4

219

alert . syslogd

. 11.4

syslogd

/path/to/file

ɋɨɨɛɳɟɧɢɹ ɡɚɩɢɫɵɜɚɸɬɫɹ ɜ ɭɤɚɡɚɧɧɵɣ ɮɚɣɥ.

@some.hostname.com

ɋɨɨɛɳɟɧɢɹ ɩɟɪɟɧɚɩɪɚɜɥɹɸɬɫɹ ɞɟɦɨɧɭ syslogd ɧɚ ɦɚɲɢɧɟ some.hostname.com (ɫ ɢɫɩɨɥɶɡɨɜɚɧɢɟɦ ɫɟɬɟɜɨɣ ɫɥɭɠɛɵ syslog).

userl

ɋɨɨɛɳɟɧɢɹ ɜɵɜɨɞɹɬɫɹ ɧɚ ɥɸɛɨɣ ɬɟɪɦɢɧɚɥ, ɫ ɤɨɬɨɪɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɶ userl ɡɚɪɟɝɢɫɬɪɢɪɨɜɚɥɫɹ ɜ ɫɢɫɬɟɦɟ.

root,userl ,user2

ɋɨɨɛɳɟɧɢɹ ɨɬɨɛɪɚɠɚɸɬɫɹ ɧɚ ɬɟɪɦɢɧɚɥɚɯ ɜɫɟɯ ɭɤɚɡɚɧɧɵɯ ɩɨɥɶɡɨɜɚɬɟɥɟɣ. ɋɨɨɛɳɟɧɢɹ ɜɵɜɨɞɹɬɫɹ ɜɫɟɦ ɡɚɪɟɝɢɫɬɪɢɪɨɜɚɧɧɵɦ

*

ɩɨɥɶɡɨɜɚɬɟɥɹɦ. ɋɨɨɛɳɟɧɢɹ ɩɟɪɟɫɵɥɚɸɬɫɹ ɩɨɥɶɡɨɜɚɬɟɥɸ root ɩɨ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɟ.

| "mail 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, — . , : /usr/local /etc/rc.local, .

, rc.d, . , , ,

,

/etc. .

, rc.local ,

,

rc.d. , -

FreeBSD. rc.local

11.3.

/etc/rc,

220

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

Ʌɢɫɬɢɧɝ 11.3 Ɏɪɚɝɦɟɧɬ ɮɚɣɥɚ /etc/rc, ɞɟɦɨɧɫɬɪɢɪɭɸɳɢɣ ɩɨɞɞɟɪɠɤɭ /etc/ɝɫ.local # grep - 5 re.local /etc/rc # ( # . # /etc/defaults/rc.conf # /etc/rc.conf, # # Use /etc/rc.local # # --- re.local --# if [ -r /etc/defaults/rc.conf ]; • . /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 # ----------------------------------

)

rc.local, , . /etc/rc.

then

daemons:'

$local_startup,

, , —

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

12

ɇɚɫɬɪɨɣɤɚ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

ɑɬɨ ɬɚɤɨɟ ɤɨɦɚɧɞɧɵɣ ɢɧɬɟɪɩɪɟɬɚɬɨɪ? ► Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦɢ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚɦɢ ► ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɚɥɶɬɟɪɧɚɬɢɜɧɵɯ ɤɨɦɚɧɞɧɵɯ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɜ ► Ɏɚɣɥɵ ɢɧɢɰɢɚɥɢɡɚɰɢɢ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ► ɇɚɫɬɪɨɣɤɚ ɫɪɟɞɵ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ► ɉɟɪɟɦɟɧɧɵɟ ɫɪɟɞɵ ɢ ɩɟɪɟɦɟɧɧɵɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ►

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

222

, X-Window,

FreeBSD ,

,

-

.

,

,

.

.

? 8. , ,

FreeBSD. : .

,

(shell)

, Windows, , UNIX , . 17). ,

!

Windows Mac OS. COMMAND.COM MS-DOS, . . (shell). , , , ( . ? . 12.1. -

. " .

"

,

-

, ,

. ɨɛɨɥɨɱɤɚ

Ɋɢɫɭɧɨɤ 12,1 ,

ɩɨɥɶɡɨɜɚɬɟɥɶ

Ƚɥɚɜɚ 12. ɇɚɫɬɪɨɣɤɚ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ



223

,

.

, , .

,

,

, . (shell)

.

, . Windows 95 ,

, ,

(Windows 3.1, DESQview " " DOS ( . . ,

DOS). ).

-

MS-

, .

" ( . .

" (shelling out) DOS UNIX). FreeBSD,

8 , sh, csh, bash, ksh

.

, tcsh.

, .

-

13 Bourne (sh),

. .

Ɋɚɛɨɬɚ ɫ ɤɨɦɚɧɞɧɵɦɢ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚɦɢ FreeBSD tcsh,

, /bin/tcsh. bash (

,

FreeBSD Linux), BSD Linux),

System V (

UNIX.

. UNIX .

,

Linux FreeBSD GNU BSD. bash, FreeBSD — tcsh. GNU, Linux

Linux bash , Public License, GPL), bash

Linux

,

, bash -

,

,

tcsh , .

.

Linux,

GNU (GNU , -

bash

.

, ksh

:

zsh.

, . tcsh

.

bash.

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

224

ɍɫɬɚɧɨɜɤɚ ɤɨɦɚɧɞɧɵɯ ɢɧɬɟɪɩɪɟɬɚɬɨɪɨɜ FreeBSD (

.

15).

. -

, .

(package manager). Packages. -

sysinstall /stand/sysinstall, Configure, CD-ROM ( FreeBSD) FTP. , , .

Shells

(X). .

Enter "

"

Install. .

sysinstall, Exit Install —

Configuration, . /usr/local/bin, man bash.

Exit .

( ) -

, ,

( 15)

, -

.

, /usr/local,

,

(

, FreeBSD).

, ,

/usr/ports sysinstall.

, /usr/ports/shells .

. ( ,

/usr/ports) ,

, ,

44bsd-csh/ Makefileesh README.html bashl/ bash2/

. Makefile, .

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

,

,

root.

/etc/master.passwd /etc/passwd).

10).

root, ,

, ,

,

(

setuid

.

chsh

/etc/shells. ( 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

), ( , telnet

root). FTP

ssh, .

, /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 — , . chsh chpass, chfn : . chsh , vi. pico, ( .) chsh. , . # chsh frank #Changing user database Shell: /bin/tcsh Full Name: Frank Allen Office Location: Office Phone: Home Phone: Other ~ ~

information

for

FreeBSD , -

. ,

, EDITOR. root

frank.

information:

vi

.

. .

, .

vi

, .

,

:q!,

Enter. .

:q! /bin/tcsh

Shell:

, /usr/local/bin/bash. vi ( (change — $, /bin/tcs$

frank . chsh frank), ) w (word — :

tcsh. ).

228

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

tcsh

Escape /bin/bash.

bash

.

(

bin) i (insert . /usr/local /usr/local/bin/bash. :w (write — :q Enter. /etc.

)— Escape. Enter

. ,

),

, /etc/passwd.

/etc/master.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. , FreeBSD ( . 12.1).

/etc/csh.login. ,

Ʌɢɫɬɢɧɝ 12.1 Ƚɥɨɛɚɥɶɧɵɟ ɮɚɣɥɵ /etc/csh.cshrc ɢ /etc/csh.login ____________ # cat /etc/csh.cshrc # $FreeBSD: src/etc/csh.cshrc,v 1.3 # # .cshrc

1999/08/27

23:23:40

peter

Exp

$

csh(l).

# 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

. .login. — /usr/share/skel/dot.cshrc) .

: .cshrc .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) :

/usr/games/fortune

]

&&

: /usr/games/fortune

, 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: ,

.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

532

(

/etc/profile,

, 12.2).

/etc/csh.cshrc) ,

12.2

( /etc/profile

# cat /etc/profile # $FreeBSD: src/etc/profile,v 1.12.2.1 # 6. .profile # 7. , 8. 4.2, 9. BLOCKSIZE=K; export BLOCKSIZE # 10. 11. login.conf(5) , 12. locale13. 14. setlocale(3). # 15. Ч 16. msgs -f 17. 18. mesg

/etc/csh.cshrc

2000/07/31 20:13:26 rwatson Exp $ sh(l). -

charset lang. /usr/share/locale/*

, /etc/csh.login.

/etc/profile bash

,

. .profile, ( Bourne:

PATH)

# /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. .cshrc, a

tcsh

, (

# alias alias alias alias alias alias

):

h='fc -11 j=jobs m=$PAGER 11='Is -laFo1 l='ls -1' 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. \!^ ( . .

,

alias lookup

grep \!

lookup frank. unalias

lookup

— \!:2, \!:3

\!:1), ,

:

/etc/passwd

unalias:

234

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

.

prompt: ,

, Perl. "

"

, ,

, . ,

sed (stream editor — )

,

:

'whoami'@'hostname

|

sed

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

"

, pwd (present working

, ):

directory — # {

-

!.

,

# set prompt="{ { root@www:23}

,

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)

. delete #

stty

-

stty. , , .

backspace :

,

-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 = ; eo12 = ; 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, 60

autologout.

, — .

. : unset

autologout;

, , ,

, — rehash.

bash ,

bash ,

tcsh, alias

11=4s

-

tcsh. .

=,

,

, lookup bash

,

, .

1

-laFo

bash. (primary)

, (PS1

(secondary) . tcsh,

,

bash

PS2), ,

. ( !,

, # {

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, ,

. .

,

-

.

ɉɟɪɟɦɟɧɧɵɟ ɫɪɟɞɵ ,

,

.

, .

,

.

, EDITOR, , BLOCKSIZE . , ,

-

,

chfn

, .

TERM 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. ɇɚɫɬɪɨɣɤɚ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

COLOR

237

- :

gold tcsh

# setenv COLOR gold

B bash

, :

4 COLOR=gold 5 export COLOR

,

.

null

.

ɉɟɪɟɦɟɧɧɵɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ ,

.

.

.

,

,

,

-



. tcsh



bash.

-

set. tcsh

set. ,

# set history noclobber

100 #

tcsh

:

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, -

,

. •

.

, ,

5—10

. •

. 100

,

, .

"for"

-



.

-

, ,

. FreeBSD .



,

. .

FreeBSD

"

-

".

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

240

, . •

.

,

,

, ,

, .

,

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. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɧɚ ɹɡɵɤɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

Bourne, /bin/sh. : /usr/bin/perl, /usr/local/bin/python . . 2 5: . ,



24 I

Perl Python —

(

). .



3

.

4:

# .

. : ,



6: ,

(

. , STDOUT echo STDOUT . "Hello, World!" STDOUT.

echo ). .



7:

echo , ( . .

).

,

, .

,

. -

. • •

.

8: 9:

.

echo exit .(

,

-

.)

,

, ,

.

0,

,

0,

, :

. .

, -

.

, . ,

-

,

.

printf echo ,

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

,

"Hello,

,

printf

World!", Bourne.

World!\n\n!"

.

242

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

,

printf

. ,

(

,

, "n" —

, -

, ).

. ,

echo,

,

printf. .

,

. ,

printf ,

,

. -

printf

printf "Hello, "World!\n\n"

:

" printf

"Hello, World!", , printf

. . printf, "Hello" "World!" printf

echo . :

Ɍɚɛɥɢɰɚ 13.1 ɍɩɪɚɜɥɹɸɳɢɟ ɫɢɦɜɨɥɵ ɮɨɪɦɚɬɢɪɨɜɚɧɢɹ ɜɵɜɨɞɚ ɤɨɦɚɧɞɵ printf

Ɂɜɭɤɨɜɨɣ ɫɢɝɧɚɥ. ȼɨ ɜɪɟɦɟɧɚ ɬɟɥɟɬɚɣɩɨɜ ɧɚ ɦɚɲɢɧɟ ɡɜɟɧɟɥ ɧɚɫɬɨɹɳɢɣ ɡɜɨɧɨɤ. ȼ ɧɚɲɢ ɞɧɢ ɷɬɨɬ ɫɢɦɜɨɥ ɩɨɞɚɟɬ ɫɢɝɧɚɥ ɧɚ ɞɢɧɚɦɢɤ ɤɨɦɩɶɸɬɟɪɚ.





ɉɟɱɚɬɚɟɬ ɫɢɦɜɨɥ "backspace".

\f

ɉɟɱɚɬɚɟɬ ɫɢɦɜɨɥ "ɩɟɪɟɯɨɞ ɤ ɧɨɜɨɣ ɫɬɪɚɧɢɰɟ".

\n

ɋɢɦɜɨɥ ɩɟɪɟɯɨɞɚ ɤ ɧɨɜɨɣ ɫɬɪɨɤɟ.



ȼɵɜɨɞɢɬ ɫɢɦɜɨɥ ɜɨɡɜɪɚɬɚ ɤɚɪɟɬɤɢ, (ɜɨɡɜɪɚɳɚɟɬɫɹ ɤ ɩɟɪɜɨɦɭ ɫɢɦɜɨɥɭ ɫɬɪɨɤɢ)

\t

ɉɟɱɚɬɚɟɬ ɫɢɦɜɨɥ ɬɚɛɭɥɹɰɢɢ.

\v

ɉɟɱɚɬɚɟɬ ɫɢɦɜɨɥ ɜɟɪɬɢɤɚɥɶɧɨɣ ɬɚɛɭɥɹɰɢɢ.

\`

ɋɢɦɜɨɥ ɨɞɢɧɚɪɧɨɣ ɤɚɜɵɱɤɢ.

\"

ɋɢɦɜɨɥ ɞɜɨɣɧɨɣ ɤɚɜɵɱɤɢ.

\\

ɋɢɦɜɨɥ ɨɛɪɚɬɧɨɣ ɤɨɫɨɣ ɱɟɪɬɵ. ɉɟɱɚɬɚɟɬ ɫɢɦɜɨɥ, ɡɚɞɚɧɧɵɣ ɜɨɫɶɦɟɪɢɱɧɵɦ ASCII-ɤɨɞɨɦ num. ȼɟɪɨɹɬɧɨ, ɜɚɦ ɧɢɤɨɝɞɚ ɧɟ ɩɪɢɞɟɬɫɹ ɩɨɥɶɡɨɜɚɬɶɫɹ ɢɦ ɜ ɫɰɟɧɚɪɢɹɯ.

\num

,

. .

ɉɟɪɟɦɟɧɧɵɟ , ,

.

-

Ƚɥɚɜɚ 13. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɧɚ ɹɡɵɤɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

, ( . .

,

243

).

:

. ,

, ,



, —

.

, ,

,

. .

ɉɪɢɫɜɨɟɧɢɟ ɡɧɚɱɟɧɢɹ ɩɟɪɟɦɟɧɧɨɣ : myvar=5

myvar 5

${myvar}

5. ,

$. .

STDOUT, . .

echo

ɉ Ɋ ɂ Ɇ ȿɑ Ⱥ ɇ ɂ ȿ ȼ ɩɪɢɫɜɨɟɧɢɢ ɩɟɪɟɦɟɧɧɵɯ ɜɚɠɧɭɸ ɪɨɥɶ ɢɝɪɚɸɬ ɩɭɫɬɵɟ ɫɢɦɜɨɥɵ. ȼɵɪɚɠɟɧɢɟ 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). "Hello,

read. 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. your name:. • 7:

read name.

, , •

— Enter,

STDIN, . read ,

. read

Please enter

-

. 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)"

0

: ,

: 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

9

0

Ɉɛɪɚɛɨɬɤɚ ɚɪɝɭɦɟɧɬɨɜ ɤɨɦɚɧɞɧɨɣ ɫɬɪɨɤɢ -

. .

,

.

. ,

$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

$#"

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

246

: 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. (%).

,

1.

5%2

,

,

, *

,

:

.

,

pr 2 * 2 . 2 \* 2.

(*) .

Ƚɥɚɜɚ 13. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɧɚ ɹɡɵɤɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

247

( ). 0.

-

, ,

1.

:

2 + 2 = 4 + 1

0(

),

2 + 2 = 3 + 1

1( != "

). .

".

,

,

5 != 3 .




— 1( :

). -

, .

.

,

/ 1( (\>=)

5 \> 4

,

).

(\ /dev/null echo $?

0

bash$ bash$ Is -2 /dev/null Is: illegal option — 2 usage: Is [-ABCFGHLPRTWabcdfgiklnoqrstul] bash$ echo $?

[file

...]

1

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 then, . .

0,

tar. .

0,

else. test.

, ,

. .

test test

: if [-f program, conf] then : # touch program.conf done

else

"program.conf. ,

0 .(

then. .



Ƚɥɚɜɚ 13. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɧɚ ɹɡɵɤɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

).

,

1, touch. , 13.3.

else, test .

261

test

-

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

if

program.conf. 1. — /tmp/program.lock.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

262

, 2.

,

, 0. .

,

.

ɉɟɪɟɯɜɚɬ ɩɪɟɪɵɜɚɧɢɣ ɩɪɢ ɜɵɯɨɞɟ ,

FreeBSD

-

,

( -

kill, , Ctrl-C). , . ,

, Ctrl-C,

. -

.

,

#!/bin/sh # trap 'echo "Interrupt received. echo -n "Enter a number: " readln num exit 0

: Quitting."

1>$2'

1, 2, 3 . "Enter a number", received"

1

2

3

15

15.

, 2 (INT). "Interrupt

Ctrl-C, ,

. , 1>&2

echo. .

, echo

-

STDERR. .

-

STDERR

1>&2.

.

, ,

(

). Ctrl-C, .

, trap

''

:

2

,

2

.

,

. . ,

. ɉɊɂɆȿɑȺɇɂȿ ɋɢɝɧɚɥ 1 5 (ɩɨɫɵɥɚɟɦɵɣ ɩɨ ɭɦɨɥɱɚɧɢɸ ɤɨɦɚɧɞɨɣ kill) ɢ ɞɪɭɝɢɟ ɫɢɝɧɚɥɵ ɤɨɦɚɧɞɵ kill ɦɨɠɧɨ ɩɟɪɟɯɜɚɬɵɜɚɬɶ, ɨɞɧɚɤɨ ɷɬɨ ɧɟ ɨɬɧɨɫɢɬɫɹ ɤ ɫɢɝɧɚɥɭ 9 (SIGKILL) Ɉɧ ɢɫɩɨɥɶɡɭɟɬɫɹ ɜ ɤɚɱɟɫɬɜɟ

13.4.

Ƚɥɚɜɚ 13. ɉɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟ ɧɚ ɹɡɵɤɟ ɤɨɦɚɧɞɧɨɝɨ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ

263

ɩɨɫɥɟɞɧɟɣ ɜɨɡɦɨɠɧɨɫɬɢ ɩɪɟɪɜɚɬɶ ɪɚɛɨɬɭ ɩɪɨɝɪɚɦɦɵ, ɤɨɝɞɚ ɨɫɬɚɥɶɧɵɟ ɦɟɬɨɞɵ ɧɟ ɩɨɦɨɝɚɸɬ. ɉɨɷɬɨɦɭ ɟɝɨ ɧɟɥɶɡɹ ɧɢ ɩɟɪɟɯɜɚɬɢɬɶ, ɧɢ ɢɝɧɨɪɢɪɨɜɚɬɶ. Ɍɚɛɥɢɰɚ 13.4 Ɋɚɫɩɪɨɫɬɪɚɧɟɧɧɵɟ ɫɢɝɧɚɥɵ ɩɪɟɪɵɜɚɧɢɣ ɢ ɢɯ ɞɟɣɫɬɜɢɟ 0

ȼɵɯɨɞ

1

HUP — Ɉɛɪɵɜ ɫɟɚɧɫɚ (ɢɥɢ ɨɬɫɨɟɞɢɧɟɧɢɟ)

2

2INT — ɉɪɟɪɵɜɚɧɢɟ (Ctrl-C)

3

QUIT — ȼɵɯɨɞ (Ctrl-\)

15

TERM — Ɉɛɵɱɧɚɹ ɤɨɦɚɧɞɚ kill

Ɏɭɧɤɰɢɢ ,

.

"

". .

, ,



, -

.

,

, —

.

, -

,

.

:

#!/bin/sh on_exit() { rm -rf /tmp/myprogram.* mv logflie logfile.old mail [email protected] < report.txt } trap on_exit 0 1 2 3 15

,

? . .



, ,

.

,

-

,

, . -

,

.

, .

,

, .

,

,

-

,

.

Ɏɚɣɥɨɜɵɟ ɞɟɫɤɪɢɩɬɨɪɵ ,

-

. . : F.D.

STDIN. ,

. -

.

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

264

F.D. 1 STDOUT. , , F.D. 2 STDERR.

. ,

. .

,

. . :

exec. #!/bin/sh # exec > testfile.txt # ↪ testfile.txt echo "Line 1 of the echo "Line 2 of the echo "Line 3 of the echo "Line 4 of the echo "line 5 of the exit 0

F.D.

1

(STDOUT)

STDOUT, file" file" file" file" file"

exec

STDOUT ,

testfile.txt.

echo

,

testfile.txt, .

,

, .

.

-

STDIN :

read.

#!/bin/sh # exec < testfile.txt while read string do echo $string done exit 0

F.D.

(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 $result exit 0

"2

*

12

/

(2+2)'

|

` echo

STDOUT STDERR :

more. . /xvtest 2>&1 | more

: 1. 2. 3.

./xvtest 2>&1 #!/bin/sh -xv

|

more

# ↪ 15. result='echo "2 * 12 / ( 2 + 3 ) " 16. + echo 2 * 12 / (2 + 3) 6. + be

7. 9.

+ result=4 8. echo $result + echo 4

1 2 3

|

`

8. 4 exit 0 + exit

0

, +

.

. 3

,

,

result. 4, 5

6. 6—

4 8-10.

9 "echo 4".

echo, (4) , 8

5— result. " "

bc , .

echo. ,

10

echo.

Ɋɚɫɲɢɪɟɧɧɵɟ ɜɨɡɦɨɠɧɨɫɬɢ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ Ʉɨrn n . . UNIX

: Bourne,

, -

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

266

rn.

-

,

. ,

,

Bourne. rn. ɋɈȼȿɌ Ȼɨɥɶɲɢɧɫɬɜɨ ɦɟɬɨɞɨɜ, ɨ ɤɨɬɨɪɵɯ ɪɚɫɫɤɚɡɚɧɨ ɞɚɥɟɟ, ɩɨɞɞɟɪɠɢɜɚɸɬɫɹ ɢ ɤɨɦɚɧɞɧɵɦɢ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚɦɢ ɫɬɚɧɞɚɪɬɚ POSIX, ɤɨɬɨɪɵɣ ɜɯɨɞɢɬ ɜ ɫɨɫɬɚɜ FreeBSD ɤɚɤ /bin/sh. ȿɫɥɢ ɫɰɟɧɚɪɢɣ ɩɪɟɞɧɚɡɧɚɱɟɧ ɞɥɹ ɞɪɭɝɢɯ ɫɢɫɬɟɦ, ɝɞɟ POSIX ɩɨɞɞɟɪɠɢɜɚɟɬɫɹ ɧɟ ɜɫɟɝɞɚ, ɧɟ ɫɥɟɞɭɟɬ ɢɫɩɨɥɶɡɨ-ɜɚɬɶ ɪɚɫɲɢɪɟɧɧɵɟ ɜɨɡɦɨɠɧɨɫɬɢ, ɩɨɫɤɨɥɶɤɭ ɭɤɚɡɚɧɢɟ #!/bin/sh ɜ ɩɟɪɜɨɣ ɫɬɪɨɤɟ ɫɰɟɧɚɪɢɹ ɝɨ-ɜɨɪɹɬ ɫɢɫɬɟɦɟ, ɱɬɨ ɨɧɚ ɫɩɨɫɨɛɧɚ ɜɵɩɨɥɧɢɬɶ ɟɝɨ. ɗɬɨ ɦɨɠɟɬ ɩɪɢɜɟɫɬɢ ɤ ɫɟɪɶɟɡɧɵɦ ɨɲɢɛɤɚɦ.

ɉɨɥɭɱɟɧɢɟ ɢ ɭɫɬɚɧɨɜɤɚ ɢɧɬɟɪɩɪɟɬɚɬɨɪɚ Ʉɨɝɩ ,

. -

(The Public Domain Korn Shell) FreeBSD ( sysinstall), /usr/ports/shells/pdksh. , #/usr/local/bin/ksh. Korn Bourne, . . rn. ,

#!/bin/sh :

rn

, Bourne.

rn.

ȼɫɬɪɨɟɧɧɚɹ ɚɪɢɮɦɟɬɢɤɚ rn , Bourne.

.

-

r, ,

rn

. ,

,

exec. rn .

:

let.

let x=7+5

12. , if

((




Ȼɨɥɶɲɟ


=

Ȼɨɥɶɲɟ ɢɥɢ ɪɚɜɧɨ

&1 1>&2 /usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 sOutputFile=/dev/fd/3 - && exit 0

311

.

\ -

#

/usr/local/bin/gs -dSAFER -dNOPAUSE -q -sDEVICE=djet500 \ -sOutputFile=- - && exit 0

else # # # # echo exit 0 fi exit 2

,

HP/PCL,

. ,

.

$first_line

&&

cat

&& printf

,

"\033S10H"

&&

.

, ,

, , GhostScript.

PostScript ,

%!.

then, . . , .

ɉɊɂɆȿɑȺɇɂȿ GhostScript ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɨɱɟɧɶ ɦɨɳɧɭɸ ɩɪɨɝɪɚɦɦɭ ɫ ɛɨɥɶɲɢɦ ɱɢɫɥɨɦ ɨɩɰɢɣ. ȿɟ ɞɨɤɭɦɟɧ-ɬɚɰɢɸ ɦɨɠɧɨ ɧɚɣɬɢ ɩɨ ɚɞɪɟɫɭ http://www.cs.wisc.edu/~ghost/index.html.

Ɏɢɥɶɬɪ ɩɟɱɚɬɢ Ipf ɉɊɂɆȿɑȺɇɂȿ FreeBSD ɫɨɞɟɪɠɢɬ ɩɪɨɝɪɚɦɦɭ ɩɨɞ ɧɚɡɜɚɧɢɟɦ Ipf, ɞɟɣɫɬɜɭɸɳɭɸ ɤɚɤ ɮɢɥɶɬɪ ɩɟɱɚɬɢ. Ɉɧɚ ɢɦɟɟɬ ɦɚɫɫɭ ɜɨɡɦɨɠɧɨɫɬɟɣ, ɜɤɥɸɱɚɹ ɜɟɞɟɧɢɟ ɭɱɟɬɚ (ɫɤɨɥɶɤɨ ɫɬɪɚɧɢɰ ɧɚɩɟɱɚɬɚɧɨ, ɤɟɦ ɢɦɟɧɧɨ ɢ ɬ.ɞ.). ɂɧɮɨɪɦɚɰɢɹ ɨɛ ɷɬɨɣ ɩɪɨɝɪɚɦɦɟ ɫɨɞɟɪɠɢɬɫɹ ɜ ɫɩɪɚɜɨɱɧɨɦ ɪɭɤɨɜɨɞɫɬɜɟ man cap.

Ɏɢɥɶɬɪɵ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ (conversion filters)

-

, ,

. 1 , . 1 ).

(

,

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

312

. 16.2

,

l r:

Ɍɚɛɥɢɰɚ 16.2 Ɉɩɰɢɢ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ ɤɨɦɚɧɞɵ Ipr -d

Ɏɚɣɥ ɜ ɮɨɪɦɚɬɟ DVI (ɢɫɩɨɥɶɡɭɟɬɫɹ ɫɢɫɬɟɦɨɣ Ɍɟɏ.)

-f

Ɏɢɥɶɬɪ ɞɥɹ ɩɟɱɚɬɢ ɮɚɣɥɨɜ ɫ ɢɫɯɨɞɧɵɦ ɤɨɞɨɦ ɧɚ ɹɡɵɤɟ FORTRAN.



Ɏɚɣɥ ɫɨɞɟɪɠɢɬ ɞɚɧɧɵɟ ɩɪɨɝɪɚɦɦɵ cifplot. ɉɨɫɥɟɞɧɹɹ ɧɟ ɜɤɥɸɱɟɧɚ ɜ ɫɨɫɬɚɜ FreeBSD.

-g

Ɏɚɣɥ ɫɨɞɟɪɠɢɬ ɞɚɧɧɵɟ, ɩɨɥɭɱɟɧɧɵɟ ɫ ɩɨɦɨɳɶɸ ɩɪɨɰɟɞɭɪ ɜɵɱɟɪɱɢɜɚɧɢɹ (plot routines) UNIX. ɗɬɢ ɩɪɨɰɟɞɭɪɵ ɜɤɥɸɱɟɧɵ ɜ FreeBSD.

-d

Ɏɚɣɥ ɫɨɞɟɪɠɢɬ ɞɚɧɧɵɟ ɩɪɨɝɪɚɦɦɵ troff, ɧɟɡɚɜɢɫɹɳɟɣ ɨɬ ɭɫɬɪɨɣɫɬɜɚ. Ɉɧɢ ɧɟ ɩɨɞɞɟɪɠɢɜɚɸɬɫɹ ɧɢɤɚɤɢɦ ɩɪɨɝɪɚɦɦɧɵɦ ɨɛɟɫɩɟɱɟɧɢɟɦ, ɜɤɥɸɱɟɧɧɵɦ ɜ FreeBSD.

-t

Ɏɚɣɥ ɫɨɞɟɪɠɢɬ ɤɨɦɚɧɞɵ ɋ/Ⱥ/Ɍ ɞɥɹ ɭɫɬɚɪɟɜɲɢɯ ɜɟɪɫɢɣ ɩɪɨɝɪɚɦɦɵ troff.

-v

Ɏɚɣɥ ɫɨɞɟɪɠɢɬ ɪɚɫɬɪɨɜɨɟ ɢɡɨɛɪɚɠɟɧɢɟ (ɞɥɹ ɪɚɡɥɢɱɧɵɯ ɭɫɬɪɨɣɫɬɜ ɩɟɱɚɬɢ ɢɡɨɛɪɚɠɟɧɢɣ). Ȼɨɥɶɲɢɧɫɬɜɨ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ɧɟ ɩɪɢɦɟɧɹɟɬ ɷɬɨɬ ɮɨɪɦɚɬ.

.

,

, ,

-

-

-

cifplot .

, ,

-

UNIX, , . , ) PostScript (

groff (

):

#!/bin/sh exec grops

grops groff

, PostScript. grops.

groff 1 , , lpr

-t

/usr/local/Iibexec PostScript. groff :

g2ps, -t -

myfile

myfile —

,

. , /etc/printcap (

-

).

ɇɚɫɬɪɨɣɤɢ ɜ ɮɚɣɥɟ /etc/printcap /etc/printcap ,

" .

, :

, .

",

, ,

-

Ƚɥɚɜɚ 16. ɉɟɱɚɬɶ

/etc/printcap . , , /etc/printcap

313

, -

/

. :

.

simba|lp|local line printer:\ # :sh:\ :lp=/dev/lptO:sd=/var/spool/lpd/simba:lf=/var/log/lpd-errs: :if=/usr/libexec/if-ps:

,

. 1 (

simba,

,

),

.

.

, ,

. .

,

-



. . :1 (

local printer —

-

).

/dev/lptO (LPT1 DOS). :sd — /var/spool/lpd/simba ( ). :lf , . , if-ps (

, log file, . .

,

. PostScript).

ɍɫɬɚɧɨɜɤɚ ɮɢɥɶɬɪɨɜ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ . (

),

. :if.

. 16.3

: Ɍɚɛɥɢɰɚ 16.3 Ɉɩɰɢɢ ɮɢɥɶɬɪɨɜ ɜ ɮɚɣɥɟ /etc/printcap /etc/printcap DVI

:df

FORTRAN

:rf

cifplot

:cf

plot

:gf

dittroff

:nf

troff

:rf

raster

:if

,

. ,

. (

, ):

:rf=/usr/local/libexec/g2ps:

,

groff PostScript

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 1 ,

/etc/printcap .

.

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 Print, Print To: , . Printer, Ipr,

File,

Print.

. 16.1. Print Command:

— ,

.

. Ipr (

, ).

, Ipr -Window PostScript, PostScript. Netscape Ipr

. GhostScript

PostScript

-PostScript,

.

— ,

. .

.

UNIX, Netscape PostScript.

-

ɑɚɫɬɶ Ɂ. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

301

16.1 Print Netscape. , File , netscape.ps., Netscape PostScript.

ɉɟɱɚɬɶ ɜ StarOffice StarOffice, Printer Setup . 16.2.

,

, .

,

StarOffice ,

PostScriptAdd new

GhostScript .

,

printer,

. Configuration. , StarOffice PostScript GhostScript, StarOffice),

(

Generic Printerin, 1 . StarOffice,

GhostScript

16.2 Printer Configuration StarOffice.

(

,

).

-

Ƚɥɚɜɚ 16. ɉɟɱɚɬɶ

317

ɉɪɨɜɟɪɤɚ ɫɨɫɬɨɹɧɢɹ ɡɚɞɚɧɢɣ ɩɟɱɚɬɢ ,

,

, .

Ipq. :

-

PRINTER, . ,

, /etc/printcap.

1 ,

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

.

-P

Ipq .

simba, -

Size bytes bytes bytes bytes

Ipq

. ,

.

Ipq, ,

.

.

,

,

-

. :

,

.

. 3, job,

, (

.

),

4

. ,

. .

, . . 16.5.

Ipq 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 -Ɋ name

.

Iprm

Ɉɩɰɢɹ ɭɤɚɡɵɜɚɟɬ ɢɦɹ ɩɪɢɧɬɟɪɚ, ɢɡ ɨɱɟɪɟɞɢ ɤɨɬɨɪɨɝɨ ɫɥɟɞɭɟɬ ɭɞɚɥɢɬɶ ɡɚɞɚɧɢɟ. ȿɫɥɢ ɨɩɰɢɹ ɧɟ ɡɚɞɚɧɚ, ɩɪɢɧɬɟɪɨɦ ɩɨ ɭɦɨɥɱɚɧɢɸ ɹɜɥɹɟɬɫɹ ɡɧɚɱɟɧɢɟ ɩɟɪɟɦɟɧɧɨɣ ɫɪɟɞɵ PRINTER ɢɥɢ ɩɪɢɧɬɟɪ ɫ ɩɫɟɜɞɨɧɢɦɨɦ Ip. ɋɢɦɜɨɥ ɞɟɮɢɫɚ ɭɤɚɡɵɜɚɟɬ ɧɚ ɭɞɚɥɟɧɢɟ ɢɡ ɨɱɟɪɟɞɢ ɜɫɟɯ ɡɚɞɚɧɢɣ, ɩɪɢɧɚɞɥɟɠɚɳɢɯ ɬɟɤɭɳɟɦɭ ɩɨɥɶɡɨɜɚɬɟɥɸ. ȿɫɥɢ ɢɫɩɨɥɶɡɭɟɬɫɹ ɩɨɥɶɡɨɜɚɬɟɥɟɦ root, ɬɨ ɭɞɚɥɹɟɬ ɜɫɟ ɡɚɞɚɧɢɹ.

user_name ɍɞɚɥɹɟɬ ɜɫɟ ɡɚɞɚɧɢɹ ɭɤɚɡɚɧɧɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɹ. ɗɬɨɣ ɨɩɰɢɟɣ ɦɨɠɟɬ ɜɨɫɩɨɥɶɡɨɜɚɬɶɫɹ ɬɨɥɶɤɨ ɩɨɥɶɡɨɜɚɬɟɥɶ root, ɬɚɤ ɤɚɤ ɨɛɵɱɧɵɟ ɩɨɥɶɡɨɜɚɬɟɥɢ ɦɨɝɭɬ ɭɞɚɥɹɬɶ ɬɨɥɶɤɨ ɫɜɨɢ ɡɚɞɚɧɢɹ.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɍɞɚɥɟɧɢɟ ɬɟɤɭɳɟɝɨ ɩɟɱɚɬɚɟɦɨɝɨ ɡɚɞɚɧɢɹ ɧɟ ɡɚɫɬɚɜɢɬ ɩɪɢɧɬɟɪ ɧɟɦɟɞɥɟɧɧɨ ɨɫɬɚɧɨɜɢɬɶ ɩɟɱɚɬɶ. ȼ ɡɚɜɢɫɢɦɨɫɬɢ ɨɬ ɨɛɴɟɦɚ ɟɝɨ ɨɩɟɪɚɬɢɜɧɨɣ ɩɚɦɹɬɢ, ɜ ɛɭɮɟɪɟ ɩɪɢɧɬɟɪɚ ɦɨɠɟɬ ɧɚɯɨɞɢɬɶɫɹ ɧɟɫɤɨɥɶ-ɤɨ ɫɬɪɚɧɢɰ ɞɚɧɧɵɯ. Ⱥ ɷɬɨ ɡɧɚɱɢɬ, ɱɬɨ ɱɚɫɬɶ ɞɨɤɭɦɟɧɬɚ (ɢɥɢ ɞɚɠɟ ɜɟɫɶ ɞɨɤɭɦɟɧɬ ɧɟɛɨɥɶɲɨɝɨ ɪɚɡɦɟɪɚ) ɛɭɞɟɬ ɪɚɫɩɟɱɚɬɚɧɚ ɭɠɟ ɩɨɫɥɟ ɭɞɚɥɟɧɢɹ ɡɚɞɚɧɢɹ ɢɡ ɨɱɟɪɟɞɢ.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɍɞɚɥɢɬɶ ɡɚɞɚɧɢɹ ɩɪɢɧɬɟɪɚ ɦɨɠɧɨ ɥɢɲɶ ɢɡ ɬɨɣ ɫɢɫɬɟɦɵ, ɨɬɤɭɞɚ ɨɧɢ ɛɵɥɢ ɩɨɫɥɚɧɵ (ɟɫɥɢ ɤ ɩɪɢɧɬɟɪɭ ɨɛɪɚɳɚɟɬɫɹ ɧɟɫɤɨɥɶɤɨ ɦɚɲɢɧ ɜ ɫɟɬɢ).

Ƚɥɚɜɚ 16. ɉɟɱɚɬɶ

319

ɍɩɪɚɜɥɟɧɢɟ ɩɪɢɧɬɟɪɨɦ 1 .

-

.

, ,

"

".

,1

, (

)

-

. ,

Ipc .

,

1

. 1

.

ɉɪɨɝɪɚɦɦɚ Ipc ɜ ɢɧɬɟɪɚɤɬɢɜɧɨɦ ɪɟɠɢɦɟ ,

1

: 1

>

help (

?

, -

Enter), help (

)

. (

).

, start

,

status

stat,

, ?Ambiguous command ( ,

,1

-

sta, .

1

--

). ?Invalid command (

).

ɋɨɫɬɨɹɧɢɟ ɨɱɟɪɟɞɢ ,

stat.

(

)

.

lpc> status lp lp: queuing is enabled printing is enabled 2 entries in spool area waiting for lp to become

ready

,

status, . ,

all :

(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, , stop

abort, .

.

,

,

-

.

ɋɈȼȿɌ ȿɫɥɢ ɩɪɢɧɬɟɪ ɧɟɨɛɯɨɞɢɦɨ ɨɬɤɥɸɱɢɬɶ ɧɚ ɞɥɢɬɟɥɶɧɵɣ ɫɪɨɤ (ɧɚɩɪɢɦɟɪ, ɞɥɹ ɜɵɩɨɥɧɟɧɢɹ ɬɟɤɭɳɟɝɨ ɨɛɫɥɭɠɢɜɚɧɢɹ), ɟɝɨ ɢɦɹ ɫɥɟɞɭɟɬ ɫɞɟɥɚɬɶ ɩɫɟɜɞɨɧɢɦɨɦ ɞɪɭɝɨɝɨ ɩɪɢɧɬɟɪɚ ɜ ɮɚɣɥɟ /etc/printcap. ȿɫɥɢ ɷɬɨ ɫɢɫɬɟɦɧɵɣ ɩɪɢɧɬɟɪ ɩɨ ɭɦɨɥɱɚɧɢɸ, ɨɛɹɡɚɬɟɥɶɧɨ ɫɞɟɥɚɣɬɟ Iɪ ɬɚɤɠɟ ɩɫɟɜɞɨɧɢɦɨɦ ɞɪɭ-ɝɨɝɨ ɩɪɢɧɬɟɪɚ. Ɍɨɝɞɚ ɜɫɟ ɡɚɞɚɧɢɹ ɛɭɞɭɬ ɩɟɪɟɧɚɩɪɚɜɥɹɬɶɫɹ ɧɚ ɞɪɭɝɨɣ ɩɪɢɧɬɟɪ, ɧɟ ɬɪɟɛɭɹ ɨɬ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ɜɧɟɫɟɧɢɹ ɢɡɦɟɧɟɧɢɣ ɜ ɤɨɧɮɢɝɭɪɚɰɢɸ. Ɋɚɡɭɦɟɟɬɫɹ, ɩɪɟɞɩɨɱɬɢɬɟɥɶɧɟɟ ɩɟɪɟɧɚɩɪɚ-ɜɢɬɶ ɜɵɜɨɞ ɩɪɢɧɬɟɪ ɬɚɤɨɝɨ ɠɟ ɬɢɩɚ ɢ ɪɚɫɩɨɥɨɠɟɧɧɵɣ ɝɞɟ-ɬɨ ɧɟɩɨɞɚɥɟɤɭ. Ʉɪɨɦɟ ɬɨɝɨ, ɜɫɟɦ ɩɨɥɶɡɨɜɚɬɟɥɹɦ ɧɭɠɧɨ ɧɚɩɪɚɜɢɬɶ ɭɜɟɞɨɦɥɟɧɢɟ ɨ ɬɨɦ, ɝɞɟ ɨɧɢ ɫɦɨɝɭɬ ɧɚɣɬɢ ɫɜɨɢ ɪɚɫɩɟɱɚɬɤɢ.

abort,

.

stop ,

-

abort, , . ,



,

,

,

.

.

Ƚɥɚɜɚ 16. ɉɟɱɚɬɶ

321

-

disable. : all (

) ).

(

:

lpc> disable lp 1p=

queuing all

status lp:

disabled lpc>

queuing is disabled printing is enabled 3 entries in spool area waiting for lp to become

ready

(offline?)

lpc>

,

— (

,

.

, ),

-

. , ,

-

:

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

, enable

: for maintenance. Total

, all (

: lpc> enable lp lp: queuing enabled lpc> status lp lp: queuing is enabled printing is disabled

)

Size

.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

322

3 entries in spool area Printer is down for maintenance. lpc>

,

,

,

. ,

.

-

down,

up. ,

,

,

. .

restart, .

ɉɟɪɟɡɚɩɭɫɤ ɞɟɦɨɧɚ, ɨɛɪɚɛɚɬɵɜɚɸɳɟɝɨ ɫɩɭɥ ,

, ,

restart. .

-

, (

restart ) lpc>

restart

). " : all (

"

. -

,

.

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:

topq lp

12

moved moved moved moved

10

9 8

cfA008simba.samplenet.org cfA009simba.samplenet.org cfA010simba.samplenet.org cfA012simba.samplenet.org

lpc>

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 , operator.

-

root. ,

-

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 ,

( .

.

,

,

r

nova.

1) , 2.

,

,

. .

, ,

, . ,

,

.

Ɋɟɲɟɧɢɟ ɩɪɨɛɥɟɦ . , .

ɉɪɢɧɬɟɪ ɧɟ ɩɨɥɭɱɚɟɬ ɞɚɧɧɵɯ, ɡɚɞɚɧɢɹ ɧɚɯɨɞɹɬɫɹ ɜ ɨɱɟɪɟɞɢ Ipq , Warning: no daemon present, . , l ,

. 1 ,

.

ɉɪɢɧɬɟɪ ɫɢɝɧɚɥɢɡɢɪɭɟɬ ɨ ɩɪɢɟɦɟ ɞɚɧɧɵɯ, ɧɨ ɧɟ ɩɟɱɚɬɚɟɬ He-PostScript-

PostScript-

.

-

, PostScript.

ȼɦɟɫɬɨ ɢɡɨɛɪɚɠɟɧɢɹ ɢɥɢ Web-ɫɬɪɚɧɢɰɵ ɩɟɱɚɬɚɸɬɫɹ ɫɨɬɧɢ ɫɬɪɚɧɢɰ ɦɭɫɨɪɚ PostScript. He-PostScript-

,

-

Ƚɥɚɜɚ 16. ɉɟɱɚɬɶ

. "

GhostScript He-PostScript-

PostScript

325

".

ɉɪɢɧɬɟɪ ɪɚɛɨɬɚɟɬ ɦɟɞɥɟɧɧɨ (polled mode) (

,

). lptcontrol

:

-

, .

.

,

Iptcontrol.

ȼɵɜɨɞ ɩɟɱɚɬɚɟɬɫɹ "ɥɟɫɟɧɤɨɣ" : Line

one

of

the

file. Line two of the file. Line three of the file.

,

. , Windows

, UNIX

DOS/Windows

(LF). :

, .

, UNIX

,

.

-

DOS,

,

,

. . ,

-

,

. . ,

CR

LF

LF. HP-PCL,

-

: #!/bin/sh # # hpif 400 401 /usr/local/libexec/hpif # 500

,

stdin

stdout.

.

# # #

LF

CR+LF.

.

printf exit

Ipd HP-PCL.

"\033Sk2G"

&&

cat

&& printf

"\033S10H"

ss exit 0

2

,

, . HP-PCL, tr.

LF :

CR LF

Ɂ26

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

#!/bin/sh # , " " # PCL. /bin/cat | tr '\ 13' '\ 13\ 10' && exit exit 2

,

ȼɟɫɶ ɬɟɤɫɬ ɩɟɱɚɬɚɟɬɫɹ ɜ ɨɞɧɨɣ ɫɬɪɨɤɟ, ɩɨɜɟɪɯ ɭɠɟ ɧɚɩɟɱɚɬɚɧɧɨɝɨ ɬɟɤɫɬɚ ,

,

.

"

,

,

CR.

".

LF ,

. CR

LF

, -

.

. , "

".

,

-

17

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ

Ɋɨɥɶ ɹɞɪɚ ► Ɂɚɱɟɦ ɤɨɧɮɢɝɭɪɢɪɨɜɚɬɶ ɫɨɛɫɬɜɟɧɧɨɟ ɹɞɪɨ? ► Ʉɨɧɮɢɝɭɪɚɰɢɨɧɧɵɟ ɮɚɣɥɵ ɹɞɪɚ ► ɋɨɡɞɚɧɢɟ ɤɨɧɮɢɝɭɪɚɰɢɨɧɧɨɝɨ ɮɚɣɥɚ ɹɞɪɚ ► Ʉɨɦɩɢɥɹɰɢɹ ɢ ɭɫɬɚɧɨɜɤɚ ɹɞɪɚ ► ɉɨɞɚɜɥɟɧɢɟ ɮɚɣɥɨɜ ɭɫɬɪɨɣɫɬɜ ɜ ɤɚɬɚɥɨɝɟ /dev ► Ⱥɜɚɪɢɣɧɨɟ ɜɨɫɫɬɚɧɨɜɥɟɧɢɟ ►

328

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

UNIX :

. , ,

. . FreeBSD . 100%, ,

, . .

Ɋɨɥɶ ɹɞɪɚ —

. . TCP/ IP , -

, , . — —

MS-DOS Windows

.

, C:\WINDOWS\SYSTEM, . UNIX. (" " )

, OS /boot.

.

Windows, Mac

FreeBSD

,

,

,

, , —

.

Windows,

. ,

.

,

. ,

,

FreeBSD Windows NT

Mach (

, ,

. (microkernel architecture), . . . Mac OS X) -

, . Linux

Windows 95/98

,

(monolithic)

. , , , ,

FreeBSD

. , Linux, .

, :

. -

,

-

Ƚɥɚɜɚ 17. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ

,

329

, .

,

. , ,

-

.

,

,

-

,

,

.

FreeBSD

,

.

Ɂɚɱɟɦ ɤɨɧɮɢɝɭɪɢɪɨɜɚɬɶ ɫɨɛɫɬɜɟɧɧɨɟ ɹɞɪɨ? FreeBSD

-

GENERIC. ,

FreeBSD

. 86

,

.

, (

, IRIX

SGI

Mac OS X .

Apple), GENERIC ,

, ).

(

,

.

, . . , , ,

-

. GENERIC. ,

.

, (

,

,

). ,

, FreeBSD. ɉɊɂɆȿɑȺɇɂȿ Ⱦɚɠɟ ɹɞɪɨ GENERIC ɩɨɡɜɨɥɹɟɬ ɨɬɤɥɸɱɢɬɶ ɩɪɨɜɟɪɤɭ ɜɫɟɯ ɢɡɜɟɫɬɧɵɯ ɟɦɭ ɭɫɬɪɨɣɫɬɜ. Ⱦɥɹ ɷɬɨɝɨ ɩɪɟɞɧɚɡɧɚɱɟɧ ɤɨɧɮɢɝɭɪɚɬɨɪ ɡɚɝɪɭɡɤɢ (ɫɦ. ɩɪɢɥɨɠɟɧɢɟ ȼ]. Ɉɧ ɩɨɡɜɨɥɹɟɬ ɹɜɧɨ ɭɫɬɪɚɧɢɬɶ ɬɟ ɭɫɬɪɨɣɫɬɜɚ, ɤɨɬɨɪɵɟ ɜɵɡɵɜɚɸɬ ɤɨɧɮɥɢɤɬɵ ɩɪɟɪɵɜɚɧɢɣ ɢɥɢ ɚɞɪɟɫɨɜ ɩɚɦɹɬɢ (ɢɥɢ ɧɟ ɩɪɢɫɭɬɫɬɜɭɸɬ ɜ ɫɢɫɬɟɦɟ]. ɗɬɨ, ɟɫɬɟɫɬɜɟɧɧɨ, ɧɟ ɢɡɦɟɧɹɟɬ ɫɚɦɨɝɨ ɹɞɪɚ ɢ ɫɤɨɦɩɢɥɢɪɨɜɚɧɧɵɯ ɫ ɧɢɦ ɷɥɟɦɟɧɬɨɜ, ɧɨ, ɩɨ ɤɪɚɣɧɟɣ ɦɟɪɟ, ɭɫɤɨɪɹɟɬ ɡɚɝɪɭɡɤɭ ɫɢɫɬɟɦɵ.

,

USB-

,

. ., . .

, SCSI, (

9). . (

-

, EXT2FS, ,

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

330

,

, ).

. ,

(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 [email protected]:/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

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: on motherboard npxO: INT 16 interface pcibO: on motherboard pciO: on pcibO pciO: at 2.0 irq 11 pcibl: at device 30.0 on pciO pcil: on pcibl

Ƚɥɚɜɚ 17. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ

331

fxpO: port Oxde80-0xdebf mem OxffSfeOOO↪ 0xff8fefff irq 11 at device 8.0 on pcil fxpO: Ethernet address 00:dO:b7:o7:74:f1 fxpl: 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:

at

device

isaO: on isabO atapciO: , . di), dmesg. .

. , not found,

, dmesg

. ,

,

.

Ʉɨɧɮɢɝɭɪɚɰɢɨɧɧɵɟ ɮɚɣɥɵ ɹɞɪɚ FreeBSD Red Hat Linux Linux. FreeBSD

linuxconf

make config,

.

, ,

. /

" .

.

",

, ,

diff

grep,

GENERIC, .

NOTES ,

, /

. , .

,

FreeBSD

config"

" . FreeBSD /sys/i386/conf.

, GENERIC.

,

332

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

ɉɊɂɆȿɑȺɇɂȿ ȿɫɥɢ ɜɵ ɪɚɛɨɬɚɟɬɟ ɧɚ ɩɥɚɬɮɨɪɦɟ Alpha, ɚ ɧɟ ɯ86, ɜ ɢɦɟɧɢ ɩɪɟɞɵɞɭɳɟɝɨ ɤɚɬɚɥɨɝɚ ɧɟɨɛɯɨɞɢɦɨ ɡɚɦɟɧɢɬɶ 1386 ɧɚ alpha. ɇɟɤɨɬɨɪɵɟ ɩɚɪɚɦɟɬɪɵ, ɭɤɚɡɚɧɧɵɟ ɜ ɷɬɨɣ ɝɥɚɜɟ ɛɭɞɭɬ ɞɪɭɝɢɦɢ, ɨɞɧɚɤɨ ɫɚɦ ɩɨɞɯɨɞ ɨɫɬɚɧɟɬɫɹ ɩɪɟɠɧɢɦ.

Ʉɨɧɮɢɝɭɪɚɰɢɨɧɧɵɣ ɮɚɣɥ GENERIC .

GENERIC ( "

"

, ). .

GENERIC

, ,

,

: i386 I386_CPO I486_CPU I586_CPU I686_CPU GENERIC 32

machine cpu cpu cpu cpu ident maxusers

" ,

"

:

,

GENERIC

.

,

17.2. 17.2

GENERIC 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

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

,

device. .

.

GENERIC. . 17.3.

device,

Ƚɥɚɜɚ 17. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ

17.3

,

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

fxp pen

devicerl devicesf devicesis deviceste devicetl devicetx devicevr devicewb devicexl

# # # # # # # # # #

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 , /boot/device.hints,

,

ata . :

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"

, ata.

(IRQ — interrupt request) .

,

: # statically compile in device #hints "GENERIC.hints"

wiring instead of /boot/device.hints #Default places to look for devices.

Ɏɚɣɥ LINT /sys/i386/conf ,

LINT, .

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

334

,

. . ,

GENERIC, (

LINT. ).

, . .

,

,

LINT. FreeBSD .

LINT, ,

-

. ,

FreeBSD 5.0

, NOTES LINT

LINT .

NOTES, . NOTES,

LINT, ,

make lint. , (

,

,

).

ɋɨɡɞɚɧɢɟ ɤɨɧɮɢɝɭɪɚɰɢɨɧɧɨɝɨ ɮɚɣɥɚ ɹɞɪɚ ,

.

GENERIC

, .

,

,

,

. ,

.

CUSTOM: #

GENERIC CUSTOM

.

CUSTOM , —

GENERIC c u

machine cpu ident maxusers

,

,

,

CUSTOM. maxusers. Pentium III:

1386 I686_CPU CUSTOM 64

ɉɊɂɆȿɑȺɇɂȿ Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ ɧɚ ɡɧɚɱɟɧɢɟ ɨɩɰɢɢ maxusers: ɷɬɨ ɧɟ ɦɚɤɫɢɦɚɥɶɧɨ ɜɨɡɦɨɠɧɨɟ ɱɢɫɥɨ ɩɨɥɶɡɨɜɚɬɟɥɟɣ, ɡɚɪɟɝɢɫɬɪɢɪɨɜɚɧɧɵɯ ɜ ɫɢɫɬɟɦɟ (ɩɨɫɥɟɞɧɟɟ ɡɚɞɚɟɬɫɹ ɜ ɫɬɪɨɤɟ device pty ). ɗɬɚ ɩɟɪɟɦɟɧɧɚɹ ɨɬɜɟɱɚɟɬ ɡɚ ɛɨɥɟɟ ɬɨɧɤɢɟ ɧɚɫɬɪɨɣɤɢ: ɩɨ ɟɟ ɡɧɚɱɟɧɢɸ ɜɵɱɢɫɥɹɸɬɫɹ ɪɚɡɦɟɪɵ ɜɧɭɬɪɟɧɧɢɯ ɬɚɛɥɢɰ, ɧɚɩɪɢɦɟɪ, ɦɚɤɫɢɦɚɥɶɧɨ ɜɨɡɦɨɠɧɨɟ ɱɢɫɥɨ ɩɪɨɰɟɫɫɨɜ (ɨɧɨ ɪɚɜɧɨ 16*maxusers+20). Ɂɧɚɱɟɧɢɟ ɷɬɨɣ ɨɩɰɢɢ ɩɪɢɦɟɪɧɨ ɪɚɜɧɨ ɨɠɢɞɚɟɦɨɦɭ ɱɢɫɥɭ ɩɨɥɶɡɨɜɚɬɟɥɟɣ, ɨɞɧɚɤɨ ɧɟ ɫɥɟɞɭɟɬ ɞɟɥɚɬɶ ɟɝɨ ɦɟɧɶɲɢɦ 4. ȼ ɷɬɨɦ ɫɥɭɱɚɟ ɞɨɩɭɫɬɢɦɨɟ ɱɢɫɥɨ ɩɪɨɰɟɫɫɨɜ ɛɭɞɟɬ ɩɪɟɜɵɲɟɧɨ ɡɧɚɱɢɬɟɥɶɧɨ ɪɚɧɶɲɟ, ɱɟɦ ɦɨɠɧɨ ɨɠɢɞɚɬɶ.

. ,

,

dmesg

NOTES, -

Ƚɥɚɜɚ 17. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɹɞɪɚ

.

335

, !

-

,

#. -



,

GENERIC, ,

.

, ,

-

-

,

.

Ʉɨɦɩɢɥɹɰɢɹ ɢ ɭɫɬɚɧɨɜɤɚ ɹɞɪɚ ,

.

,

(

)

: #

cd /usr/src

# #

make make

buildkernel KERNCONF=CUSTOM installkernel KERNCONF=CUSTOM

,

KERNCONF GENERIC. ,

,

, ,

,

/boot (

:

make #

— /boot/kernel.old). .

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:

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

336

,

,

"

"

-

/dev, .



(

,

sndO). : # ./MAKEDEV sndO

Ⱥɜɚɪɢɣɧɨɟ ɜɨɫɫɬɚɧɨɜɥɟɧɢɟ ,

. ,

,

(

"*** Error code 1"), , . , WebFreeBSD (http://

— , .

,

www.freebsd.org) ,

. (

18), , -CURRENT . : freebsd-current FreeBSD).

, -STABLE)

(

freebsd-stable (



:

-

Web-

,

,

. , .

, .

.

,

. )

(

10 ,

/boot/kernel.old

. ȼɇɂɆȺɇɂȿ! ɉɨɦɧɢɬɟ, ɱɬɨ ɩɪɢ ɫɥɟɞɭɸɳɟɣ ɩɨɩɵɬɤɟ ɫɛɨɪɤɢ ɢ ɢɧɫɬɚɥɥɹɰɢɢ ɹɞɪɚ ɮɚɣɥ /boot/kernel.old ɛɭɞɟɬ ɩɟɪɟɡɚɩɢɫɚɧ ɬɟɤɭɳɢɦ (ɬ.ɟ. ɧɟɪɚɛɨɬɨɫɩɨɫɨɛɧɵɦ ɹɞɪɨɦ]. ɑɬɨɛɵ ɢɡɛɟɠɚɬɶ ɷɬɨɝɨ, ɫɞɟɥɚɣɬɟ ɤɨɩɢɸ ɹɞɪɚ kernel.old ɫ ɞɪɭɝɢɦ ɢɦɟɧɟɦ, ɧɚɩɪɢɦɟɪ, /boot/kernel.frank. ɗɬɢɦ ɹɞɪɨɦ ɜɵ ɜɫɟɝɞɚ ɫɦɨ-ɠɟɬɟ ɜɨɫɩɨɥɶɡɨɜɚɬɶɫɹ ɜ ɫɥɭɱɚɟ ɧɟɭɞɚɱɧɨɣ ɡɚɝɪɭɡɤɢ.

,

: ps, top

,

,

,

. ,

18).

-



libkvm. , .

,

.

libkvm

world (

, .

w,

make

18

ɉɨɞɞɟɪɠɤɚ FreeBSD

Ɉɬɫɥɟɠɢɜɚɧɢɟ ɢɫɯɨɞɧɨɝɨ ɤɨɞɚ FreeBSD ɑɬɨ ɬɚɤɨɟ make world?

► ►

ɇɚ ɱɬɨ ɫɥɟɞɭɟɬ ɨɛɪɚɬɢɬɶ ɜɧɢɦɚɧɢɟ ɩɟɪɟɞ ɫɛɨɪɤɨɣ ɜɫɟɣ ɫɢɫɬɟɦɵ



Ɂɚɞɚɱɢ, ɜɵɩɨɩɧɩɟɦɵɟ ɞɨ ɫɛɨɪɤɢ ɜɫɟɣ ɫɢɫɬɟɦɵ



ɋɛɨɪɤɚ ɫɢɫɬɟɦɵ ɢɡ ɢɫɯɨɞɧɵɯ ɮɚɣɥɨɜ



ɂɫɩɨɥɶɡɨɜɚɧɢɟ mergemaster ɞɥɹ ɩɪɨɜɟɪɤɢ ɢɡɦɟɧɟɧɧɵɯ ɤɨɧɮɢɝɭɪɚɰɢɨɧɧɵɯ ɮɚɣɥɨɜ ɉɟɪɟɡɚɝɪɭɡɤɚ ɫɢɫɬɟɦɵ ɩɨɫɥɟ ɨɛɧɨɜɥɟɧɢɹ

► ►

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeSSD

338

, .

,

, . ,

.

,

Internet ( ,

), ,

! Microsoft

"

Windows NT/2000. Macintosh . FreeBSD . FreeBSD (4.0, 5.0) (3.4, 4.1.1), , , , ", , CVSup make world).

. " (service pack)

-

Windows -

Linux. . , -

,

-

" FreeBSD (

,

. , .

Ɉɬɫɥɟɠɢɜɚɧɢɟ ɢɫɯɨɞɧɨɝɨ ɤɨɞɚ FreeBSD ,

-

. (

,

) 2.

.

, . FreeBSD

CVS (CVS -

repository), .

Linux (

, ,

), FreeBSD

, .

, ,

CVS.

Ɉɛɴɹɫɧɟɧɢɟ ɜɟɬɜɟɣ ɢɫɯɨɞɧɨɝɨ ɤɨɞɚ STABLE ɢ CURRENT FreeBSD ,

. (

),

,

. . . .

,

Ƚɥɚɜɚ 18. ɉɨɞɞɟɪɠɤɚ FreeBSD

339

,

,

-

.

-

CURRENT (

),

- STABLE (

).

5.x . .) . . "

"

(3.x, 4.x, , -

. :

, ,

18.1.

. ,

FreeBSD,

CURRENT --

,

CURRENT STABLE.

-

! CURRENT ,



. .

, ,

CURRENT — STABLE ( CURRENT, . . CURRENT CURRENT,

— ,

( , 5.0), STABLE , a STABLE — .

). CURRENT , .

CURRENT ,

STABLE

,

.

.

ȼɵɛɨɪ ɰɟɥɢ ɨɛɧɨɜɥɟɧɢɹ ,

,

.

:

, CVSup.

). FreeBSD.

,

, ;

-

,

(

,

15.)

. . , RELENG — RELease ENGineer (

, ),

RELEASE. .

. 18.1

CVSup.

(

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, [email protected] [email protected], , , , , . [email protected] (make world)

342

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

. ,

, ,

, ,

.

ɉɊɂɆȿɑȺɇɂȿ Ɉɛɚ ɫɩɢɫɤɚ ɪɚɫɫɵɥɤɢ ɫɥɟɞɭɸɬ ɫɬɚɧɞɚɪɬɭ majordomo ɉɨɞɩɢɫɚɬɶɫɹ ɧɚ ɥɸɛɨɣ ɢɡ ɧɢɯ ɦɨɠɧɨ, ɩɨɫɥɚɜ ɷɥɟɤɬɪɨɧɧɨɟ ɫɨɨɛɳɟɧɢɟ: subscribe freebsd-stable

ɩɨ ɚɞɪɟɫɭ [email protected]. ɇɟ ɩɨɫɵɥɚɣɬɟ ɡɚɩɪɨɫɵ ɩɨ ɩɨɞɩɢɫɤɟ ɧɚ ɚɞɪɟɫɚ freebsdstable ɢɥɢ freebsd-current! ɗɬɨ ɨɞɧɚ ɢɡ ɫɚɦɵɯ ɪɚɫɩɪɨɫɬɪɚɧɟɧɧɵɯ ɨɲɢɛɨɤ ɜ Internet! Ⱦɜɚ ɷɬɢɯ ɚɞɪɟɫɚ ɩɪɟɞɧɚɡɧɚɱɟɧɵ ɞɥɹ ɤɨɧɬɪɨɥɹ ɬɪɚɮɢɤɚ ɫɩɢɫɤɚ ɪɚɫɫɵɥɤɢ, ɚ ɧɟ ɞɥɹ ɩɨɞɩɢɫɤɢ. ȼɵ ɩɨɥɭɱɢɬɟ ɡɚɩɪɨɫ ɩɨɞɬɜɟɪɠɞɟɧɢɹ, ɤɨɬɨɪɵɣ ɧɟɨɛɯɨɞɢɦɨ ɩɟɪɟɫɥɚɬɶ ɨɛɪɚɬɧɨ, ɱɬɨɛɵ ɜɚɫ ɜɤɥɸɱɢ-ɥɢ ɜ ɫɩɢɫɨɤ ɪɚɫɫɵɥɤɢ. ɑɬɨɛɵ ɨɬɩɢɫɚɬɶɫɹ, ɩɪɨɞɟɥɚɣɬɟ ɬɨ ɠɟ ɫɚɦɨɟ, ɡɚɦɟɧɢɜ ɫɥɨɜɨ subscribe ɧɚ unsubscribe ɜ ɬɟɥɟ ɫɨɨɛɳɟɧɢɹ.

,

,

, /usr/src) ( ), . ( ,

,— —

make world . ( , 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 . , , Anonymous CVS CVSup.

FreeBSD, Web).

. Synchronizing Your Source ( CVSup, .

FreeBSD

CVSup CVSup ,

,

15. CVSup 15.



(

cvsupit ,

.

STABLE,

STABLE 4.3-RELEASE, ( .

)

. , RELENG_4_3. , ".", —



Enter . ,

, .

cvsupit, . ), , -

-

344

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

3.

. . /etc/cvsupfile.

,

-

— periodic,

cvsupit

!

-

. , CURRENT,

STABLE

,

. 15.

-

. CVSup

RELEASE

CVSup — RELEASE,

. (

). .

cvsupit cvsupit /etc/cvsupfile 18.1.

cvsupit

/etc/cvsupfile. .

,

Ʌɢɫɬɢɧɝ 18.1 ɉɪɢɦɟɪ ɮɚɣɥɚ /etc/cvsupfile, ɫɨɡɞɚɧɧɨɝɨ ɭɬɢɥɢɬɨɣ cvsupit ________ *default *default *default *default

host=cvsup8.FreeBSD.org base=/usr prefix=/usr release=cvs

*default

tag=RELENG_4

*default

delete

use-rel-suffix

src-all *default tag=. ports-all doc-all

. 4.3-RELEASE *default

-

tag=RELENG_4_3_0_RELEASE

, STABLE

, :

CVSup,

"

"

( CURRENT).



.

make world .

/etc/cvsupfile , .

. ,

,

CVSup , .

• CVSup



, .

(Connection refused — ).

, -

Ƚɥɚɜɚ 18. ɉɨɞɞɟɪɠɤɚ FreeBSD

CVSup.

( .

cvsup8.freebsd.org), CVSup • CVSup , , IP-

345

, -

,

,

(

,

).

. NAT, NAT, , 5999.

. CVSup . CVSup.

• CVSup

/usr/src! ,

. CVS , .

-

. .

,

Ɍɟɤɫɬɨɜɵɣ ɮɚɣɥ UPDATING ,

UPDATING

/usr/src.

,

-

, (



, ).

! — (

UPDATING

)

,

. , ,

make world. ,

. make world

/etc

. ,

,

. , -



. .

UPDATING, ,

. mergemaster, /etc. make world.

, ,

mergemaster

Ɉɛɴɟɞɢɧɟɧɢɟ ɮɚɣɥɨɜ /etc/group ɢ /etc/passwd ɫ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɦɢ ɧɨɜɵɦɢ ɜɟɪɫɢɹɦɢ /etc

. , .

make world — .

,

-

. ,

.

/etc/group. /usr/src/etc/group. 20 . /usr/src/etc/group

,

/etc/group , ,

/etc/group. , 100.

,

.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

346



-

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:

, /usr/src/etc/group network. , GID group. , /etc/group

-, /etc/group

/etc/group, +.

-

, , . (

, )

. find: #

find

/

-group -print

chmod, ,

. passwd, group.

,

/usr/src/etc/master.passwd. /etc/master.passwd adduser.

Ɉɛɴɟɞɢɧɟɧɢɟ ɮɚɣɥɚ /etc/make.conf ɫ ɟɝɨ ɧɨɜɨɣ ɜɟɪɫɢɟɣ make.conf /etc/rc.conf

FreeBSD /etc/ defaults/rc.conf)

.

, make, make world. /etc/make.conf, ( /etc/defaults/make.conf, . ,

. ( CFLAGS= NOPROFILE=

FreeBSD (FreeBSD handbook) /etc/defaults/make.conf /etc/make.conf): -pipe true

10.

# 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

( . schg (

),

root. ,

, rm -rf \.*.

, 1 2 3

cd /usr/obj chflaqs -R noschg rm -rf *

), rm -rf. -

: *

,

securelevel 1 -

( /etc/rc.conf, . man securelevel schg. .

29). ,

Ɂɚɩɭɫɤ ɡɚɩɢɫɢ ɜ log-ɮɚɣɥ log-

make world , )

. (

.

,

,

, ,

.

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

348

,

script.

"

",

.

-

script

exit. f script -/buildworld.out Script started, output # make buildworld

file

is

-/buildworld.out

...

# exit Script done,

output

file

is

-/buildworld.txt

,

. .

log-

make world

.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɇɟ ɪɚɡɦɟɳɚɣɬɟ 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 ,

. # , .

buildworld

"*** Error code I ****. ,

,

Ƚɥɚɜɚ 18. ɉɨɞɞɟɪɠɤɚ FreeBSD

349

,

.

,

,

.

/usr/obj

,

.

/usr/obj

. , stable/freebsd-stable . ,

http://www.freebsd.org ( current/freebsd-current) , uname - , .

CVSup

Ɉɛɧɨɜɥɟɧɢɟ ɹɞɪɚ ,

,

. . GENERIC GENERIC (

17),

: # make buildkernel # make

installkernel

: #

make

kernel

FreeBSD 5.0),

/kernel (/boot/kernel /kernel.old (/booVkernel.old FreeBSD 5.0). , . ,

( . .

GENERIC, . . /usr/src #

make

buildkernel

make

— GENERIC, /boot/kernel , ). installkernel

KERNCONF=GENERIC

kernel.GENERIC: #

/boot/kernel

-

:

KERNCONF=GENERIC

. kernel.prev ( #

)

/boot/kernel.GENERIC

: # make buildkernel KERNCONF=CUSTOM

/boot/ , :

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

350

,

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 schg

installkernel .

, loader),

-s . /usr/src

,

make -

(

boot

.

mount make installkernel.

make installworld ,

(

),

.

. . loader (

reboot.

-

) 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 FreeBSD, mergemaster . , #

.

mergemaster, ,

. ,

-

,

-Rp /etc /etc. old

/etc.

:

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

352

, mergemaster . ) - (

, -v ( ).

diff,

# mergemaster -cv

mergemaster (

, ).

,

-

,

/var/tmp/temproot. ( ,

/etc ,

). /var/tmp/temproot. diff, PAGER ( diff 18.3.

/etc , ). .

,

.

,

Ʌɢɫɬɢɧɝ 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

, /var/tmp/temproot , mergemaster — 'm'

file

to deal with by hand

, .

-

. , .

sdiff. (

)

(

)

*** Type h at the sdiff prompt pccard beep="l" %

# pccard beep

|

(%)

. to get usage help

pccard_beep="2"

# pccard beep

, .

, .

: # mergemaster -cv -w 120

, -w

, -

Ƚɥɚɜɚ 18. ɉɨɞɞɟɪɠɤɚ FreeBSD

sdiff

353

-

'h',

. mergemaster. ).

( . , mergemaster /var/tmp/temproot. , "n ". /var/tmp/temproot

,

,

. mergemaster ,

,

,

, /etc.

,

-

. •

!

/etc . mergemaster,

(

, /etc.old), -

Ctrl+C,

/etc. • Mergemaster

,

mergemaster .

/var/tmp/temproot! , /var/tmp/temproot

"n ".

ɉɟɪɟɡɚɝɪɭɡɤɚ ɫɢɫɬɟɦɵ ɩɨɫɥɟ ɨɛɧɨɜɥɟɧɢɹ : •

?



buildworld?

• • • •

? ? installworld? ,

ps top?



/etc

?

" ", #

.

reboot

?

top.

,

, uname -

ps

: #

uname

-a

FreeBSD stripes.somewhere.com 4.3-STABLE FreeBSD 4.3-STABLE #0: Wed Jan 31 18:45:43 PST2001 [email protected]:/usr/src/sys/compile/CUSTOM i386 , ! make world.

19

Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

◀ Ɋɟɠɢɦɵ ɞɨɫɬɭɩɚ

IDE/ȺɌȺ

◀ Ⱦɢɫɤɢ SCSI ◀ Ƚɟɨɦɟɬɪɢɢ ɠɟɫɬɤɨɝɨ ɞɢɫɤɚ ◀ Ɋɚɡɛɢɟɧɢɟ ɠɟɫɬɤɨɝɨ ɞɢɫɤɚ ɧɚ ɪɚɡɞɟɥɵ ◀ ɋɨɡɞɚɧɢɟ ɞɢɫɤɨɜɵɯ ɦɟɬɨɤ ◀ ɉɨɞɝɨɬɨɜɤɚ ɮɚɣɥɨɜɨɣ ɫɢɫɬɟɦɵ ɤ ɢɫɩɨɥɶɡɨɜɚɧɢɸ

Ƚɥɚɜɚ 19. Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

. Macintosh (

)

Windows (

355

BIOS

), UNIX-

,

,

.

FreeBSD

. 9,

UNIX , : ,

. (slices)

,

,

,

.

, sysinstall

.

-

.

Ɋɟɠɢɦɵ ɞɨɫɬɭɩɚ IDE/ATA IDE (Integrated Drive Electronics — ,

). ,

, ( , ATA (Advanced Technology IDE IDE/ATA SCSI.

, , SCSI). Attachment — . , ,

). IDE-

. .

SCSIIDE ( ). ,

.

IDE 86. ,

,

FreeBSD.

Ɋɟɠɢɦɵ ɊIO IO (Programmed I/O IO DMA .

IO

) . BIOS

,

. Ultra DMA.

, 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-

,

,

. . 19.2. ,

DMA. -

90-

.

, .

. Ɍɚɛɥɢɰɚ 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-

,

Windows

, -

DMA ,

95. .

Ɋɟɠɢɦ Ultra DMA , DMA /

Ultra DMA. . SCSI,

. Ultra DMA DMA.

,

-

Ƚɥɚɜɚ 19. Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

. 33 Ultra DMA IDE: 80

357

, / .

-

. 19.3. 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, :

• • 80• •

,

Ultra DMA; IDE; ( Ultra DMA

IDE), (

Ultra DMA; BIOS).

,

, ,

IO,

,

-

BIOS.

,

-

UDMA, "

, BIOS (

" . UDMA),

UDMA

,

. Ultra DMA. , dmesg:

FreeBSD .

,

ad0: 6194MB UDMA33

[13424/15/63]

at

,

,

ataO-master

using

UDMA , (

,

-

),

MS-DOS

UDMA.

, .

Ⱦɢɫɤɢ SCSI IDE, SCSI ( IDE.

SCSI. . 19.4)

,

1. ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD 19.4

SCSI ,

/

,

,

,

SCSI-1

SCSI

5

6

8

50

SCSI-2

Fast SCSI

10

3

8

50

10

6

16

68

Wide SCSI Fast Wide SCSI SCSI-3

20

3

16

68

20

1,5-3

4-8

50

Wide Ultra SCSI

40

1.5-3

4-16

68

Ultra2 SCSI

40

12

8

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-

16.

, ( .

.

, ),

SCSI IDE/ATA . ,

, IDE/ATA ). , (

, SCSI. (

,

Iomega ZIP, . SCSI FireWire (IEEE 1394). SCSIIDE1,5—2 .

...

, ,

). ). . PC Guide

,

,

, ( ,

Web-

. SCSI-

.

, SCSI , SCSI BIOS,

:

) , -

( SCSI-

,

,

.

, SCSI-

,

. SCSI

8

,

, SCSIhttp://www.pcguide.com.

,

Ƚɥɚɜɚ 19. Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

, fdisk ( FreeBSD ,

359

). , , Pentium 166 :

Windows. FreeBSD. IDE-

70- -



8

.

.

,

. ,

,

,

,

IDE

. ,

(

.

,





. 19.1),

,

.

,

. ɝɨɥɨɜɤɚ

ɞɨɪɨɠɤɚ ɐɂɅɂɇȾɊ -

Ɋɢɫɭɧɨɤ 19.1

, .

.

-

, 8

.

— .

. (

64, , 512).

(

63). .

.

,

9,

fdisk

:

# 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 ,

/

255

heads

x

63

)

:

sectors/track x 512 bytes/sector =

?

? 64

,

, —

,

. ,

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

360

,

. ,

BIOS. (

LBA

,

Extended INT13).

Ɋɟɠɢɦ LBA ɢ ɩɪɟɞɟɥ 528 Ɇɛ -

, ,

528 ,

,

-

. BIOS . 19.5.

.

,

Ɍɚɛɥɢɰɚ 19.5 Ɉɝɪɚɧɢɱɟɧɢɹ, ɧɚɤɥɚɞɵɜɚɟɦɵɟ ɧɚ ɝɟɨɦɟɬɪɢɸ ɠɟɫɬɤɨɝɨ ɞɢɫɤɚ ɐɢɥɢɧɞɪɵ

10

210-1 = 1023

Ƚɨɥɨɜɤɢ

8

28-1 = 255

ɋɟɤɬɨɪ/Ⱦɨɪɨɠɤɚ

6

26-1 = 63

, (

255

1023 — ,

, ).

-

,

. 528 . 1993 .

16 , BIOS

.

, .. 1023

, BIOS ).

LBA 1024

, 1852 463

.

! LBA (Logical Block Addressing — BIOS " ", , ( 255). ,

16 64

.

, ,

BIOS.

...

.

Ɋɟɠɢɦɵ Extended INT13 ɢ ɩɪɟɞɟɥ 8.4 Ƚɛ ,

LBA -

, .

8,4

,

.

. BIOS,

Extended INT13 (

-

13), Windows (

-

BIOS, Addressing Packet), ,

FreeBSD). 16-

).

(Disk (

Ƚɥɚɜɚ 19.0 ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

8,4

Extended INT13, , , ,

,

. 16383

, 16 ,

"

IDE

63

.

, .

,

361

".

,

FreeBSD ,

137 — 65536... (

.—

.)

ɉɪɚɤɬɢɱɟɫɤɢɟ ɜɨɩɪɨɫɵ FreeBSD

,

LBA, .

, 8,4 ,

,

,

-

10

.

, , . FireWire (IEEE 1394),

, SCSI

,

. ,

IDE/ATA.

Ɋɚɡɛɢɟɧɢɟ ɠɟɫɬɤɨɝɨ ɞɢɫɤɚ ɧɚ ɪɚɡɞɟɥɵ : , IDE-

.

, ,

,

SCSI-

. ,

. , (slave) 9, — /dev/adl. (SCSI , adl,

40 , /dev/dal.) ,

IDE. .

.

, ,

,

.

Ɋɚɡɞɟɥɵ BIOS (Slices) . FreeBSD

, BIOS Windows

BIOS. FreeBSD . , BSD".

, BIOS, ,

.

BIOS FreeBSD ,

. " Macintosh,

" (partitions). "

" (slices).

, .

"

Ɋɚɡɞɟɥɵ BSD FreeBSD, : /var, /usr, /home

. .

,

-

# ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeB

.

BSD,

19.6.

.

BSD (

,

), . 19.6

BSD

ɚ

Ʉɨɪɧɟɜɨɣ ɪɚɡɞɟɥ (/)

b

Ɋɚɡɞɟɥ swap

ɫ

Ⱥɞɪɟɫɭɟɬɫɹ ɤ ɫɥɨɸ ɰɟɥɢɤɨɦ ɢɥɢ ɜɫɟɦɭ ɞɢɫɤɭ ɜ "ɨɩɚɫɧɨɦ" ɪɟɠɢɦɟ. ("Ɉɩɚɫɧɵɣ" ɪɟɠɢɦ ɢɫɩɨɥɶɡɨɜɚɥɫɹ ɜ ɩɪɨɲɥɨɦ, ɱɬɨɛɵ ɨɛɨɣɬɢ ɩɪɨɛɥɟɦɵ ɫ ɝɟɨɦɟɬɪɢɟɣ ɞɢɫɤɚ. Ɉɧ ɧɟ ɢɫɩɨɥɶɡɭɟɬɫɹ ɜɨ FreeBSD 4.4 ɢ 5.0)

d

Ⱦɥɹ ɨɛɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ (ɧɟ ɢɫɩɨɥɶɡɭɟɬɫɹ ɭɬɢɥɢɬɨɣ Disklabel Editor)

ɟ

Ⱦɥɹ ɨɛɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ

f

Ⱦɥɹ ɨɛɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ

g

Ⱦɥɹ ɨɛɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ

h

Ⱦɥɹ ɨɛɳɟɝɨ ɢɫɩɨɥɶɡɨɜɚɧɢɹ

. 19.2 ,

. . IDE/ATA ). BSD (e).

adO

(adl) ad3 (

,

1 (s1).

1

1

BSD e

19.2

/dev/ad1s1e

FreeBSD:

, DOS (Extended DOS Partition) ( ).

, DOS/Windows-

-

Linux. , DOS, , DOS).

, DOS,

FreeBSD. . FreeBSD 5(..

. , Windows,

Linux-

FreeBSD . Linux

Ƚɥɚɜɚ 19. Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

. DOS/

363

(

FreeBSD

)

,

FreeBSD:

, FreeBSD

.

Linux

. 19.7,

/

. , FreeBSD.

DOS

Ɍɚɛɥɢɰɚ 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 "Fdisk",

"Configure". partition) Editor". . slave.

"Slice (PC-Style , adl ( , , , -

, ). , /var/run/dmesg.boot.

,

, .

,

,

, "Single". -

,

"Master", , fdisk (fixed disk —



"Slave".

(

) ).

, BIOS ( ,

).

fdisk

,

, ,

sysinstall. ,

! .

,

. FreeBSD, Linux — "Use Entire Disk" ( . 19.3. : ( .

BIOS

DOS.

,

, ).

, . " FreeBSD (adlsl)

, " ,

, "

,

.

-

"

-

),

1

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

19.3

Slice Editor ( "Use Entire Disk").

. , Slice Editor

W. ,

Q. .

,

None ( ). Boot Manager (BootMgr).

, FreeBSD

, ,

"Standard" — MBR Linux BootMgr FreeBSD),

, . DOS fdisk /MBR, ( LILO , , Windows.

, ,

,

FreeBSD, — Disklabel Editor ( sysinstall,

.

).

Label (

),

.

adl

disklabel.

Disklabel Editor. . Disklabel Editor — BSD.

ɉɊɂɆȿɑȺɇɂȿ Disklabel Editor ɜɨ FreeBSD ɧɟ ɩɨɡɜɨɥɹɟɬ ɢɡɦɟɧɹɬɶ ɪɚɡɦɟɪɵ ɫɭɳɟɫɬɜɭɸɳɢɯ ɪɚɡɞɟɥɨɜ. ɗɬɨɝɨ ɧɟɥɶɡɹ ɫɞɟɥɚɬɶ, ɧɟ ɩɟɪɟɮɨɪɦɚɬɢɪɨɜɚɜ ɟɝɨ ɫ ɩɨɬɟɪɟɣ ɜɫɟɯ ɞɚɧɧɵɯ, ɩɨɷɬɨɦɭ ɬɳɚɬɟɥɶɧɨ ɩɪɨɞɭɦɚɣɬɟ ɫɯɟɦɭ ɫɨɡɞɚɧɢɹ ɪɚɡɞɟɥɨɜ ɞɨ ɬɨɝɨ, ɤɚɤ ɫɨɯɪɚɧɹɬɶ ɢɡɦɟɧɟɧɢɹ!

ɉɨɥɧɚɹ ɪɚɡɦɟɬɤɚ ɪɚɡɞɟɥɚ FreeBSD , , BSD /var

. ,

,

"Adding a New Disk". Disklabel Editor FreeBSD, , /usr, FreeBSD , .

Ƚɥɚɜɚ 19. Ɉ ɠɟɫɬɤɢɯ ɞɢɫɤɚɯ ɢ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦɚɯ

365

"Auto Defaults for all!" ( ). (

.

, FreeBSD-

. 19.4).

,

. 19.4 Disklabel Editor

(

"Auto

Defaults for all!".

. log-

100 log-

/var. ,

100

,

/var

Web-

20

,

. .

, , ,

D.

,

/var

— Disklabel Editor. /var /usr. "Free:"

,

. .(

,

,

W.) " ",

"Partition name: adlsl", ,

. /var 200 ,

.

,

.( .)

"200m".

,

, (

FS — ,

).

/var. .

"Free:" "/usr", .

. 19.5.

Ⱦɨɛɚɜɥɟɧɢɟ ɧɨɜɨɝɨ ɞɢɫɤɚ BSD. He

, .

,

"Partition name: adlsl" /home),

BSD , ..

. (

, .

40

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

366

,

:

(

, 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. /etc/fstab

.

. mount 9. :

FreeBSD.

.

mount ,

,

, /mnt/newdisk. ( mount:

.) #

mount

/dev/adlsle

/mnt/newdisk

,

,

df. To

, . #

umount

umount:

/mnt/newdisk

— FreeBSD!

20

Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

◀ ɉɟɪɟɯɨɞ ɤ FreeBSD ◀ ɑɟɝɨ ɞɟɥɚɬɶ ɧɟ ɫɥɟɞɭɟɬ ◀ Ɍɨɧɤɚɹ ɧɚɫɬɪɨɣɤɚ ɩɪɨɢɡɜɨɞɢɬɟɥɶɧɨɫɬɢ ◀ ɉɨɞɝɨɬɨɜɤɚ ɤ ɯɭɞɲɟɦɭ: ɪɟɡɟɪɜɧɵɟ ɤɨɩɢɢ

Ƚɥɚɜɚ 20. Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

FreeBSD,

369

,

. ,

-

. FreeBSD.

, . -

:

, . .

-

,

, .

FreeBSD

. FreeBSD ,

— Linux. ,

, .

Windows, ,

, ,

,

,

.

ɉɟɪɟɯɨɞ ɤ FreeBSD 15-20% FreeBSD. Linux. NetBSD, OpenBSD

. ,

UNIX65%.

(

FreeBSD , UNIX,

UNIX-

,

Windows NT/2000 , , , . , . . Linux

20-30%

, )

FreeBSD , -

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 ( ,

UNIX. , ,

SSH) — .

,

-

,

. ,

-

: ( Windows, ,

, .

,

, )

— .

Windows NT/2000

. .

, o-

Ƚɥɚɜɚ 20. Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

371

,

Windows,

FreeBSD

. Administrator.

root root

. -

: ,

(

,

).

Windows NT/2000 FreeBSD. • FreeBSD User, Group Other. ACL •

(

Windows NT/2000 paths), "

Windows NT/2000 (Access Control Lists). FreeBSD 5.0 . 10), Windows NT/2000 — . " " (trusted , . , Windows " -

,

(

),

-

. FreeBSD

. Kerberos (

29). •

FreeBSD

16 .

-

. •

Windows NT/2000

27 . FreeBSD root,

( •

set-user-ID —

FreeBSD

. •



). . . Windows NT/2000 -

UNIX

. Windows ( ,

, setuid -

FreeBSD

.

UNIX. , Domain Controller Windows NT/2000) NIS (yellowpages, " "). NIS man nis. , NetBIOS Windows, UNIXNFS. Samba FreeBSD Windows. NFS 31, Samba 32.

,

372

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

• Windows

Authenticode. "

", .

. /

,

UNIX FreeBSD , . 15.

, .

Windows NT/2000 , UNIX,

, ,

. Windows , FreeBSD, UNIX (

: . .

,

), UNIX. , Administration, Networking, and Security) — http://www.sans.org.

Windows,

FreeBSD (

,

, ,

SANS (System ,

-

, . 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

, .

: UNIX

. .

, Web-

, DNS-cep

: • UNIX.

, .

• Windows,

UNIX "

"

, .

,

UNIX.

,

,

UNIX,

,

Windows-

Microsoft (service packs).

.

— ,

(

.

,

) Web-

(hotfixes),

Microsoft. FreeBSD , , ,

, ,

,

. FreeBSD ,

, ,

. CVSup

, .

FreeBSD,

, (patches). . FreeBSD Security Officer (

, ),

,

,

-

.

. .

,

-

.

,

-

, make world,

.

18.

,

FreeBSD, . ,

18,

RELEASE, ,

, .

374

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

Linux , Linux UNIX, . , Linux).

(

FreeBSD,

Windows NT/2000.

FreeBSD , , Linux

. FreeBSD

,

-

, ,

,

Windows. Linux

FreeBSD:

12 13 14 15 16 17 FreeBSD?

:

, , (/usr/bin, /var/lib

,

/usr/local. FreeBSD " " . .).

. 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

Linux

)

RPM ( FreeBSD,

/ .

FreeBSD, FreeBSD

(Linux BSD). 15.

,

System V,

Ɋɚɡɞɟɥɵ ɢ ɬɢɩɵ ɮɚɣɥɨɜɵɯ ɫɢɫɬɟɦ Ext2FS,

Linux,

DOS: "

BIOS, ",

"

.

"

"

",

. (

-

!), FreeBSD

(slice),

. :

,

BIOS, BSD). ,

( , .

,

. FreeBSD

,

FreeBSD , Ext2FS. ,

19. Linux

UFS/FFS. FreeBSD

-

17.

ɉɨɪɬɵ ɢ ɩɚɤɟɬɵ ,

Linux,

, RPM.

FreeBSD,

(

, /usr/lib).

, FreeBSD

.

(pkg_*) ,

Linux

UNIX,

. FreeBSD

. ,

,

,

. (committers).

15.

ɋɢɧɯɪɨɧɢɡɚɰɢɹ ɫɢɫɬɟɦɵ FreeBSD

,

Linux:

-

, Linux

.

. .

,

Linux.

, -

376

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

, . , FreeBSD

CVSup, Linux

(hotfixes) (

18. RPM, FreeBSD .

) : ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ

Ɉɛɧɨɜɥɟɧɢɟ ɤɨɦɩɨɧɟɧɬɨɜ ɫɢɫɬɟɦɵ (ɚ ɧɟ ɫɢɫɬɟɦɵ ɰɟɥɢɤɨɦ) ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɷɮɮɟɤɬɢɜɧɵɣ ɦɟɬɨɞ, ɤɨɬɨɪɵɣ ɪɚɛɨɬɚɟɬ ɜ ɛɨɥɶɲɢɧɫɬɜɟ ɫɥɭɱɚɟɜ (ɨɫɨɛɟɧɧɨ ɞɥɹ ɧɟɛɨɥɶɲɢɯ ɤɨɦɩɨɧɟɧɬɨɜ ɫɢɫɬɟɦɵ]. ɇɨ ɱɟɦ "ɮɭɧɞɚɦɟɧɬɚɥɶɧɟɟ" ɫɨɫɬɚɜɧɨɣ ɷɥɟɦɟɧɬ ɫɢɫɬɟɦɵ, ɬɟɦ ɛɨɥɶɲɟ ɜɟɪɨɹɬɧɨɫɬɶ ɬɨɝɨ, ɱɬɨ ɞɥɹ ɟɝɨ ɤɨɪɪɟɤɬɧɨɣ ɪɚɛɨɬɵ ɩɨɬɪɟɛɭɟɬɫɹ ɜɵɩɨɥɧɢɬɶ make world (ɫɦ. ɝɥɚɜɭ 18]. Ɍɚɤɢɟ ɜɚɠɧɵɟ ɫɨɫɬɚɜɧɵɟ ɱɚɫɬɢ ɫɢɫɬɟɦɵ ɜɤɥɸɱɚɸɬ, ɤɚɤ ɩɪɚɜɢɥɨ, ɨɫɧɨɜɧɵɟ ɛɢɛɥɢɨɬɟɤɢ (ɜ ɤɚɬɚɥɨɝɟ /usr/lib] ɢ ɡɚɝɨɥɨɜɨɱɧɵɟ ɮɚɣɥ (/usr/include) Ʉ ɦɟɧɟɟ ɪɢɫɤɨɜɚɧɧɵɦ ɨɛɥɚɫɬɹɦ ɨɬɧɨɫɹɬɫɹ ɞɜɨɢɱɧɵɟ ɮɚɣɥɵ ɜ /usr/bin ɢ /usr/sbin.

Linux

FreeBSD

10. FreeBSD , a /etc/passwd — Linux /etc/shadow . /etc/shadow Linux, FreeBSD. . 20.1 ( CD-

(shadow passwords). /etc/master.passwd ( ). , /etc/passwd master.passwd Perl, mkpasswd.pl).

20.1 Linux

FreeBSD

#!/usr/bin/perl 5 6 ), $newshell = "/bin/csh"; open (PASSWD,"/etc/passwd"); @passwd = ; close (PASSWD) ; open (SHADOW,"/etc/shadow"); @shadow = ; close (SHADOW); foreach $user (@shadow) { @sdata = split(/:/,$user); $passhash(@sdata[0]} = @sdata[l];

bash

FreeBSD-

( /bin/csh

#

/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

,

. FreeBSD

11 , tcsh .

bash.

tcsh, , . .

csh

-

bash,

. Linux (

12 /compat/linux, , linux.ko ( "

) -

Linux-

. kldstat). Linux.

"

-

, .

, FreeBSD,

.

-

378

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD



FreeBSD root. (

.

/etc/ttys

10).



5.0 FreeBSD " 17.

/dev, ,

DEVFS, PCI FreeBSD .

• "

"

, .

Linux , , FreeBSD

. ethl Linux

ethO fxpO.

fxpl

PCI

, "

DEVFS .

"

, " ,

,

Linux

Ethernet ,

FreeBSD

.

ɑɬɨ "ɫɥɟɞɭɟɬ" ɢ "ɧɟ ɫɥɟɞɭɟɬ" ɞɟɥɚɬɶ , ,

. -

. ,

:



. , "

"

,

,

.

, ,

[email protected]. , . •

(

,

)

-

. ,

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,

,

. NTP-

ntpd, /etc/ntp.conf.

,

man ntp.conf. FreeBSD.

,

13

-

15

-

Linux;

( Microsoft

).

,

14

. ?

, .

,

,

, Web-

,

,

.

,

.

29. FreeBSD. freebsdfreebsd-

15 ,

[email protected]. [email protected] [email protected]. STABLE CURRENT, [email protected] [email protected]. 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),

,

, , -

, (

,

).

• Windows-

Perl FTP.

,

,

, ( .

, #!/usr/bin/perI)

-

CGI-

, ,

,

ASCII-

. .

-

.

Ɍɨɧɤɚɹ ɧɚɫɬɪɨɣɤɚ ɩɪɨɢɡɜɨɞɢɬɟɥɶɧɨɫɬɢ FreeBSD ,

.

, ,

, ,

Linux .

FreeBSD .

Windows. ,

, FreeBSD

FreeBSD ,

. .

Ƚɥɚɜɚ 20. Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

381

. (



17),

.

ɇɚɫɬɪɨɣɤɢ ɹɞɪɚ , .

GENERIC ,

. ,

. MAXUSERS (

, 32).

, (

),

,

(

,

NMBCLUSTERS 128

MAXUSERS

. .). 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 .

. Soft Updates, , (I/O) . GENERIC

"

.

, .

tunefs. FFS,

FreeBSD. ,

,

,

tunefs , -

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

382

.

tunefs

-

/sbin, . boot -s

( :

).

-

tunefs -n enable / tunefs n enable /usr tunefs -n enable /var

. tunefs.

/sbin/tunefs (

, Soft Updates)

, . ,

— ,

. (

). , async

,

/etc/fstab. :

mount

mount,

,

# mount -

async /usr /dev/adOslf

async :

/etc/fstab, /dev/adOslf

/usr

ufs

rw,async

2

2

ȼɨɩɪɨɫɵ ɝɟɨɦɟɬɪɢɢ ɞɢɫɤɚ 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

,

, .

,

,

sysctl.conf,

/etc/ :

sysctl

# sysctl vfs.vmiodirenable vfs.vmiodirenable: 0

,

-w:

# sysctl -w vfs.vmiodirenable=l vfs.vmiodirenable: 0 -> 1

ɉɨɥɟɡɧɵɟ ɫɩɪɚɜɨɱɧɵɟ ɪɭɤɨɜɨɞɫɬɜɚ man tuning. , ,

, .

man tunefs Soft Updates, ,

tunefs 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" [email protected]

/etc/periodic/daily

-

crontab

root.

Ɋɟɡɟɪɜɧɵɟ ɤɨɩɢɢ . ,

, .

, ,

.

Ƚɥɚɜɚ 20. Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

385

, . dump.

UNIX /etc/ fstab ( , -

dump, 9).

"

" ,

.

. . , (/dev/rsaO

. ),

, .

,

, .

SCSI-

SCSI.

,

,

,

FreeBSD

Fire Wire (IEEE 1394). IDE/ATAPI. !

,

dump

. /home: # dump -Ou -f /dev/nrsaO /home

0( . .

0 dump,

), ,

/etc/dumpdates. " " .

,

ɉɊɂɆȿɑȺɇɂȿ ɍɫɬɪɨɣɫɬɜɨ nrsaO ɫɨɜɩɚɞɚɟɬ ɫ rsaO ɡɚ ɢɫɤɥɸɱɟɧɢɟɦ ɬɨɝɨ, ɱɬɨ ɩɟɪɜɨɟ ɢɦɹ ɭɤɚɡɵɜɚɟɬ ɧɚ "ɧɟɩɟɪɟɦɚɬɵɜɚɟɦɨɟ" ɭɫɬɪɨɣɫɬɜɨ. ɗɬɨ ɢɦɹ ɭɤɚɡɵɜɚɟɬ ɩɪɨɝɪɚɦɦɟ, ɱɬɨ ɩɨ ɨɤɨɧɱɚɧɢɢ ɡɚɩɢɫɢ ɥɟɧɬɭ ɩɟɪɟɦɚɬɵɜɚɬɶ ɧɟ ɧɭɠɧɨ. ɇɨɫɢɬɟɥɢ ɧɚ ɦɚɝɧɢɬɧɨɣ ɥɟɧɬɟ, ɜ ɱɚɫɬɧɨɫɬɢ ɫɨ SCSI-ɢɧɬɟɪɮɟɣɫɨɦ, ɢɫɩɨɥɶɡɭɸɬ ɢɦɟɧɚ ɭɫɬɪɨɣɫɬɜɚ ɤɚɤ ɨɩɰɢɢ, ɡɚɞɚɸɳɢɟ ɭɬɢɥɢɬɟ dump ɪɟɠɢɦ ɪɚɛɨɬɵ ɫ ɥɟɧɬɨɣ. ɋɦ. ɬɚɛɥ. 20.3. Ɍɚɛɥɢɰɚ 20.3 Ɇɟɬɚɢɦɟɧɚ ɭɫɬɪɨɣɫɬɜɚ ɜ ɤɚɱɟɫɬɜɟ ɨɩɰɢɣ ɭɩɪɚɜɥɟɧɢɹ /dev/saO

Ɋɟɚɥɶɧɨɟ ɢɦɹ ɭɫɬɪɨɣɫɬɜɚ

/dev/rsaO

ɍɤɚɡɵɜɚɟɬ dump ɩɟɪɟɦɨɬɚɬɶ ɥɟɧɬɭ ɤ ɧɚɱɚɥɭ ɩɨ ɡɚɜɟɪɲɟɧɢɢ ɡɚɩɢɫɢ

/dev/nrsaO

ɍɤɚɡɵɜɚɟɬ dump ɧɟ ɩɟɪɟɦɚɬɵɜɚɬɶ ɥɟɧɬɭ ɤ ɧɚɱɚɥɭ ɩɨ ɡɚɜɟɪɲɟɧɢɢ ɡɚɩɢɫɢ

/dev/ersaO

ɍɤɚɡɵɜɚɟɬ dump ɜɨɡɜɪɚɬɢɬɶ ɤɚɫɫɟɬɭ ɢɡ ɤɚɫɫɟɬɨɩɪɢɟɦɧɢɤɚ ɩɨ ɡɚɜɟɪɲɟɧɢɢ ɡɚɩɢɫɢ

" , #

dump -lu -f /dev/nrsaO /home

"

, dump:

386

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

,

dump . 3,

,

4,

, 3. 2,

.

,

-

3 .

,

4, 0 ,

, . : 0, (



1,

).

. . man dump.

ȼɨɫɫɬɚɧɨɜɥɟɧɢɟ restore. . ,

,

. restore

cd, : # restore

-if

/dev/nrsaO

( delete.

)

: cd, Is, pwd, add, delete , (

add). extract .

.

,

restore

man restore.

restore> add frank restore> extract

: # restore

-rf

/dev/nrsaO

, .

,

.

, .

, mt (magnetic tape —

). ,

, .

(fast forward —

,

,

fsf

):

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 , .

, usr/local/www, /var/mail , , /usr/local/sbin , . .

,

/etc.

CVSup. : /home, -

, . cvsupd ( cvsup),

. root,

:

cd /usr/local/etc mkdir -p cvsup/sup cd cvsup/sup mkdir home www mail etc

# # # #

: .cvs

releases. . :

upgrade home rsymlink

*

" home

"

cvsupd home.cvs

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

388

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 *default *default *default *default

CVSup (mirror-supfile)

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

, pwd_mkdb

master.passwd (

"

Ƚɥɚɜɚ 20. Ʉɭɪɫ ɜɵɠɢɜɚɧɢɹ ɞɥɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ FreeBSD

389

Linux"). ,

. CVSup .

,

-

,

!

-

,

-

, CVSup . CVSup

4-5

15

/etc/periodic/daily

, , root. -

crontab .

,

-L.

mirror-supfile.

. /usr/local/etc/cvsup/sup —

cvsupd .

-

, . ,

, .

,

,

,

-

FreeBSD

. . ,

, .

-

21

Perl

◀ ◀ Perl

Perl? FreeBSD



Perl



Perl

◀ ◀

Perl ,

Perl

Ƚɥɚɜɚ 21. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ ɹɡɵɤɟ Perl

UNIX "

Perl. .

Perl

391

Internet ", Perl

,

-

,

,

.

,

, Perl .

, ,

,

,

Perl FreeBSD

C++ ( ). Perl

-

.

ɑɬɨ ɬɚɤɨɟ Perl? Perl

, ,

,

.

FreeBSD

. "Practical Extraction and Report Language" — ( (Larry Wall) awk. , Perl 6. Perl ,

). Perl .

. —

,

-

, "

"

,

Perl. , (

)

. ,

FreeBSD

,

,

Perl ,

, Internet.

Perl

Perl ɜɨ FreeBSD , Perl.

,

.

, "

, .

Perl -

, C++ ,

, ", .

,

,

Perl — /usr/bin/perl.

13, .

Perl -

-

. .

/bin/sh. ,

FreeBSD, -

.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

392

" (batch programs, ,

" -

MS-DOS). , . A Perl , ,

Web-

.

Perl

,

,

,

(

, ,

).

Perl ,

, adduser,

,

. Perl ,

FreeBSD. sockstat. , majordomo ( ,

adduser, pkg_version , ).

, ,

Perl,

. Perl

, ,

-

,

.

ɋɢɥɶɧɵɟ ɫɬɨɪɨɧɵ Perl Perl (

)

(

).

,

,

,

, -

, ,

,

,

, , . Perl

, , .

Perl Web-

CGI-

,

. 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

( ) , . .

:

,

,

, -

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

394

#!/usr/bin/perl $string = "Hello world!"; $hostname = 'hostname'; if ($hostname eq "uncia") print $string."\n"; print "date'; }

{

, "if/fi"

if

,

"case/esac".

(;),

. : "$ = 1" ,

Perl

"$ =1". , Perl

.

, ,

. Perl

,

: — "

" .

, Perl

. . .

Perl

,

,

, (

#

, adduser Perl, chmod:

majordomo). -

chmod +x myscript.pl

, — -rwxr-xr-x

1 frank

, "." ( . .

frank

170 Jun 14

2000 myscript.pl*

, ,

),

# ./myscript.pl Hello world! Sat Apr 28 15:29:17

0755 (

10): ./

PDT 2001

Perl

,

, . #

-

, , perl:

perl myscript.pl

.

perl . #

-

:

-w ,

:

perl -w myscript.pl

#!/usr/bin/perl -w

ɉɟɪɟɦɟɧɧɵɟ ɢ ɨɩɟɪɚɬɨɪɵ Perl

,

-

. .

Ƚɥɚɜɚ 21. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ ɹɡɵɤɟ Perl

(

395

),

,

Perl " )

( Perl

-

" (literals). ($). ,

, , . Perl

(

. .). , ,

, . . Perl

. ,

, , "123blah"

,

,

"123". :

(+, -, =),

(++

(+=, -=, *=), (>, , = 5) { print "Greater than 5\n" ; } else { print "Must be less than 5\n" ; }

ɉɊɂɆȿɑȺɇɂȿ

Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ, ɱɬɨ ɜ ɭɫɥɨɜɢɢ ($ɚ == 5) ɢɫɩɨɥɶɡɭɟɬɫɹ ɪɚɜɟɧɫɬɜɚ ==, ɚ ɧɟ ɨɩɟɪɚɬɨɪ ɩɪɢɫɜɚɢɜɚɧɢɹ =. Ɉɩɟɪɚɬɨɪ == ɢ ɞɪɭɝɢɟ ɨɩɟɪɚɬɨɪɵ ɫɪɚɜɧɟɧɢɹ ɜɫɟɝɞɚ ɩɪɢɦɟɧɹɸɬɫɹ ɜ ɭɫ-

398

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

ɥɨɜɧɵɯ ɨɩɟɪɚɬɨɪɚɯ. ȿɫɥɢ ɫɪɚɜɧɢɜɚɟɦɵɟ ɡɧɚɱɟɧɢɹ ɹɜɥɹɸɬɫɹ ɫɬɪɨɤɚɦɢ, ɚ ɧɟ ɱɢɫɥɚɦɢ, ɢɫɩɨɥɶɡɭ-ɸɬɫɹ ɢɯ ɫɬɪɨɤɨɜɵɟ ɷɤɜɢɜɚɥɟɧɬɵ: eq ɜɦɟɫɬɨ ==, It ɜɦɟɫɬɨ 0)

+

1 ɢɥɢ ɩ ɜɯɨɠɞɟɧɢɣ ɩɪɟɞɵɞɭɳɟɝɨ ɬɟɤɫɬɚ (ɩ > 1)

*?

Ɂɚɫɬɚɜɥɹɟɬ ɩɪɨɢɡɜɨɞɢɬɶ ɩɨɢɫɤ ɫ ɤɜɚɧɬɢɮɢɤɚɬɨɪɨɦ *, ɧɚɱɢɧɚɹ ɫ ɦɢɧɢɦɚɥɶɧɨɝɨ ɫɨɨɬɜɟɬɫɬɜɢɹ

, ,

402

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

{m}

Ɍɨɱɧɨ m ɜɯɨɠɞɟɧɢɣ ɩɪɟɞɵɞɭɳɟɝɨ ɬɟɤɫɬɚ

{m,n}

Ɉɬ n ɞɨ m ɜɯɨɠɞɟɧɢɣ ɩɪɟɞɵɞɭɳɟɝɨ ɬɟɤɫɬɚ

{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-

.

, " "

" tr///

? Perl s///, , substr( ).

": ,

-

=~, ,

.

,

,

-

Ƚɥɚɜɚ 21. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ ɹɡɵɤɟ Perl

,

s,

403

-

.

-

:

$mystring =~ s/^test[0-9]/foo/g;

,

-

HTML-

:

$myhtml =~ s//>/g;

,

g .

c

,

,

. ?

([0-9]) .

,

, . , /abc(123)(.*)\l\2/, ,

. \1 0,

# —

\#, , \2 —

, 123,

-

.*.

1. . ,

,

,

\1

,

$2.

\2, ,

$1

, .

:

$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

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

404

-

substr( ). Perl. , .

-

:

$mystring = "cat and dog"; $newstring = substr($mystring,0,3);

Snewstring substr( )

"cat". index( ).

,

-

: $mystring = "cat and dog"; $newstring = substr($mystring,index($mystring,"cat"),index($mystring,"dog"));

"cat and " (

Smystring

-

).

Ɋɚɛɨɬɚ ɫ ɮɚɣɥɚɦɢ ,

(filehandles) ,

operator) ( (

. . ,

-

. (diamond

). )

( ).

,

,

: while

(< >) {

print

$_;

}

, —

-

:

# ./myscript.pl filel.txt file2.txt ...

,

cat. . -

,

. . ,

n( ). .

,

:

open (FH,"/path/to/filel.txt"); @contents = ; close

(FH);

,

Perl

,

,

,

.

-

die: die, (

)

.

Ƚɥɚɜɚ 21. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ ɹɡɵɤɟ Perl

-

:

open (FH,"/path/to/filel.txt") @contents = ; close

405

|| 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. (

), . , select

. / select( ):

(FH);

print FH. STDOUT opendir( ) ,

FH

. readdir( ). -

: opendir (DIR,"/path/to/dir"); @files = sort readdir (DIR); closedir (DIR) ;

.

,

, /etc/passwd, 1000, .

#!/usr/bin/perl open (PASSWD,"/etc/passwd") @passwd = ; close (PASSWD);

|| die ("Can't open passwd file!");

,

-

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

406

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 sub sum { local($mysum); $mysum += $_ foreach (@_) ; $mysum; # # }

$mysum

,

407

,

,

. ,

-

. :

my

($mysum,

$name,

$hash);

Perl , ,

"

" (strict mode),

,

. ,

Perl,

, . .

Ɇɨɞɭɥɢ Perl ,

Perl

.

,

Perl ( Perl-

) . m (

Perl module -• " Perl"). Internet , , Perl . Perl ( , mylib.pm) ,

FreeBSD. . m ,

"

"

, . use (

. m

): use mylib;

FreeBSD Perl

Perl

/usr/lib/perl5. . /usr/local/lib/perl5. man (

Perl),



, : (

(site_perl). ,

) .

,

i386-freebsd, ,

Perl

(

,

). : (::) Net::TeInet

.

, C++.

,

Perl,

Telnet, a Net::DNS — /usr/local/lib/perl5/site_perl/5.005 Telnet.pm DNS.pm.

. Net

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

408

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 " !

" /usr/ports

,

Perl?

,

. Perl,

5-. FreeBSD. (

.)

, , .

, .

Ƚɥɚɜɚ 21. Ɂɧɚɤɨɦɫɬɜɨ ɫ ɩɪɨɝɪɚɦɦɢɪɨɜɚɧɢɟɦ ɧɚ ɹɡɵɤɟ Perl

, /usr/ports/net/p5-Net-Telnet

409

Net::Telnet. :

. Perl. . ,

, Perl ,

-

,

. , cd make test, .

: make

Perl

make install. ,

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. ,

.

ɑɚɫɬɶ 3. Ⱥɞɦɢɧɢɫɬɪɢɪɨɜɚɧɢɟ FreeBSD

410

Ʉɧɢɝɚ ɫ ɜɟɪɛɥɸɞɨɦ ("Camel" Book) Perl (Programming Perl) — , (Larry Wall) ( (Tom Christiansen) (Jon Orwant) ( — Perl.

2000). , "

Perl),

O'Reilly, -

Perl, "

. .

Ʉɧɢɝɚ ɫ ɥɚɦɨɣ ("Llama" Book) Perl (Learning Perl), (Randal L. Schwartz) (Tom Phoenix) (

. O'Reilly, 2001),

-

"

"

).

"

. Perl ( "

,

. , Perl.

ɋɥɨɜɚɪɶ (Clinton Pierce) (

Perl (Perl Developer's Dictionary) Perl (Perl Developer's Dictionary), Sams, 2001), Perl. .

Perl, ,

Perl.

CPAN CPAN (Comprehensive Perl Archive Network, . , , . , ( . CPAN CPAN

Perl) , . , ),

,

http://www.perl.com/CPAN-Iocal/. , .

4 Ь 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 ( Mach)

FreeBSD

Windows 2000/XP —

, .

,

.

TCP/IP,

Internet,

, FreeBSD. FreeBSD,

,

.

,

, .

,

,

FreeBSD.

,

,

-

FreeBSD,

Internet.

ȼɜɟɞɟɧɢɟ ɜ ɫɟɬɢ — . :

, (

, .

Internet HTML-

m ,

),

, , . .

, Internet (

)

. TCP/IP. ,

TCP/IP,

-

. . ARPAnet (

), , 1974

TCP/IP ", (Bob Kahn). .

" Internet —

1969

.

,

, (Vint Cerf) -

— TCP (Transmission Control Protocol -

414 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

) .

, 1977

,

UNIX.

IP (Internet Protocol — ,

).

Bell Labs

, ,

-

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 . RIP (Route Information Protocol). . TCP/IP,

TCP —

UDP IP (Internet Protocol)

DNS.

- ,

FreeBSD.

Ɍɨɩɨɥɨɝɢɢ ɫɟɬɟɣ , ,

. . — FreeBSD-

. ,

,

, (

: -

,

Internet ).

— 22.1

, . 1,

, DSL (

). —

(33-56 -48 . 22.1.

/ )

-192, -

Ƚɥɚɜɚ 25. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 415

,

22.1 ,

,

.

Ɍɚɛɥɢɰɚ 22.1 Ɍɢɩɵ ɩɨɫɥɟɞɨɜɚɬɟɥɶɧɵɯ ɝɥɨɛɚɥɶɧɵɯ ɫɨɟɞɢɧɟɧɢɣ ɢ ɫɨɨɬɜɟɬɫɬɜɭɸɳɢɟ ɢɦ ɫɤɨɪɨɫɬɢ ɩɟɪɟɞɚɱɢ ɞɚɧɧɵɯ. Ɇɨɞɟɦ

Ⱦɨ 56 Ʉɛɢɬ/ɫ

ISDN

56 —128 Ʉɛɢɬ/ɫ

DSL

192 Ʉɛɢɬ/ɫ — 1,5 Ɇɛɢɬ/ɫ

Ʉɚɛɟɥɶɧɵɣ ɦɨɞɟɦ

1 — 5 Ɇɛɢɬ/ɫ

Ɍ1

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

/ (Fast Ethernet) Gigabit Ethernet.

Ethernet, 100 1 /

-

/

. Ethernet(

). ,

, ,

, ,

Ethernet-

. 22.2.

Ethernet

Ɍɚɛɥɢɰɚ 22.2 Ɋɚɡɥɢɱɧɵɟ ɬɢɩɵ Ethernet-ɤɚɛɟɥɹ

,

/

10Base-2

Ɍɨɧɤɢɣ Ethernet

10

Ɍɨɧɤɢɣ ɤɨɚɤɫɢɚɥ

ȼNɋ

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

", ,

. ,

,

-

,

RJ-

45 ( ).

Ɋɢɫɭɧɨɤ 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,

24,

,

4

. $40

,

,

420 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

10base-T 100base-TX. ( 10 / , (N-Way), — .

100

/ ).

,

. 19-

,

, .

telnet,

:

,

, ,

. .

ɉɊɂɆȿɑȺɇɂȿ

ɉɚɪɭ ɫɥɨɜ ɨɬɧɨɫɢɬɟɥɶɧɨ ɬɟɪɦɢɧɨɥɨɝɢɢ. Ⱥɧɝɥɢɣɫɤɨɟ ɫɥɨɜɨ hub ɨɛɨɡɧɚɱɚɟɬ ɤɨɧɰɟɧɬɪɚɬɨɪɵ, ɤ ɤɨɬɨɪɵɦ ɩɨɞɤɥɸɱɚɸɬɫɹ ɭɡɥɵ ɫ ɨɞɢɧɚɤɨɜɨɣ ɫɟɬɟɜɨɣ ɚɪɯɢɬɟɤɬɭɪɨɣ, ɫɥɨɜɨ concentrator ɨɛɨɡɧɚɱɚɟɬ ɤɨɧɰɟɧɬɪɚɬɨɪɵ, ɤ ɤɨɬɨɪɵɦ ɦɨɠɧɨ ɩɨɞɤɥɸɱɚɬɶ ɭɡɥɵ ɫ ɪɚɡɥɢɱɧɵɦɢ ɫɟɬɟɜɵɦɢ ɚɪɯɢɬɟɤɬɭɪɚɦɢ. Ɋɚɡɥɢɱɢɟ ɦɟɠɞɭ ɞɜɭɦɹ ɷɬɢɦɢ ɬɟɪɦɢɧɚɦɢ, ɜɨɨɛɳɟ ɝɨɜɨɪɹ, ɜɟɫɶɦɚ ɪɚɡɦɵɬɨ, ɩɨɷɬɨɦɭ ɜ ɨɛɢɯɨɞɟ ɤɨɧɰɟɧɬɪɚɬɨɪɵ ɥɸɛɵɯ ɬɢɩɨɜ ɧɚɡɵɜɚɸɬ ɯɚɛɚɦɢ.

, .

. .

,

,

, uplink-

. ,

, -

,

,

, . (upstream device).

-

Uplink-

, , . .

uplink-

, 4

),

— .

-

, 5-

,

(uplink-

3

(

).

DIP-

. .

,

. — (Full Duplex). , .. , Fast Ethernet / .

(Half Duplex) , . 100 100

/

— . ,



Ʉɨɦɦɭɬɚɬɨɪɵ ,

(switch) ,

,

.

,



, RJ-45. ,

.

-

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 421

,

, .

,

. . ,

,

,

-

,

, (collision domain).

, , . ,

,

-

,

.

,

-

: ,

,

,

. ,

.

, .

, .

. . ,

,

,

, ,

. . , .

ARP-

. ,

.

, .

, .

(telnet)

, ,

. .

( 100base-TX 100 / ,

)

.

, 8,

8

.

,

, -

, . (

OSI).

, .

,

8-

— 100 100,

/ .

100 8800

100/

-

.

, ,

. ,

, "

.

,

/

-

" (tcpdump

EtherPeek),

422 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

promiscuous mode, ,

. . .

, -

— (

,

)— .

,

,

,

,

-

,

. , (

,

,

,

uplink-

) ,

,

.

:

, , .

uplink-

Ɇɨɫɬɵ ,

(bridges) —

,

.

,

. 4-

TCP/IP. ,

,



,

, ,

Ethernet

. ,

, Token Ring.

Ɇɚɪɲɪɭɬɢɡɚɬɨɪɵ -

(routers) — . ,

-

,

. -

,

, .

, (

TCP/IP). .

, ,

-

. ,

, . ,

,

. "

" . ,

,

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 423

.



,

Internet. RJ-45

28.

AUI,

.

/

DSU/CSU , ).

,

:

,

, ,

.

( 1, -

, ,

.

ɋɟɬɟɜɵɟ ɩɪɨɬɨɤɨɥɵ ,

Internet-

-

TCP/IP, .

; ,

TCP/IP —

. IP — InternetInternet. OSI (Open Systems Interconnection). Internet. , . ICMP,

TCP, ,

.

ping

traceroute. .

TCP: Transmission Control Protocol TCP

UDP — . , TCP

-

, ,

,

, .

-

, TCP

. ,

TCP

,

(

).

(Acknowledge —

).

.

-

, ,

-

TCP-

" ,

" .

,

-

, (

, ).

424 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

TCP , .

,

TCP

,

, ,

,

,

.

UDP

, TCP

.

,

/

. , HTTP-

, FTP

Internet,

. .

UDP: User Datagram Protocol UDP

. .

,

UDP,

, . . ,

. , UDP-

,

. UDP-

"

,

"

,

.



,

UDP-

,

.

,

NFS,

, ,

,

UDP, UDP?

31.

, , ,

NFS,

. TCP UDP, NFS.

, ,

UDP-

,

-

NFS

(

). UDP ,

.

-

,

,

,

. -

, .

,

,

,

.

,

( -

/ ,

).

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 425

. , UDP

. .

ICMP: Internet Control Message Protocol ICMP , IP IPX; TCP UDP. , —

, , : .

ICMP ICMPIP-

, ,

. ICMP

,

. traceroute,

ping ,

ICMP. ,

ICMP , . , ICMP

reply).

,

,

, UDP-

(

)

.

(echo-

UDP(Port Unreachable), ICMP 16

.

TCP/IP ?

TCP/IP ,

, , .



22.7



, (

), , (

). ,

,

.

TCP-, ,

, (

UDP).

, ,

IP-

426 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

IP-

.

,

( )

.

-

. ,

, (

). .

, ,

, , ,

.

,

. - .

, , IP-

. ,

,

,

,

FreeBSD. TCP/IP,

Addison-Wesley, 1994. , ,

.

IP-ɚɞɪɟɫɚ IPInternet,

, .

, IP-

,



-

,

, .

IP-

32-

,

IP-

:

. 8

0 IP-

, .. : 111.112.113.114. -

255.

,

,

,

( , ,

,

32-

).

IP-

,

. . IP.

, IP, IP-

, , , , ).

IP(.. Ethernet-

,

.

,

-

802.11. IP-

, , 22.1.

ifconfig, -

(

-

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 427

)

.

( .

;

,

, 10) IP-

inet

!0

IP-

. 22.1

ifconfig _______________________

# ifconfig -a xlO: flags=8843 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 lOObaseTX lObaseT/UTP lObaseT/UTP lOObaseTX 1pO: flags=8810 mtu 1500 gifO: flags=8010 mtu 1280 gifl: flags=8010 mtu 1280 gif2: flags=8010 mtu 1280 gif3: flags=8010 mtu 1280 loO: flags=8049 mtu 16384 inet6 fe80::l%loO prefixlen 64 scopeid 0x7 inet6 ::1 prefixlen 128 inet 127.0.0.1 netmask Oxff000000 pppO: flags=8010 mtu 1500 slO: flags=c010 mtu 552 faithO: flags=8000 mtu 1500

IP— 64.41.131.0.

,

. 64.41.131 ,

. 255. 64.41.131.255 64.41.255.255

-

,

, ,

, , . 64.41.131, 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-

,

-

, IPIP-

TCP/IP, ,

. . . ,

,

. , .

,

-



- , (Media Access Controller). . , -

,

,

, -

. , IP. ,

,

,

. -

-

,

,

.

.

3Com. , —

,

ifconfig, ether. 00:01:02:55:12:56, 48. 6 2 800 000 000 000 000 30 . ,

-

. . 3Electrical and Electronics Engineers — ). 3 — 16,7 . 16,7 .

IEEE (Institute of -

, . , .

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 429

,

. ,

(

,

,

.

) ,

IP-

,

-

,

IP-

.

,

IP-

?

ARP. ARP (Address Resolution Protocol) — IPIP10.5.6.100,

, . ,

IP.

ARP,

,

,

, 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) —

(

)

. , ( (

,

), ARP-

, IP-

,

,

. TCP/IPIP-

,

) ,

. 32— 255.255.255.0. . IP-

,

, IP-

IP-

IP64.41.131 IP-

64.41.131.45. ,

,

, .

,

and, .

, ,

. ,

. ,

TCP/IP. ( -

), , . .

. IP,

, ARP-

. ,

.

, 64.41.

.

(64.41 —

,.

.

). , R2, 64.41.132.

,

.

,

— 64.41.131. 64.41.131. , 64.41.132 ( . . 22.8), , — 255.255.255.0, . 255.255.0.0, 64.41.131. , 64.41.132, , . -

R1

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 431

,

, ( 255.255.0.0,

, ,

64.41.13l.xxx

, 64.41

-

13l.xxx!)

22.8

,

.

OxffffffOO (255.255.255.0) 64

OxfffffcO (255.255.255.192), 1 64.

,

, , 64.41.131 3 (24

CIDR (Classless Inter-Domain Routing — ), , . , 255.255.255.0 CIDR 64.41.131/24, ), 1. 255.255.255.192 64.41.131/26, 26 ,

CIDR

.

, .

Ɇɚɪɲɪɭɬɢɡɚɰɢɹ ,

— .

,

, , portsentry,

29. , , . ,

FreeBSD ,

netstat -rn: # netstat -rn Routing tables

-

IP-

432 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ Internet: Destination default

Gateway Flags hsrp-gw.netnation.UGSc

64.41.53.101/32

localhost

Refs 126

Use Netif 1379327 xlO

net-64-40-lll.netn link#l

UC

UGScB

0

3 loO

ip3.somewhere.com 0:50:b :b :98:13 ip4.somewhere.com 0:50:ba:b :95:bb

OHLW UHLW

2 0

357107 xlO 2272 xlO

ip6.somewhere.com ip6.somewhere.com hsrp-gw.netnation. 64.77.63.139/32

0:1:2:55:12:56 localhost 0:0:c:7:ac:le localhost

UHLW UGScB UHLW UGScB

Toronto-ppp218408.localhost

xlO =>

0 0 119 0

UGScB

localhost localhost goo. cs.und. nodak. e localhost

Expire

118941 0 8814 0

0

735 500

loO => loO xlO loO

405

0 loO

45 45210727 loO 0 0 loO

UGScB

: •

(Destination). FreeBSD , ,

(

IP, CIDR) (default route).

, ,

, •

.

(Gateway address).

-

,

,

,

-

. -

IP-

, ), . FreeBSD

,

( link#l, -

, , (flags).



(

). . ,

. 5 . man netstat. (Network Interface). , . 2



-

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) -

, , . , . .

. H1

2

22.8:

,

,

. R2.

H1

2

R1.

434 ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

.

R2,

,

;

, ,

. —

,

-

. , NAT-

,

. -

, , :

— FreeBSD natd,

,

. NAT — ,

— NAT-

. 28.

ɂɦɟɧɚ ɯɨɫɬɨɜ ɢ ɞɨɦɟɧɨɜ Internet , . . IP, .

,

, Internet

.

, ,

,

IP-

.

-

.

DNS-

, Network System Inc. , . . FreeBSD /etc/namedb.

-

DNSBIND,

DNS-

30. , tiger

, .

Pluto, Internet,

tiger, somethere.com. , IP-

IP,

,

.

,

.

somethere.com IP-

, . 64.41.131.45,

, HTTPFTP-

www.somethere.com ftp.somethere.com — 213.11.31.221. , TCP/IP.

DNS

.

: IP, , —



-



IP-

ARP ,

— IP-

IPIP,

.

. , DNS

,



-

.

Ƚɥɚɜɚ 22. Ɉɫɧɨɜɵ ɤɨɦɩɶɸɬɟɪɧɵɯ ɫɟɬɟɣ 435

DHCP , Ethernet-

,

)

IP-

23 , DHCP (Dynamic Host Configuration Protocol, ). IP. DHCP, DHCP. ( , ARP. DHCPIP, ( , ). 33.

23

◄ Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɫɟɬɟɜɨɣ ɤɚɪɬɵ ◄ ɇɚɫɬɪɨɣɤɚ ɫɟɬɟɜɵɯ ɩɚɪɚɦɟɬɪɨɜ ɩɪɢ ɩɨɦɨɲɢ sysinstall ◄ ɇɚɫɬɪɨɣɤɚ ɫɟɬɟɜɵɯ ɩɚɪɚɦɟɬɪɨɜ ɜɪɭɱɧɭɸ ◄ ɋɨɡɞɚɧɢɟ IP-ɩɫɟɜɞɨɧɢɦɨɜ ◄ ɇɚɫɬɪɨɣɤɚ ɢɦɟɧ ɢ IP-ɚɞɪɟɫɨɜ ɜ ɮɚɣɩɟ /etc/hosts ◄ ɍɬɢɥɢɬɚ ping ◄ ɇɚɫɬɪɨɣɤɢ DN5 ɜ ɮɚɣɩɟ /etc/resolv.conf ◄ Ⱦɪɭɝɢɟ ɮɚɣɥɵ ɤɨɧɮɢɝɭɪɚɰɢɢ ɫɟɬɢ

Ƚɥɚɜɚ 33. ɇɚɫɬɪɨɣɤɚ ɨɫɧɨɜɧɵɯ ɫɟɬɟɜɵɯ ɫɥɭɠɛ

,

437

,

,

.

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɫɟɬɟɜɨɣ ɤɚɪɬɵ , , .

,

IP,

, IP-

.

, IP-

,

.

, .

23.1

,

FreeBSD. ,

,

,

23.1 (PCI-

,

).

, FreeBSD ,

.

,

,

( . 23.1

,

. 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")

/sys/1386/conf/NOTES). 17. FreeBSD

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 ɞ ɚ ɧ ɧ ɨ ɣ ɫ ɢ ɫ ɬ ɟ ɦ ɵ .

. , ( ISA-

PCI, IRQ, DMA ISA). .

,

,

ɇɚɫɬɪɨɣɤɚ ɫɟɬɟɜɵɯ ɩɚɪɚɦɟɬɪɨɜ ɩɪɢ ɩɨɦɨɳɢ sysinstall , TCP/IP . sysinstall, ,— /stand/sysinstall. Configure , — FTP FTP— : Running multi-user, assume that the network is already configured? ( , , ?) No. . , FreeBSD , , ,

sysinstall.

Media. -

.

.

Ƚɥɚɜɚ S3. ɇɚɫɬɪɨɣɤɚ ɨɫɧɨɜɧɵɯ ɫɟɬɟɜɵɯ ɫɥɭɠɛ

,

1

SLIP IPv6

-

( giro

439

) faithO.

-

.

,

,

. Intel EtherExpress Pro/100B. , IPv6, — DHCP.

PCI:

fxpl, . 23.1.

,

23.1 sysinstall.

, . •

,

(Host). .

,

www.somewhere.com, • (Domain). somewhere.com. , , cslab.ivyleague.edu. • IPv4 (IPv4 Gateway). . , ( • (Name server). IP. , • IPv4 (IPv4 Address). . ,



, . .

IP-

, ). .

IP-

, ,

IPv4 Gateway, ,

. (Netmask).

(

.

www.

IP— 255.255.255.0,

) — 255.255.0.0

(

)

: — 255.0.0.0.

440

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ



,

. -

, , .

,

,

ifconfig,

sysinstall. , , a sysinstall

FTP-

OK,

-

.

, .

,

FreeBSD — , .

ɉɊɈȻɅȿɆɕ ɋ ɋȿɌȿȼɕɆɂ ISA-ɄȺɊɌȺɆɂ ȼɨɨɛɳɟ-ɬɨ, ɛɨɥɶɲɢɧɫɬɜɨ ɫɟɬɟɜɵɯ PCI-ɤɚɪɬ ɧɟ ɫɨɡɞɚɸɬ ɩɪɨɛɥɟɦɧɵɯ ɫɢɬɭɚɰɢɣ. ȿɫɥɢ ɤɚɪɬɚ ɩɨɞɞɟɪɠɢɜɚɟɬɫɹ ɹɞɪɨɦ ɫɢɫɬɟɦɵ, ɬɨ ɜɫɟ, ɱɬɨ ɬɪɟɛɭɟɬɫɹ ɫɞɟɥɚɬɶ, — ɷɬɨ ɜɫɬɚɜɢɬɶ ɫɟɬɟɜɭɸ ɤɚɪɬɭ ɜ ɪɚɡɶɟɦ ɧɚ ɦɚɬɟɪɢɧɫɤɨɣ ɩɥɚɬɟ, ɜɤɥɸɱɢɬɶ ɤɨɦɩɶɸɬɟɪ ɢ ɧɚɛɥɸɞɚɬɶ, ɤɚɤ ɫɢɫɬɟɦɚ ɫɚɦɚ ɨɩɪɟɞɟɥɹɟɬ ɫɟɬɟɜɭɸ ɤɚɪɬɭ ɜ ɩɪɨɰɟɫɫɟ ɡɚɝɪɭɡɤɢ: fxpO: port Oxde8O-Oxdebf mem Oxff8feOOO-Oxff8fefff irq 11 at device 8.0 on pcil fxpO: Ethernet address 00:dO:b7:c7:74:fl fxpl: quit Connection closed.

/etc/

imap pam.conf (

),

.

: imap

auth

required

pam_unix.so

try_first_pass

auth required account required session required

pam_unix.so pam_unix.so pam_deny.so

try_first_pass

auth required account required session required

pam_unix.so pam_unix.so pam_deny.so

: imap imap imap

To

: 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 . USE_SSL=YES

, , make

make make install USE_SSL=YES 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,

Pine,

. ,

, Mutt, Elm /var/ mail . ,

UNIX. -

IMAP-

FreeBSD, 1

,

,

-

.

Fetchmail — (Eric Raymond).

Fetchmail . .

-

.fetchmailrc, IMAP-

, 25

,

, Fetchmail .

,

(/usr/ports/mail/fetchmail) home, , , . Fetchmail Sendmail. .fetchmailrc

,

fetchmailconf. , (SDK fetchmailconf , .

,

. Fetchmail Python.

.fetchmailrc man-

X Window). Python TCL/ . . Fetchmail.

484

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

ɇɚɫɬɪɨɣɤɚ ɮɚɣɥɚ .fetchmailrc , .fetchmailrc. , .

.

,

, . .

.fetchmailrc ,

.

Fetchmail

.

, . .

.fetchmailrc , . , ,

, Fetchmail.

-

: set daemon 600 set postmaster foobar set logfile ./.fetchmail.log

Fetchmail (10

600

). .

, Fetchmail . (fallback address). ,

Fetchmail . Fetchmail.

,

,

,

,

log-

,

Fetchmail

.

set syslogd.

syslog, , . ,

. .

.fetchmailrc ,

.

,

:

poll mail.samplenet.org proto no dns

, skip mail.samplenet.org

set daemon ,

mail.samplenet.org . Fetchmail

.

Ƚɥɚɜɚ 25. ɇɚɫɬɪɨɣɤɚ ɫɥɭɠɛ E-mail

485

, ,

Fetchmail. Fetchmail : , ,

, .

. DNS.

. Internet

,

-

. . man fetchmail. .fetchmailrc .

.

: user foobar pass secretword fetchall flush

, ISPFetchmail .

,

. ,

,

" ).

" (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

: " .fetchmail.log. foobar ".

'foobar'. mail.samplenet.org DNS. secretword,

600 10

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ Ɍɚɤ ɤɚɤ ɮɚɣɥ .fetchmailrc ɫɨɞɟɪɠɢɬ ɢɦɹ ɩɨɥɶɡɨɜɚɬɟɥɹ ɢ ɩɚɪɨɥɶ, ɧɟɨɛɯɨɞɢɦɵɟ ɞɥɹ ɪɟɝɢɫɬɪɚɰɢɢ ɧɚ ɩɨɱɬɨɜɨɦ ɫɟɪɜɟɪɟ, ɩɪɚɜɚ ɞɨɫɬɭɩɚ ɤ ɧɟɦɭ ɞɨɥɠɧɵ ɛɵɬɶ ɭɫɬɚɧɨɜɥɟɧɵ ɧɚ ɱɬɟɧɢɟ ɬɨɥɶɤɨ ɜɚɦɢ. Ɍɚɤɢɦ ɨɛɪɚɡɨɦ, ɡɧɚɱɟɧɢɟ ɧɟ ɞɨɥɠɧɨ ɛɵɬɶ ɜɵɲɟ, ɱɟɦ 60Ɉ. ȼɨɫɩɨɥɶɡɭɣɬɟɫɶ ɤɨɦɚɧɞɨɣ chmod

.

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

486

600 .fetchmailrc. ɗɬɨ ɩɪɟɞɨɫɬɚɜɥɹɟɬ ɩɪɚɜɚ ɧɚ ɱɬɟɧɢɟ ɢ ɡɚɩɢɫɶ ɬɨɥɶɤɨ ɜɥɚɞɟɥɶɰɭ ɮɚɣɥɚ. ȿɫɥɢ ɮɚɣɥ .fetchmailrc ɢɦɟɟɬ ɛɨɥɟɟ ɥɢɛɟɪɚɥɶɧɵɟ ɩɪɚɜɚ ɞɨɫɬɭɩɚ, Fetchmail ɧɟ ɡɚɩɭɫɬɢɬɫɹ.

ɇɚɫɬɪɨɣɤɚ Sendmail ɞɥɹ ɨɬɞɟɥɶɧɵɯ ɪɚɛɨɱɢɯ ɫɬɚɧɰɢɣ Fetchmail Sendmail ( , . , Mutt Sendmail,

,

25 ).

, 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')

dnl

define, your.isp.mail.server ,

make cf

. make install

/etc/mail. ,

SMTP-

SMTP-

,

ISP-

.

. Mutt

MUA,

Pine,

, SMTP-

Sendmail, SMTP-

,

-

,

WindowsSMTP-

. .

, DNS-

,

IP-

,

SMTP-

,

DNS

ISP

,

.

FreeBSD ,

.

ISP-

SMTP(

,

MUA

Windows), .

SMART_HOST , Sendmail

. ( /etc/defaults/rc.conf).

,

30

-q30m, ,

/etc/rc.conf

.

Sendmail

SMART_HOST ISP-

,

sendmail_flags="- bd -qlOm"

. :

Ƚɥɚɜɚ 25. ɇɚɫɬɪɨɣɤɚ ɫɥɭɠɛ E-mail

,

487

-q30m Internet.

,

-

sendmail -q, -v. ,

,

,

sendmail -q

-up,

24.

Ⱥɥɶɬɟɪɧɚɬɢɜɧɵɟ ɩɨɱɬɨɜɵɟ ɫɟɪɜɟɪɵ Sendmail

,

. ,

m4, (

,

virtusertable), , Sendmail

. (

), .

, Sendmail.

, ,

, ,

,

.

Postfix , Postfix,

Sendmail (Wietse Venema). . Sendmail,

,

Sendmail

. ,

Postfix

(

,

, Qmail, Postfix

, ).

, "

"

Postfix

Sendmail http://www.postfix.org.

Qmail.

Qmail (Dan Bernstein) Internet, Qmail

.

Qmail Sendmail . Hotmail, Network Solutions Yahoo! mail. , Sendmail. , Qmail Sendmail. Qmail , Qmail http:// www.qmail.org.

Exim , :

,

Exim -

-

488

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

.

, .

,

Exim Sendmail

. SMTPhttp://www.exim.org.

-

, , Sendmail.

Exim

Small , Smail, . ( Smail

Exim),

Sendmail. .

, ,

Sendmail

26

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

Ɉɛɳɢɟ ɫɜɟɞɟɧɢɹ ɨ ɩɪɨɬɨɤɨɥɟ HTTP ► ɉɨɩɭɱɟɧɢɟ ɢ ɢɧɫɬɚɥɥɹɰɢɹ ɫɟɪɜɟɪɚ Apache



Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɫɟɪɜɟɪɚ Apache ► Ɂɚɩɭɫɤ ɢ ɨɫɬɚɧɨɜ ɞɟɦɨɧɚ HTTP ► Ɉɫɧɨɜɵ ɤɨɧɬɪɨɥɹ ɞɨɫɬɭɩɚ ɤ ɫɟɪɜɟɪɭ ► ȼɢɪɬɭɚɥɶɧɵɣ ɯɨɫɬɢɧɝ ► Ɇɨɞɭɥɢ ɫɟɪɜɟɪɚ Apache ► ɋɟɪɜɟɪɧɵɟ ɪɚɫɲɢɪɟɧɢɹ ► Ɉɫɧɨɜɵ CGI ►

490

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

,

Internet,

Web, Web,

. —

. FreeBSD

Web-

, . Sendmail —

FreeBSD

, . .

,

. 90%

WebWeb( , Roxen Internet,

Apache NCSA httpd. Apache

Apache. AOLserver),

,

,

, .

Sendmail, Apache — .

,

,

.

,

. Apache Web-

— .

, , Perl. Apache

,

.

Ɉɛɳɢɟ ɫɜɟɞɟɧɢɹ ɨ ɩɪɨɬɨɤɨɥɟ HTTP HyperText Transfer Protocol (HTTP, Wide Web. 1993 CERN ( ),

) —

World

, . . HTTP ,

( .

HTTP) HyperText Markup Language (HTML,

). HTTP

-

. ,

,

WWW

( ,

HTTP

1994 .

HTMLGIF ).

. JPEG -

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

HTTP/1.1,

,

491

( ).

. SMTP, FTP "

, HTTP

".

-

, HTTP

,

. HTTP .

, , (relaying),

. SMTP:

-

, , MX,

,

. . HTTP-

,

,

-

. HTTP/1.0 HTTP GET.

,

. 80

HTTP:

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

test page

test

( HEAD.

),

(

Enter) . .

,

HTTP-

,

,

Server:. ,

Content-*:, .

(HTML,

, Content-Length: , a Content-Type: — , GIF JPEG

Web-

,

. .).

492

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

/1.0

,

cookies, (

, ), , /1.0,

. ,

. (

,

. . . /1.1 (Host:) -

Web-

).

, .

Web,

HTTP-

TCP/IP

, WebIP- -

, 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

, HTTP/I.I , HTTP/1.1. HTTP/1.1, ,

( Lynx), Host:. ( , Netscape Navigator /1.0.) Host: (

),

-

, IP.

-

.

Ʉɨɞɵ ɨɬɜɟɬɚ ɢ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɟ (GET, HEAD HTTP/1.1), ,

-

. .

HTTP). 26.1

POST,

(

. 26.1 Apache

HTTP2

200

ɈɄ

201

Created (ɋɨɡɞɚɧɨ)

202

Accepted (ɉɪɢɧɹɬɨ)

203

Partial Information (ɑɚɫɬɢɱɧɚɹ ɢɧɮɨɪɦɚɰɢɹ)

204

No Content (ɇɟɬ ɫɨɞɟɪɠɢɦɨɝɨ)

— ɋɬɚɧɞɚɪɬɧɵɣ ɤɨɞ ɭɫɩɟɲɧɨɝɨ ɜɵɩɨɥɧɟɧɢɹ

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

493

— 300

Ɂɚɩɪɨɫɵ MultiViews ɢɥɢ CheckSpelling

Multiple Choices

ɧɚɲɥɢ ɧɟɫɤɨɥɶɤɨ ɫɨɨɬɜɟɬɫɬɜɢɣ 302

Moved Permanently

ɉɨɫɥɟɞɧɢɣ ɫɢɦɜɨɥ ɤɨɫɨɣ ɱɟɪɬɵ ɨɩɭɳɟɧ

303

Moved Temporarily

ɇɚɣɞɟɧɨ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɟ

304

Not Modified

Ɇɨɠɧɨ ɢɫɩɨɥɶɡɨɜɚɬɶ ɤɟɲɢɪɨɜɚɧɧɭɸ ɤɨɩɢɸ 4



402

Bad Request (ɉɥɨɯɨɣ ɡɚɩɪɨɫ)

403

Unauthorized

Ⱦɥɹ ɩɪɨɞɨɥɠɟɧɢɹ ɧɟɨɛɯɨɞɢɦɚ ɚɭɬɟɧɬɢɮɢɤɚɰɢɹ

403

Forbidden

ɉɪɚɜɚ ɞɨɫɬɭɩɚ ɢɥɢ ɤɨɧɮɢɝɭɪɚɰɢɹ ɫɟɪɜɟɪɚ ɡɚɩɪɟɳɚɸɬ ɞɨɫɬɭɩ

404

Not Found

Ɏɚɣɥɚ ɧɟ ɫɭɳɟɫɬɜɭɟɬ 5

— Ɉɲɢɛɤɚ CGI-ɩɪɨɝɪɚɦɦɵ

501

Internal Server Error

502

Not Implemented (He ɪɟɚɥɢɡɨɜɚɧɨ)

503

Bad Gateway (ɉɥɨɯɨɣ ɲɥɸɡ)

504

Service Unavailable

Ɋɟɫɭɪɫɵ, ɧɟɨɛɯɨɞɢɦɵɟ ɞɥɹ ɨɛɪɚɛɨɬɤɢ ɡɚɩɪɨɫɚ, ɧɟɞɨɫɬɭɩɧɵ

404 CGI-

403,

500,

.

304. .

, (/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 , ,

log-

494

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

.

,

.

Apache,

ServerName .

Webwww.w3.org/Protocols. RFC 1945, a HTTP/1.1 — RFC 2068.

Consortium)

W3 (WWW /1.0 -

ɉɨɥɭɱɟɧɢɟ ɢ ɢɧɫɬɚɥɥɹɰɢɹ ɫɟɪɜɟɪɚ Apache Apache, , ), " " , 1995 NCSA httpd. Apache — . — AIX Windows, BeOS

(

"A Patchy Server" , -

Mac OS X, ,

,

FreeBSD. HTTP-

, .

! -

60% Apache

(

, . 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,

Rewrite (mod_rewrite), . FreeBSD.

, , URL (Ralf Engelschall), a , Apache

Apache , , http://httpd.apache.org.

. Apache

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

495

ɋɯɟɦɚ ɪɚɫɩɨɥɨɠɟɧɢɹ ɮɚɣɥɨɜ ɫɟɪɜɟɪɚ Apache Apache , /usr/local/www,

/usr/local.

, .

Apache /usr/local ( (

. 26.1.

Apache FreeBSD), /var/log

loglog-

).

, ,

. .

/usr/local/www/data.default /usr/local/share/doc/apache, a /usr/local/www/data ( , . . ) — . , /usr/Iocal/www/cgi-bin.default cgi-bin, cgi-bin

, /usr/local/www/cgi-bin ( ). cgi-bin.default, .

,

HTML. , -

Ɋɢɫɭɧɨɤ 26.1

Apache.

/usr/local/etc/apache .default.

, ,

-

. Sendmail,

, Apache

FreeBSD Linux, Solaris , "

. Apache

,

Windows. : ", , Apache.

, ,

log.

,

Linux ,

, /usr/local/www FreeBSD, , , /var/ lib/apache. Apache, , -

496

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

,

FreeBSD,

,

,

,

.

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɫɟɪɜɟɪɚ Apache /etc/mail ( apache (

25), /usr/local/etc/ ,

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 sendmail.cf)

(

/etc/mail/ . , . Apache

. , ,

. Apache

. . :

httpd.conf # # # #

,

. , .

,

,

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

497

# ServerAdmin

[email protected]

# # ServerName # , # ( , # ). # #ServerName new.host.name

, , www

, ServerName ).

301 (

, Apache

301 (Moved . Apache URL , URL http://some.host.com/images/foo, /1.1, Apache ServerName. , ( ), Apache Host: . ServerName. , ServerName. URL. WebApache Group — http://

URL,

Permanently)

, URL. /images/foe.

, Host:,

URL. HTTP/1.1 ServerName. ServerName

Apache httpd.apache.org/docs/.

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɮɚɣɥɨɜ .htaccess ɢ ɡɚɦɟɧɹɸɳɢɯ ɨɩɰɢɣ httpd.conf. ,

.

,

.

, .htaccess,

. ,

-

httpd.conf, (.htaccess), .

-

.htaccess

, . .htaccess,

httpd.conf

AllowOverride. None /usr/local/www/data. , . , AllowOverride ( /usr/ local/www/data) ( , AllowOverride AuthConfig Limit).

AllowOverride .htaccess None . 26.2

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.

( Webhttpd.conf (

-

httpd.conf, .htaccess

).

( http://httpd.apache.org/docs/). ,

/home). ,

, 1.1 (DELETE, COPY #

MOVE),

, ,

# UserDir. # . # # # AllowOverride Filelnfo AuthConfig Limit # Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec #

# Order allow,deny # Allow from all #

#

# Order deny,allow # Deny from all #

#

, Filelnfo, AuthConfig . ɉɊɂɆȿɑȺɇɂȿ

AllowOverride Limit,

HTTP/ : ,

.htaccess 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

,

, Apache : apachectl,

kill.

,

/usr/ local/sbin

(

). Apache

:

apachectl

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 httpd: );

kill -HUP

(

. (

Apache

,

, "

"

),

,

SIGHUP

SIGUSR1. .

,

.

# apachectl graceful /usr/local/sbin/apachectl graceful: httpd gracefully restarted

apachectl Apache (

configtest. )

,

,

/usr/local/etc/apache start. . restart

: graceful:

, , configtest

apachectl .

,

. 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 , /usr/local/www/data ( ), Apache

(

. (Allow, Deny ,

Order)

AllowOverride Limit. ,

Allow

Deny,

. , , Order Deny Allow Allow Allow Allow Allow

:

.htaccess

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),

(

),

,

.

Order deny,allow Deny from all Allow

from

64.41.131.102

.

FilesMatch , .png:

Order deny,allow Deny from all Allow from 64.41.131.102

,gif, .jpg, .jpeg

502

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

, .htaccess ,



. (limit —

,

), .

, GET POST, ,

,

.



, . ,

. , /home.

Ʉɨɧɬɪɨɥɶ ɞɨɫɬɭɩɚ ɩɨ ɩɚɪɨɥɸ . (

,

-

), IP-

. .

Apache

, .

/etc/master.passwd , . ,

FreeBSD

,

Apache Web( ), ,

Web-

. ,

.

— .

.htaccess (

httpd.conf), , . , Apache.

,

:

AuthType Basic AuthName "Restricted Area" AuthUserFile /usr/local/www/.htpasswd Require validuser

, (

)

.

: • AuthType. Basic. • AuthName.

Basic

Digest. . (

, "Enter username for

. -

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

'Restricted Area' at www.somewhere.com" — " ' www.somewhere.com"),

503

' , -

. . • AuthUserFile, AuthDBUserFile

, AuthDBMUserFile.

. -

, /

. , . AuthUserFile,

-

, db dbm, ( ), — AuthDBUserFile AuthDBMUserFile, . , db/dbm, . • AuthGroupFile, AuthDBGroupFile AuthDBMGroupFile. , AuthUserFile. AuthUserFile, , . , , AuthUserFile , , . • Require. Apache, . valid-user ( AuthUserFile; ), user ... ( ) group ... ( ). apachectl configtest , Apache. ,

,

-

AuthUserFile. FreeBSD

htpasswd,

/usr/ :

local/bin • htpasswd -

/usr/local/www/.htpasswd frank

-

. ,

. ,

, ,

,

-

htpasswd, . -

: • htpasswd -b /usr/local/www/.htpasswd joe Prld3L4ndz

- . MD5, . man apachectl.

htpasswd crypt(), -

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

504

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ Ɏɚɣɥ ɫ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɣ ɛɚɡɨɣ ɞɚɧɧɵɯ ɦɨɠɟɬ ɧɚɯɨɞɢɬɶɫɹ ɜ ɥɸɛɨɦ ɦɟɫɬɟ ɫɢɫɬɟɦɵ, ɝɞɟ ɟɝɨ ɦɨɠɟɬ ɩɪɨɱɟɫɬɶ ɩɨɥɶɡɨɜɚɬɟɥɶ Web-ɫɟɪɜɟɪɚ [nobody], ɢ ɢɦɟɬɶ ɥɸɛɨɟ ɢɦɹ. ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɢɦɟ-ɧɢ .htpasswd ɹɜɥɹɟɬɫɹ ɬɪɚɞɢɰɢɨɧɧɵɦ ɢ ɡɚɳɢɳɚɟɬ ɮɚɣɥ ɨɬ ɩɪɨɫɦɨɬɪɚ ɜ ɤɨɧɮɢɝɭɪɚɰɢɢ ɫɟɪɜɟɪɚ ɩɨ ɭɦɨɥɱɚɧɢɸ. ȿɫɬɟɫɬɜɟɧɧɨ, ɧɟ ɫɥɟɞɭɟɬ ɪɚɡɦɟɳɚɬɶ ɮɚɣɥ ɬɚɦ, ɝɞɟ ɩɨɫɟɬɢɬɟɥɢ ɫɚɣɬɚ ɫɦɨɝɭɬ ɩɪɨɱɟɫɬɶ ɟɝɨ ɫ ɩɨɦɨɳɶɸ Web-ɛɪɚɡɭɟɪɚ, ɬ.ɟ. ɜ ɤɚɬɚɥɨɝɟ /usr/local/www/data ɢɥɢ ɜ ɤɚɤɨɦ-ɥɢɛɨ ɢɡ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɢɯ ɤɚɬɚɥɨɝɨɜ publicjitml. Ⱦɥɹ ɧɟɝɨ ɜɩɨɥɧɟ ɩɨɞɨɣɞɟɬ ɬɚɤɨɟ ɧɟɞɨɫɬɭɩɧɨɟ ɩɨ Webɩɪɨɬɨɤɨɥɭ ɦɟɫɬɨ, ɤɚɤ /usr/local/www. Ɋɚɡɭɦɟɟɬɫɹ, ɜɚɦ ɫɨɜɫɟɦ ɧɟ ɧɭɠɧɨ, ɱɬɨɛɵ ɩɨɥɶɡɨɜɚɬɟɥɢ ɫɦɨɝɥɢ ɡɚɝɪɭɡɢɬɶ ɛɚɡɭ ɞɚɧɧɵɯ ɩɚɪɨɥɟɣ ɢ ɩɨɩɵɬɚɥɢɫɶ ɟɟ ɜɡɥɨɦɚɬɶ!

. ,

,

, . db dbm AuthDBMUserFile. , , /usr/local/bin/dbmmanage:

AuthDBUserFile -

# 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 ,

,

.

, . ,

, ,

( ,

, AuthDBUserFile,

,

dbmmanage, /etc/group), . AuthGroupFile .

, .

Ʉɨɧɬɪɨɥɶ ɞɨɫɬɭɩɚ ɩɨ ɚɞɪɟɫɭ ɢ ɩɚɪɨɥɸ :

. Satisfy:

Allow from 64.41.131.102 Require valid-user Satisfy all

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

Allow

505

,

Satisfy all Require.

, -

Allow,

— ,

-

,

,

, .

,

Satisfy any

, Allow.

,

Web-

, .

ȼɢɪɬɭɚɥɶɧɵɣ ɯɨɫɬɢɧɝ Web. Apache.

,

www.mystore.com IP, Apache ,

DNS

www.frankspage.com

( ServerName). ,

HTTP/1.0

. ,

IP( EthernetWeb-

, IP-

,

, Web-

IP). ,

.

,

IPIP-

.

/1.1

. ,

Host: ,

, Host:

Internet. .

,

. IPWeb-

,

,

Apache. httpd.conf



,

,

Apache.

ServerName URL-

301. ,

, .

Host: . ,

stripes.somewhere.com. ServerName. NameVirtualHost

" :

"),

* (

-

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

506

NameVirtualHost *

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

ServerName www.frankspage.com ServerAlias frankspage.com DocumentRoot /home/frank/public_html ServerAdmin [email protected] ErrorLog logs/www.frankspage.com-error_log CustomLog logs/www.frankspage.com-access_log common

.

ServerName DocumentRoot , , a ErrorLog CustomLog — . ServerAlias

, , , (stripes.somewhere.com) IP, . :

. log. , ,

NameVirtualHost *

ServerName stripes.somewhere.com

ServerName www.somewhere.com ServerAlias *.somewhere.com DocumentRoot /usr/local/www/data ServerAdmin [email protected] ErrorLog logs/www.somewhere.com-error_log CustomLog logs/www.somewhere.com-access_log common

ServerName www.frankspage.com ServerAlias frankspage.com DocumentRoot /home/frank/public_html ServerAdmin [email protected] ErrorLog logs/www.frankspage.com-error_log CustomLog logs/www.frankspage.com-access_log common

: . http://httpd.apache.org/docs/vhosts/.

IP-

Ƚɥɚɜɚ 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 Apache, DSO, Apache,

Core , a mod_so — , .

mod_so.

ɉɊɂɆȿɑȺɇɂȿ

ɋɨɨɛɳɟɧɢɟ ɨ suexec ɦɨɠɧɨ ɢɝɧɨɪɢɪɨɜɚɬɶ. ɗɬɚ ɭɬɢɥɢɬɚ ɩɨɡɜɨɥɹɟɬ ɜɵɩɨɥɧɹɬɶ ɩɪɨɰɟɫɫ Apache ɫ setuid ɤɨɝɞɚ ɡɚɩɪɨɫɵ ɡɚɩɭɫɤɚɸɬɫɹ ɨɬ ɢɦɟɧɢ ɨɩɪɟɞɟɥɟɧɧɨɝɨ ɩɨɥɶɡɨɜɚɬɟɥɹ (ɨɛɵɱɧɨ ɞɥɹ ɪɚɡɧɵɯ ɜɢɪɬɭɚɥɶɧɵɯ ɯɨɫɬɨɜ ɩɨɥɶɡɨɜɚɬɟɥɢ ɷɬɢ ɪɚɡɧɵɟ]. Ɉɛɨɥɨɱɤɚ suexec ɩɨ ɭɦɨɥɱɚɧɢɸ ɧɟ ɭɫɬɚɧɚɜɥɢɜɚɟɬɫɹ. Ɉɡɧɚɤɨɦɢɬɶɫɹ ɫ ɞɨɤɭɦɟɧɬɚɰɢɟɣ ɦɨɠɧɨ ɩɨ ɚɞɪɟɫɭ http://httpd.apache.org/docs/ suexec.html. ȼ ɝɥɚɜɟ 29 ɪɚɫɫɤɚɡɚɧɨ ɨ CGIwrap — ɚɥɶɬɟɪɧɚɬɢɜɟ suexec.

Ⱦɢɧɚɦɢɱɟɫɤɢ ɡɚɝɪɭɠɚɟɦɵɟ ɦɨɞɭɥɢ . httpd.conf.

httpd, , Apache.

, Apache http://httpd.apache.org/docs/mod/. : LoadModuIe ( httpd)

LoadModuIe

AddModule ( httpd.conf,

). AddModule /usr/local/libexec/apache. ,

-

, Apache, . . .

ɋɬɨɪɨɧɧɢɟ ɦɨɞɭɥɢ Apache .

,

508

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

,

Apache, .

Apache ,

. Apache

mod_perl, Perl,

CGI-

, -

. PHP/usr/ports/www

ASP). Apache.

mod_php4, -

(

CGIApache

UNIX34

mod_.

apxs ,

DSO

Apache .

,

, "

,

, "

" ( Apache),

-

"

-

, . Apache

,

. apxs, APache eXtenSion ( /usr/local/sbin,

,

Apache). ,

,

DSO,

-

( ,

mod_so),

httpd. : apxs -

Apache .so, .

LoadModule, ,

.

apxs .

( /usr/ports/www Apache,

,

), make.

apxs. —

.

,

. .

mod_perl CGIApache. CGI-

Perl,

Perl, Apache , mod_perl Apache

— raodjerl. , HTTP-

Perl Perl

. Perl .

Apache. ,

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

,

Apache, .

CGI-

,

509

,

. mod_perl

http://

perl.apache.org.

mod_python Python mod_python, Python, mod_perl Python Apache CGImod_python

Perl Apache

Perl.

, . www.modpython.org.

mod_php PHP,

UNIX, Apache Apache

mod_php3

mod_php4. php-

, .

mod_php4 httpd.conf php- phps. mod_php4 Web, Apache HTTP-

, www.php.net. Apache. , FreeBSD

.

ɋɟɪɜɟɪɧɵɟ ɪɚɫɲɢɪɟɧɢɹ Apache — HTML(server-side includes)

, . , HTML-

-

. HTML-

HTML).

,

HTML (parsed Apache

, .

-

:

, attribute=value (

command

include, exec, config, echo )

( )

.

. .

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

510

, Apache httpd.conf ( .htaccess): AddType text/html .shtml AddHandler server-parsed .shtml

Includes

Web-

.htaccess),

( :

Options +Includes

MIME, /usr/local/etc/apache/mime.types, a AddHandler ( ). HTML, ).

AddType , , shtml ( ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ

ȿɫɥɢ ɧɟ ɫɱɢɬɚɬɶ ɧɚɥɢɱɢɹ ɫɟɪɜɟɪɧɵɯ ɪɚɫɲɢɪɟɧɢɣ, ɟɞɢɧɫɬɜɟɧɧɨɟ ɪɚɡɥɢɱɢɟ ɦɟɠɞɭ html- ɢ shtmlɮɚɣɥɚɦɢ — ɷɬɨ ɪɚɡɧɵɟ ɪɚɫɲɢɪɟɧɢɹ. Ɉɛɚ ɬɢɩɚ ɹɜɥɹɸɬɫɹ ɨɛɵɱɧɵɦɢ HTML-ɮɚɣɥɚɦɢ. ȿɫɥɢ ɜ htmlɮɚɣɥ ɛɵɥɢ ɜɤɥɸɱɟɧɵ ɫɟɪɜɟɪɧɵɟ ɨɩɟɪɚɰɢɢ, ɫɥɟɞɭɟɬ ɢɡɦɟɧɢɬɶ ɟɝɨ ɪɚɫɲɢɪɟɧɢɟ ɧɚ .shtml. ɋɟɪɜɟɪɧɵɟ ɪɚɫɲɢɪɟɧɢɹ ɜ html- ɢɥɢ htm-ɮɚɣɥɚɯ ɨɛɪɚɛɚɬɵɜɚɬɶɫɹ ɧɟ ɛɭɞɭɬ.

: • — . , . — CGI.

• •







shtml-

,

-

CGI-

. , -

counter

,

-

, HTML-

. ,

. .

,

, Apache

, -

-

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

.

,

AddType .

Web-

AddHandler

511

ȿɫɥɢ ɢɦɹ ɮɚɣɥɚ ɧɟ ɭɤɚɡɚɧɨ, ɬɨ ɩɨ ɭɦɨɥɱɚɧɢɸ ɤɥɢɟɧɬɭ ɨɬɨɛɪɚɠɚɟɬɫɹ ɮɚɣɥ 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 ɢ ɬ.ɞ.

,

:

CGIhttp://httpd.apache.org/docs/howto/ssi.html.

, —

Ɉɫɧɨɜɵ CGI Web(

HTML. ,

.

-

Web)

,

CGI, Common

. Gateway Interface ( CGI

). ,

-

Web-

,

HTML— . CGIPerl, ,

, -

, ,

Apache (nobody). . , HTML,

Apache CGI-

Web-

,

Sendmail, (

-

HTMLPerl.

.

-

, ) ,

ȼɤɥɸɱɟɧɢɟ CGI ɜ Apache , (

CGIhttpd.conf CGIWeb):

Apache. ScriptAlias,

,

-

512

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

ScriptAlias /cgi-bin/ "/usr/local/www/cgi-bin/"

, cgi-bin — CGI-

, ,

httpd.conf ,

CGI, .

,

500 (Server Error), . . ScriptAlias . CGI, /usr/local/www/cgi-bin/)

, CGI. ( Web-

Apache,

.

,

nobody. WebCGI.

.

,

.

ɉɊɂɆȿɑȺɇɂȿ Ɉɛɪɚɬɢɬɟ ɜɧɢɦɚɧɢɟ, ɱɬɨ ɜ ɩɭɬɢ /cgi-bin/ ɭɤɚɡɚɧ ɡɚɦɵɤɚɸɳɢɣ ɫɢɦɜɨɥ ɤɨɫɨɣ ɱɟɪɬɵ. ɗɬɨ ɟɳɟ ɨɞɧɚ ɩɪɟɞɨɫɬɨɪɨɠɧɨɫɬɶ, ɤɨɬɨɪɚɹ ɩɪɟɞɨɬɜɪɚɳɚɟɬ ɧɟɚɜɬɨɪɢɡɨɜɚɧɧɵɣ ɞɨɫɬɭɩ ɤ ɥɢɫɬɢɧɝɭ ɤɚɬɚɥɨɝɚ. ɂɦɹ CGIɩɪɨɝɪɚɦɦɵ ɜ Apache ɨɛɪɚɡɭɟɬɫɹ ɩɭɬɟɦ ɞɨɛɚɜɥɟɧɢɹ ɧɟɩɨɫɪɟɞɫɬɜɟɧɧɨ ɢɦɟɧɢ ɩɪɨɝɪɚɦɦɵ (ɧɚɩɪɢɦɟɪ, script.cgi] ɤ ɜɢɪɬɭɚɥɶɧɨɦɭ ɩɭɬɢ ɞɢɪɟɤɬɢɜɵ ScriptAlias (ɧɚɩɪɢɦɟɪ, /cgi-bin/), ɩɨ-ɷɬɨɦɭ ɫɢɦɜɨɥ ɤɨɫɨɣ ɱɟɪɬɵ ɧɟɨɛɯɨɞɢɦ ɞɥɹ ɩɪɚɜɢɥɶɧɨɝɨ ɜɨɫɫɨɡɞɚɧɢɹ ɩɭɬɢ (ɜ ɞɚɧɧɨɦ ɫɥɭɱɚɟ, /cgi-bin/script.cgi] ɉɟɪɟɧɚɩɪɚɜɥɟɧɢɹ ɫ ɤɨɞɨɦ 301 ɡɞɟɫɶ ɧɟ ɩɨɞɞɟɪɠɢɜɚɸɬɫɹ.

CGIExecCGI

Options

(

, CGI-

. public_html.

, .cgi)

. ,

cgi-

:

Options +ExecCGI AddHandler cgi-script .cgi

CGI)

(

ScriptAlias log-

blah

, 500 (Server Error). Apache. 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

,

, -

HTTPCGI-

,

, , Content-type: (

).

, CGI-

,

, .

Ƚɥɚɜɚ 26. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ Web-ɫɟɪɜɟɪɚ

513

ɇɚɩɢɫɚɧɢɟ CGI-ɩɪɨɝɪɚɦɦ ,

CGI-

, URL (=),

— (STDIN).

(&).

-

CGI-

Perl, .

Perl, CGI

Web-

-

,

:

,

, a ,

.

Perl

CGI-

,

. Perl (

21) . HTML-

,

( . .)

,

,

,

. HTML-

CGI-

Perl

:

,

CGIPerl,

post2me. .

,

, — (

): 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;

, . ,

HTMLHTML-

,

,

. nobody ( .

), , HTML-

. CGl-npo ,

,

, http-

, .

,

-

. , %FORM. $FORM{'e-maiI'}.

,

e-mail

-

514

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

HTML:

.

HTML,

,

URL,

. MIME (

Content-type:, ,

),

,

:

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, , , IPFreeBSD. Perl %ENV, , $ENV{ 'REMOTE_HOST'}. CGIPerl, 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'} cd mydir 250 CWD command successful.

ftp> Is 150 Opening ASCII mode data connection for '/bin/Is'. total 484 -rw-r—r— 1 frank frank 43175 Apr 8 01:14 addresses.txt -rw-r—r— 1 frank frank 100523 Apr 8 01:14 contents.html -rw-r—r— 1 frank frank 37864 Apr 8 01:14 directions -rw-r—r— 1 frank frank 37308 Apr 8 01:14 lk_logo.gif -rw-r—r— 1 frank frank 52427 Apr 8 01:12 picturel.gif -rw-r—r-- 1 frank frank 18648 Apr 24 13:04 picture2.jpg -rw-r—r— 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.

,

TelnetHTTP, HTTP,

,

. ,

Apache FTP ,

FTP-

.

Ƚɥɚɜɚ 27. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ FTP-ɫɟɪɜɟɪɚ

FTP-

519

Telnet. FTP, (

FTP (anonymous FTP), F3T : Is, cd, mkdir, pwd . .

-

) .

,

-

, . ,

led.

,

FTP), get ( mget (

put ( )

), mput (

). , 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 ɩɪɢɜɟɞɟɬ ɤ ɢɯ ɢɫɤɚɠɟɧɢɸ.

FTPBSD-

,

FreeBSD

ftpd.

inetd, . ,

( —

ProFTPD).

, telnetd Qpopper, , , WU-FTPD ,

. .

-

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 ,

. /var/ftp/pub. , /etc/ftpchroot.

,

cd /pub, ,

ɇɚɫɬɪɨɣɤɚ FTP-ɫɟɪɜɟɪɚ FTP

, /etc,



/var/ftp/etc.

,

FTP, /var/ftp. FTP-

/etc, • /etc/ftpusers. " FTP.

"

.

, FTP

-

. • /etc/ftpchroot. ,

,

( ), .

-

Ƚɥɚɜɚ 27. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ FTP-ɫɟɪɜɟɪɚ

• /etc/ftphosts. Apache ( • /etc/ftpwelcome.

, .

521

-

26). . ,

-

,

. • /etc/ftpmotd.

(Message Of The Day - "

-

"), . • /etc/shells.

12. ,

,

, .

bin, tty nobody, .

, /etc, ,

FTP-

.

.

/var/ftp ,

/, /bin, /bin/Is

/etc. FTP-

, .

/bin/date ,

/var/ftp/bin. /var/ftp

. ,

/var/ftp/etc • /var/ftp/bin. FTP-

"

"(

,

,

). Is date. ,

-

, ( ) /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 .

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

522

• /var/ftp/incoming. (sticky bit) (1777). .

, ,

:

. ! , ,

ftp

stream

.

inetd

1048

, tcp

ftpd

,

# ps -waux | grep inetd root 1640 0.0 0.6 inetd -Ww

/etc/rc.conf. /etc/inetd.conf

FTP-cep,

/etc/inetd.conf. inetd ps

:

780

??

Ss

ThuO8PM

,

inetd inetd_enable="NO" ftpd

nowait

root

0:00.15

, . :

/usr/libexec/ftpd

ftpd -1

, (

inetd ,

killall -HUP inetd). (ftp localhost). . , inetd.

, .

,

-

ɍɩɪɚɜɥɟɧɢɟ ɊɌɊ-ɞɨɫɬɭɩɨɦ FTP

, .

(

, Web-

),

,

.

,

, ,

( , .

HTTP

-

) 29, : Telnet

Secure HTTP, a POPS IMAP — . FTP ( , sftp sftpd

SSH, -

, ),

FTP-

, . ,

29.

,

, FTP

. , FTP . shells.

. /etc/ftpusers , /var/run/nologin, .

,

/etc/

Ƚɥɚɜɚ 27. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ FTP-ɫɟɪɜɟɪɚ

523

Ɏɚɣɥ /etc/ftpusers FTP— FreeBSD (operator, bin, tty . .). ,

ftpd

/etc/ftpusers, ,a . . ftpd

/etc/ftpusers . -

, 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 ,

-

, /etc/shells.

access denied. FTP , /sbin/nologin. account not available (

12. )

ftpd

.

Ɏɚɣɥ /var/run/nologin FTP /var/run.

ftpd :

#

ftp

localhost

Connected to localhost.somewhere.com. 530 System not available. ftp>

,

/etc/inetd.conf nologin

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

524

( /var/run/nologin. (rm /var/run/nologin).

)

touch FTP-

,

Ɋɚɡɪɟɲɟɧɢɟ ɚɧɨɧɢɦɧɨɝɨ ɞɨɫɬɭɩɚ ɩɨ FTP FTP

. /stand/sysinstall, Anon FTP Anonymous FTP Configuration,

sysinstall. Configure Networking. . . 27.2. UID, Group

, Comment FTP

,

FreeBSD, : , ftp (

. ftp. ftp /etc/ftpchroot, anonymous)

/var/ftp.

27.2 FTP.

, ,

UID, incoming,

( ftp

14, ). /var/ftp.

/stand/sysinstall , /var/ftp. ftp. ftp ).

, • • •

,

:

/etc/ftpusers (

,

, , — root). 1777: chmod 1777 /var/ftp/incoming. incoming

755 ( ,

FTP

-

Ƚɥɚɜɚ 27. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ FTP-ɫɟɪɜɟɪɚ

525

ȼɢɪɬɭɚɥɶɧɵɣ ɯɨɫɬɢɧɝ " FTP-

"

IP-

,

.

/etc/ FreeBSD

ftphosts, ).

( , ,

,

. (

. 27.2.

/etc/ftphosts)

Ɍɚɛɥɢɰɚ 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 (

,

, ,

,

). WU,

FTPD FreeBSD. WU-FTPD ftpd :

/etc/inetd.conf ftp stream stream tcp

(/usr/ports/ftp/wu-ftpd). ,

tcp nowait nowait root

ftp

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,

,

httpd.conf ( Apache.

,

Apache,

. , (/usr/ports/ftp/ pro ftpd). , ,

Apache. ProFTPD Apache,

, inetd, /usr/local/libexec/proftpd:

ftp stream

Apache. -

, 26),

stream tcp tcp nowait

nowait root /usr/local/libexec/proftpd root /usr/libexec/ftpd ftpd -1

ProFTPD

inetd. ,

ftp

proftpd #ftp

http://www.proftpd.org .

28 Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

ɑɬɨ ɬɚɤɨɟ ɦɚɪɲɪɭɬɢɡɚɬɨɪ? ► Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ NAT ɜ Ɉɋ FreeBSD ► ȼɤɥɸɱɟɧɢɟ ɩɨɞɞɟɪɠɤɢ NAT ► Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɤɥɢɟɧɬɨɜ ɞɥɹ ɢɫɩɨɥɶɡɨɜɚɧɢɹ ɧɨɜɨɝɨ ɲɩɸɡɚ ► Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɛɟɫɩɪɨɜɨɞɧɨɝɨ ɞɨɫɬɭɩɚ ɤ Internet ► Ɇɚɪɲɪɭɬɢɡɚɢɢɹ ɦɟɠɞɭ ɬɪɟɦɹ ɢ Donee ɫɟɬɹɦɢ ► Ⱦɢɧɚɦɢɱɟɫɤɚɹ ɦɚɪɲɪɭɬɢɡɚɢɢɹ ►

528

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

22, (network address translation —

NAT ).

23

, . FreeBSD

. . .

ɑɬɨ ɬɚɤɨɟ ɦɚɪɲɪɭɬɢɡɚɬɨɪ? ,

,



-

. .

,

, .

ɉɊɂɆȿɑȺɇɂȿ — ɷɬɨ ɩɚɤɟɬ ɰɢɮɪɨɜɨɣ ɢɧɮɨɪɦɚɰɢɢ. Ʉɪɨɦɟ ɩɟɪɟɞɚɜɚɟɦɵɯ ɞɚɧɧɵɯ, ɞɚɬɚɝɪɚɦɦɚ ɫɨɞɟɪɠɢɬ ɢɧɮɨɪɦɚɰɢɸ ɨɛ ɚɞɪɟɫɟ ɦɟɫɬɚ ɧɚɡɧɚɱɟɧɢɹ. ɇɟ ɜɫɟ ɞɟɣɬɚɝɪɚɦɦɵ ɩɪɨɯɨɞɹɬ ɩɨ ɨɞɧɨɦɭ ɢ ɬɨɦɭ ɠɟ ɦɚɪɲɪɭɬɭ, ɞɚɠɟ ɟɫɥɢ ɭ ɧɢɯ ɨɞɧɨ ɦɟɫɬɨ ɧɚɡɧɚɱɟɧɢɹ ɢ ɨɞɢɧ ɢɫɬɨɱɧɢɤ.

, 28.1

. -

,

.

. 28.1. . -

,

28.1, , wolf, bear, fox .

"

lynx , , .

,

, lion, cheetah, tiger " . . . .

Ɋɢɫɭɧɨɤ 28.2.

, ,

. 28.2

puma, " .

"

,

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

-

529

.( ,

, ,

?

,

, -

23.) "

,

.

"

.

" ,

,

,

.

-

— ,

,

.

cheetah cheetah

lynx.

,

.

simba, "

lynx.

(

"

. .

lynx simba " lynx

cheetah -

,

lynx,

falcon).

lynx. .

(

),

-

, ,

.

, ,



.

,

-

. .

,

? ,

-

,

?

.



. .

Internet. " .

",

-

, .



. ,

.

cheetah (

,



,

lion

-

), .

,

,

.

, Internet, ,

,

Internet. (

).

, .

" ,

.

,

, .

, Internet.

",

530

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

ɑɬɨ ɬɚɤɨɟ ɲɥɸɡ? ,

— ,— " -

:"

". "

"

"

.

simba

.

falcon

, .

,



,

-

. ;

.

, "

"

"—

"

. ,

Internet

.

ɑɬɨ ɬɚɤɨɟ NAT? NAT — ) —

Network Address Translation ( Internet

IPNAT . Internet,

.

, NAT NAT.

NAT " " Internet NAT). NAT). NAT

IPIP-

( IP-

, IP(

, ,

IP-

.

: •

IPIP-

.

IP-



,

. .

IP-

NAT .



Internet

, . .

Internet. , ,

Internet

.

FreeBSD. Internet .

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ NAT ɜ Ɉɋ FreeBSD Internet, .

, . 28.3.

Internet.

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

— Internet

531

, . ,

NAT. Ɋɢɫɭɧɨɤ 28.3.

. Internet

simba

.

,

lion, tiger, cheetah Internet

puma, simba

. ,

,



Internet.

Ethernet (

, edO). "

.

"

,

.

Internet.

Internet edO

.

,

Internet,

edO, Internet. ,

,

.

ȼɤɥɸɱɟɧɢɟ ɩɟɪɟɧɚɩɪɚɜɥɟɧɢɹ ɩɚɤɟɬɨɜ ,

, .

-

Internet , Internet)

, (

, . ,

FreeBSD

, . . Sysinstall.

.

,

, . :

/etc/rc.conf gateway_enable="YES"

, . IP.

, ,

simba

.

,

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

532

,

,

,

. . ɉɊɂɆȿɑȺɇɂȿ ȼ ɷɬɨɦ ɢ ɩɨɫɥɟɞɭɸɳɢɯ ɪɚɡɞɟɥɚɯ ɩɪɟɞɩɨɥɚɝɚɟɬɫɹ, ɱɬɨ ɫɢɫɬɟɦɚ, ɤɨɧɮɢɝɭɪɢɪɭɟɦɚɹ ɜ ɤɚɱɟɫɬɜɟ ɲɥɸɡɚ, ɭɠɟ ɩɨɞɤɥɸɱɟɧɚ ɤ Internet. ȿɫɥɢ ɷɬɨ ɟɳɟ ɧɟ ɫɞɟɥɚɧɨ, ɨɛɪɚɬɢɬɟɫɶ ɤ ɝɥɚɜɟ 23, ɜ ɤɨɬɨɪɨɣ ɨɩɢɫɚɧɚ ɧɚɫɬɪɨɣɤɚ ɞɨɫɬɭɩɚ ɤ ɥɨɤɚɥɶɧɨɣ ɫɟɬɢ (ɜ ɷɬɨɣ ɝɥɚɜɟ ɬɚɤɠɟ ɨɩɢɫɚɧɨ ɩɨɞɤɥɸɱɟɧɢɟ ɤ Internet ɱɟɪɟɡ ɢɧɬɟɪɮɟɣɫ ADSL ɢɥɢ ɩɨ ɜɵɞɟɥɟɧɧɨɣ ɥɢɧɢɢ). ȿɫɥɢ ɧɟɨɛɯɨɞɢɦɨ ɫɤɨɧɮɢɝɭɪɢɪɨɜɚɬɶ ɩɨɞɤɥɸɱɟɧɢɟ ɤ Internet ɱɟɪɟɡ ɦɨɞɟɦ, ɨɛɪɚɬɢɬɟɫɶ ɤ ɝɥɚɜɟ 24, ɝɞɟ ɩɪɟɞɫɬɚɜɥɟɧɚ ɞɨɩɨɥɧɢɬɟɥɶɧɚɹ ɢɧɮɨɪɦɚɰɢɹ ɩɨ ɧɚɫɬɪɨɣɤɟ ɬɚɤɨɝɨ ɩɨɞɤɥɸɱɟɧɢɹ.

,

, IPIP-

Internet .

.

Internet

(NAT).

ȼɤɥɸɱɟɧɢɟ NAT Internet — Internet NAT

(User , User , .

)

(Kernel

Internet

).

,

. NAT

.

,

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɪɟɚɥɢɡɚɰɢɢ ɊɊɊ ɩɨɥɶɡɨɜɚɬɟɥɶɫɤɨɝɨ ɭɪɨɜɧɹ FreeBSD NAT,

. -nat

,

. (

.

24). Windows, Macintosh . "

. "

-

.

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɪɟɚɥɢɡɚɰɢɢ ɊɊɊ ɧɚ ɭɪɨɜɧɟ ɹɞɪɚ ɢɥɢ ɩɨɞɤɥɸɱɟɧɢɟ ɤ Internet ɩɨ ɜɵɞɟɥɟɧɧɨɣ ɥɢɧɢɢ Internet NAT (natd),

(ADSL, .

, Tl, OC3) .

Ƚɥɚɜɚ 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"

Internet

, .

natd_interface , 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 ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

, ( ,—

.

firewall.conf

.

/etc/rc.conf, /usr/local/etc/firewall.conf, , 29). , :

, /usr/local/etc/

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 My Computer, Panel , ,

,

Network. . 28.4.

98, Control

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

TCP/IP, Gateway,

— TCP/IP.

,

28.4 Configuration Windows 98. Windows ME

Network Windows 95

535

Properties. . 28.5.

28.5. Gate-way Windows 98

IP,

New gateway, — 64.41.131.72.)

IP-

Add, gateways). , 98

. ( (Installed

.

. . , .

Windows 95 , — Windows ME

. Internet

Windows-

.

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɤɥɢɟɧɬɨɜ Mac OS ɢ Mac OS X FreeBSD,

Macintosh Windows-

,

TCP/IP .

9), Manually ( IP-

TCP/IP, Configure:, Router address:. .

)

Mac OS ( . 28.6, .

. Mac OS X . 28.7. Configure:

System Preferences Mac OS 9,

Network, Manually

-

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"

,

IPFreeBSD,

IP.

,

.

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet 537

, ,

root:

route add default 64.41.131.162

Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɤɥɢɟɧɬɨɜ Linux -

Linux FreeBSD

Linux-

.

,

.

-

,

.

ɉɊȿȾɍɉɊȿɀȾȿɇɂȿ ɉɨ ɬɨɣ ɠɟ ɩɪɢɱɢɧɟ ɧɟɞɨɫɬɚɬɨɱɧɨɣ ɫɬɚɧɞɚɪɬɢɡɚɰɢɢ ɞɢɫɬɪɢɛɭɬɢɜɨɜ Linux ɩɪɢɦɟɪɵ ɷɬɨɝɨ ɪɚɡɞɟɥɚ ɦɨɝɭɬ ɭ ɜɚɫ ɧɟ ɫɪɚɛɨɬɚɬɶ. Ɉɛɪɚɬɢɬɟɫɶ ɤ ɞɨɤɭɦɟɧɬɚɰɢɢ ɩɨ ɢɫɩɨɥɶɡɭɟɦɨɦɭ ɞɢɫɬɪɢɛɭɬɢɜɭ Linux, ɟɫɥɢ ɩɪɢ ɤɨɧɮɢɝɭɪɢɪɨɜɚɧɢɢ ɢɫɩɨɥɶɡɭɟɦɨɝɨ ɲɥɸɡɚ ɜɨɡɧɢɤɧɭɬ ɩɪɨɛɥɟɦɵ.

Ⱦɢɫɬɪɢɛɭɬɢɜ Red Hat Linux Red Hat Linux

/etc/sysconfig/network. FreeBSD,

: GATEWAY=64.41.131.162

IPFreeBSD, , GATEWAY Red Hat Linux

IP. ,

, . ,

.

, , route

add default gw

root:

64.41.131.162

Ⱦɢɫɬɪɢɛɭɬɢɜ Slackware Linux Slackware Linux ,

/etc/rc.inetl.

.

FreeBSD, : GATEWAY="64.41.131.162"

IP-

IP-

FreeBSD, , GATEWAY Slackware Linux

. ,

, . ,

.

, , route add default gw 64.41.131.162

root:

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,

,

. ,

.

Ɇɚɪɲɪɭɬɢɡɚɰɢɹ ɦɟɠɞɭ ɬɪɟɦɹ ɢ ɛɨɥɟɟ ɫɟɬɹɦɢ .

,

Internet

simba .

. 28.8

. lion, tiger, cheetah

puma Internet.

simba ,

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

539



simba Internet.

, .

,

,

,

,

.

Ɋɢɫɭɧɨɤ 28.8. simba — Internet

,

. 28.9.

simba ,

falcon — . Ɋɢɫɭɧɨɤ 28.9. .

simba

,

falcon,

.

, ,

falcon. .

, ,

simba

, .

falcon, ,

.

falcon, 169.151.116.121. falcon,

-

, ,

simba, , IP-

Internet simba

205.211.117. . simba

defaultroute="212.214.Ill.59" static_routes="falcon" falcon="-net 205.211.117.0 169.151.116.121"

,

falcon , /etc/rc.conf.

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

540

IP-

212.214.111.59 — ,

simba.

simba

, .

, 212.214.111.59 —

Internet,

simba. , simba, 205.211.117.0, falcon — falcon, simba -

. ,

. , IP-

169.151.116.121. ,

. 205.211.117.

, ,

. , 212.214.111.59.

falcon, ,

, ,

simba ,

. , ,

.

, , route

add

-net

-

, . root:

205.211.117.0

169.151.116.121

Ⱦɢɧɚɦɢɱɟɫɤɚɹ ɦɚɪɲɪɭɬɢɡɚɰɢɹ , . . ,

.

, Internet.

Internet Internet

simba falcon

,

,

Internet. simba. Internet.

,

,

Internet

-

. .

. , .

,

,

.

FreeBSD FreeBSD

. , RIP (Routing Information Protocol — ). RIP , , routed. FreeBSD gated zebra — . FreeBSD . 15. -

routed.

net .

.

Ƚɥɚɜɚ 28. Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɲɥɸɡɚ Internet

541

, .

, (

-

,

Internet). .

Ɇɚɪɲɪɭɬɢɡɚɰɢɹ ɜ ɦɚɫɲɬɚɛɟ ɩɪɟɞɩɪɢɹɬɢɹ ɢ ɞɟɦɢɥɢɬɚɪɢɡɨɜɚɧɧɚɹ ɡɨɧɚ (DMZ) (DMZ),

-

. ,

( IP-

, Web-

)

,

NAT.

. — NAT,

Internet, —



,

,

,

NAT. IP-

(Demilitarized Zone — DMZ}. 29.

-

, DMZ

.

29

Ɂɚɳɢɬɚ ɫɟɬɢ

◄ Ɇɨɞɟɥɢ ɡɚɲɢɬɵ ◄ ɉɪɚɜɢɥɚ ɡɚɞɚɧɢɹ ɩɚɪɨɥɟɣ ◄ ɉɪɨɛɥɟɦɵ ɫɨ ɫɥɭɠɛɚɦɢ, ɩɟɪɟɞɚɸɳɢɦɢ ɢɧɮɨɪɦɚɰɢɸ ɜ ɹɜɧɨɦ ɜɢɞɟ ◄Ɂɚɲɢɬɚ ɬɟɪɦɢɧɚɥɶɧɨɣ ɢɧɮɨɪɦɚɰɢɢ [OpenSSH) ◄Ɂɚɲɢɬɚ ɫɥɭɠɛ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ [ɊɈɊɁ ɢ IMAP] ◄Ɂɚɲɢɬɚ ɊɌɊ-ɫɟɪɜɟɪɚ < Ɂɚɲɢɬɚ ɫɟɪɜɟɪɚ Apache ◄ ɉɪɨɮɢɥɢ ɡɚɲɢɬɵ ɫɢɫɬɟɦɵ ɢ ɡɚɲɢɬɚ ɹɞɪɚ [securelevel] ◄ ɂɫɩɨɥɶɡɨɜɚɧɢɟ Ȼɪɚɧɞɦɚɭɷɪɚ ◄ ɉɪɟɞɨɬɜɪɚɳɟɧɢɟ ɜɬɨɪɠɟɧɢɣ ɢ ɜɡɥɨɦɨɜ ◄ Ⱥɬɚɤɢ ɧɚ ɫɥɭɠɛɵ [DOS] ◄ Ɏɢɡɢɱɟɫɤɚɹ ɡɚɲɢɬɚ ◄ Ⱦɪɭɝɢɟ ɢɫɬɨɱɧɢɤɢ ɢɧɮɨɪɦɚɰɢɢ ɨ ɡɚɲɢɬɟ

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

,

543

, .



,

,

, FreeBSD. He

UNIX,

Windows, ,

,

. .

,

.

.

-

, , . Internet — " ("rootkit") , , , ,

" . .

FreeBSD . ,

-

,



-

,

. . •

-

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. Crack.

Crack, Linux cracklib (pluggable authentication module — ) — FreeBSD ( . man pam], FreeBSD cracklib ,

/usr/ports/security/cracklib. , . cracklib

547

,

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:\

24h (24

).

, /etc/login.conf (

,

90 . ), 6w (6

2 (2

25), :

) , /etc/mail, -

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") =

5 037 78522671 89 2 1 2 9 80 6

( b5b037 7) ,

,

, passwd

, Perl,

rand ( ).

. MD5

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

549

Ɉɞɧɨɪɚɡɨɜɵɟ ɩɚɪɨɥɢ ɧɚ ɛɚɡɟ ɫɢɫɬɟɦɵ S/Key , , ,

, :

. (key), Java,

— . http://www.cs.umd.edu/~harry/jotp/src.html. ( MD4.)

FreeBSD ,

SSH

Telnet (

SSH

).

, "

" ("challenge" phrase) (

, ), . . .

ɉɊɂɆȿɑȺɇɂȿ ɋɢɫɬɟɦɚ S/Key ɧɟ ɦɟɧɟɟ ɰɟɧɧɨɟ ɫɪɟɞɫɬɜɨ ɞɥɹ ɨɡɚɛɨɱɟɧɧɨɝɨ ɡɚɳɢɬɨɣ ɩɨɥɶɡɨɜɚɬɟɥɹ, ɱɟɦ ɬɪɟɛɨɜɚɧɢɟ ɫɨɛɥɸɞɚɬɶ ɩɪɢɧɰɢɩɵ ɡɚɳɢɬɵ ɞɥɹ ɚɞɦɢɧɢɫɬɪɚɬɨɪɚ. Ɇɧɨɝɢɟ ɱɚɫɬɢ ɫɢɫɬɟɦɵ S/Key, ɧɚɩɪɢɦɟɪ ɩɪɨɝɪɚɦɦɚ keyinit, ɞɨɥɠɧɵ ɩɨɞɞɟɪɠɢɜɚɬɶɫɹ ɩɨɥɶɡɨɜɚɬɟɥɟɦ. ȿɫɥɢ ɩɨɥɶɡɨɜɚɬɟɥɶ ɯɨɱɟɬ ɨɛɟɫɩɟɱɢɬɶ ɤɨɧɮɢɞɟɧɰɢɚɥɶɧɨɫɬɶ ɩɚɪɨɥɟɣ, ɨɧ ɦɨɠɟɬ ɢɫɩɨɥɶɡɨɜɚɬɶ ɨɞɧɨɪɚɡɨɜɵɟ ɩɚɪɨɥɢ, ɞɚɠɟ ɟɫɥɢ ɜ ɷɬɨɦ ɧɟɬ ɨɫɨɛɨɣ ɧɟɨɛɯɨɞɢɦɨɫɬɢ.

,

,

Frank UNIX,

S/Key. ,

( ,

SSH), S/Key:

keyinit

# 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/

/etc/skeykeys, )

skey.access (

:

deny user frank

FreeBSD,

/etc/skey.access

UNIX, S/Key. permit ( UNIX) deny (

S/Key,

S/Key),

. man skey.access, ,

,

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 " keyinit).

; keyinit

(99

, "(

, st28077 —

, 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

98,

.

— ).

S/Key ,

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

.

Frank 99,

551

,

keyinit ,

.(

,

/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/

/etc/skeykeys, skey.access.

ɋɢɫɬɟɦɚ Kerberos — Kerberos "

" ("tickets")

Telnet, FTP, POP3 , ,

. ,

Kerberos. Athena

Kerberos Kerberos.

NFS

FreeBSD

Kerberos,

, Kerberos Kerberos

,

.

. ,

, ,

.

,

Kerberos .

, ,

UNIX. Kerberos

, 2000

Windows Kerberos (

), .

FreeBSD. .

Kerberos kerberos_server_enable="YES"

FreeBSD, /etc/rc.conf

552

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

,

Kerberos. , /etc/pam.conf

, pam_kerberos!V.so try_first_pass

,

: login auth sufficient

Kerberos FreeBSD

man kerberos (http://www.freebsd.org/handbook).

ɉɪɨɛɥɟɦɵ ɫɨ ɫɥɭɠɛɚɦɢ, ɩɟɪɟɞɚɸɳɢɦɢ ɢɧɮɨɪɦɚɰɢɸ ɜ ɹɜɧɨɦ ɜɢɞɟ ,

(

Telnet,

HTTP)



(

),

, ,

,

,

-

. , Internet ,

"

, .

", -

,

.

,

? .

,

(

,

), — . " ("security through obscurity") — , .

" , , — .

, , ,

,

,

.

,

, .

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɭɬɢɥɢɬɵ tcpdump ɞɥɹ ɤɨɧɬɪɨɥɹ ɩɟɪɟɞɚɜɚɟɦɨɣ ɢɧɮɨɪɦɚɰɢɢ , ,

— , "

Ethernet ,

mode"),

" , 22).

( . .

, . ("promiscuous ,

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ 553

FreeBSD —

tcpdump, — /dev/bpfO (root).

/usr/sbin. (Permission denied) (

). tcpdump

EtherPeek

WildPackets), ,

TCP/IP ( ,

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 (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 1 2 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 (DF) 4500 002c c9c2 4000 4006 9acd 4002 2bOc 4002 2 2 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. ,

EtherPeek , IMAP, FTP Syslog. .

tcpdump . Finger

HTTP,

, ,

.

. , FreeBSD.

,

, .

Ɂɚɳɢɬɚ ɬɟɪɦɢɧɚɥɶɧɨɣ ɢɧɮɨɪɦɚɰɢɢ (OpenSSH) ,

Telnet , SSH (Secure Shell — Telnet rlogin,

,

rlogin,

.

FreeBSD ), , .

OpenSSH, FreeBSD.

OpenBSD, SSH

22

(

,

Apache) /etc/rc.conf (

(

sshd SSH,

. )

sshd): sshd_enable="YES"

SSH

Telnet.

#

ssh

:

telnet ssh

stripes.somewhere.com

Ssh

,

,

. : # ssh stripes.somewhere.com -1 frank # ssh [email protected]

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 FreeBSD

qpopper SSL (Secure Sockets Layer — .

) -

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

556

IMAP-UW. SSL

IMAP-UW 25. , qpopper),

(

, ,

.

IMAP-UW. http://www.washington.edu/imap/. IMAP, SSL

IMAP-UW SSL

stunnel. /usr/ports/security/stunnel) .

( SSL ,

, —

, .

, 993 (

(/usr/local/etc/rc.d/stunnel.sh.sample) ) 995 (

), ,

/etc/services.

ɉɊɂɆȿɑȺɇɂȿ ɇɟ ɡɚɛɭɞɶɬɟ ɩɟɪɟɢɦɟɧɨɜɚɬɶ ɮɚɣɥ stunnel.sh.sample ɜ stunnel.sh, ɤɚɤ ɛɵɥɨ ɨɩɢɫɚɧɨ ɜ ɝɥɚɜɟ 11. ɋɭɮɮɢɤɫ .sample ɡɚɞɚɟɬɫɹ, ɱɬɨɛɵ ɚɞɦɢɧɢɫɬɪɚɬɨɪ ɨɛɹɡɚɬɟɥɶɧɨ ɩɪɨɫɦɨɬɪɟɥ ɫɨɞɟɪɠɢɦɨɟ ɫɰɟɧɚɪɢɹ ɢ ɭɛɟɞɢɥɫɹ ɜ ɤɨɪɪɟɤɬɧɨɫɬɢ ɩɭɬɟɣ ɤ ɮɚɣɥɚɦ ɫɟɪɬɢɮɢɤɚɬɨɜ [ɫ ɪɚɫɲɢɪɟɧɢɟɦ .pern].

,

stunnel qpopper IMAP-UW. /usr/local/etc/stunnel.pem. 995

110

stunnel (993 .

)

143

, SSL Outlook,

. ,

,

Microsoft

— . SSL

,

. .

— ,

,—

,

stunnel SSL,

, /etc/inetd.conf. ,

IPFW (

), localhost.

,

Ɂɚɳɢɬɚ ɊɌɊ-ɫɟɪɜɟɪɚ FTP, .

27, — ,

,

. FTP Telnet,

,

,

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ 557

Web-

,

,

.

, ,

,

.

FTP SSH (

FTP SSH: SSH /usr/libexec/sftp-server . FTP, FreeBSD

SSH. ,

),

.

-

FTP , FTP . FTP OpenSSH. Windows FreeBSD, Mac OS

sftp, FTP, SSH Communications Security.

-

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

OpenSSL

: Apache-SSL FreeBSD, .

mod_ssl.

, SSL,

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

558

ɉɊɂɆȿɑȺɇɂȿ Ɂɚɳɢɳɟɧɧɚɹ ɢ ɨɛɵɱɧɚɹ ɬɟɤɫɬɨɜɚɹ ɜɟɪɫɢɹ ɩɪɨɬɨɤɨɥɚ HTTP ɩɪɟɞɧɚɡɧɚɱɟɧɵ ɞɥɹ ɫɨɜɦɟɫɬɧɨɣ ɪɚɛɨɬɵ. Ɉɛɫɥɭɠɢɜɚɬɶ ɜɫɟ ɡɚɩɪɨɫɵ HTTP ɱɟɪɟɡ ɫɢɫɬɟɦɭ SSL — ɧɟ ɨɱɟɧɶ ɯɨɪɨɲɚɹ ɢ ɪɟɞɤɨ ɩɪɢɦɟɧɹɟɦɚɹ ɢɞɟɹ. ɑɚɫɬɢɱɧɨ ɷɬɨ ɫɜɹɡɚɧɨ ɫ ɩɪɨɢɡɜɨɞɢɬɟɥɶɧɨɫɬɶɸ (ɫɤɨɪɨɫɬɶ ɪɚɛɨɬɵ Web-ɫɚɣɬɚ ɫ ɛɨɥɶɲɢɦ ɤɨɥɢɱɟɫɬɜɨɦ ɨɛɪɚɳɟɧɢɣ ɪɟɡɤɨ ɫɧɢɡɢɬɫɹ, ɱɬɨ ɫɜɹɡɚɧɨ ɫ ɞɨɩɨɥɧɢɬɟɥɶɧɵɦɢ ɜɵɱɢɫɥɟɧɢɹɦɢ ɩɪɢ ɲɢɮɪɨɜɚɧɢɢ ɤɚɠɞɨɣ ɫɬɪɚɧɢɰɵ ɢ ɢɡɨɛɪɚɠɟɧɢɹ, ɧɟɡɚɜɢɫɢɦɨ ɨɬ ɧɚɥɢɱɢɹ ɜ ɧɢɯ ɫɟɤɪɟɬɧɨɣ ɢɧɮɨɪɦɚɰɢɢ], ɚ ɱɚɫɬɢɱɧɨ — ɫ ɧɟɭɞɨɛɫɬɜɨɦ ɢ ɧɟɩɪɢɜɵɱɧɨɫɬɶɸ ɬɚɤɨɝɨ ɫɩɨɫɨɛɚ ɜɡɚɢɦɨɞɟɣɫɬɜɢɹ. Ȼɨɥɶɲɢɧɫɬɜɨ ɨɛɳɟɞɨɫɬɭɩɧɵɯ ɞɚɧɧɵɯ Web ɧɟ ɧɚɞɨ ɲɢɮɪɨɜɚɬɶ. ɇɨ ɩɟɪɟɤɥɸɱɟɧɢɟ ɜ ɡɚɳɢɳɟɧɧɵɣ ɪɟɠɢɦ ɩɪɢ ɜɯɨɞɟ ɤɥɢɟɧɬɚ ɧɚ ɫɬɪɚɧɢɰɭ ɩɨɤɭɩɤɢ ɢɥɢ ɜ ɮɨɪɦɭ ɞɥɹ ɫɛɨɪɚ ɢɧɮɨɪɦɚɰɢɢ ɭɛɟɠɞɚɟɬ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ɜ ɬɨɦ, ɱɬɨ ɨɧɢ ɜɨɲɥɢ ɜ ɛɨɥɟɟ ɡɚɳɢɳɟɧɧɭɸ ɡɨɧɭ. ɉɨɦɧɢɬɟ: ɜɵ ɞɨɥɠɧɵ ɭɞɨɜɥɟɬɜɨɪɢɬɶ ɨɠɢɞɚɧɢɹ ɩɨɥɶɡɨɜɚɬɟɥɟɣ ɢ ɨɛɟɫɩɟɱɢɬɶ ɤɨɧɮɢɞɟɧɰɢɚɥɶɧɨɫɬɶ, ɚ ɧɟ ɬɨɥɶɤɨ ɩɪɟɞɨɫɬɚɜɢɬɶ ɞɚɧɧɵɟ.

ɋɢɫɬɟɦɚ Apache-SSL "

"

Apache,

Apache-SSL

-

Apache Group, mod_ssl. , -

.

Apache-SSL

.

Apache-SSL httpd

httpsd,

443. SSL.

httpsd Apache, Apache-SSL /usr/ports/www/apachel3-ssl), www.apache-ssl.org.

,

httpd. HTTP

80, ,

, (

Web-

http://

ɋɟɪɜɟɪ Apache ɫ ɦɨɞɭɥɟɦ mod_ssl SSL Apache-SSL, — mod_ssl — OpenSSL .

HTTP Apache,

Apache ,

Apache-SSL, .

, , httpd, ,

apache 13-modssl apache13, SSL: Listen 80 Listen 443

mod_php

Apache . .,

mod_ssl /usr/ports/www. , Apache-SSL.

,

,

mod_perl, mod_ssl —

,

. Apache modssl.

mod_ssl Web-

/usr/ports/www/ apachel3— http://www.modssl.org.

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

559

ɗɤɫɩɥɭɚɬɚɰɢɹ ɡɚɳɢɳɟɧɧɨɝɨ Web-ɫɟɪɜɟɪɚ , Apache-SSL , , HTTP,

WebApache-SSL httpd

Apache .

mod_ssl, , ,

443. Apache-SSL,

httpsd , httpsdctl,

,

Apache, httpd.conf.

apachectl /usr/local/etc/apache, mod_ssl

httpsd.conf Apache —

,

26. apachel3-ssl,

( Apache, ,

apache 13-modssl) , HTML-

. Apache-SSL

Apache. , .

mod_ssl Apache, OpenSSL ,

Web-

, ,

. ( ,

), .

,

, . , (Security Information)

,

, .



,

.

ɉɥɨɯɨ ɧɚɩɢɫɚɧɧɵɟ ɫɰɟɧɚɪɢɢ CGI — Apache.

He (

,

,

)

, .

Apache

nobody ( ,

nobody

, )

CGI, .

, . ,

, CGInobody. , CGI-

560

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

,

. CGI-

.

, ,

Apache

nobody. —

Apache

CGI-

-"

",

,

(

)

, suexec,

nobody. Apache. , CGIWrap,

(Nathan Neulinger).

ɉɨɜɵɲɟɧɢɟ ɛɟɡɨɩɚɫɧɨɫɬɢ ɫɰɟɧɚɪɢɟɜ CGI ɫ ɩɨɦɨɳɶɸ ɫɢɫɬɟɦɵ CGIwrap CGIWrap, ports/www/cgiwrap,

/usr/ CGI,

: CGI.

,

CGI-

,

,

,

nobody. ,

,

Web-

.

— CGI.

CGI,

, root,

,

,

,

, . CGIWrap

. ,

,

,,

CGI, .

,

CGI

, ,

CGI,

. CGIWrap

cgiwrap ( , /usr/Iocal/www/cgi-bin. CGIWrap suexec, URL :

)

cgi-bin Apache, ,

http://www.somewhere.com/cgi-bin/cgiwrap/frank/myscript.cgi

:

myscript.cgi public_html/cgi-bin.

CGI-

/home/frank/

29.

561

,

public_html/cgi-bin.

. CGIWrap,

CGICGI DocumentRoot,

,

, Options +ExecCGI. WebCGIWrap http://cgiwrap.unixtools.org/.

,

ɉɪɨɮɢɥɢ ɡɚɳɢɬɵ ɫɢɫɬɟɦɵ ɢ ɡɚɳɢɬɚ ɹɞɪɚ (securelevel) FreeBSD 3,

, /etc/rc.conf.

kern_securelevel , ,

-1

, ,

, ( 17,

IPFW

, securelevel

). — . man securelevel.

FreeBSD . /stand/sysinstall,

"Configure",

"Security". : Low,

Medium, High sendmail, sshd

Extreme. 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,

, —

,

, sendmail, "High" —

amount ( ).

mount amd, NFS

sshd,

,

.

securelevel 1, . "Extreme",

, sendmail

,

sshd

inetd,

. ,

. 29.1

, /etc/rc.conf, , . ,

. , . ; ,

.

,

.

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɛɪɚɧɞɦɚɭɷɪɚ ,

,

,

,

,

Internet. "

, " ("script kiddies"), ,

, ,

.

, , ,

. FreeBSD,

IPFW, . , ,

. , .

-

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

— "

"

563

;

,

,

,

.

-

. ,

. Internet. ,

,

( ).

-

,

, ,

, .

IPFW FreeBSD

,

,

, .

, ( (LAN), "

.

; . 29.1

FreeBSD 28), " (DMZ)

(WAN).

29.1.

,

.

LAN, DMZ

WAN

ɉɊɂɆȿɑȺɇɂȿ "Ⱦɟɦɢɥɢɬɚɪɢɡɨɜɚɧɧɚɹ ɡɨɧɚ" — ɷɬɨ ɫɟɬɶ, ɧɟɩɨɫɪɟɞɫɬɜɟɧɧɨ ɞɨɫɬɭɩɧɚɹ ɞɥɹ ɢɧɮɨɪɦɚɰɢɢ ɢɡ ɝɥɨɛɚɥɶɧɨɣ ɫɟɬɢ, ɚ ɧɟ ɢɡ ɥɨɤɚɥɶɧɨɣ. Ɉɫɨɛɟɧɧɨ ɩɨɥɟɡɧɚɹ ɜ ɫɥɭɱɚɟ ɩɪɟɨɛɪɚɡɨɜɚɧɢɹ IP-ɚɞɪɟɫɨɜ ɜ ɥɨɤɚɥɶɧɨɣ ɫɟɬɢ (ɤɚɤ ɛɵɥɨ ɩɨɤɚɡɚɧɨ ɜ ɝɥɚɜɟ 22) ɞɟɦɢɥɢɬɚɪɢɡɨɜɚɧɧɚɹ ɡɨɧɚ ɩɪɟɞɫɬɚɜɥɹɟɬ ɫɨɛɨɣ ɫɟɬɶ ɞɥɹ ɩɪɟɞɩɪɢɹɬɢɹ ɢɥɢ ɩɨɫɬɚɜɳɢɤɚ ɭɫɥɭɝ Internet, ɜ ɤɨɬɨɪɭɸ ɩɨɦɟɳɚɸɬɫɹ ɦɚɲɢɧɵ ɫ ɪɟɚɥɶɧɵɦɢ ɚɞɪɟɫɚɦɢ, ɧɚɩɪɢɦɟɪ Web-ɫɟɪɜɟɪɵ, ɲɥɸɡɵ ɷɥɟɤɬɪɨɧɧɨɣ ɩɨɱɬɵ ɢ ɞɪɭɝɢɟ ɯɨɫɬɵ, ɤɨɬɨɪɵɟ ɞɨɥɠɧɵ ɛɵɬɶ ɞɨɫɬɭɩɧɵ ɢɡ ɨɛɳɟɣ ɫɟɬɢ Internet. Ɂɨɧɚ DMZ ɦɨɠɟɬ ɛɵɬɶ ɡɚɳɢɳɟɧɚ ɩɪɚɜɢɥɚɦɢ ɛɪɚɧɞɦɚɭɷɪɚ ɧɚ ɲɥɸɡɨɜɨɦ ɦɚɪɲɪɭɬɢɡɚɬɨɪɟ, ɚ ɦɨɠɟɬ ɢ ɧɟ ɡɚɳɢɳɚɬɶɫɹ. Ɂɚɳɢɬɚ ɨɛɵɱɧɨ ɠɟɥɚɬɟɥɶɧɚ, ɧɨ ɜ ɧɟɤɨɬɨɪɵɯ ɫɩɟɰɢɚɥɶɧɵɯ ɫɥɭɱɚɹɯ ɬɪɟɛɭɟɬɫɹ, ɱɬɨɛɵ ɞɟɦɢɥɢɬɚɪɢɡɨɜɚɧɧɚɹ ɡɨɧɚ ɛɵɥɚ ɨɫɜɨɛɨɠɞɟɧɚ ɨɬ ɨɛɳɢɯ ɩɪɚɜɢɥ ɛɪɚɧɞɦɚɭɷɪɚ ɥɨɤɚɥɶɧɨɣ ɫɟɬɢ. ɗɬɨ ɡɚɜɢɫɢɬ ɨɬ ɤɨɧɮɢɝɭɪɚɰɢɢ ɢ ɧɚɡɧɚɱɟɧɢɹ ɫɟɬɢ.

ȼɤɥɸɱɟɧɢɟ ɩɨɞɞɟɪɠɤɢ ɛɪɚɧɞɦɚɭɷɪɚ IPFW

GENERIC.

, , IPFIREWALL_VERBOSE IPFW ,

17: IPFIREWALL, IPFIREWALL_VERBOSE_LIMIT=10. — /etc/rc.network. , /etc/rc.conf:

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

564

firewall_enable="YES" firewall_type="open"

,

(firewall_type="open"), 65535 ( ,

IPFW ),

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. ;

(

( from

, tcp), ,

,

to. badhost.com,

, deny), , , TCP, deny tcp from badhost.com to any, a

: # ipfw add deny tcp from badhost.com to any

. —

( CIDR ( , . .

,

, 255.255.255.0),

, /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

( firewall_type="/etc/firewall.conf"

firewall_type)

/etc/rc.conf:

/etc/netstart 100, 200, 300 . . — ,

/etc/ firewall.conf all 65000 . ,

80

any

allow

. IPFW

man ipfw http://www.freebsd.org/ handbook.

FreeBSD Handbook

ɉɪɟɞɨɬɜɪɚɳɟɧɢɟ ɜɬɨɪɠɟɧɢɣ ɢ ɜɡɥɨɦɨɜ , . ,

"rootkit"

, .

, .

, . .

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

567

ɂɫɩɨɥɶɡɨɜɚɧɢɟ PortSentry PortSentry,

Psionic Software, —

,

,

, -

,

, .

,

PortSentry

, IPFW, PortSentry

.

" TCP-,

" UDP-

;

, ,

,

,

. , PortSentry (/usr/ports/security/portsentry). /usr/local/bin, /usr/local/etc/portsentry.conf. PortSentry

portsentry — . , PortSentry. UDP_PORTS.

, —

TCP_PORTS

;

, . ,





,

, , .

"),

,

("

.

,

, .

. !

,

143 —

,

,

143

.

,

143

.



. . :

IPFW ( )

IPFW

).

, /sbin/ipfw,

, (black-hole routes) ( ,

KILL_ROUTE PortSentry , :

. IPFW,

,

# , к о FreeBSD ( # ), # . KILL ROUTE="/sbin/ipfw add 1 deny all from $TARGET$ :255.255.255 .255 to any"

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

568

IPFW

,

, ,

,

,

IPFW: # FreeBSD ( .) KILL_ROUTE="route add -net $TARGET$ -netmask 255.255.255.255 127.0.0.1 ~ blackhole"

PortSentry . 29.1 ( , /usr/local/etc/rc.d,

-

. PortSentry , portsentry.sh).

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

, , local/etc/portsentry.blocked.tcp /usr/local/etc/portsentry.blocked.udp PortSentry , , .

,

/usr/ TCP UDP.

, . -

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

PortSentry. IPFW,

569

, ,

, , .

ɋɈȼȿɌ ɉɪɢ ɢɫɩɨɥɶɡɨɜɚɧɢɢ ɦɟɬɨɞɚ 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 /32. ȿɫɥɢ ɧɟɨɛɯɨɞɢɦɨ ɡɚɳɢɬɢɬɶ ɨɩɪɟɞɟɥɟɧɧɵɟ ɯɨɫɬɵ [ɧɚɩɪɢɦɟɪ, ɜɚɲɢ ɫɨɛɫɬɜɟɧɧɵɟ ɦɚɲɢɧɵ) ɨɬ ɛɥɨɤɢɪɨɜɚɧɢɹ ɞɟɦɨɧɨɦ PortSentry, ɞɨɛɚɜɶɬɟ ɢɯ IP-ɚɞɪɟɫɚ ɜ ɮɚɣɥ /usr/local/etc/ portsentry. ignore.

ɂɫɩɨɥɶɡɨɜɚɧɢɟ ɮɚɣɥɚ /etc/hosts.allow -

/etc/hosts.allow .

570

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

PortSentry. IP-

, , .

/etc/hosts.allow, , :

sendmail sendmail

: localhost : allow : .nice.guy.exanple.com : allow

sendmail

:

.evil.craclcer.example.com

sendmail sendmail sendmail

: : :

231.21.15.0/255.255.255.0 : deny 12.124.231. : deny ALL : allow

:

IPFW

deny

,

.

: ), ,

IP—

( (

).

,

(

), ,

: ,

DNS,

— ,

IP-

.

IP-

.

"

"

,

, .

,

, "

, ,

/etc/hosts.allow "deny".

"allow"

,

". ,

, ,

(

,

,

). .

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

tw.config —

gunzip

,

. ,—

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

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

### ### Attr ### ======

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, -update:

Tripwire, .

# tripwire -update /usr/sbin/sshd

( . gzip # # # #

, /var/adm/tcheck/ databases) ; 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, —



,

,

.

.

, . /var/tmp,

/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. Ɂɚɳɢɬɚ ɫɟɬɢ

, IPFW, PortSentry ;

,

575

. ,

, .

,

. , ,

. .

,

ping (ICMP) ,

,

.

,

DDoS,

, ,

, . . .

,

, ,

, ,

.

Ɉɝɪɚɧɢɱɟɧɢɟ ɤɨɥɢɱɟɫɬɜɚ ɩɨɪɨɠɞɚɟɦɵɯ ɫɟɪɜɟɪɧɵɯ ɩɪɨɰɟɫɫɨɜ DoS "

Apache, Sendmail

"

, .

,

, .

,

,

,

,

. ,

-

. Apache

MaxClients

150, .

, CGI

, ,

,

Apache , HTML-

.

, Telnet

SSH, , , Apache.

Apache (apachectl stop) HTTP IPFW ,

. IPdeny from MaxClients, .

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

576

Sendmail: . , /etc/mail/sendmail.cf Sendmail " 12

,

MaxDaemonChildren, (make restart). ", .

, ,

Sendmail

. , ,

( /etc/ ,

, ,

),

login.conf . , Apache, ,

— nobody , chfn. login.conf:

baduser:\ :cputime=30m:\ :openfiles=24:\ :maxproc=32:\ :memoryuse=l6m:\ :tc=default:

cap_mkdb /etc/login.conf .

Ɂɚɳɢɬɚ ɨɬ ɚɬɚɤ ɫ ɩɥɚɰɞɚɪɦɚ "

"

. -

, , . "smurf")

ping (

,

(

ping ), —

,

. ping. ,

( UDP-

)

.

smurf

,

echo "

echo (

.

-

", FreeBSD

). ,

, ping.

-

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

FreeBSD,

577

icmp_bmcastecho="NO" ,

/etc/defaults/rc.conf . GENERIC ICMP-

ICMP_BANDLIM, (

),

.

Ɏɢɡɢɱɟɫɤɚɹ ɡɚɳɢɬɚ , .

, , ,

. (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.

ɋɩɢɫɤɢ ɪɚɫɫɵɥɤɢ [email protected]. [email protected] subscribe freebsd-security . .

, . ,

UNIX

, — Bugtraq. ,

Internet,

FreeBSD. www.securityfocus.com,

, Bugtraq

http:// .

Ɋɭɤɨɜɨɞɫɬɜɚ ɩɨ ɡɚɳɢɬɟ Ɉɋ FreeBSD (security advisories) FreeBSD (FreeBSD Security Officer) [email protected]

[email protected] . http://www.freebsd.org/security/.

:

FreeBSD FreeBSD,

,

. -

,

,

. [email protected],

. (

.

FreeBSD, , (-STABLE -CURRENT). . , make world.

15). ,

.

,

,

18.

Web-ɪɟɫɭɪɫɵ FreeBSD, http://www.freebsd.org/security/, FreeBSD . ,

, FreeBSD , .

. Security

How-To ,

(http://people.freebsd.org/~jkb/howto.html) FreeBSD. ,

Ƚɥɚɜɚ 29. Ɂɚɳɢɬɚ ɫɟɬɢ

CERT (http://www.cert.org) —

.

579

Internet -

CERT

.

, .

SecurityFocus —

,

Bugtraq.

,

: .

.

FreeBSD, .



http://www.securityfocus.com.

Ʉɧɢɝɢ /etc/rc.firewall :" (Firewalls & Internet Security) (William R. Cheswick) (Steven M. Bellowin) , " Internet" (Building Internet Firewalls, 2nd Edition) (Brent Chapman) (Elizabeth Zwicky) .

Internet"

SecurityFocus

"Library" ("

").

30

ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

► ȼɜɟɞɟɧɢɟ ɜ ɫɢɫɬɟɦɭ BIND ► ɉɨɞɤɥɸɱɟɧɢɟ ɞɟɦɨɧɚ ɫɟɪɜɟɪɚ ɢɦɟɧ ► Ɏɚɣɥ ɤɨɧɮɢɝɭɪɚɰɢɢ ɫɢɫɬɟɦɵ BIND [namecl.conf] ► ɋɨɡɞɚɧɢɟ ɮɚɣɥɚ ɡɨɧɵ ► Ʉɨɧɮɢɝɭɪɢɪɨɜɚɧɢɟ ɤɷɲɢɪɭɸɲɟɝɨ ɫɟɪɜɟɪɚ ɢɦɟɧ

Ƚɥɚɜɚ 30. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

, (DNS) IPFreeBSD

22

23, Internet .

581

; -

. FreeBSD

, ,

,

. — .

Web-

,

,—

, ,

.

"

",

DNS,

,

,

-

.

DNS,

,

,

. DNS.

,



.

FreeBSD . DNS

.

UNIX,

Internet, Internet Software Consortium (ISC).

BIND,

ȼɜɟɞɟɧɢɟ ɜ ɫɢɫɬɟɦɭ BIND ,

BIND ( (named),

Berkeley Internet Name Domain) , . BIND .

FreeBSD,

ɋɬɪɭɤɬɭɪɚ ɫɢɫɬɟɦɵ ɞɨɦɟɧɧɵɯ ɢɦɟɧ (DNS) — Internet , . ,

( , ,

. — top-level domains , DNS somewhere.com ( , nsl.somewhere.com). DNS . Network Solutions,

, . " Internet Network Solutions, Inc. , somewhere.com) — com, org, net (.), ( TLD) , DNS Internet. "

. .—

, "

, , .

"

",

"

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

582

:

Network Solutions . DNS,

, TCP/IP, —

,

. 30.1.

,

DNS

,

.

,

.

DNS.

(

NS), .

-

DNS, ,

.

,

DNS

,

-

DNS,

.

Ʉɨɪɧɟɜɵɟ ɫɟɪɜɟɪɵ Ɋɢɫɭɧɨɤ 30.1.

DNS, DNS,

DNS ,

. , DNS

Internet. DNS

,

, DNS ,

,

. DNS "

"

-

. .

Ɂɨɧɵ BIND

IPDNS.



, (.),

somewhere.com. —

, ,— — , cluster.somewhere.com. —

, ,

, ,

. IP-

, com. com. ! ; . . DNS,

.

Ƚɥɚɜɚ 30. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

DNS,

IP-

583

,

. ARPAnet (

DNS .

, addr.arpa. .in-addr.arpa. addr.arpa. , — ( ).

IP-

22) DNS

IP,

CCC.BBB.AAA.in, 131.41.64.in-

, 64.41.131.* , ,

IP,

.

,



DNS;

.

Ɏɚɣɥɵ ɢ ɩɪɨɝɪɚɦɦɵ ɫɢɫɬɟɦɵ BIND BIND .

,

FreeBSD,

,

, .



/usr/sbin/named.



/usr/sbin/ndc.

. DNS. .

, •

53,

,

.

/etc/namedb. BIND,

,

( ).



BIND.

/etc/namedb/named.conf. 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"),

" /etc/namedb .

"

".

. " named , named BIND .

,

sandbox (

, ), /etc/named/

,

sandbox bind: # chown -R bind:bind /etc/namedb/sandbox # chmod -R 750 /etc/namedb/sandbox

/etc /var/run /etc/namedb/sandbox/etc. /var/run,

/etc/localtime

sandbox. 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

:

named " :

) - . # ndc -

/etc/namedb/sandbox"

ndc ( ",

/etc/namedb/sandbox/var/run/ndc start

, sandbox.

named

,

Ɏɚɣɥ ɤɨɧɮɢɝɭɪɚɰɢɢ ɫɢɫɬɟɦɵ BIND (named.conf) ,

, ,

,

Ƚɥɚɜɚ 30. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

585

. . /etc/namedb/named.conf . , BIND ; , , (

, 8(



FreeBSD 9) , ). BIND 8, , .

BIND 4

BIND 4,

30. 1

named.conf, . Ʌɢɫɬɢɧɝ 30.1. ɉɪɢɦɟɪ ɮɚɣɥɚ /etc/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"; } ;

, "

")

( ,

-

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

586

({}). named.conf. logging

options, controls,

zone. ;

named.conf (//),

: /*

*/. (

#). FreeBSD,

named.conf, ,

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

, options IP, .

127.0.0.1 forwarders (127.0.0.1, /* */ /*

)

-

forwarders { 127.0.0.1;

}; */

— , forward only

named .

-

options, -

named .

DNS,

, —

.

forward only,

.

Ʉɨɧɮɢɝɭɪɚɰɢɢ ɝɥɚɜɧɨɝɨ ɢ ɩɨɞɱɢɧɟɧɧɨɝɨ ɫɟɪɜɟɪɚ , FreeBSD. somewhere.com:

-

588

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

zone "somewhere.com" { type master;

file

"somewhere.com"; };

( ,

), (

),

.

-

type, ,

,

,

. type master (

)

,

master, slave, stub, forward slave ( ); .

, , Internet.

master

hint. — —

, , 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 DNS-

, NS —

, , .

Ƚɥɚɜɚ 30. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

• forward.

589

forward .

zone -

forwarders, options. . hint

• hint.



/etc/ -

, ,

namedb/named.root. , "

"

BIND,

, ,

-

.

Ɉɝɪɚɧɢɱɟɧɢɟ ɞɨɫɬɭɩɚ ɤ ɫɥɭɠɛɟ DNS BIND (Access Control List — ACL).

ACL

acl, .

,

;

,

ACL

ACL.

-

. • any. • . • localhost. • localnets.

. . IP-

. ,

111.112.113.114), (1111.112.113.114, key ( ). , . , ,

. IP( , 111.112.113/24), 111.112.113.114")

CIDR ( "

, -

ACL, , , . . ,

named.conf

-

, . options. acl

]

"my_list" { localhost; localnets; another_list; !132.112.14.124; 132.112.14/24; };

acl

named.conf, :

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

590

) • allow-query {

_

_ DNS.

, allow-query

allow-query -

zone — ,

options. . • allow-transfer {

-

options. : ; ... };.

_

_

; ... };.

, -

. zone — options.

allow-transfer allow-transfer , • 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,

. ( ,

BIND

— Master Zone File, ,

— Master File) . " " .

, , .

(

)

Ƚɥɚɜɚ 30. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

591

, .

30.2,

,

(;)

. 30.2.

$TTL

5omewhere.com.

3600

somewhere.com.

; @ @

IN

SOA

stripes.somewhere.com. root.somewhere.com. 20010610 ; Serial 10800 ; Refresh 3600 ; Retry 604800 ; Expire 86400 ) ; Minimum TTL

(

DNS IN NS IN NS

stripes.somewhere.com. spots.somewhere.com.

; localhost nsl ns2 mail @

IN IN IN IN IN

; www ftp ;

@

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

IN CNAME IN CNAME

@ www.somewhere.com.

MX

IN MX 10

mail.somewhere.com.

, ,

.

30.2

: • • • • •

STTL; SOA (Start-of-Authority); NS ( ); ( ); CNAME ( ; MX (Mail Exchanger).



,

— Canonical Name),



(Resource

Record — RR), " " ("origin").

.

Ⱦɢɪɟɤɬɢɜɵ e.

. ($). ,

. SORIGIN.

592

ɑɚɫɬɶ 4. FreeBSD ɢ ɪɚɛɨɬɚ ɜ ɫɟɬɢ

• SORIGIN. : SORIGIN < SORIGIN

> [
] SINCLUDE , SINCLUDE. < • 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. ɋɟɪɜɟɪ ɞɨɦɟɧɧɵɯ ɢɦɟɧ

,