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

GENERALGNU/Linux

LPILevelI(LPI101/102).


1. GNU/Linux...........................................................................................................7
GNU/Linux.......................................................................................................7
?.....................................9
GNU/Linux......................................................9
GNU/Linux ....................................................................11
2. GNU/Linux.............................................................................................12
................................................................................12
shell?......................................................................................................15
........................................................................................................16
.....................................................................................................17
?................................................................................................................................18
3. Bash......................................................................................................20
?.....................................................................................................................20
......................................................................................................21
GNU/Linux..............................................................23
............................................................................................25
, .............................................................................26
.....................................................................29
............................................................................................................................32
....................................................................35
(aliases)......................................................................................................36
...............................................................................................................37
..............................................38
.....................................................................................39
4. ...................................................................................................42
................................42
Bash...........................................................................................42
man...............................................................................................................43
man.....................................................................................................................45
TexInfo...........................................................................................................................47
, .................................................49
Internet..............................................................................................49
5. ........................................................................................51
.......................................................................................................51
....................................................................................53
.............................................................................................55
..................................................................................56
, ...........................................................60
...............................................................................................................................62
................................................................64
...........................................................................................................64
6. .............................................................................................................................66
.....................................................................................................................66
.......................................................................................68
.........................................................................................................70
...............................................................................................................72

........................................................................................................................................77
Bash......................................................................................79
..........................................................................................79
7. vi..........................................................................................................................82
vi ..................................................................................................82
vi.........................................................................................83
vi ............................................................................................84
................................................................................................86
......................................................................................................................87
8. ................................................................................................89
-...................................................................................89
..................................................................................................................93
echo................................................................................................................................95
more less.................................................................................96
cat.........................................................................................97
head tail......................................................................................................................98
cut...............................................................................................99
sed............................................................................................................100
awk...........................................................................................................103
.................................................................................................104
.................................................................................106
..............................................................................................107
.......................................................................................................108
.......................................................................................................................109
................................................................................................110
.................................................................111
...................................................................................111
tr................................................................112
............................................................................................................................114
........................................................................................................................115
......................................................................................................116
xargs.............................................................................................................................118
9. ....................................................................................................119
..................................................................................119
grep...................................................................................................121
.............................................................................................124
sed.........................................................................125
awk...................................................................................................126
10. , DAC..................................................................................128
.................................................................................................128
...........................................................................................................130
, ............................................................................131
........................................................................................................132
.........................................................................................134
.............................................................................................................136
..............................139
: SUID, SGID sticky bit....................................................141
Linux.....................................................................................................144
................................................................................................145
.........................................................................................148

11. ....................................................................151
.......................................151
...........................................................................................152
fdisk.............................................................................153
....................................................................................................155
..............................................................................157
.............................................................................................159
......................................................................................................161
/etc/fstab.................................................................163
...............................................................................................164
12. Bash............................................................................................166
....................................................................................................................166
.....................................................................................168
(quotation)........................................................................................................170
...................................................................171
..........................................................................................................172
test................................................................................................................................174
...................................................................................................177
case...............................................................................................................................180
..........................................................................................................................................182
......................................................................................................................................185
13. ..........................................................................................189
..............................................................................189
, ............................190
................................................................................................................194
.......................................................................................195
............................................................................................................197
..........................................................199
..................................................................204
14. ..................................................................................................206
..................................................................................206
dd..................................................................................................................................209
.....................................................................................................210
tar..................................................................................................................................212
cpio...............................................................................................................................214
dump.................................................................................................................216
restore..................................................219
15. .........................................................222
at....................................................................222
.....................................................223
16. ......................................................................................................226
syslog.............................................................................................................................226
........................................................................................................230
17. ......................................................................233
..................................................................................233
GRUB........................................................................................................................234
......237
..........................................................................................242
18. ....................................................................244
.......................................................244

.................247
........................................................................................................250
RPM............................................................................................................254
YUM......................................................258
Debian.....................................................................................263
19. .......................................................................271
...............................................................................................271
.............................................................................................................273
udev............................................................................................................277
PCI...........................................................................................................................280
SCSI-........................................................................................................281
Ethernet.....................................................................................282
...................................................................................................283
USB..........................................................................................................................284
20. Linux......................................................................................................................285
Linux.................................................................................................285
21. DNS DHCP...................................................................287
TCP/IP..........................................................................................................................................287
IPv4..........................................................................................................................290
Ethernet................................................................................293
.............................................................................295
.....................................................................................................296
Red Hat....................................................................................................................299
......................................................................................302
22. ...................................................................................................................307
......................................................................................................307
................................................................................................................309
inetd tcpd..................................................................311
tcpd..........................................................................................................................312
xinetd..........................................................................................314
23. .........................................................................................318
telnet..............................................................................................................................318
(r-services)..................................................................................321
SSH...............................................................................................................................324
24. FTP.....................................................................................................................328
FTP...........................................................................................................328
vsftpd..........................................................................................................329
FTP...............................................................................................................................331
25. NIS, NFS, autofs...........................................................................................335
NIS NFS.......................................................................................................335
NIS NFS................................................................................................................335
NIS............................................................................................................336
NIS..................................................................................................340
NFS..............................................................................................................342
NFS ....................................................................................................344
NFSv4................................................................................................345
AutoFS..........................................................................................................................346
26. SMB/CIFS SAMBA............................................................................................349
SAMBA..............................................................................................................349
SAMBA....................................................................................................................350

SAMBA............................................................................................353
27. DNS BIND...........................................................................................................356
DNS......................................................................................................................356
BIND...............................................................................................359
DNS.............................................................................................................361
DNS BIND........................................................................................................367
DNS.......................................................................................................368
28. WEB Apache........................................................................................................372
Apache.............................................................................................372
.................................................................................................................................376
Apache.....................................................................................................378
WEB .............................................................................................................379
WEB ......................................................................................380
......................................................................................................................382
29. Sendmail.....................................................................383
.............................................................................................383
Sendmail...................................................................................................385
Sendmail sendmail.mc..............................................................388
Sendmail..........................................................................................................................392
..............................................................................................................393
..................................................................................................395
Sendmail..............................................................................................................396
30. ...............................................................................................................399
CUPS................................................................................................................399
CUPS............................................................................................................................401
CUPS..............................................................................................402
CUPS......................................................................................404
31. X Window.........................................................................................................407
X Window.............................................................................................................407
X Window..................................................................................................408
.........................................................................................................................412
X ...................................................................................414
X xdm............................................................................................................417
X .............................................................................................................................419
......................................................................................................................................421
X .............................................................................................................423
X ............................................................................................424
xdm .................................................................426
X VNC.....................................................................428
32. GNU/Linux....................................................................................................434
GNU/Linux.......................................................................434
GNU/Linux x86/64................................................435
Centos CD/DVD.......................................................................440
kickstart.............................................................................................................445

1.GNU/Linux.
GNU/Linux.
GNU/Linux UNIX
, UNIX . UNIX Bell
Lab AT&T 1969 .
,
. UNIX : UNIX System
V ( AT&T) BSD (Berkeley Software Distribution
Berkeley). UNIX
. Oracle Solaris ( Sun)
UNIX System V ( SVR4 System V release 4), FreeBSD
BSD.
GNU/Linux -
UNIX . , ,
, , .
, , FreeBSD, GNU/Linux ,
, .
(), ,
, GNU/Linux.
GNU/Linux? Linux
, GNU GNU is not UNIX
( , ), 1984 .
FSF (FSF Free Software Foundation). , 1991
. , MINIX (
) i386. 25
1991 . comp.os.minix usenet
, MINIX AT
,
. ,
, , ... ,
GNU ....
, , , ,
FSF. FSF
GNU,
GPL Copy Left UNIX System V
( GPL Copy Left ). FSF 1991 .
.
: Bash (Bourne again shell), Emacs, gcc
. GNU
. GNU HURD,
, :
, , , GNU,
GNU/HURD.
1991 1992 . GNU/Linux 1993 .
GNU/Linux, Red Hat
GNU/Linux .
7

,
,
. 199... - .
, GNU/Linux
(, SMTP Sendmail DNS BIND).
GNU/Linux :
,
.
GNU/Linux
.
GNU/Linux
.
Xorg: GNOME KDE, , ,
.
GNU/Linux
,
GNU/Linux.

GNU/Linux:

Red Hat , .
: Red Hat Enterprise Linux (RHEL)
,
, Fedora ,
Red Hat.

Novell SUSE .

. SLES (SUSE Enterprise Linux Server),
SLED (SUSE Enterprise Linux Desktop) Open
SUSE.

Debian
.
.

Ubuntu ,
. Debian,
.
Canonical, ,
.

SlackWare ,
.

Mandriva , Red
Hat. ,
.

CentOS Red Hat Enterprise Linux.


. RHEL,
.

ASP ,
Red Hat. .
8

ALT - ,
. Mandriva,
.

?
,
, GPL BSD, . ,
.
Linux , , , SUSE.
.
FSF :
0.
( 0).
1.
( 1).
2. ( 2).
3.
( 3).
, , GPL,
(Public Domain).
.

GNU/Linux.
GNU/Linux ,

. ,
GNU/Linux :
1) ,
(, ).
2) (, ),

.
3)
.
4)
.
5) /.
6) .
7) .
8) c
.
9)
9

.
10)
.
GNU/Linux :
1) .
2) .
3) .
4) .
5) .
GNU/Linux
.
GNU/Linux .
,
, -
( ). ,
,
. , ,
,
.
(kernel space) (user space). ,
,
.
. ,

.

, .
, , ,
. , ,
,

.
,
, , ,
. (system
calls) - C,
.

(, libc), , ,
.
,
.
(, df ls)

.
.
10

, ,
, ,
(, X xdm Xorg).
, ,
.., , gcc gdb,
, .

- ,
.
, ,
,
.

. ,
GNOME KDE, ,
Linux.

GNU/Linux.
GNU/Linux ,
, .

, , , .
, , -
Linux .
GNU/Linux, ,
.
Linux
. , Red Hat Linux,
,
i386, Mandriva Pentium. ,
, , -
GNU/Linux :

Pentium .

, 256 . X Window
512 .

(swap partition) .

( CD Linux),
,
, .
500
10 ( ) .

VGA .

, : USB ,
CD/DVD-ROM, .
11

2.GNU/Linux.
.
GNU/Linux ,
.
, ,
(account). ,
.
, ,
. ,
.
GNU/Linux
,
.
. ,
,
(,
nsimonova).
, ,
. , ,
.
GNU/Linux (
,
). ,

:

, .

(@,#,$ ).

ASCII, , .

Linux
, , , UNIX .

,
,
, , ,
.
( ) ,
, .

,
. ,
12

, ,
.
, ,
:
4. .
,
.
5. ,
(, ).
6. ,
,
.
7. , , ,
.
8. .
9. ,
,
.
10. ,
.
11. ( ) ,
. ,
,
.
12. .
13.
.
14.
.
, ,
.
,
, Bourne Shell,
X Window.

:
GNU/LinuxonTTY2
login:
login: getty ( ),
. login:
13

, .
Enter.
login,
:
password:

. ,
Back Space () . ,
, , , -
. :
GNU/LinuxonTTY2
login:student
password:
loginincorrect
student ,
. loginuncorrect,
.
, ,
, ,
. ,
. :
GNU/LinuxonTTY2
login:#4T),k%%
password:
loginincorrect
,
.
.
Linux ,
.
exit .
logout . <Ctrl>+<D>,
bash (
setoignoreeof).
login: .

14

.
11) .
12) .
13) , .
?
14) , .
?
15) ?
16) setoignoreeof
<Ctrl>+<D>.

shell?
,
.
.
<Enter>. <Ctrl>+<J>
<Ctrl>+<M>.
.
. :
[tania@worketc]$
tania,
work - etc.
PS1,
:
$ >
.
,
#.
:
[root@workroot]#
, .
, who , :
$hwo
bash:hwo:commandnotfound

15

, hwo .
who.
, ,
. clear <Ctrl>+<L>.

.
6) WHO Who. ?

.
.
Linux
, PAM (PAM Pluggable Authentication
Module). , ,
. , ,
.
PAM :
,
.
, ,
. , .

.
, ,
.
.
PAM.
, .
:
$passwd
Changingpasswordforcolobok.
Entercurrentpassword:
Youcannowchoosethenewpasswordorpassphrase.
Avalidpasswordshouldbeamixofupperandlowercaseletters,
digitsandothercharacters.Youcanusean8characterlong
passwordwithcharactersfromatleast3ofthese4classes,or
a7characterlongpasswordcontainingcharactersfromallthe
classes.Charactersthatformacommonpatternarediscardedby
thecheck.
Apassphraseshouldbeofatleast3words,12to40characters
longandcontainenoughdifferentcharacters.
Alternatively,ifnooneelsecanseeyourterminalnow,youcan
pickthisasyourpassword:"senilE&the&PinK".
16

Enternewpassword:
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
colobok.
, passwd ,
,
.
.
,
, :
#passwdcolobok
Changingpasswordforusercolobok.
Newpassword:
Retypenewpassword:
passwd:allauthenticationtokensupdatedsuccessfully.
,
.
passwd .

.
linux123?

R#6aF1*&/pi. ?

.
UID GID.

. UID (User ID), GID
(Group ID). Linux
,
.
, , ,
id, :
$id
uid=503(colobok)gid=503(colobok)=503(colobok),22(cdrom)
, id , UID colobok
17

503, colobok GID503.


cdrom, 22.
colobok colobok. ,
, .
Red Hat Linux ( )
.
Linux UID ,
100 500 ( /etc/login.defs,
, ),
UID. , ,
mail id :
$idmail
uid=8(mail)gid=12(mail)groups=12(mail)
mail UID8 mail GID12.
,
id.

UID GID.

root?

UID id? :
idhelp .

?
, .
who , .
$who
taniatty3Sep2119:10(localhost)
loretty:0Sep2118:48
colobokpts/1Sep2120:40(localhost)
who .
, . loretty
,
:0. loretty (
), X
colobok, pts/1.
18

, tty3 19:10
tania.
, , who
/var/run/utmp ( ).
who b. ,
.
$whob
systembootSep2117:16
, 21 17:16.
Linux
, uptime.
$uptime
21:02:14up3:46,2users,loadaverage:0.06,0.04,0.03
, ,
,
1, 5 15 .
, w .
$w
22:29:33up5:13,3users,loadaverage:0.00,0.00,0.00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
taniatty2localhost10:29pm15.00s0.04s0.03sbash
rootpts/1localhost6:51pm34.00s0.06s0.05sbash
.
last,
/var/log/wtmp.

who H. ?

, .

, .

19

3.Bash.
?
(shell) ,

.
. ,
, . exit
.
, ,
, $
.
#,
.
GNU/Linux ,
de facto Bourne Again Shell Bash.
.
.
login ,
/etc/passwd. login
SHELL. , ,
, :
$echo$SHELL
/bin/bash
SHELL
, .
Bash. $
.
, . ,
<Enter>, ,
, . ,
.
, ,
.
, .

,
. : less/etc/passwd,
.
20

echo$SHELL SHELL.

.
,
. ,
, .
,
,
. :

, ,
.

, .

, , ,
, ,
.
.
- .
, GNU/Linux.
.
UNIX98 ( - POSIX ) ,
():

UNIX98 ,
, :
$lsdl/etc/default
ls, ,
, , d l. d
ls , .
l , .
BSD :

BSD :

21

$psaux
ps . a, u, x
, ,
, .
Linux GNU.
, :
12
,
. GNU help,
:
$gziphelp
gzip . ,
, --help.
,
, +5 .
, , , ,
, mydir
:
$lsdmydir
$lsdirectorymydir
, ls, d
directory ,
.
, X , ,
, "", GNU. :
$xtermdisplay:0.0
xterm.
, ,
.
Enter,
, :
, . ,
, .

22

lsl~,
.

:
, ?

lsd. ,
.

GNU/Linux.
GNU/Linux ,
,
. :

Bash shell (bash) GNU/Linux ;

Public domain Korn shell (pdksh ksh);

Enhanced C shell (tcsh);

Z Shell (zsh).

(
).

( ,
). , ,
.
Bash shell GNU/Linux
.
GNU/Linux .
Bash , ,
, $,
(root) #.
.
.
chshl ,
.
/etc/shells, ( ,
, ) .
:
$cat/etc/shells
/bin/sh
/bin/bash
/bin/csh
/bin/tcsh
23

/bin/ksh
/bin/zsh
cat /etc/shells,
.
, GNU/Linux, , ,
/etc/shells .
, . ,
FTP ,
.

, Enhanced C shell:
$tcsh
$ps
PIDTTYTIMECMD
2349pts/000:00:00bash
10295pts/000:00:00tcsh
10319pts/000:00:00ps
Enhanced C shell. ps
, tcsh bash.
,
, .
exit .
, ,
.
chshs<shell> , <shell> - , :
$chshs/bin/csh
, , C shell,
/bin/csh. , , ,
.

, .

, tcsh,
. -?

bash , .

tcsh .

GNU/Linux tcsh
24

%, $. ,
? ps,
, .

, psp$$.

.
GNU/Linux : .
,
, ,
.
, ,
, . , ,
, ,
-. , set Bash C shell
-.
, , .
bash, , , cd,
alias, bg, kill, pwd echo.
,
:
/bin
/sbin
/usr/bin
/usr/sbin
/usr/local/bin
/usr/local/sbin
.

bin.
- ,
, .
, .

, /bin.
?

pwd
/bin. pwd help.
?

25

,.

. , -,
, Home, , -,
.
, .

CtrlB

CtrlF

AltB

AltF

CtrlA

CtrlE

CtrlH

CtrlD

AltD

CtrlU

CtrlK

CtrlMCtrlJ

CtrlV

CtrlL

AltT

AltL

AltU

CtrlC

CtrlZ


, .
, ,
CtrlV:
$echo"123"
123
, echo
, .
26

CtrlV,
Bash .
CtrlC INT,
kill2 . .
CtrlZ ,
bg,
kill.
, , ,
.
Bash ,
.
. :
^^ Enter,
:
$ls/dmb
ls:/dmb:Nosuchfileordirectory
$^dmb^tmp
ls/tmp
010374014307934554641645210352AcromIO5pU
ls ,
. ,
, dmb tmp,
/tmp.
, ,
\
:
$find.\
>name"*prim*"\
>user501\
>typef\
>ls
135283620rwrr1useruser1640814
1999./Documents/DocBook/html/primaryie.html
135313516rwrr1useruser1609314
1999./Documents/DocBook/html/primary.html
find.name"*prim*"user501typefls , ,
. ,
prim, UID=501,
, lsl. ,
, , ,
. , ,
. PS2.
, ,
27

;. :
$cd/opt;lsl;cd;pwd
8
drwxrxrx7rootroot40962308:21drweb
drwxrxrx7oracleoinstall40962307:20oracle
/home/user
, , ,
.
&&,
. , ,
.
:
$lsnofile&&catnofile
ls:nofile:Nosuchfileordirectory
$ls/etc/motd&&cat/etc/motd
/etc/motd
It'stimetowork!
lsnofile ,
, .
, ,
/etc/motd.

:
$lsnofile||echo"NetEGO"
ls:nofile:Nosuchfileordirectory
NetEGO
, echo"NetEGO"
, lsnofile
.

slF/etc/tmp/opt. ,
ls. .

ld
.

, ,
.
.

28

.
Bash ,
.
. ,
. , VAR1
Privet!.
$VAR1=Privet!
$echo$VAR1
Privet!

$. echo ,
VAR1, .
.
, - Bash .
.
.
, . .
( )
, .
$hostname
work.doma.ru
$echo$HOSTNAME
work.doma.ru
, hostname
, HOSTNAME. ,
.
,
.
$VAR1='BolshoyPrivet!'
$echo$VAR1
BolshoyPrivet!
VAR1 .

, , .
$VAR1='Vamvsem'$VAR1
$echo$VAR1
29

VamvsemBolshoyPrivet!
VAR1 , Vamvsem
. ,
!

.
$VAR1=${VAR1}'?'
$echo$VAR1
VamvsemBolshoyPrivet!?
, ,
. ,
$VAR1? Bash .
, ,
set. , , :
$set|less
, , ,
less.
,
unset, .
$VAR1="It'savariable"
$echo$VAR1
It'savariable
$unsetVAR1
$echo$VAR1
, VAR1 unset , echo$VAR1
.
, .
,
.
.
, ,
.
export.
$VAR1=01/01/1970
$echo$VAR1
01/01/1970
$bash
30

$echo$VAR1
$exit
exit
$exportVAR1
$bash
$echo$VAR1
01/01/1970
$exit
exit
, VAR1, ,
bash, . ,

.
, environ.
, ,
.
env.
.
-
. ,
, .
.

HOME

LOGNAME

MAIL

PATH

PS1

PWD

SHELL

USER

PS1 ,
. \u ,
, \W ,
\h Bash .
[user1@worktmp]$echo$PS1
[\u@\h\W]\$

31

, , , ,
.

, .
, ,
/etc/profile,
: ~/.bash_profile,
~/.bash_login, ~/.profile. .
bash ~/bashrc.

, ,
.

NEWVAR 1982 ,
.

NEWVAR ,
.

.
?

.
Bash
.
~/.bash_history ( HISTFILE ).
$echo$HISTFILE
/home/user1/.bash_history
, ,
HISTFILESIZE . HISTFILESIZE,
500 .
$echo$HISTFILESIZE
9999
history.
$history
685echo$HISTFILE
686echo$HISTFILESIZE
32

687history
.
, , ,
.
, .
$!685
echo$HISTFILE
/home/user1/.bash_history
, , ,
685.
,
!!.
,
. , ls/tmp,
, !l.
,
. , .
.
$ls/opt
drweboracle
$pwd
/home/user1
$cd/tmp
$!l
ls/opt
drweboracle
, ls/opt,
.
ls/opt, . ,
!l.
, , .
. :
$!?cho
echo$HISTFILE
/home/user1/.bash_history
,
cho.

. ,
33

, . ,
,

. fc. fc ,
.
, .
. ,
.
fcl , ,
history. , fcl ,
.
s fc , ,
. fcs<>
, , . ,
. s . :
$lsld/tmp
drwxrwxrwt30rootroot4096222:01/tmp
$fcstmp=optls
lsld/opt
drwxrxrx4rootroot40962308:21/opt
tmp=opt, fc
ls
opt tmp.
, ,
( <Ctrl>+<P>)
( <Ctrl>+<N>)
. ,
.
<Ctrl>+<R>,
:
$mkdirtxt
(reverseisearch)`txt':mkdirtxt
mkdirtxt
<Ctrl>+<R>, .
txt,
.

, echo
34

echo .

, ho.

.
, ,
. , ,
PATH.
, Bash
. Bash
.
, .
:

Bash
, ,
.
Bash .
$, ~, @, Bash :

($);

(~);

(@).

,
:

Alt? - .

Ctrlx/ - .

Ctrlx~ - .

Ctrlx@ - .

Alt* - .

Alt/ - , .

Alt~ - , .

Alt$ - , .

Alt@ - , .
35

lsld/ ,
.
.

HISTFILESIZE,
.

,
H.

ping3 localhost.
. localhost
.

(aliases).
, , .
alias,
. ,
r fcs, ,
:
$aliasr='fcs'
$alias
aliasls='lscolor=auto'
aliasmv='mvi'
aliasr='fcs'
aliasrm='rmi'
$rls
lsd/bin
/bin
r fcs.
alias , ,
. r.
ls.
.
unalias.
unaliasa .

lf lsF .

.
36

.
(command substitution) Bash.
,
.

, $.
``.
,
: My UID is ...,
UID . UID
idu,
echo. , , .
.
$echo"MyUIDis`idu`"
MyUIDis501
, echo ,
. idu, ,
Bash .

.
$lsl$(cat/etc/shells)
ls:/bin/ash:
ls:/bin/bash1:
ls:/usr/bin/bash:
rwxrxrx1rootroot582728102009/bin/bash
lrwxrwxrwx1rootroot42109:35/bin/csh>tcsh
rwxrxrx1rootroot22228242009/bin/false
lrwxrwxrwx1rootroot162109:37/bin/ksh>/lib/ast/bin/ksh
lrwxrwxrwx1rootroot42314:12/bin/sh>bash
rwxrxrx1rootroot358092242009/bin/tcsh
rwxrxrx1rootroot22228242009/bin/true
rwxrxrx1rootroot620556242009/bin/zsh
lrwxrwxrwx1rootroot92109:35/usr/bin/csh>/bin/tcsh
lrwxrwxrwx1rootroot162109:37/usr/bin/ksh>/lib/ast/bin/ksh
rwsrxrx1rootshadow80268192009/usr/bin/passwd
lrwxrwxrwx1rootroot92109:35/usr/bin/tcsh>/bin/tcsh
lrwxrwxrwx1rootroot82109:35/usr/bin/zsh>/bin/zsh

, ,
/etc/shells.
, , cat
/etc/shells, ,
ls. ,
, /etc/shells .

.
37

$SYSTEM_START=`whob`
$echo$SYSTEM_START
systemboot2010062720:45
SYSTEM_START,
whob,
.

,
. psu,
, whoami,
.
.

MYGROUP, .
idgn.

.
, ,
, $,
- .
, .
$echo$((192*512))
98304
192*512. echo
, .
.
$V1=5
$V2=$(($V1/2))
$echo$V2
2
V1 5. V2
V1 . , Bash
, V2 2.

38

Bash 16
.

TTL , .
.

.

, ().
,
, .

echo, , .
*
. ,
. ,
echo, ,
, echo

.
$echo*
f1f2f3f4
$rm*
$echo*
*
, ,
Bash echo,
*. , .
echo . Bash
, echo .
,
ls ( )
. .
.* .
,
. :
$echo*
f1f2ss1s2
$echos*
ss1s2

39

, f1, f2, s, s1 s2.


echos* ,
s s.
? , ,
:
$echos?
s1s2
, s , Bash
echo.
, ,
. ,
.
,
. , [09] , [azAZ]
.
, , ,
f, s, .
[fs]? .
$echo[fs]?
f1f2s1s2
: ?a[ah]* ,
, a,
a h. .
[!] ( ),
. :
$echo*[!09]
s
s,
, .
, , Bash.
,
,
, . :
$echos{1,2}
s1s2
$echos1s2
s1s2
40

. Bash ,
, ,
, .
.
$echo{s,f}{1,2}
s1s2f1f2
.
$echo{s,{f1,f2}}
sf1f2
.
$echo{s,f?}
sf1f2

,
.

,
, A ?

,
(, 255 ), ?

. ,
?

41

4..
.
, , ,
.
, .
:
$pwdh
bash:pwd:h:invalidoption
pwd:usage:pwd[PL]
pwd, ,
, .
.
GNU , help .
$wchelp
Usage:wc[OPTION][FILE]
Printline,word,andbytecountsforeachFILE
, help
. , GNU,
.

, help id.

help h id.

/etc/hosts wc,
.

Bash.
Bash .
Bash help.
Bash,
.
$helppwd
pwd:pwd[PL]
42

Printthecurrentworkingdirectory.WiththePoption,pwdprints
thephysicaldirectory,withoutanysymboliclinks;theLoption
makespwdfollowsymboliclinks.

cd ?

alias.

man.
man ( manual ) , , UNIX UNIX . ,
, . man
, .
, ..,
man :
$manls
ls.
Linux . man,
? , passwd
, /etc /etc/passwd.
man ,
.

1
2
3
4
5
6
7
8
9

.
.
.
.
.
.
, ,
.
.
.

, , 1p 1x, ,
POSIX , .
man man
.
43

$man3zlib
zlib.
man.
man .
,
, . less.
less.

CtrlN

CtrlP

CtrlVPgDown

AltVPgUp

<Space>

man.

,
a man. man
, ,
.

. k man
apropos.
man NAME,
. mank ,
, , NAME
. :
$mankclock
CLOG_csync(4)synchronizeclocksforadjustingtimes
inmerge
adjtimex(2)tunekernelclock
alarm(2)setanalarmclockfordeliveryofa
signal
clock(3)Determineprocessortime
clock(n)Obtainandmanipulatetime
clockdiff(8)measureclockdifferencebetweenhosts
hwclock(8)queryandsetthehardwareclock(RTC)
44

aproposclock.
, .
NAME ,
, manf whatis. :
$manfclock
clock(3)Determineprocessortime
clock(n)Obtainandmanipulatetime
, ,
. , apropos ,
whatis .
, apropos whatis (, , mank manf
), , man.
makewhatis.

P man?

man.

, groff.

man.
man UNIX
nroff. ,
. GNU groff,
nroff. man apropos.
.THapropos1"Jan15,1991"
.LO1
.SHNAME
apropos\searchthewhatisdatabaseforstrings
.SHSYNOPSIS
.BIapropos
keyword...
.SHDESCRIPTION
apropossearchesasetofdatabasefilescontainingshort
descriptions
ofsystemcommandsforkeywordsanddisplaystheresultonthe
standardoutput.
.SH"SEEALSO"
whatis(1),man(1).
, . ,
45

.SH man.
man ,
man. , rm.1
rm, man. man
gzip bzip2 ,
, , gz bz2.
man /usr/share/man. ,
, /usr/man
, FHS (. manhier).
/usr/share/man man1, man2 ... man9.
, ,
. , ,
/usr/share/man/man8/ man
.
, ,
, man, /usr/share/man
. man
/usr/share/man/ru, man
, : /usr/share/man/ru.
$ls/usr/share/man
man1man2man3man4man5man6man7man8man9mannru
$ls/usr/share/man/ru
man1man2man3man4man5man6man7man8man9mann
/usr/share/man/ru
man. , ,

/usr/share/local/man.
,
, ,
X Window. 1x,
.
, X Windows,
1, , xterm.1x .
man,
. MANPATH
, man.
MANPATH manpath.
GNU/Linux
man,
man LANG.
/etc/man.config man.
man ,
groff.
, ,
46

groff.

NAME
SYNOPSIS
DESCRIPTION

OPTIONS
FILE
AUTHOR
SEEALSO
COPYRIGHT

,
.
,
.

(,),
,.

.
,.
.
,
..,.
,..

, ,
(rpm, dselect .),
/usr/share/local/man.

man, , exit.

X Window, xzombie.
man ?

,
?

,
RPM (Red Hat Package Manager).
?

TexInfo.
TexInfo man GNU.
man GNU
TexInfo, .
TexInfo ,
. (node).
TexInfo ,
, .
TexInfo info
. info, ,
,
47

. , ,
info, TexInfo,
man.
$infols
, TexInfo,
ls.
info /usr/share/info,
/usr/info , ,
man, , , info
, man.
info, :

CtrlN

CtrlP

CtrlF

CtrlB

CtrlEEnd

CtrlAHome

AltF

AltB

CtrlVPgDown

AltVPgUp

Alt<

Alt>

info.

who, info.

48

info,
, .

, scroll .

info.

,.
/usr/share/doc
.
, avahi0.6.16 , avahi, 0.6.16.

.
README. /usr/doc.

.
.
, .
, , :

README , ,
, , , .

INSTALL .

ToDo - .

Changelog .

License .

HTML.

, Bash .

man?

Internet.
GNU/Linux The Linux
Documentation Project www.tldp.org.
, http://ldp.dvo.ru.
LPD :

HOWTO
GNU/Linux. HOWTO ( )
, , ,

49

.
, HOWTO
Linux ,
, .

FAQ (Frequently Asked Questions).


, ,
. Linux
, , , -
, , .
FAQ.

(Tutorals) (Guides) GNU/Linux.

Linux Gazette
GNU/Linux.

www.sf.net Source Forge,


.

www.ibm.com IBM
GNU/Linux.

www.gnu.org FSF GNU.

www.linux.org.ru .

www.nixp.ru ,
, .

www.opennet.ru , UNIX GNU/Linux


.

HOWTO.
/usr/share/doc.

www.linuxgazette.org GNU/Linux
. .

50

5..
.
GNU/Linux ,
.
, .
,
. , GNU/Linux
.
(root directory).
: /. ,
. , , .
$ls/
bindevhomelost+foundmiscnetprocsbinsrvtmpvar
bootetclibmediamntoptrootselinuxsysusr
ls , .
/.
GNU/Linux ,
, ,
.
(plain files, ordinary files regular files)
. ,
.
,
. ,
.
- , .
- (
).
,
. ,
.
,
, (path).
/. ,
/etc/hostname , , ,
/etc, .
GNU/Linux .
: /
\0 (null), 255 . ,

, ,
51

, .
(case sensitive), TheFile
thefile .
.
,
. (path)
. , :

, / -
. .

- , ,
.

. . GNU/Linux, , , MS DOS,
. ,
, .
. , ,
myarch.gz , gzip.
: tarball.tar.gz.
, ,
ls . , , ls
a (all) A:
$>.hidden
$ls
$lsa
....hidden
$lsA
.hidden
ls .
, .hidden, ,
. >.hidden.
lsa, ,
. .hidden.
.(), , .. ,
. lsA
, .

~. .

, .

ls ,
? : . sort.

52

() .

.
,
.
,
. pwd :
$pwd
/home/tania
tania c
pwd. : /home/tania ( ,
) tania.
(absolute pathname),
(relative pathnames),
, . ,
/, . , tania/referat.txt
.

ls. :
$ls
archive.gzreferat.txttext.txt
ls , : archive.gz,
referat.txt text.txt.
,
ls:
$ls~mail
zelenkarootrpc

mail.
.
. (). ls
ls./ ls. .
./ . , ./myfile ,
.
.. . , ,
/home/tania /home. ,
/home/tania, ls..
/home.
53

, .

( ).
-
/home. , tania - /home/tania.
Bash
: ~ , ,
~ . , ,
, , tania:
$ls~tania
archive.gzreferat.txttext.txt

tania /home/tania.

HOME. ls$HOME,
.
ls
l, :
$lsl/tmp
52
drwx3zztopzztop40962321:41gconfdzztop
drwx2rootroot40962022:41gconfdroot
drwx2zztopzztop40962321:41keyring746Fqa
srwxrwxrx1zztopzztop02321:41mappingzztop
drwx2zztopzztop40962321:45orbitzztop
drwx2zztopzztop40962321:41sshqtiEPO2629
drwx2zztopzztop40962321:41virtualzztop.kRE57A
, ,
( ), , , ,
. .
Linux
lsl.

- .

d .

l ( ).

b ( ,
, ,
, ).

c - ( ,
, , ,
54

).

p (PIPE FIFO,
).

s (socket,
).

ls F.
/, - *,
- @ .
$lsF~
Desktop/intro.txtscr1.sh*
ls F
. Desktop ,
/. intro.txt . scr1.sh
, *.
, ,
d ls . d ls
,
l:
$lsld/etc
drwxrxrx87rootroot6064706:16/etc
/etc. d
, , ,
.

ls ,
.

, ?

/tmp.

.
cd . ,
.
$pwd
/home/tania/books/poetry/Lermontov
55

$cd
$pwd
/home/tania
:
/home/tania/books/poetry/Lermontov. cd
. pwd :
/home/tania. cd .
dir_name cd
dir_name:
$pwd
/home/tania
$cd/etc
$pwd
/etc
cd/etc /etc.
cd, (
).

/tmp.

local/bin /usr.

, , .

, cd.

.
touchfile file:
$ls
article1.txtarticle2.txt
$touchempty
$ls
article1.txtarticle2.txtempty
empty, ls
, .
touch ,
. ,
, touch
.

56

$lsl
4
rwrr1zztopusers4702322:24ls.txt
$date
2322:34:38YEKST2010
$touchls.txt
$lsl
4
rwrr1zztopusers4702322:34ls.txt

touch.

" " >newfile.
rm :
$ls
f1f2f3
$rmff1f2
$rmif3
rm:`f3'?y
$ls
$
f1, f2 f3.
rmf. -
, f. ,
, rm,
i.
rm,
, i.
rm
ls.
$touchfile{1,2,3}
$ls
file1file2file3
$lsf*[12]
file1file2
$rmf*[12]
$
ls
57

rm.

rm, .
$aliasrm='rmi'

.bash_profile, .bashrc.
rm . , ,
, .
,
rm r :
$lsRd1
d1:
direc1file3
d1/direc1:
Remember
$rmrfd1
$lsRd1
ls:d1:Nosuchfileordirectory
d1 . rmrf
.
rmrf ,
f - .
, ,
, rmrf
, .
,
.
mkdirdir dir:
$mkdirdir1
$cddir1
$ls
$mkdirpmydir/mydir/mydir
$lsRmydir
mydir:
mydir
mydir/mydir:
mydir
mydir/mydir/mydir:

58

mkdir
dir1. ,
cd. , p mkdir ,
mydir/mydir/mydir. p
.
rmdir , .
$mkdiremptyDir
$lsFR
.:
emptyDir/mydir/
./emptyDir:
./mydir:
mydir/
./mydir/mydir:
mydir/
./mydir/mydir/mydir:
$rmdir*
rmdir:`mydir':Directorynotempty
emptyDir.
, , emptyDir.
mydir , .
rmdirp .
,
.
$>mydir/f1
$rmdirpmydir/mydir/mydir
rmdir:`mydir':Directorynotempty
$lsFR
.:
mydir/
./mydir:
f1
mydir , .
mydir , >mydir/f1,
.
rmrfmydir .

59

dir1/dir2/dir3/dir4
. .

dir1/dir2 Bubuka.

dir1/dir2/dir3/dir4 . ,
.

dir1 .

,.
cp :

cpsrcFiletagFile srcFile tagFile;

cpfile1file2fileNdir file1file2
fileN dir;

cprdir1dir2 dir1 dir2 ,


dir2 dir1 , .

$lsFR
.:
mydir/
./mydir:
f1
$cpmydir/f{1,2}
$lsFR
.:
mydir/
./mydir:
f1f2
cpmydir/f{1,2} f1 f2
mydir, . cpmydir/f{1,2}
cpmydir/f1mydir/f2 , .
mydir /tmp.
$ls
mydir
$cprmydir//tmp/
$lsR/tmp/mydir
/tmp/mydir:
f1f2
60

, mydir /tmp.
mv :

mvoldNamenewName oldName newName ;

mvfile1file2fileNdir dir ;

mvoldNamenewName oldName newName .

/tmp/mydir .
$mv/tmp/mydir/~
$lsR~/mydir
/home/user1/mydir:
f1f2
mv , ,
. ,
.
.
$mv~/mydir/f*.
$lsR
.:
f1f2mydir
./mydir:
f1f2
f1 f2 ~/mydir/ .

Toppler, high11 low11.


/tmp.

/tmp ,
.

Toppler /tmp.

/tmp Roller.

,
.

61

.
find .
: find_ , _ ,
.
.
. , , ,
, , , , . , find
.
find
, ,
. :

name ;

iname ;

type ;

size ;

, , .. ( );

perm ;

user group .

, ,
d1.
$find.name"d1*"
./d1
,
, .
Bash , ,
.
,
:
$find.name"d1*"typedls
120420drwxrxrx2zztopzztop192721:58./d1
, find ,
, lsl.
,
o.
$find.name"d1*"oempty
./d1
62

./d1/*
./d1/s
./d1/f1
./d1/f2
./d1/s1
./d1/s2
, .
, d1,
(empty).
type ,
:

b ;

c ;

d ;

f ;

p ;

s ;

l .

find .
exec:
$find~emptyexecrmf{}\;
,
.
{}\; :
, .
\
Bash.
.

, 1,
10.

/dev , .

63

.
GNU/Linux
mlocate, .

updatedb.
.
, , , spice :
$locatespice
/usr/share/jed/lib/spicemod.sl
/usr/share/jed/lib/spicemod.slc
/usr/share/vim/syntax/spice.vim
locate .

, user.

filemy. locate.

,
.

.
, file,
, (magic
numbers):
$filetab_d
tab_d:ASCIItext
tab_d, file, ,
ASCII.

file.
.

, /bin/bash ~/.bashrc.

.
64

. find ?

65

6..
.
GNU/Linux . ,
,
.
,
, ,
. GNU/Linux
. ,
. , ,
.
,
, .
:

, .

(, Bash Perl).

,
(magic numbers . manfile)
.
, ,
.
, (,
/bin/bash), , , .
, , .
, , ,
.
,
. , ,
. , ,
.
GNU/Linux ,
.
,
( ).
(task job). ,
.
. , HTTP Apache
httpd.
.
(
) ,
.
. , Linux . ,
. , ,
66

(kernel space), (user space).


,
,
.
, , ,
, .
user space ,
.
.
, ,
,
. , ,
(paging). , ,
,
, swap .
Linux .
(time slices),
. .
Linux
(preemptive multitaskings).
.
.
,
:

, , , ,
(, ELF COFF).

( text).

(data).

(heap) ,
..

(stack) LIFO (Last Input First Output),


.

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

(stdin) 0;

(stdout) 1;

(stderr) 2.

fork(). ,
,
. , , , ,
. ,
. .
.

67

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

PID (Process ID) .


.

PPID (Parent Process ID) PID .


.

UID , .

GID , .

, ,
UID. , .
, ,
.
:

. kernel space . ,
, ,
.
( ),
.

,
.
,
. ,
- ,
.

, , ,
.

, -.

,
?

.
,
.
, . GNU/Linux
.
.
(foreground),
68

(background).

&, :
$find~name"*t">&t.file&
[1]546
find ,
&. ,
1. , - PID .
>&
t.file.
jobs,
. ,
:
$find~emptymtime0execrmf{}\;&
[1]548
$find/tmpemptytypefexecrmf{}\;&
[2]551
$jobs
[1]Done
find~emptymtime0execrmf{}\;
[2]+Running
find/tmpemptytypefexecrmf{}\;
. 1 2.
jobs , 1 , 2 .
%% %+ , % . , , jobs,
+ .
fg%
( %). ,
fg%1 %1 1 .
,
CtrlZ, bg
% ( %&). , ,
bg%1 %1& ( CtrlZ)
1 .
%
, %:
$jobs
[2]+Running
$fg%fi

find/tmpemptytypefexecrmf{}\;


69

fg%fi,
, .
kill
%:
$jobs
[2]+Running
find/tmpemptytypefexecrmf{}\;
$kill%2
$jobs
[2]+Terminated
find/tmpemptytypefexecrmf{}\;
2 kill.

: sleep200 sleep2000,
.

2- , .

.
, .

fork(). , ,
psf, , .
$psf
UIDPIDPPIDCSTIMETTYTIMECMD
user117511745021:01pts/000:00:00bash
user118701751021:32pts/000:00:00psf
psf, , ,
, ,
, .
, .
, , , Bash PID 1751 PPID 1745.
psf,
Bash, . ,
fork(). ,
, ,
. ,
Bash.
, fork(). , ,
70

PID. ,
Bash, , PID
1870, PPID PID 1751.
, Bash.
psf. , Bash
exec() (. man3exec),
/bin/ps
, , , .
Bash
wait() , . ,
, Bash .
: Bash
, exec(), wait()?
, fork().
PID . Bash
, , , PID, ,
0, .
Bash
ps. . psf
,
( ps). ,
psf exit(),
, ,
wait() , .

- . ,
, .

.
wait() (. man2wait).
, ,
wait().
,
,
defunct , ,
(zombie).

,
, .

execls.
, , .

71

.
ps.
.
, , .
$ps
PIDTTYTIMECMD
1751pts/000:00:00bash
1890pts/000:00:00ps
PID, , , TTY ,
TIME , .
CMD , .
(full format) f.
$psf
UIDPIDPPIDCSTIMETTYTIMECMD
user117511745021:01pts/000:00:00bash
user119701751023:14pts/000:00:00psf
, UID
, (PPID), STIME
, C .
, l (long
format). .
$psl
FSUIDPIDPPIDCPRINIADDRSZWCHANTTYTIMECMD
0S50017511745076078111c541pts/000:00:00bash
0R500198817510770617pts/000:00:00ps

F , (. manps).
S , :

D (,
-).

R .

S .

T .

Z defunct (zombie).

NI Nice Number.
.
. SZ , ,
WCHAN ,
72

( S).
e , .
A.
psef, .
- ,
. ps
. :

u UID.

t .

p PID .

C .

, , ,
:
$psfttty2
UIDPIDPPIDCSTIMETTYTIMECMD
root15571006:18tty200:00:00/sbin/mingettytty2

POSIX , GNU
ps BSD .
psaux
. :
$psaux
USERPID%CPU%MEMVSZRSSTTYSTATSTARTTIMECOMMAND
root10.00.1126860?SOct080:04init


. VSZ RSS
.
POSIX, BSD ps .
$psfUroot
UIDPIDPPIDCSTIMETTYSTATTIMECMD
root10006:18?S0:04init
root21006:18?SW0:00[keventd]
root31006:18?SWN0:00[ksoftirqd_CPU0]
root41006:18?SW0:00[kswapd]
root51006:18?SW0:00[bdflush]
root61006:18?SW0:00[kupdated]
root71006:18?SW0:00[kinoded]
root81006:18?SW<0:00[mdrecoveryd]
root111006:18?SW0:00[kreiserfsd]
root8461006:18?SW0:00[khubd]
root10161006:18?S0:00/sbin/cardmgr
root12901006:18?SW0:00[kapmd]
root13141006:18?S0:00crond
root14991006:18?S0:00/usr/lib/postfix/master

73

root15181006:18?S0:00gpmm/dev/psauxt
imps2
root15561006:18tty1S0:00/sbin/mingettytty1
root15571006:18tty2S0:00/sbin/mingettytty2
root15581006:18tty3S0:00/sbin/mingettytty3
root15591006:18tty4S0:00/sbin/mingettytty4
root15601006:18tty5S0:00/sbin/mingettytty5
root15611006:18tty6S0:00/sbin/mingettytty6
root15631006:18?S0:00kdmnodaemon
root15901563006:18?R0:03/etc/X11/Xauth
/var/run/xaut
root15911563006:18?S0:00:0

root BSD U, POSIX


f .
top,
,
. top
. q. ,
,
k. i top .
load
averages 1, 5 15 .
w,
.
$w
00:07:50up2:09,3users,loadaverage:0,00,0,00,0,00
USERTTYFROMLOGIN@IDLEJCPUPCPUWHAT
aberes:022:01?xdm?1:080.56s/usr/bin/gn
aberespts/1:0.022:040.00s0.10s0.01sw
aberespts/2:0.023:095:160.36s0.36sbash

,
, /proc. , ,
, .
, .
$ls/proc
1222632532273288154interruptsschedstat
10200822682533273028876iomemscsi
11203422812591273828907ioportsself
11620402290259327432891acpiirqslabinfo
1172064230425962762297asoundkallsymsstat
1182079232226002763298buddyinfokcoreswaps
11920912331260227753buskeyssys
1202100234126252778303cmdlinekeyuserssysrqtrigger
12582113235026612787312cpuinfokmsgsysvipc
12592124238526842789323cryptoloadavgtty
13192160240226852795354deviceslocksuptime
151921702425269227973641diskstatsmdstatversion
172821842426269527993771dmameminfovmcore
18802185248726972802387drivermiscvmstat
192521942492271728123899execdomainsmoduleszoneinfo
192721982493272128144fbmounts

74

1944220924942723284849filesystemsmtrr
195322262495272728505fsnet
1956224625312728285252idepartitions

/proc , ,
.
$$ PID.
$ls/proc/$$
attrcpusetfdmapsoom_adjsmapstask
auxvcwdiomemoom_scorestatwchan
cmdlineenvironlimitsmountsrootstatm
coredump_filterexeloginuidmountstatsschedstatstatus
$cat/proc/$$/cmdline
bash
$cat/proc/$$/status
Name:bash
State:S(sleeping)
SleepAVG:98%
Tgid:2891
Pid:2891
PPid:2887
TracerPid:0
Uid:500500500500
Gid:500500500500
FDSize:256
Groups:500
VmPeak:4700kB
VmSize:4700kB
VmLck:0kB
VmHWM:1464kB
VmRSS:1464kB
VmData:316kB
VmStk:84kB
VmExe:696kB
VmLib:1444kB
VmPTE:32kB
StaBrk:08e1f000kB
Brk:08e61000kB
StaStk:bf85ab30kB
ExecLim:080f5000
Threads:1
SigQ:0/6143
SigPnd:0000000000000000
ShdPnd:0000000000000000
SigBlk:0000000000010000
SigIgn:0000000000384004
SigCgt:000000004b813efb
CapInh:0000000000000000
CapPrm:0000000000000000
CapEff:0000000000000000
Cpus_allowed:00000001
Mems_allowed:1

, cmdline , ,
status .
fd , .
.
.
fuser,
75

- . , ,
/mnt/floppy,
, .
$mount/mnt/floppy
$cd/mnt/floppy/
$/sbin/fuser.
.:1751c
$ps
PIDTTYTIMECMD
1751pts/000:00:00bash
7188pts/000:00:00ps
fuser PID , ,
. fuser , c PID
. fuser PID :

c .

e- .

f .

r .

m , .

m fuser ,
:
$/sbin/fuserm/dev/hda1
/dev/hda1:1751c
m,
, .
,
, pstree:
$pstree
init+2*[automount]
|cron
|6*[getty]
|inetd
|kdm+XF86_SVGA
|`kdm+kwm+kaudioservermaudio
|||kbgndwm
|||kfmkonsolebashpstr
|||kpanel
|||krootwm
||`kwmsound
|`netserv
76

|kflushd
|klogd
|kpiod
|kswapd
|lpd
|portmap
|proftpd
|sleep
|syslogd
`xfs
, pstree.

, , ,
.

, .

,
, .

PID , /dev/hda1.

ps.

.
.
- , , , ,
,
, .
.
, , killl,
man7signal.
:

1 HUP (Hang Up ).
,
. Bash
.

2 INT . GNU/Linux
CtrlC.

3 QUIT .
.

15 TERM .
( ) , -.
77

kill .

9 KILL
.


, .
. KILL .
, ,
. , ,
.
, PID
, kill ,
. ,
kill 15 (TERM). , ,
Bash:
$kill$$
$kill2$$
$kill1$$
login:
, Bash 15 (TERM) 2 (INT) ,
1 (HUP) .
.
, ,
.
pkill killall. kill,
, kill, . ,
kill PID, pkill
killall . ,
httpd :
#killall9httpd
9 (KILL) httpd
, .

Bash. , Bash
TERM, INT, QUIT HUP, .

KILL ,
. ?
78

sleep1000. ,
: TERM, INT, QUIT HUP, .

Bash.
Bash trap,
- .
, .
, .
, INT, QUIT
EXIT:
$trap"echoINT"INT
$trap"echoQUIT"QUIT
$trap"echo!"EXIT
$trapp
trap'echo!'EXIT
trap'echoINT'SIGINT
trap'echoQUIT'SIGQUIT
$INT
$kill3$$
QUIT
$exit
!
login:
trap echo. INT
INT, QUIT - QUIT,
! , trapp
. CtrlC,
INT .
echo. QUIT,
.
.

, TERM
pwd.txt, .

. ?

.
GNU/Linux .
79


, .
time slices,
.
. . ,
, .
, :

time slice.


(scheduler), .
, PRI , psl.
, ,
, , , , ,
. PRI,
, , .
$psl
FSUIDPIDPPIDCPRINIADDRSZWCHANTTYTIMECMD
0S50017471741074078311c541pts/000:00:00bash
0R500251017474770618pts/000:00:00ps

PRI
.
NI nice number. ,
. nice number
.
nice number, ,
. GNU/Linux nice number -20 19.
nice number 0.
nice.
. ,
.
nice number nice,
, .
nice nice number 10, ,
, . nice
number , n.
, , Bash :
$nicen19bash
$psl
FSUIDPIDPPIDCPRINIADDRSZWCHANTTYTIMECMD
0S50017471741074078411c541pts/000:00:00bash
0S500255917470781978011c541pts/000:00:00bash
0R5002560255907919618pts/000:00:00ps
$nice
19

80

, nicen19bash,
Bash . NI psl
19. PRI ,
Bash (78 Bash 74
).
nice, , nice number
.
nice number
renice. nice number
renice.
nice number , PID
p . , nice number
Bash , :
#renice102559
2559:oldpriority19,newpriority10
#pslp2559
FSUIDPIDPPIDCPRINIADDRSZWCHANTTYTIMECMD
0S5002559174707610782read_cpts/100:00:00bash

( NI) ,
nice number 19. , (. PRI)
.
renice
u , g . :
#renice0uuser1
nice number ,
user1, 0.

Bash nice
number -1. ?


: timenicen19updatedb.
, nice updatedb 5.
.


student +5.

81

7.vi.
vi.
vi ( visual)
.
, ,
.
vi :

vi vi .

vi - - (stdin).

vifilename .

viewfilename viRfilename .

vi+[num]filename num
, num .

vi+/regexpfilename
, regexp.

vi ESC, :q!.
vi .
vi ,
:help, ESC.
vi :

, vi
ESC. ,
.

, vi
, , i . , ,
. .
ESC.

, , , , vi
: .
ex mode,
ex, ed. ,
.

, i
(insert), vi , .
ESC. ,
, u.
ZZ,
vi .

82

/etc/passwd ,
.

vi, ,
?

vi.
GNU/Linux vim (vi
improved), vi.
PgUp,
PgDn. vi
, .
? vi
, CTRL, ESC ENTER.

, : h, j, k l:

h ;

j ;

k ;

l .

,
.
, : 20l.
CtrlF ( forward)
CtrlB (backward) .
.

, .

, .

83

#G

# - (, 20G).

zENTER

z.

CtrlU

- .

CtrlD

- .

CtrlF

CtrlB

vi ,
, .

^ 0.

.
?

PgUp PgDn?

vi.
, vim (vi improved)

, DEL BackSpace ,
.
-, vi ( vim)
, -, vim (, - ,
TERM ),
.
.
84

cwcW

, ( ) (cw).

dwdW

, () (dw).

ddD

(dd) (D).

yyY

ywyW

, () (dw).

(UNDO).

, ,
,
. , 10x ,
. 2Y ,
10p ( vim).

85

vi, 11o 192.168.1.1.


ESC. ?

cw IP ,
192.168.200.1.

192.168.200.121 .
?

IP 10.10.10.10 . ,
10. ?

.
:

/ ;

? - .

,
. n.
vi
:s///.
, ten 10
:
:s/ten/10/
, ,
g ( go).
:s/ten/10/g
, , ten Ten 10.
i.
:s/ten/10/i

. ,
86

, :
:%s/ten/10/g
% .
:

, , :3,5s/ten/10/ ;

: :,5s/ten/10/ ;

: :3,$s/ten/10/ .

, 10.

, , 10
127.

.
vi .
ZZ, vi . ,
,
vi.

:q

:q!

:wq

:w

:w

:e

:e!

:r

:r!

87

vi psef.

ps.txt.

,
.

88

8..
.
, .

, ,
.
:

(stdin), 0;

(stdout), 1;

(stderr), 2.

,
. , .
,
.
Bash ,
:

< <0 ;

> 1> ;

2> .

, ,
letter :
$mails'Pismo'user1<letter
user1. (Subject),
s,
letter.

ls.txt :
$ls>ls.txt
ls.txt
, ls .
:
$lsld/etc/ctc2>ls.err
drwxrxrx87rootroot60641518:57/etc
$catls.err
89

ls:/ctc:Nosuchfileordirectory
ls.err. ,
lsld /ctc,
,
ls.err. cat.
,
ls.txt ls.err.
$lsld/etc/ctc>ls.txt2>ls.err
ls.txt ,
, &.
$lsld/etc/ctc>ls.txt2>&1
, :
$lsld/etc/ctc2>ls.txt>&2
:
$lsld/etc/ctc&>ls.txt
,
, .
. ,
, ls.txt :
$>ls.txt
,
, . Bash

noclobber. :
$setonoclobber
seto,
:
$seto
90

allexportoff
braceexpandon
emacson
errexitoff
hashallon
histexpandon
historyon
ignoreeofoff
interactivecommentson
keywordoff
monitoron
noclobberon
noexecoff
nogloboff
nologoff
notifyon
nounsetoff
onecmdoff
physicaloff
posixoff
privilegedoff
verboseoff
vioff
xtraceoff
, seto, ,
setonoclobber,
( on).
. , ,
dir.txt.
$>dir.txt
bash:dir.txt:cannotoverwriteexistingfile
noclobber, (
) .
, - noclobber

. :

>| - ;

2>| - .

:
$lsl>|dir.txt

dir.txt, ,
91

noclobber.
noclobber ( )
:
$set+onoclobber

, :

>> - ;

2>> - .

, dir.txt :
$pwd>>dir.txt
, ,
. , , vi,
.
, , CtrlD,
. ,
, .
view, , :
$view
Privet
<CtrlD>
view ,
CtrlD.
( )
, , - .
here document ( ).
,
, . ,
user1,
mail here document:
$mailsHereDocuser1<<.
ThisistheHereDocumenthere!
.
,
.
<<. . , ,
92

, .
, .
(
).

ps.txt.

/usr ,
SysComm ,
-/dev/null.

, ,
SysComm.

SysComm ,
date.

noclobber ps.txt
. noclobber .

.
(pipe)
. , (stdout)
, (stdin) .
| ,
. , ,
:
$last|view
last
view ( vi).
view , ,
last .
tee , ,
, , . , , ps
ps.txt .
$ps|teeps.txt
PIDTTYTIMECMD
1720pts/000:00:00bash
2438pts/000:00:00ps
2439pts/000:00:00tee
$catps.txt
PIDTTYTIMECMD
93

1720pts/000:00:00bash
2438pts/000:00:00ps
2439pts/000:00:00tee
ps.txt ps.
tee.
tee ,
. ,
. , tee,
, ,
.
,
. ,
, ,
. , wcl ,

. , , , ,
user1.
$psuuser1|wcl
8
.
:

, , .

, ,
, , :
$who|sort|mails'Loggedusers'root
who mail , who
, mail ,
, , . sort,
, ,
,
- .

/usr/share/doc ,
sort.

, ,
94

seans.txt .

echo.
echo ,
, $:
$echo"It'scool"
It'scool
$echo$PS1
/u:/w$
echo , .
PS1,
$.
echo .
n.
e, echo
ASCII. :
$echoe'\0101\t\0102'
AB
A B, ASCII,
. , e :
$echo'\0101\t\0102'
\0101\t\0102
.
ESC :
$echone'\033c'

manascii
echo.

n echo . man
, .

95

moreless.
more less . ,
, /etc/passwd.
$less/etc/passwd
,
.
(pager).
UNIX . less , , (more , less ),
, more.
less GNU/Linux . ,
man, , man,
less. less
, more ,
, PgUp PgDn.
more vi less.
more less.

more

less

Space

PgDn

CtrlB

PgUp

Return

CtrlN
CtrlP

.
.

less/etc/passwd less</etc/passwd?
96

man ,
. .

man , ,
PAGER ?

less , .

cat.
cat ,
. , .

( cat catenate ). ,
/etc/issue /etc/issue.net,
, , ,
.
$cat/etc/issue{,.net}
, Bash, .
, :
$cat/etc/issue/etc/issue.net
, .
, f1.
$cat>f1
!
<CtrlD>
$catf1
!
f1
, cat .
CtrlD. ,
cat f1.
cat , .
,
.
cat tac,
, , .

97

cat , .
, .

cat ,
, .

/etc/passwd .

b tac ?

headtail.
head
, .
. , :
$head3/etc/passwd
root:x:0:0:root:/root:/bin/bash
bin:x:1:1:bin:/bin:/sbin/nologin
daemon:x:2:2:daemon:/sbin:/sbin/nologin
/etc/passwd.
, tail. ,
, . ,
, , pse,
tail :
$pse|tail
3308?00:00:00mappingdaemon
3310?00:00:00clockapplet
3312?00:00:00notificationar
3314?00:00:00mixer_applet2
3321?00:00:03wnckapplet
3325?00:01:59soffice.bin
3344?00:00:00getstylegnome
3362?00:00:47xpdf
3653pts/100:00:00ps
3654pts/100:00:00tail
tail f,
,
. , , .

/usr/bin. :
98

sort ls.

, , .

128 ?

cut.
cut ,
, .
, stdin.
c,
:
$lsld
drwx51user1user137522221:04.
$lsld|cutc110,3543
drwx3752
, , lsld
,
.
, ,
b.
, , ,
cutf . ,
/etc/hosts, IP ,
IP , :
$cutf1/etc/hosts
127.0.0.1
#212.193.90.39
212.193.90.25
.
d. ,
UID. /etc/passwd.
.
$cutf1,3d:/etc/passwd

, .

,
99

, .

sed.
,
. ,
, ,
.
, .
sed
, ,
. .
, stdout
.
sed . ,
, sed
. d
sed.
$ps|sed1d
1757pts/000:00:00bash
1870pts/000:00:00ps
1871pts/000:00:00sed
1d .
sed , -
. :


(, sed'2,4d'
). .
$.

, , ,
.

, , -
( tty), (,
pts/1). ,
tty. ( ),
, .
$psA|sed'/tty/d'
,
, .
100

sed:

d .

p (print).

s ( ) .

i .

a .

c .

q .

y --.

= - .

, (
/etc/passwd), ,
daemon. :
$sed/daemon/q/etc/passwd
root:x:0:0:SystemAdministrator:/root:/bin/bash
bin:x:1:1:bin:/:/dev/null
daemon:x:2:2:daemon:/:/dev/null
,
q. sed daemon, sed .
, .
, sed .
, /etc/passwd,
bash zsh.
$seds/bash/zsh//etc/passwd
s bash.
zsh.
.
/etc/group (,
), :

, user1;

$sedn/user1/s/:/_/gp/etc/group
adm_x_4_root,adm,daemon,user1
wheel_x_10_root,user1
ftpadmin_x_51_user1
101

ldap_x_55_user1
users_x_100_user1
webmaster_x_103_user1
user1_x_500_
s user1.
, , user1.
s .
g. s
() ().
,
.
g p. ,
, .
p n sed, sed
stdout , . ,
n, ,
, , , .
, ,
(, ). ,
user1 ,
, , #####################.
$last|sed'/user1/a\
#####################'
,
, sed.
/user1/a,
, user1. a sed
, .
sed sed,
.
$catsed.scr
/user1/a\
#################
$last|sedfsed.scr
sed.scr cat.
, sed f.

sed , -
102

( tty).

sed user
provider.

awk.
awk, GNU gawk,
,
. awk
, , .
awk :
//{}
//{}
...
//{}
,
f, awk.
, . , , ,
, stdout , . ,

/etc/passwd , bash.
$awk'/bash/'/etc/passwd
root:x:0:0:SystemAdministrator:/root:/bin/bash
user1:x:500:500::/home/user1:/bin/bash
tania:x:502:502::/home/tania:/bin/bash
figus:x:503:503::/home/figus:/bin/bash
, bash.
, bash, UID.
. awk
, , :

$0 ;

$1 ;

$2 .

,
F.
$awkF:'/bash/{print$1,$3}'/etc/passwd
root0
user1500
tania502
103

figus503
print.
, UID 500
$3>500.
$awkF:'$3>500{print$1,$3}'/etc/passwd
tania502
figus503
awk
.
NR . ,
,
/etc/passwd.
$awkF:'$3>500{printNR,$1,$3}'/etc/passwd
48tania502
49figus503
, ,
15 .
$ls|awk'length($0)>15'
lpi05102003.tar.bz2
Plan_Sem_PM_1.rtf
Plan_Sem_PM_1.sxw
Plan_Sem_PM_2.rtf
Plan_Sem_PM_2.sxw
length awk .
, 15 .

awk .

awk .

.
diff
. :

104

$ps>ps1.txt
$ps>ps2.txt
$diffps1.txtps2.txt
3c3
<3084pts/000:00:00ps

>3088pts/000:00:00ps
.
ps , PID .
diff. .
, , (3c3).
q ,
:
$diffqps1.txtps2.txt
ps1.txtps2.txt
i ,
.
u c , (unified)
(context) :
$diffups1.txtps2.txt
ps1.txt2010063023:18:16+0500
+++ps2.txt2010063023:18:21+0500
@@1,3+1,3@@
PIDTTYTIMECMD
2164pts/000:00:00bash
3084pts/000:00:00ps
+3088pts/000:00:00ps
$diffcps1.txtps2.txt
***ps1.txt2010063023:18:16+0500
ps2.txt2010063023:18:21+0500
***************
***1,3****
PIDTTYTIMECMD
2164pts/000:00:00bash
!3084pts/000:00:00ps
1,3
PIDTTYTIMECMD
2164pts/000:00:00bash
!3088pts/000:00:00ps
.

.
patch,
(patches). , diff,
105

patch.
cmp. :
$ddif=/dev/urandomof=r1.bincount=10
10+0
10+0
$ddif=/dev/urandomof=r2.bincount=10
10+0
10+0
$cmpf1.binf2.bin
$cmpr1.binr2.bin
r1.binr2.bin:1,1
: f1.bin f2.bin,
, r1.bin r2.bin, .
. cmp, , f1.bin f2.bin
. , r1.bin r2.bin - .

,
.

, diff .

patch.txt ps1.txt ps2.txt


. ps2.txt
ps1.txt patch.txt.

r1.bin r2.bin .

.
expand .
,
.
:
$echoe'\t\t'

$echoe'\t\t'|expand3

echo ,
. expand3 ,
.
, t ,
:
106

$echoe'\t\t'|expandt10,20

. ,
, ,
.

.bashrc,
.

.
fmt .
, ( 75
). fmt , ,
7%, . w
. :
$lsl/home
24
drwx47user1user140962423:22user1
drwx6colobokcolobok40962119:07colobok
drwxrxrx2user1user140962408:26isotmp
drwxrxrx4user1user140963120:54mp3
drwx12user1user14096223:43sveta
drwx28taniatania40961919:07tania
$lsl/home|fmtw50
24drwx47user1user1
40962423:22user1drwx6colobok
colobok40962119:07colobokdrwxrxrx
2user1user140962408:26isotmp
drwxrxrx4user1user14096
3120:54mp3drwx12user1user1
4096223:43svetadrwx28tania
tania40961919:07tania
fmtw50 lsl/home ,
50 .
, .
, , s :
$lsl/home|fmtw50s
107

24
drwx47user1user14096
2423:22user1
drwx6colobokcolobok4096
2119:07colobok
drwxrxrx2user1user14096
2408:26isotmp
drwxrxrx4user1user14096
3120:54mp3
drwx12user1user14096
223:43kotleto
drwx28taniatania4096
1919:07tania

fmt
/usr/share/doc.

.
pr ,
(stdout).
, .
+ , .
, pr+3
, .
, , : pr
2 .
pr c m , ,
.
, . b
,
.
h .
pr:

a ;

e , ,
;

, , i
, ;


c;

v - ;

108

t ;

l ;

w ;

o ;

f ;

n.

,
.

,
.

.
sort ,
. ,
(stdin). sort
.
r sort. ,
.
$ls/|sortr
var
usr
tmp
swap
sbin
root
proc
opt
mnt
lib
home
etc
dev
boot
bin
sort ,
. .
, t.
k. n
sort , . , ,
109

, /etc/passwd,
, UID.
$head/etc/passwd|sortt:k3n
root:x:0:0:SystemAdministrator:/root:/bin/bash
bin:x:1:1:bin:/:/dev/null
daemon:x:2:2:daemon:/:/dev/null
adm:x:3:4:adm:/var/adm:/dev/null
lp:x:4:7:lp:/var/spool/lpd:/dev/null
sync:x:5:0:sync:/:/bin/sync
shutdown:x:6:0:shutdown:/:/sbin/shutdown
halt:x:7:0:halt:/:/sbin/halt
mail:x:8:12:mail:/var/spool/mail:/dev/null
news:x:9:13:news:/var/spool/news:/dev/null
, t.
( k3), UID
. ,
n.

, GID
.

find, head sort


, .

.
uniq
sort, .
f1 f2 , -
, :
catf1f2|sort|uniq
c uniq
. d , ,
, , u
( ) .
i.
,
. ,
, f. ,
uniqf6
110

,
, , .

.
join12
.
(stdout). ,
. ,
. t ,
.
,
j1 j2
. ,
.
, ,
, a.
, . , v
,
.

. join ,
?

,
?

, ?

.
wc , ,
. , wc .
$wc/etc/hosts
3892/etc/hosts
, /etc/hosts.
111

l .

w .

c.

, ,
, :
$who|wcl
1
nl ,
. catb , nl
. nl ,
, .

, /etc/passwd,
, .

bash.

, UID 100?

, .

tr.
tr :
1. . .

.
2. d , .
3. . ,
, . tr
s.
4. .
s. tr
,
, .
5.
d s. :
, , ,
112

.
:
$echotarelka|trazAZ
TARELKA

, .
,
:
$ls/|trd'\n'
binbootdevetchomelibmntoptprocrootsbinswaptmpusrvar
ls/,
.
s :
$echoroot|trso
rot
.
c tr ,
d , , . ,
trdc09 , .
, ,
, .
t tr , ,
.
:

[:alnum:]

[:alpha:]

[:blank:]

[:cntrl:]

[:digit:]

[:graph:]

, .

113

[:lower:]

[:print:]

, .

[:punct:]

[:space:]

(, ).

[:upper:]

[:xdigit:] .
:
$echo"str"|tr[:lower:][:upper:]
STR
.

/etc/passwd,
.

wc
.

/etc/sysctl.conf ?

.
,
pastes . ,
/etc/hosts :
$pastes/etc/hosts
192.168.1.1note192.168.1.2
work.jpsartr.ruwork127.0.0.1
localhost.localdomainlocalhost
s , paste
,
. paste,
: /etc/passwd /etc/group .
:
$paste/etc/{passwd,group}
root:x:0:0:SystemAdministrator:/root:/bin/bashroot:x:0:root
bin:x:1:1:bin:/:/dev/nullbin:x:1:root,bin,daemon
daemon:x:2:2:daemon:/:/dev/nulldaemon:x:2:root,bin,daemon
adm:x:3:4:adm:/var/adm:/dev/nullsys:x:3:root,bin,adm
114

.
paste
, :
$ls|paste|head3
anacondaks.cfg
atd.pam.txt
auto_home
auto.master
bash.txt bind.txt
config
cron.txt dev.txt
, ls .
paste .

PID , , ,
, PID
. : awk
.

:
/etc/sysconfig/networkscripts/ifcfgeth0
/etc/sysconfig/networkscripts/ifcfgeth1.

,
. ().

, sed tr, ,
.

.
od ,
. .
od ( ,
). . ,
ABC :
$echoABC|odtoC
0000000101102103012
0000004
to od , C ,
.
manascii,
ABC, 012.
,
. ta :
115

$echoABC|odta
0000000ABCnl
0000004
,
. , nl .
. ,
A, , :

Ad ;

Au ;

Ao ;

Ax ;

An .

t
.
,
, , , .
:

C (char);

S (short);

I (int);

L (long).

/etc/hosts.

/bin/ls.
.
(short).

/bin/ls /bin/pwd ?

.
split csplit .
,
. .
split ,
. 1000
. ,
aa. , x,
, , : xaa,
xab, xac .
116

l split ,
:
$splitl9/etc/passwd
$lsx*
xaa xab
/etc/passwd ,
( ).
- xaa xab, .
b split ,
. , , .
splitb512 , 512 , ,
.
Cn ,
, n . ,
, splitC1024 ,
1Kb, .
csplit , , , . ,
csplit/etc/hosts/et/ .
, et, . csplit
, split:
xx, .
, csplit
, .
,
.
. , csplitfile/etc/{1}
. , , csplit
, .
k
.

/etc/passwd , .
, .
passwd.

/etc/passwd , uucp.

csplit
, k ?

117

xargs.
xargs , ,
, echo.
find. ,
core-, :
$find/usrtypefnamecore.*execrmf{}\;
$find/usrtypefnamecore.*|xargsrmf
find,
rm.
rm. Linux
.


, xargs.
, .


find, ? : time.

118

9..
.
, ,
, . .
- .
:

, ,
.
, :

, ;

,
.

,
.
.

\<

\>

, .

[]

()

().

.
*

.
.

119

{n}

n .

{n,}

n .

{n,m}

n m .


. , Perl
.
, , :
, . ,
[03] ,
^[03]$ ,
(^ - , $ - ).
, ,
() ,
.

[:alnum:]

- .

[:alpha:]

[:blank:]

[:cntrl:]

000 037 177.

[:digit:]

[:graph:]

: - .

[:lower:]

[:print:]

: -, .

[:space:]

, , , .

[:upper:]

[:xdigit:] .

,
120

007?

grep.
grep .
, ,
. ,
.
grep( GNU grep):

grep (basic) ;

grepF fgrep ,
;

grepE egrep
.

grep, egrep fgrep, GNU,


. , .
UNIX . GNU
egrep grep ,
(
) .
, ,
Solaris FreeBSD.
, Bash
grep .
$grep'bash$'/etc/passwd
root:x:0:0:SystemAdministrator:/root:/bin/bash
tania:x:502:502::/home/tania:/bin/bash
figus:x:503:503::/home/figus:/bin/bash
user1:x:504:504::/home/user1:/bin/bash

. .
, , /etc/sysconfig/
, IP IPv4.
, ,
egrep :
$egrep'[09]{1,3}(\.[09]{1,3}){3}'/etc/sysconfig/*
,
,
121

,
.
fgrep , ,
, . , ,
, - :
$psA|fgrep'?'
fgrep ,
.
i .
,
, X x :
$psA|grepix
1546?00:00:01xfs
1599?00:00:19X
1752?00:00:00xvt
,
c :
$egrepc'^.{1,3}:'/etc/passwd
7
,
.
v grep : ,
. , ,
/etc/group, user1 :
$grepvuser1/etc/group
- ,
, grep , .
egrep , , ,
\< \>. ,
/etc/sysctl.conf , Enable , Enables ,
:
$egrep'\<Enable\>'/etc/sysctl.conf
#Enablethemagicsysrqkey
#Enabletcp_syncookies

122

, w grep,
:
$grepwEnable/etc/sysctl.conf
#Enablethemagicsysrqkey
#Enabletcp_syncookies
,
x .
/etc , , :
$grepx'.'/etc/*
n ,
. , , /etc/hosts ,
local, .
$grepnlocal/etc/hosts
1:127.0.0.1localhost.localdomainlocalhost
,
.
r grep ,
. , /usr/share/doc/HOWTO/ ,
trainer :
$greprtrainer/usr/share/doc/HOWTO/

, grep
.

grep , 10<GID<100.

, /var/log/messages ,
, 8.30 12.30.

/etc/rc.d , fsck .
.

ps, grep, sort, uniq


(tty) .

123

.
,
.
(back reference) : \1 ,
,
. ,
, ( /etc/passwd)
( /etc/passwd).
, :
$egrep'^(.+):.*\1$'/etc/passwd
sync:x:5:0:sync:/:/bin/sync
shutdown:x:6:0:shutdown:/:/sbin/shutdown
halt:x:7:0:halt:/:/sbin/halt
^(.+): ,
.
, ,
. \1
.
, ,
, GNU grep.
,
. GNU egrep (
grep) .
, egrep :
$grep'^\(..*\):.*\1$'/etc/passwd
sync:x:5:0:sync:/sbin:/bin/sync
shutdown:x:6:0:shutdown:/sbin:/sbin/shutdown
halt:x:7:0:halt:/sbin:/sbin/halt
.
,
,
.
, IP
/etc/hosts ( IP ) , IP
127, 192,
(Fully Qualified Domain Name FQDN)
( ).
$egrep'^(192|127)\..*([[:alnum:]]+)\..*\2$'/etc/hosts
127.0.0.1localhost.localdomainlocalhost

124


( ),
.
, \2.

,
( ) .

, /var/log/messages ( )
, (, 09:09).

sed.
, sed.
. , ,
, bash,
, ,
sh, :
$sede'/[^s][^h]$/d'e'/bash/a\
@@@@@@@@@@@@@@@@@@@@'/etc/passwd
root:x:0:0:SystemAdministrator:/root:/bin/bash
@@@@@@@@@@@@@@@@@@@@
bamboo:x:501:100::/home/bamboo:/bin/csh
tania:x:502:502::/home/tania:/bin/bash
@@@@@@@@@@@@@@@@@@@@
figus:x:503:503::/home/figus:/bin/bash
@@@@@@@@@@@@@@@@@@@@
user1:x:504:504::/home/user1:/bin/bash
e sed ,
sed. ,
sh, ,
bash.
sed ,
. , ,
/etc/group, daemon pokemon.
$sed's/daemon$/pokemon/'/etc/group
, sed
. . ,
,
. , ,
125

.txt , .bak .
$ls*.txt|sed's/txt$/&.bak/'
dir.txt.bak
distfiles.txt.bak
ps.txt.bak
, , sed
& .

sed ,
(tty1tty4 vt01vt04
).

user , /etc/passwd,
extrauser .

awk.
awk ,
sed , . , ,
,
15:20 15:29 :
$psef|awk'/[[:blank:]]15:2[09][[:blank:]]/{print$5,$8}'
15:20/usr/lib/openoffice/program/soffice.bin
15:29[kjournald]
, psef :
,
.

, psef ,
.

. , awk
, .
, , :
$psef|awk'$5~/15:2[09]/{print$5,$8}'
15:20/usr/lib/openoffice/program/soffice.bin
126

15:29[kjournald]
:
. ~ ,
.
, ,
!~ . , , ,
, 15:20
15:29 :
$psef|awk'$5!~/15:2[09]/{print$5,$8}'
awk ( GNU)
. , , ,
bash csh :
$psA|awk'$4~/(ba|c)sh/'
1749pts/000:00:00bash
7372pts/000:00:00csh
, awk ,
( | ).
, , awk
, .

awk ,
/sbin/nologin, /bin/false, /dev/null
/etc/passwd .

awk
(beep)?

awk /etc/bashrc, .

127

10.,DAC.
.
:

(superblock);

(inode list);

C ,
:

, ..

,
.

.
, , .
:

(link count);

( );

( );

, ;

, ,
128

, ,
(inode).
, , ,
. ,
, . ,
,
. ,
.
.
(link counter) .
, ,
(hard link). , , , ,
.
.
, , .
( ):

, (,
/home/user1).

(.) - .

,
, (..)
- .
lsl,
, lsi. :
$lsldi/etc
390913drwxrxrx105rootroot 122882520:18/etc
, inode /etc 390913,
105, ,
103.
$lsl/etc|grepc'^d'
103
, .
,
stat.
$stat/etc
File:`/etc'
Size:12288
Blocks:32IOBlock:4096
Device:fd00h/64768d Inode:390913Links:105
Access:(0755/drwxrxrx)Uid:(0/root)Gid:(0/root)
Access:2010052509:31:01.000000000+0600
Modify:2010052500:20:18.000000000+0600
Change:2010052500:20:18.000000000+0600
129

0 inode ,
;

1 ;

2 inode .

inode .

inode /home (.) .

/bin/gzip.

inode .

.

. ,
(inode).
.
( - user) .
,
. , .
(GID)
, .
lsl. :
$id
uid=501(user1)gid=100(users)=100(users)
$>file
$lslfile
rwrr1user1users01218:03file
, user1, .
lsl , user1
( ) users ( ).
users
.
, ,
UID GID , .
Linux :

130

User access (u) ;

Group access (g) ;

Other access (o) .

,
, ,
. ,
. ,
,
.

/bin/ls
?

, , stat.

,.
.
.
,
.

u
w

g
w

o
w

(u);

- (g);

(o).

1 (4 )
r;

1 (2 )
: w;

1 (1 )
: x.

131

, rxwxrxx (751) ,
(rxw 7),
(rx 5),
(x 1).
.
,
. ,
rwxrxr 754, 7=22+21+20, 5=
22+20, 4=22.
, lsl,
.

.
?

: 641.

rwr .

, mail,
.

Bash script.sh 750, root, sys.


user2, user2 mail , -
?

user2 ?

, user2
?

.
, ,
. :

x (search) ,
cd ,
.

r , ,
ls. search (x)
- , .

w , , ,
. search (x) ,
.

search (x), , ,
. ,
, .
, :
132

0 () .

1 (x) , , ,
ls - ,
, .

3 (wx) - ,
, ls .

5 (rx) -
lsl, , , , , .

7 (rwx) .

lsld.
$lsld
drwxrxx10user1users40961218:03.
, , 751,
(user1) , (users)
, ,
.
, , , ,
, . , ls
, . ,
.

mail?

d1 drwxx . adm, sys.


user1, sys, f1
?

user1 , f1 ?

, f1 640, adm, sys.


user1 ?
?

751, user1
f1 ?

, user1
f1 d1 ?

enigma 600, root


root. ?
133

.
:

chown - ,
;

chgrp - .

Linux ,
, ,
. -
,
(, SUID - ),
. ,
,
, .
:
#lslf1
rwrr1taniaprof82221:04f1
#chownuser1f1
#lslf1
rwrr1user1prof82221:04f1
, -
, , .
f1 text.c :
#lslf1text.c
rwrr1user1prof82221:04f1
rwrr1profprof1751321:24text.c
#chgrptaniaf1text.c
#lslf1text.c
rwrr1user1tania82221:04f1
rwrr1proftania1751321:24text.c
chown
, ,
:
#chowntania:sysf1
#lslf1
134

rwrr1taniasys82221:04f1
,
chown.
POSIX. , Linux BSD
, . ,
chown BSD ( ):
#chown.admf1
#lslf1
rwrr1taniaadm82221:04f1
c GNU chown chgrp .

:
#chgrpctaniaf1
`f1'tania
chown chgrp R,
. :
#lsRlscores/
scores/:
1
drwxrwxrx2profprof802416:20rnd_tutorial
scores/rnd_tutorial:
4
rwrwr1profprof10402416:20000.score
#chownRtania.taniascores/
#lsRlscores/
scores/:
1
drwxrwxrx2taniatania802416:20
rnd_tutorial
scores/rnd_tutorial:
4
rwrwr1taniatania10402416:20000.score
tania ( ).
BSD ( ).

. v chown
chgrp :
135

#chgrpRvusersscores/
`scores/'users
`scores//rnd_tutorial'users
`scores//rnd_tutorial/000.score'users
, v ,
, .
! chown chgrp, R,
!

,
. ?

,
( ),
, daemon.

sys.


POSIX .

.
chmod ,
.
, .
. .
chmod
:
$lsltext.c
rwrr1proftania1751321:24text.c
$chmod660text.c
$lsltext.c
rwrw1proftania1751321:24text.c
chmod660text.c 660
text.c .
chmod ,
. :
chmod
136

u ;

g ;

o ;

a .

+ - ;

- ;

= - .

r ;

w ;

x .

, text.c ,
(, ,
):
$chmodgw,a+rtext.c
$lsltext.c
rwrr1proftania1751321:24text.c
(+) () ,
, . ,
,
f1, , .
, (=) ,
. , , text.c
, -
:
$chmodug=rw,o=text.c
$lsltext.c
rwrw1proftania1751321:24text.c
chown chgrp , chmod
, R. ,
137

,
-
( ),
- ( search
).
scores :
$lslRscores
scores:
1
drwxrwxrx2profusers802416:20rnd_tutorial
scores/rnd_tutorial:
4
rwrwr1profusers10402416:20000.score
$chmodRgwscores
$lslRscores
scores:
1
drwxrxrx2profusers802416:20rnd_tutorial
scores/rnd_tutorial:
4
rwrr1profusers10402416:20000.score
, ,
.
.
R
chmod . find
execchmod ( xargschmod). , scores
644, :
$findscorestypefexecchmod644{}\;
$lslRscores
scores:
1
drwxrxrx2profusers802416:20rnd_tutorial
scores/rnd_tutorial:
4
rwrr1profusers10402416:20000.score
GNU chmod v
, , c
.

138

$chmodRvgwscores
`scores'0755(rwxrxrx)
`scores/rnd_tutorial'0755(rwxrxrx)
`scores/rnd_tutorial/000.score'0644
(rwrr)
, v , c ,
.
$chmodcgwtext.c
`text.c'0640(rwr)
$chmodv660text.c
`text.c'0660(rwrw)

d1/d2/d3, - d1/f1, d1/d2/f2,


d1/d2/d3/f3 . d1/f1 400.
?

d1.
f1?

d1 .
?

find exec
d1 750.

find, xargs chmod d1


rwrrw .

.
umask
. ,
777 666 .
:
$umask
0022
umask
,
.

139

$umask002
$mkdirdir1
$>file1
$lslddir1file1
drwxrwxrx2profprof481420:43dir1
rwrwr1profprof01420:43file1
$umask077
$mkdirdir2
$>file2
$lslddir2file2
drwx2profprof481420:44dir2
rw1profprof01420:44file2
, umask 002
775, - 664. umask ,
077 , , 700 - 600 -
.
umask.
umask

002

775

664

007

770

660

022

755

644

027

750

640

077

700

600

umask :
$umaskg=rwx,g=rx,o=
$umask
0027
umask
, .

umask027.
.

umask,
644.
140

, ,
, .
.
. ,
?

:SUID,SGIDstickybit.
, ,
, :

Sticky bit (Save text mode) - ;

SUID UID;

SGID GID.

Sticky bit 1 ( 001), SGID 2


(010), SUID - 4 (100). t T Sticky bit, s
S SUID SGID. ,
(x). :

SUID s , ;

SGID s , ;

Sticky bit t ,
.

S T ,
. :
$lsld/tmp/bin/ping
rwsxx1rootroot32908162002/bin/ping
drwxrwxrwt94rootroot34881420:31/tmp
, ping
SUID ( s ),
/tmp Sticky bit ( t ).
Sticky bit , UNIX
, (Save text mode).
,
, (UID GID),
, SUID / SGID, .
SUID
, , .
, SGID
, , .
:

141

RUID - Real UID, UID , .

RGID - Real GID, GID , .

EUID - Effective UID, RUID,


SUID, UID .

EGID - Effective GID, RGID,


SGID, GID .

root. ,
ping (. ), ,
, root,
. , , , passwd,

, . ,
, .
Shell SUID SGID ,
.
Sticky bit ,
,
.
/tmp, ,
, , .
SGID ,
(
BSD), RGID , System V. :
$cddir1
$lsld
drwxrwsrx2taniausers481420:43.
$id
uid=500(prof)gid=500(prof)=500(prof),100(users)
$>file
$lsl
0
rwr1profusers01422:00file
, SGID, .
, ,
, .
chmod .
chmod :

u+s - SUID;

g+s - SGID;
142

o+t - Sticky bit.

.
chmod2775d1 SGID :
$mkdird1
$lsldd1
drwxrx2profprof481422:31d1
$chmod2770d1
$lsldd1
drwxrws2profprof481422:31d1
,
.

rwsxx

rwxsx

drwxrws , ,

,
.

drwxrwxrwt

, passwd.

awk , RUID
EGID.

- passwd
. , .
passwd?

find SUGID.txt ,
SUID SGID.

SGID Sticky bit.

( root) users.
SGID . .
, .

143

Linux.
GNU/Linux (
lsl, ):

, ,
, . , ,
,
ls
.
.
, ,
.
, , ,
. :
$lsldoc
lrwxrwxrwx1profprof1412010doc>/usr/share/doc

$cddoc
$pwd
/home/prof/doc
lsl ,
doc /usr/share/doc . , doc
, , cd ,
. ,
doc, pwd.
, ,
144


. , ,
, .
,
, .
, , ..
, .
lsl - .
:
$lsl/dev/fd0/dev/tty1
brwrw1proffloppy2,0202003/dev/fd0
crw1rootroot4,11423:55/dev/tty1
, , , ( b
) /dev/fd0 2, - 0.
( c ) /dev/tty1
- 4, - 1.
, ,
.

, , ,
. - ,
,
. BSD.
, ,
, -
. ,
.

, ?

.
,
(inode). , ,
, lsl.
(link count). link count ,
, . :
145

$lslf1link1
rwrr2taniatania82221:04f1
rwrr2taniatania82221:04link1
$lsif1link1
13598f113598link1
f1 link1 ,
. lsl , - (
lsl), ,
, . lsi ,
inode .
, , ,
, ,
, , .
$echo'Thisisahardlink'>f1
$catlink1
Thisisahardlink
f1,
link1.
(link count) ,
,
.
$lslf1link1
rwrwrw2taniatania201522:03f1
rwrwrw2taniatania201522:03link1
$rmff1
$lslf1link1
ls:f1:Nosuchfileordirectory
rwrwrw1taniatania201522:03link1
, , ,
.
ln. , , - . :
$lnfile1newname
$lslifile1
4676rwrwr2profprof01420:43file1
$lslinewname
4676rwrwr2profprof01420:43newname
146

file1 - newname. lsli


, inode .
,
,
, , . ,
, .
ln ,
:
$lsldLPI
drwxrwx10profusers544210:15LPI
$lnLPIl1
ln:`LPI':
- ,
, .
. ,
, ,
:
$lsldi
3555drwx16user1user111201522:15.
$mkdirdir1
$lsilddir1
1598drwxrx2user1user1481523:03dir1
$lsialdir1
2
1598drwxrx2user1user1481523:03.
3555drwx17user1user111441523:03..
$lsldi
3555drwx17user1user111441523:03.
dir1 , inode 1598. ,
dir1 - , 1598.
, dir1 . - ,
dir1 , inode 3555, inode
. , ,
dir1
.
cp l , (
) . :

147

$lslif???
4629rwrr1user1user101112:30f112
4631rwrr1user1user101112:30f113
4632rwrr1user1user101112:30f117
$cplf???dir1
$lslidir1
0
4629rwrr2user1user101112:30f112
4631rwrr2user1user101112:30f113
4632rwrr2user1user101112:30f117
, cp l
dir1.

file1 link1.

/tmp ?

ln . ?

?
?


/dev/fd0.

.
- ,
. lns ,
- , - ,
, ,
. :
$lnsfile1slink1
$lslifile1slink1
4639rwrwr1user1user101115:55
file1
1604lrwxrwxrwx1user1user151601:37
slink1>file1
$echo123>file1
$catslink1
123
file1 slink1 . file1
148

slink1 , . ,
.
:
$lns~/dir1/tmp
$lsldidir1/tmp/dir1
4635drwxrxrx2user1user11441600:26dir1
163286lrwxrwxrwx1user1user1161601:12
/tmp/dir1>/home/user1/dir1
dir1 /tmp. ,
inode,
. , , -,
, , -,
.
:

( - ),
;

,
( ) , ,
.

, :

, , ;

, ;

, .

:
$mvfile1file11
$catslink1
cat:slink1:Nosuchfileordirectory
file1 file11 slink1 .
,
.
$lns/dev/fd0.
$lslfd0
lrwxrwxrwx1user1user181601:13fd0>
/dev/fd0

149

, .
cp s ,
:
$cps~/f???/tmp
$lsl/tmp/f???
lrwxrwxrwx1user1user1161601:52/tmp/f112
>/home/user1/f112
lrwxrwxrwx1user1user1161601:52/tmp/f113
>/home/user1/f113
lrwxrwxrwx1user1user1161601:52/tmp/f117
>/home/user1/f117
lrwxrwxrwx1user1user1161601:52/tmp/f122
>/home/user1/f122

/tmp.
cp ,
, , ,
. ,
, d cp :
$cpd/tmp/f122Documents/
$lslDocuments/f122
lrwxrwxrwx1user1user1161602:00
Documents/f122>/home/user1/f122

/usr/share/doc .
cd~/doc.

- , /usr.


/bin/ls. .

150

11..
.

, head .
. track.
cyl.
track=cyl*head .
sect, 512
. capacity=cyl*head*sect*512 .
63.
,
( ),
cyl head.
, , fdiskl :
#fdiskl
/dev/hda:10.7,10794041344
255heads,63sectors/track,1312cylinders
=16065*512=8225280
Id
/dev/hda1*11310439183Linux
/dev/hda214131210434217+8eLinuxLVM
255 1312 .
.
(partitions).
, , , ,
. ,
.
IBM PC
. UNIX/Linux
,
. Linux ( Microsoft)
.
(primary), ,
(extended).
(logicalpartitions).

fdiskl.
151

sfdisks . , .

.
GNU/Linux PATA IDE :

/dev/hda - Primary Master;

/dev/hdb - Primary Slave;

/dev/hdc - Secondary Master;

/dev/hdd - Secondary Slave.

IDE .
/dev/hda /dev/hdzz.
SCSI, SAS, SATA USB sd.
/dev/sda , /dev/sdb .
GNU/Linux IDE 3,
: 0 - , 1 - . SCSI
( 8) :
$lsl/dev/hda{,1}
brwrw1rootdisk3,0202010/dev/hda
brwrw1rootdisk3,1202010/dev/hda1
$lsl/dev/sda{,1}
brwrw1rootdisk8,0202010/dev/sda
brwrw1rootdisk8,1202010/dev/sda1
.
, , SCSI
/dev/sda1, /dev/sda2, /dev/sda3 /dev/sda4.
. ,
(
), -
5. , , Secondary Master
IDE
/dev/hdc5 .
, sfdiskl ,
1.
#sfdiskl
Disk/dev/hda:1222cylinders,255heads,63sectors/track
Units=cylindersof8225280bytes,blocksof1024bytes,counting
from0

152

DeviceBootStartEnd#cyls#blocksIdSystem
/dev/hda125526286426083Linux
/dev/hda226312219597703167+5Extended
/dev/hda30+254255204825683Linux
/dev/hda40000Empty
/dev/hda5263+7084463582463+83Linux
/dev/hda6709+7393124897682Linuxswap
/dev/hda7740+12214823871633+83Linux
(/dev/hda1...3),
(/dev/hda2) (extended).
(/dev/hda5...7).

fdiskl
.

fdiskl sfdiskl .

swap?

fdisk.
fdisk
, .
sfdisk, , fdisk ,
.
,
sfdisk.
fdisk .
,
:
#fdisk/dev/sda
Thenumberofcylindersforthisdiskissetto19077.
Thereisnothingwrongwiththat,butthisislargerthan1024,
andcouldincertainsetupscauseproblemswith:
1)softwarethatrunsatboottime(e.g.,oldversionsofLILO)
2)bootingandpartitioningsoftwarefromotherOSs
(e.g.,DOSFDISK,OS/2FDISK)
Command(mforhelp):m
Commandaction
atoggleabootableflag
beditbsddisklabel
ctogglethedoscompatibilityflag
ddeleteapartition
153

llistknownpartitiontypes
mprintthismenu
naddanewpartition
ocreateanewemptyDOSpartitiontable
pprintthepartitiontable
qquitwithoutsavingchanges
screateanewemptySundisklabel
tchangeapartition'ssystemid
uchangedisplay/entryunits
vverifythepartitiontable
wwritetabletodiskandexit
xextrafunctionality(expertsonly)
fdisk -
SCSI . m,
fdisk. fdisk:

q ;

l - ;

d - ( );

n - ;

t - (
);

a - ;

w .

p fdisk .
Command(mforhelp):p
Disk/dev/sda:20.0GB,20003880960bytes
64heads,32sectors/track,19077cylinders
Units=cylindersof2048*512=1048576bytes
Disk/dev/sda:20.0GB,20003880960bytes
64heads,32sectors/track,19077cylinders
Units=cylindersof2048*512=1048576bytes
DeviceBootStartEndBlocksIdSystem
/dev/sda11190771953483283Linux
Command(mforhelp):q
1. fdisk
:
2. - p.
3. ( )
d.

154

4. n. : (p
, e , l ), ,
;
, +, (, +15000k)
(+1200M).
5. , (83 Linux
Native), t (
l).
6. , w.

fdisk
.

Linux LVM (Logical Volume


Manager).

FAT, ?

,
, fdisk. !
! ,
, .

.
,
, .
,
.
GNU/Linux ext2.
ext2 :

ext3 - ext2
, Red Hat;

ext4 - , ext2 ext3,



;

XFS -
, Silicon Graphics, Open
Source;

JFS - IBM,
.

GNU/Linux ,
: ext2, ext3 ext4 ,
. ,
155

,
.
, ,
, . ,
,
, .

.
mkfs,
,
( ).
mkfs ext2. , ,
ext2 Primary Master IDE
:
#mkfs/dev/hda2

,
.

t mkfs. ,
ext3 :
#mkfstext3/dev/hda2

:

mke2fs - ext2 , ext3 ext4 ;

mkfs.xfs - XFS;

vfat - FAT.

mkfs ,
, :

/sbin/mkfs.ext2;

/sbin/mkfs.ext3;

/sbin/mkfs.ext4;

/sbin/mkfs.vfat.

, , ,
, . :
$lsl/sbin/mkfs*
rwxrxrx1rootroot5712222009/sbin/mkfs
rwxrxrx1rootroot13948222009/sbin/mkfs.bfs
rwxrxrx1rootroot22216222009/sbin/mkfs.cramfs
rwxrxrx4rootroot55268192009/sbin/mkfs.ext2

156

rwxrxrx4rootroot55268192009/sbin/mkfs.ext3
rwxrxrx4rootroot55268192009/sbin/mkfs.ext4
rwxrxrx1rootroot19188222009/sbin/mkfs.minix
lrwxrwxrwx1rootroot72109:29/sbin/mkfs.msdos>mkdosfs
lrwxrwxrwx1rootroot162109:29/sbin/mkfs.ntfs>/usr/sbin/mkntfs
rwxrxrx2rootroot174296192009/sbin/mkfs.reiserfs
lrwxrwxrwx1rootroot72109:29/sbin/mkfs.vfat>mkdosfs

mke2fs c,

. j ext3.
-b ext2 ext3:

1024 - ,
;

2048 ;

4096 -

( ).

ext2.

ext3
. 2048
.

,
.

.
, ,
.
,
(dirty not
clean), , . ,
, ,
clean - .
, ,
, , .
:

. , :

, ,
.
157

,
.

..


(backup).
.
.
GNU/Linux
fsck, mkfs
.
!
.
!
$lsl/sbin/fsck*
rwxrxrx1rootroot26536222009/sbin/fsck
rwxrxrx1rootroot13968222009/sbin/fsck.cramfs
rwxrxrx4rootroot185112192009/sbin/fsck.ext2
rwxrxrx4rootroot185112192009/sbin/fsck.ext3
rwxrxrx4rootroot185112192009/sbin/fsck.ext4
rwxrxrx1rootroot26288222009/sbin/fsck.minix
lrwxrwxrwx1rootroot72109:29/sbin/fsck.msdos>dosfsck
rwxrxrx2rootroot330200192009/sbin/fsck.reiserfs
lrwxrwxrwx1rootroot72109:29/sbin/fsck.vfat>dosfsck

fsck t, ,
e2fsck, ext2
ext3. :
#fscktext3/dev/sda1
fsck1.39(29May2006)
e2fsck1.39(29May2006)
USBDISK:clean,3585/2442240files,3004291/19534832blocks
ext3
SCSI . ,
:

dirty ,
.

.
158


, f e2fsck.

c e2fsck. ,
,
.
#e2fsck/dev/sda1
e2fsck1.39(29May2006)
USBDISKhasbeenmounted27timeswithoutbeingchecked,check
forced.
Pass1:Checkinginodes,blocks,andsizes
Pass2:Checkingdirectorystructure
Pass3:Checkingdirectoryconnectivity
Pass4:Checkingreferencecounts
Pass5:Checkinggroupsummaryinformation
USBDISK:3585/2442240files(2.2%noncontiguous),
3004291/19534832blocks
e2fsck lost+found,
.
.

, .

,
.

.
GNU/Linux , ,
.
, ,
. ,
,
GNU/Linux.
,
/etc/fstab, .
FHS ,
/mnt, CD, DVD, USB Flash
/media. , /media/cdrom
CD-ROM.
mount t
( ext2) - .
mount - , .
159

- . ,
CD-ROM iso9660 :
#mountrtiso9660/dev/cdrom/media/cdrom
mount ,
,
.
$mount
/dev/mapper/VolGroup00LogVol00on/typeext3(rw)
procon/proctypeproc(rw)
sysfson/systypesysfs(rw)
devptson/dev/ptstypedevpts(rw,gid=5,mode=620)
/dev/hda1on/boottypeext3(rw)
tmpfson/dev/shmtypetmpfs(rw)
noneon/proc/sys/fs/binfmt_misctypebinfmt_misc(rw)
sunrpcon/var/lib/nfs/rpc_pipefstyperpc_pipefs(rw)
/dev/hdcon/media/CentOS_5.5_Finaltypeiso9660
(ro,noexec,nosuid,nodev,uid=500)

inode - .
inode , ,
. - inode -
.
#lsldi/media/usbdisk
160574drwxrxrx2rootroot48May202010/media/usbdisk
#mount/dev/sda1/media/usbdisk
#lsldi/media/usbdisk
2drwxrwxrwx9rootusers2048Nov2519:43/media/usbdisk
,
/mnt/usbdisk, 160574 , - 2.
2.
#lsid//boot/home/mnt/usbdisk
2/2/boot2/home2/media/usbdisk
, inode
, - 2.
, (
/etc/fstab) .
umount,
- , . :

160

#umount/media/usbdisk/
: - ,
.

, ,
/mnt.

- .
. ?

, ?

.
GNU/Linux
.
. ,
, , ,
, .
paging,
swap .

swapons.
$/sbin/swapons
FilenameTypeSizeUsedPriority
/dev/hda5partition24896801
, swapons, :
Primary Master IDE . 248
, 0.
swap .
, .
.
, . ,
.
- ,
.
,
.
, .
161

128 , :
$ddif=/dev/zeroof=swap.filebs=1Mcount=128
128+0
128+0
$lslswap.file
rwrr1user1user11342177281917:43swap.file
mkswap ( )
, :
$/sbin/mkswapswap.file
Settingupswapspaceversion1,size=134213kB
swap.file .
, , Linux
Swap (82 fdisk).
mkswap, :
#mkswapc/dev/sda2
SCSI .
c,
.
swapon ,
swapoff. :
#swapon~user1/swap.file
#swapons
FilenameTypeSizeUsedPriority
/dev/hda5partition24896801
/home/user1/swap.filefile13106402
#swapoff~user1/swap.file
#swapons
FilenameTypeSizeUsedPriority
/dev/hda5partition24896801

swapon, swapoff.

162

swap1 1.

, .

/etc/fstab.
GNU/Linux /etc/fstab,
,
. /etc/fstab :
/dev/VolGroup00/LogVol00/ext3defaults11
LABEL=/boot/bootext3defaults12
tmpfs/dev/shmtmpfsdefaults00
devpts/dev/ptsdevptsgid=5,mode=62000
sysfs/syssysfsdefaults00
proc/procprocdefaults00
/dev/VolGroup00/LogVol01swapswapdefaults00

, # . ,
/etc/fstab, , :
1. <device> , UUID
.
2. <mountpoint> - , ,
/boot.
3. <type> .
4. <options> mount ,
. swap
sw.
5. <dump>
(backup) dump.
1, , 0 .
6. <pass>
.
1. ,
, 2. ,
0 .
, mount,
<options> /etc/fstab .

163

defaults

:rw,suid,dev,exec,auto,nouser,asynch.

asynch

/.

auto

noauto

exec

noexec

suid

SUID.

nosuid

SUID.

user

nouser

ro

rw

,.

/etc/fstab ,
mount
. ,
/etc/fstab , , .

/etc/fstab,
, Primary Master IDE
/mydisk ?

- /etc/fstab, ,
SCSI CD-ROM? , CD-ROM
?

user, users owner mount.


?

.
df
, ,
. h,
(human readable format):
$dfh
%
/dev/mapper/VolGroup00LogVol00
8,9G2,9G5,6G34%/
/dev/hda199M18M76M20%/boot

164

tmpfs189M0189M0%/dev/shm
/dev/hdc3,9G3,9G0100%/media/CentOS_5.5_Final


dfi :
$dfi
%
/dev/mapper/VolGroup00LogVol00
241062410572423049005%/
/dev/hda12610441260631%/boot
tmpfs481581481571%/dev/shm
/dev/hdc000/media/CentOS_5.5_Final

,
du, ,
. duh
:
$duh/etc/rc.d
161K/etc/rc.d/init.d
1.0K/etc/rc.d/rc0.d
1.0K/etc/rc.d/rc1.d
1.0K/etc/rc.d/rc2.d
1.0K/etc/rc.d/rc3.d
1.0K/etc/rc.d/rc4.d
1.0K/etc/rc.d/rc5.d
1.0K/etc/rc.d/rc6.d
18K/etc/rc.d/scripts
207K/etc/rc.d
,
. dus :
$dush~
467M/home/user1
,
.

165

12.Bash.
.
, ,
.
, , , .
, .

.
Bash .sh .
:


.
.

,
, ,
.


:
$bashmyscr1.sh
Privet!
v x bash. v
.
. x
.

:
$catmyscr1.sh
#!/bin/bash
echo'Privet!'
#!/bin/bash
. .
,
:
$chmoda+rxmyscr1.sh
$./myscr1.sh
Privet!
166

,
.
PATH () ./ .
, Bash ,
PATH. , ,
.

,
. ,
. ,
, .
()
inline :
$..bashrc
(.) inline .
.bashrc .
Inline ,
:
$catmyscr2rc
VAR1='SnovaPrivet!'
$catmyscr2.sh
#!/bin/bash
.myscr2rc
echo$VAR1
$./myscr2.sh
SnovaPrivet!
myscr2.sh inline
myscr2rc, VAR1.

scr1.sh , V1
.

, .

scr1.sh ,
167

scr2.sh, V1.

scr1.sh , V1
scr1rc.

.
.
. ,
, .
, ,
,
:
$V1=10
$echo$((V1+1))
11
,
. ,
. .
,
,
:
$f1=str
$echo$f1
str
$echo$f11
$echo${f1}1
str1
f1 str. str
1 ,
f11
1 f1.
.
: , .
. : ${:
}. :
$V1=abcdef
$echo${V1:09876}
abcdef

168

$echo${V2:09876}
09876
$echo$V1
abcdef
$echo$V2

V1 , V2 - . V1
${V1:09876} , V2 ${V2:09876} 09876. V1 V2
.
,
, ${:=}.
$echo${V2:=12345}
12345
$echo$V2
12345
, V2 ,
12345, .

${:+}. :
$echo${V2:+'nuidela...'}
nuidela...
-
.

,
?

, ?

ENV , environ.

, SMTP
?

169

(quotation).
-
, ,
.
(quotation).
, , STR1 BolshoyPrivet.
, .
, , :
$STR1=Bolshoy\Privet
$echo$STR1
BolshoyPrivet
, .
:

'' ;

"" ;

\ .


, ,
. :
$STR1='Strokasoderzhit$TERM'
$echo$STR1
Strokasoderzhit$TERM
, , ,
.

:

$ ;

\ ;

` .

:
$STR1="'Strokasoderzhit$TERM'"
$echo$STR1
'Strokasoderzhitxterm'
170

,
. , ,
, .

V1 , $1000.

V1 , ,
.

.

read, . :
$echon':';readvar;echo$var
:!
!
var. n
echo
.
:
readvar1var2var3
, read,
, read, ,
,
.
, , , ,
, .

,
.
, , .

171

read IFS.
- . - .
, ?

.
,
.
Bash : $0, $1, $9. :

$0 ;

$1 $9 - ,
, .

:
$catparam.sh
#!/bin/bash
echo$1
echo$2
$./param.shfirstsecond
first
second
param.sh echo,
,
.
Bash :

$* - , ,
, IFS;

$@ - , ,
;

$# - ;

$? - ;

$$ - PID .

:
$catcomline.sh
#!/bin/bash
echo$*

172

$./comline.shmyarg
./comline.shmyarg
.
,
.
() ,
, shift.
shift , ,
. , $1 ,
$2, $2 $3 .
:
$catparam.sh
#!/bin/bash
echo$1
echo$2
echoAndnowallparametersareshifted.
shift
echo$1
echo$2
$./param.shfirstsecondthird
first
second
Andnowallparametersareshifted.
second
third
. ,
,
shift , $1 $2.
,
shift. , shift4
.
.

, .

set,
, .
:
$catparam.sh
#!/bin/bash
echo$1
173

echo$2
set12
echo$1
echo$2
$./param.shfirstsecond
first
second
1
2
, set
.

set , ,
.
:
set$1$2newarg$4
.
set , ,
.
- newarg.

, , PID
.

, bash.

v bash.

, .

, shift. ,
.

set
.

test.
test
. , test,
:

;
174

, test .
- . , , e test
:
$teste/etc/passwd
$echo$?
0
$testenot_existent_file
$echo$?
1
test , ,
, .
.
test ,
. test
[] . , ,
, :
$[e/etc/passwd]
$echo$?
0
[e/etc/passwd] teste/etc/passwd .
test, :

e - ;

f - (plain file);

d - ;

h L - ;

r - ;

w - ;

x - ;

s - ;

N - , .

test , :
175

[file1ntfile2] -
. , .

[file1otfile2] -
. , .

[file1effile2] -
.

o :
$setonoclobber
$[onoclobber]
$echo$?
0
$set+onoclobber
$[onoclobber]
$echo$?
1
test :

[str1=str2] - ;

[str1!=str2] - ;

[str1<str2] - str1 ,
str2 ;

[str1>str2] - str1 ,
str2 ;

[zstr] - ;

[nstr] - .

test :

eq - ;

ne - ;

lt - ;

le - ;

gt - ;

ge - .

:
$[1lt2]
176

$echo$?
0
$[1eq2]
$echo$?
1

test
?

, STR1, , ,
str1.
. , test,
str1?


C^D .

test gzip gunzip.

.
&& ||
.
.
&& ,
:
$ls/tmp&>/dev/null&&cd/tmp
$pwd
/tmp
($ls/tmp&>/dev/null)
, (cd
/tmp) .

test :
$[d/tmp]&&cd/tmp
$pwd
/tmp
test .
.

177

|| . , d1.
.
:
$[dd1]||mkdird1;cdd1
$pwd
/tmp/d1
test . , .
.
if ,
. ,

.
.
:
#!/bin/bash
if[$#ne1]
then
cat<<ERR
.
:
if.shfile
file.
ERR
exit1
fi
lsl$1
if then
, .
if - test,
, , .
, then fi,
if.
cat<<ERR - here document.
,
cat . ERR.
<< <<
.
:
$./if.sh
.
178

:
if.shfile
file.
$./if.shif.sh
rwxrr1aberesaberes172819:34if.sh
if elif
:
#!/bin/bash
if[$#ne1]
then
cat<<ERR
.
:
if.shfile
file.
ERR
exit1
elif[!f$1]
then
echon''
file$1
exit1
fi
lsl$1
, .
$./if.sh.
.:directory
if else ,
, .
, :
#!/bin/bash
if[$#ne1]
then
cat<<ERR
.
:
if.shfile
file.
ERR
179

exit1
elif[!f$1]
then
echon''
file$1
exit1
else
lsl$1
fi

,
.

, ,
. ,
. , 1,
. - .

case.
,
, . ,
, .
case. ,
case , .
case :
casein
1)

;;
2)

;;
esac
.

.
,
GNU/Linux. , ,
start,
, S s.
K k, , ,
stop.

180

:
$catcase.sh
#!/bin/bash
[$#ne1]&&exit1;
FIRST=`echo$1|cutc1`
case$FIRSTin
[Ss])
echo"$1"
./$1start
;;
K|k)
echo"$1"
./$1stop
;;
*)
echo"$1"
./$1status
;;
esac
. 1,
. FIRST
(, ).
case FIRST
[Ss]. , .
, S, s.
, FIRST ,
.
( ) ,
: K, k. . ,
.
FIRST ,
.
:
#ls*postfix
K11postfixpostfixS89postfix
#./case.shS89postfix
S89postfix
*Startingpostfix...

[ok]

#./case.shpostfix
postfix
181

*status:started
#./case.shK11postfix
K11postfix
*Stoppingpostfix...

[ok]

/etc/init.d .
case ?

, ,
.
. , - root
.
case .

.
,
, .
:

for - ;

while - , , ;

until - , , .

, ,
, - .
for.
, , :
#!/bin/bash
forDIRin/etc/tmp/var
do
echon"$DIR"
lsld$DIR|cutc211
done
DIR : /etc, /tmp
/var. for, in
. do done .
:

182

$./for.sh
/etcrwxrxrx
/tmprwxrwxrwt
/varrwxrxrx
for in ,
, . ,
.
,
:
#!/bin/bash
[$#lt1]&&exit1
forDIR
do
if[d$DIR];then
echon"$DIR"
lsld$DIR|cutc211
elif[!e$DIR];then
echo"$DIR"
fi
done
DIR
, for .
:
$./for.sh/usr/rsu/root
/usrrwxrxrx
/rsu
/rootrwx
while until.
, , 1 10
:
#!/bin/bash
i=1
while[$ile10];do
echo$i
i=$((i+1))
done
:
183

$./while.sh
1
2
3
4
5
6
7
8
9
10
while , , ,
. , until -
.
,
(FQDN) .
, , , , .
#!/bin/bash
HN=`hostname`
until[z$HN];do
echo$HN
HN=`echon$HN|tr'.''\n'|sed'1d'|tr'\n''.'`
done
HN, .
. -
, ,
.
until , HN
.
:
$hostname
nechto.zamislovatoe.tmn.ru
$./until.sh
nechto.zamislovatoe.tmn.ru
zamislovatoe.tmn.ru
tmn.ru
ru

184

,
, .
.
for.

,
while until.

.

. Bash ,
. (
) .
if.sh
. , ,
, , .
:
function()
{

}
.
.
if.sh :
$catif.sh
#!/bin/bash
functionerr_msg()
{
cat<<ERR
.
:
if.shfile
file.
ERR
}
if[$#ne1]
then
err_msg
exit1
elif[!f$1]
185

then
echon''
file$1
exit1
fi
lsl$1
if.sh :
$./if.sh
.
:
if.shfile
file.
$./if.sh/etc/passwd
rwrr1rootroot20331923:24
/etc/passwd
,
.
.
if.sh , ,
:
$catif.sh
#!/bin/bash
functionerr_msg()
{
echo":$1"
cat<<ERR
.
:
if.shfile
file.
ERR
}
if[$#ne1]
then
err_msg'001'
exit1
elif[!f$1]
then
echon''
file$1
exit1
fi

186

lsl$1
- .
.
:
$./if.sh
:001
.
:
if.shfile
file.
,
inline .
, err_msg myfunctions.
myfunctions if.sh :
$catmyfunctions
functionerr_msg()
{
echo":$1"
cat<<ERR
.
:
if.shfile
file.
ERR
}
$catif.sh
#!/bin/bash
../myfunctions
if[$#ne1]
then
err_msg'001'
exit1
elif[!f$1]
then
echon''
file$1
exit1
fi
lsl$1

187

if.sh inline myfunctions


err_msg , .

, man ,
. man
env LANG C.
Bash.

case.sh , case, ,
, FIRST,
.

188

13..
.
GNU/Linux
. :

,
/etc/passwd /etc/shadow.

Kerberos.

NIS/NIS+.

LDAP.

,
, ,
.
/etc/passwd ,
/etc/shadow .
.
.
/etc/passwd :

x
/etc/shadow ( man5passwd ,
*). ,
.

UID .

GID .

, ,
() .

,
.

, /etc/passwd
.
, ,

. ,
, - /etc/shadow
, . :

01 1970 .,
.
189

,
, .

.
.

,
.

,

.


. 01 1970 .,

.

/etc/shadow ( root).

?


/etc/shadow ?

,
.
.
useradd.
. :
#useradduser1
#iduser1
uid=504(user1)gid=504(user1)groups=504(user1)
user1.
user1.
.
.

/etc/passwd /etc/shadow :
#grepuser1/etc/passwd
user1:x:504:504::/home/user1:/bin/bash
190

#grepuser1/etc/shadow
user1:!!:12407::::::
:
#lsa/home/user1
..bash_logout.bashrc.i18n.mutt.rpmmacrosDocuments
...bash_profile.emacs.lpoptions.pinerc.xsession.dtmp

Red Hat
Linux .
, , .
m
useradd, d,
. Red Hat , n.

(. ) .
useradd /etc/default/useradd
D useradd :
#useraddD
GROUP=100
HOME=/home
INACTIVE=1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
useraddD :

GROUP=100 - GID - 100 ( Red Hat


);

HOME=/home -
/home;

INACTIVE=1
;

SHELL=/bin/bash ;

SKEL=/etc/skel ,
,
.

/etc/skel
,
:
$lsa/etc/skel
191

..

.bash_logout

.bash_profile

.bashrc

.mozilla

useradd :

s ;

d ;

m , ;

M ;

k ;

u UID ;

g GID ( ) ;

G , ( );

e , (
);

f ,
.


( M) sinix ( g).
,
/sbin/nologin . 21 2011 .
( e).
#useraddMgsinixs/sbin/nologine20110121sinixuser
#idsinixuser
uid=505(sinixuser)gid=107(sinix)groups=107(sinix)
#grepsinixuser/etc/shadow
sinixuser:!!:14754:0:99999:7::14995:

sinixuser. 1 1970 .
, .
,
:

/bin/false , 1 (
);

/dev/null ,
;

/sbin/nologin ,
.


, , .
192

usermod .
:
#usermods/bin/falsesinixuser
useradd usermod . , ,
, ,
:
#usermodG"`idGsinixuser|tr''','`,users"sinixuser
#idsinixuser
uid=505(sinixuser)gid=107(sinix)groups=107(sinix),100(users)
idG , ,
. tr,
usermod . ,
, ,
usermod .
usermod
l. L U , ,
.
userdel.
:
#userdelsinixuser
#idsinixuser
id:sinixuser:Nosuchuser
sinixuser .
,
, . userdel
. ,
, (, find/home/usruser...)
, , .

test1, ,
/var/spool/mail, users mail.
UID=1000.

test2 ,
. ,
, .
193

test2 test3.

test3
sys.

/etc/default/useradd ,
useradd. .
UID ?

.
,
. , , :

,
passwd.


. , , ,
,
PAM
. PAM passwd Red Hat
/etc/pam.d/passwd
/etc/pam.d/systemauth.
passwd .
passwd :

l ;

u ;

S ;

d ;

n ( );

x ;

w ,
;

i , .

.
#idcolobok
uid=503(colobok)gid=503(colobok)groups=503(colobok),22(cdrom)
#cat/etc/shadow
194

colobok:$1$08$Z4jZgPzM2GDVguFd4TRF3ubB:14754::::::

#passwdlcolobok
#cat/etc/shadow
colobok:!$1$08$Z4jZgPzM2GDVguFd4TRF3ubB:14754::::::


/etc/shadow .
.

test4
.
/etc/shadow.

31 .
, /etc/shadow.

/etc/shadow.

test4.

.

,
.
, . ,
, , ,
,
.
/etc/group .
: name:password:GID:user(s), :

. , .

- GID .

, ,
.

groupadd ,
/etc/group.
#groupaddclass

195

#grepclass/etc/group
class:x:505:
class.
GID,
/etc/passwd. ,
, , ,
/etc/group. :
#grepsys/etc/group
sys:x:3:root,bin,adm
sys root, bin adm.
g.
#groupaddg512project
project, GID 512.
groupdel.
#groupdelproject
project.
- .


.

gpasswdA, :
#gpasswdAivanovdevelopers
developers ivanov.

gpasswdM:
#gpasswdMmartadevelopers
marta developers .
:
196

gpasswda;

gpasswdd.

$gpasswdasemkodevelopers
developers
semko.

xusers GID 1010.

( root) xusers.

, GID .
yusers.

.

, .
() (Master Profile)
(Login Profiles).
(resource files), .
,
,
.
Bash (
),
/etc/profile , ,
. Bash ,
:

~/.bash_profile

~/.bash_login

~/.profile

, :

PATH - ,
;

TERM - ;

USER - ( idun);

HOME - ;

MAIL - ;
197

HOSTNAME - .

, ,
export. , ,
PATH bin,
:
PATH=$PATH:$HOME/bin
exportPATH
, PATH .
umask.

source , :
#source/etc/profile
,
.
~/.bashrc
Bash , .
,
( ), Bash
, ~/.bashrc
.
:
$cat.bash_profile
#Getthealiasesandfunctions
if[f~/.bashrc];then
.~/.bashrc
fi
#Userspecificenvironmentandstartupprograms
BASH_ENV=$HOME/.bashrc
exportBASH_ENV
,
,
, .
inline - (.). .~/.bashrc
( , ),
, ,
. Inline
198

, .
BASH_ENV , ,
, (,
), , ,
.
~/.bashrc inline
/etc/bashrc. , ,
, , ,
,
~/.bashrc.
, ,
Bash:

/etc/profile.

(,
~/.bash_profile).


~/.bashrc , , , .

,
/etc/bashrc.

3 4 .

umask 027 ,
Bash.

l lsLl.

,
,
Bash?

PATH
bin, ?

> ,
Bash .

.
,
,
.
. , ,
.

.
199

.
, ,
.
, , ,
quota ( BSD). ,
RPM, rpmqquota .
. :
$rpmqquota
quota3.131.2.5.el5
whichquota
quota , PATH.
quota , ,
, .

.
:

, .

,
:

usrquota - ;

grpquota - .

,
. , ,
.
, usrquota
grpquota /etc/fstab .
:
/dev/hda6/homeext3defaults,noatime,usrquota12
/home
/dev/hda6 , .
/etc/fstab
, .
mount - .

, . :
$mount
200

...
/dev/hda6on/hometypeext3(rw,noatime,usrquota)
, mount , ,
/home ,
usrquota .
,
/etc/fstab
.

,
, . :

aquota.user - ;

aquota.group - .

-
. ,
/home , .
quotacheck ,
.
.
quotacheck :

c - .
.

m -
.

a -
. , ,
, .

u - .

g - .

v - .



:
#quotacheckcaumv

/home.
/home/aquota.user .
/ .
:

;
201

inode, , .

, ,
(hard quota), ,
,
(soft quota). , soft quota,
grace period. 7 .
hard quota .
- .
,
:
1. grace period .
, .
2. soft hard (inode)
.
.
3. ,
.
grace period edquota
t . (,
vi), grace period
. ,
,
edquota grace period.
grace period :

seconds - ;

minutes - ;

hours - ;

days - ;

weeks - ;

months - .

grace period
. edquotau . :
#edquotauasimonov
asimonov .
grace period , ,

inode.
soft hard
inode.
.
edquota , .
202

,
.
edquotap<> .
. ,
, , ,
, u .
:
#edquotapasimonovubsmirnovakozlovrruminzkravchenko
asmirnov
: bsmirnov, akozlov, rrumin
zkravchenko.
, u
edquota g ,
.
/
.
quotaon . a ,
,
. :
#quotaonvu/dev/hda6
/dev/hda6. u ,
, v
.
quotaon
.
quotaoff .
a ,
.
,
quota . .
soft quota ,
. grace period.
, hard quota,
.

repquota . a ,
,
.

203

/home ,
/etc/fstab
. .

grace period 2 .

user1 : soft hard quota


, , 100 120 ; , ,
10 12.

dd.
/dev/urandom , .
hard quota . ?

soft quota . 2 ,
quota ( ) repquota (
). grace period?

user1 ,
user2. repquota?

.
who ,
.
/var/run/utmp .
$who
user1:0Jan2115:10
, ,
. who :

b ;

H ;

login , ;

q ;

w ;

u ;

a , .

, , :
$whouH
204

NAMELINETIMEIDLEPIDCOMMENT
user1:0Jan2115:10?2014
rootpts/1Jan2115:21.2611(localhost)
, ,
, /var/log/wtmp .
, /var/run/utmp ,
, who . ,
last :
$last
rootpts/1localhostWedJan2115:21stillloggedin
user1:0WedJan2115:10goneno
logout
rebootsystemboot2.6.18194.3.1WedJan2115:09(00:27)
postgres???localhostWedJan2115:0915:09(00:00)
rootpts/1localhostWedJan2114:52down(00:10)


.
/var/log/lastlog ,
.
, , lastlog .

, .

a who
.

who , .

, last.

lastlog .

205

14..
.
-
, .
,
.
,
( ).

.
:

(
, , , );

,
.


, . , ,

. , -,
, , . ,
,
.
,
, , RHEL
FHS.
/usr . , ,
/var /home . , ,
,
, .

.

206

/boot - , Linux;

/etc - ,
(
);

/lib - ;

/opt - ,
;

/bin /sbin - , ;

/usr - , .

,
,
.
/etc
, ,
, .
, . ,
,
, .

, , ,
.
, ,
/usr/local /opt ,
.
:

, SCSI ATAPI
(streamers), .

CD-RW CD-R - 700 .

DVD-R - 4,7 .

, ,
, ,
(VTL Virtual Tape Library).

, :

, ;

,
207

. .

. (
).
,
(attended backup).
-
- (, ).
- , , ,
.
-
.
- (unattended backup).
.
.

.
,
.
, ,
, ,
,
, .
:

,
;

( );

,
.
:

- ;

- ,
,
.

GNU/Linux ext2, ext3


ext4 dump . ,
,
.
. ,

. , ,
, - , ; , , ,
, - ,
. , ,
.
208

dump
. .

, . :
man.

dd.
dd ,
if= , , of= .
512 . dd
.
, , CD
:
ddif=/dev/cdromof=cd.imgbs=1k
1 ( bs=1k)
cd.img .
if= of= , dd
.
dd :

count - , ;

skip - ,
;

seek - ,
.

dd
. conv . ,
, ,
:
$who|ddconv=ucase2>/dev/null
USER1:0JAN1015:17
USER1PTS/0JAN1015:17(:0.0)
who dd
. -
.
209

512 ,
, first_sect.img .

first_sect.img.

.
UNIX GNU/Linux .
, .
,
, .
GNU/Linux :

gzip - , .gz .

bzip2 - , gzip,
.bz2 .

compress - UNIX , GNU/Linux ,


, .Z .

:
$lsldistfiles.*
rwrr1user1user12392632623:10distfiles.lst
rwrr1user1user119678812215:01distfiles.txt
$gzipdistfiles.*
$lsldistfiles.*
rwrr1user1user1632982623:10distfiles.lst.gz
rwrr1user1user11873112215:01distfiles.txt.gz

gzip .
.gz .
gzip ,
l :
$gzipldistfiles.*
compresseduncompressedratiouncompressed_name
6329823926373.6%distfiles.lst
187311196788190.5%distfiles.txt
250609220714488.6%(totals)
gzip :

d - , gunzip ;
210

- ,
;

r - ;

S - , .gz , ;

t - ;

v - .

, , :
$gziptvdistfiles.*
distfiles.lst.gz:OK
distfiles.txt.gz:OK
gzip gunzip ,
, gzip :
$gunzipvdistfiles.*
distfiles.lst.gz:73.6%replacedwithdistfiles.lst
distfiles.txt.gz:90.5%replacedwithdistfiles.txt
zcat gzip .

gzip .
bzip2 , ,
. bzip2
gzip ( !):
$bzip2vdistfiles.*
distfiles.lst:3.879:1,2.063bits/byte,74.22%saved,239263in,61689out.
distfiles.txt:14.576:1,0.549bits/byte,93.14%saved,1967881in,135009out.

$lsldistfiles.*
rwrr1user1user1616892623:10distfiles.lst.bz2
rwrr1user1user11350092215:01distfiles.txt.bz2

bzip2 gzip , ,
, .

gzip . ? ?

gzip bzip2 /bin/mount .


211

. .

bzip2 ,
gzip ?

tar.
- tar
(tape archive). ,
. , ,
f . tar BSD ,
. , ,
, /home ,
:
#tarcvf/dev/st0/home

( ) /home .
, .
c tar (create), v
tar .
UNIX tar .
, GNU/Linux tar
, -
. , /home/user1/.bashrc
home/user1/.bashrc ,
.
tar , gzip
z bzip2 j .
. , /bin /sbin
binaries.tar.gz :
$tarczvfbinaries.tar.gz/{,s}bin
tar .tar . ,
(, .gz).
t (type). ,
, .
, binaries.tar.gz
:
$tartzvfbinaries.tar.gz
212

x (extract).
GNU tar
. , . ,
, binaries.tar.gz :
$tarxzfbinaries.tar.gz
f tar
, . , ,
, :
$gzipdcbinaries.tar.gz|tarxf
gzip ,
c gzip
.
tar ,
.
GNU tar :

A - tar ();

c - ;

delete - ;

r - ;

u - , , ;

b - (nx512 );

C - ;

h - ,
, , ;

l -
;

L - (nx512 );

m - ;

p -
;

M - , ;

P - ;

N - ,
;

O - ;
213

T -
;

Z - compress .


/etc. etc.tar.gz .
.

/etc/hosts ,
/tmp .

, 50 K,
split . cat
?

cpio.
cpio tar ,
,
tar . , cpio
,
.
cpio , :

o - (copy-out),
, (output) ;

i - (copy-in), ,
(input);

p - (pass-through),
.

, ,
cpio find .
, cpio .
,
, :
#find~taniamtime1|cpioov>tania.cpio
tania ,
24 , cpio ,
tania.cpio ,
214

. v
. cpio copy-out ( o).

copy-in cpio t
(type):
#cpioivt<tania.cpio
cpio
. cpio copy-in ( i).

t . d ,
cpio
, . , ,
tania.cpio :
#cpioivd<tania.cpio
cpio :

B - 5120 512
;

blocksize - nx512 512


;

F - ;

O - ;

I - ;

A - , F O ;

E - ,
;

f - ,
;

n - UID GID ;

r - ;

u - .

cpio , .

, fd.
215

cpio ,
, .

dump.
dump
ext2, ext3 ext4.
,
. ,
. ,
,
.
,
.

.
,
. , ,
, - .
.
.
:
N , ,
M, , N (M<N).
, ,
.
dump :
- 0 - ;
- 9.
0 9 .
dump GNU/Linux .
dump :
dump<>[]<>
- , 0 - .
- , ,
.
dump :

a - (auto size) ,
( ,
- );
216

A - TOC (Table of Contents) -



restore ;

D - ,
/etc/dumpdates ;

e - inode ,
;

E - , inode ,
inode ;

f - , ,
, ,
;

F - ,
, ;

j - bzlib;

z - bzlib;

y - , lzo,
;

L - ;

M - , ,
, f ,
;

S - , ;

T - /etc/dumpdates
, ;

u -
/etc/dumpdates ;

W - ,
/etc/dumpdates
/etc/fstab .

, :
$/sbin/dump0ftmp/proceed.0.dumpProceed/
DUMP:Dateofthislevel0dump:SatFeb512:23:082009
DUMP:Dumping/dev/sda3(/(dirhome/zztop/Proceed))totmp/proceed.0.dump
DUMP:Label:/
DUMP:Writing10Kilobyterecords
DUMP:mapping(PassI)[regularfiles]
DUMP:mapping(PassII)[directories]
DUMP:estimated28857blocks.
DUMP:Volume1startedwithblock1at:SatFeb512:23:082009
DUMP:dumping(PassIII)[directories]
DUMP:dumping(PassIV)[regularfiles]
DUMP:Closingtmp/proceed.0.dump
DUMP:Volume1completedat:SatFeb512:23:102009
DUMP:Volume132560blocks(31.80MB)

217

DUMP:Volume1took0:00:02
DUMP:Volume1transferrate:16280kB/s
DUMP:32560blocks(31.80MB)on1volume(s)
DUMP:finishedin2seconds,throughput16280kBytes/sec
DUMP:Dateofthislevel0dump:SatFeb512:23:082009
DUMP:Datethisdumpcompleted:SatFeb512:23:102009
DUMP:Averagetransferrate:16280kB/s
DUMP:DUMPISDONE
$lsltmp/
32600
rwrwr1zztopzztop33341440512:23proceed.0.dump

proceed.0.dump , Proceed.
/etc/dumpdates .
dump
/home, :
dump0uf/dev/st0/home
( 0),
/etc/dumpdates ( u).
/dev/st0 .
:
dump0S/dev/sda3
7172227072
/dev/sda3 7,1 .
:
dump2uL'Level2'f/dev/st0/dev/sda3
/dev/sda3 Level2
/dev/st0.

, dump
.


. ?

218

restore.
restore , dump.
, , .
restore
:

C - ;

i- restore ;

P - ,
;

r - (rebuild
filesystem);

R - , ;

t - ;

x - r

.

f restore (,
).
, .
:
restorerf/dev/st0
r , f .
i restore . restore
.
:

add - ;

cd - ;

delete - ;

extract - ;

help - ;

ls - ;

pwd - ;

quit - ;

setmodes - ,
;

verbose - .

restore :
219

a - ,
( x i);

A - , (
t , i a);

F - ;

M - (. M dump);

V - (, CDROM);

N - ;

o - (
x i);

X - , ,
.

. ,
, .
$/sbin/restoretfproceed.0.dumpiptraf.sh
Dumpdate:SatFeb512:23:082009
Dumpedfrom:theepoch
Level0dumpof/(dirhome/zztop/Proceed)onblack.class.edu:/dev/sda3
Label:/
./iptraf.shisnotonthetape
$/sbin/restoretfproceed.0.dumphome/zztop/Proceed/8marta/iptraf.sh
Dumpdate:SatFeb512:23:082009
Dumpedfrom:theepoch
Level0dumpof/(dirhome/zztop/Proceed)onblack.class.edu:/dev/sda3
Label:/
617210./home/zztop/Proceed/8marta/iptraf.sh

t.
,
.
.
.
, :
$/sbin/restorexaofproceed.0.dumphome/zztop/Proceed/8marta/iptraf.sh
$ls
homeproceed.0.dump
$lsRhome/
home/:
zztop
home/zztop:
Proceed
home/zztop/Proceed:
8marta
home/zztop/Proceed/8marta:
iptraf.sh

220

x . a
, o
.
, .

,
.

, ,
.

221

15.
.
at.
-
, . at
, .
. :
$date
2612:12:38YEKT2010
$at22:00
warning:commandswillbeexecutedusing/bin/sh
at>find/home/user1mtime0|xargstarczf/backup/user1.tgz
at><EOT>
job1at2010052622:00
12:12 at 22:00 . at ,
at>
, . ,

user1.

, . , :
$atnow+10minutes
at , ,
.

at f .
-m , at
, .
atq atl :
$atq
32010052613:13auser1
,
- .
atrm atd .
:
222

$echo'wallHello!'|atm+1minutes
warning:commandswillbeexecutedusing/bin/sh
job5at2010052622:04
$atq
52010052622:04auser1
$atrm5
$atq
wall ,
Hello! , ,
. , atrm .
batch at ,
, ,
0.8 .
/proc/loadavg . batch at .
/etc/at.allow /etc/at.deny .
/etc/at.allow , , ,
at . ,
/etc/at.deny , , at .

, ,
, .

at , 3 .

at .

.
at cron ,
.
GNU/Linux Vixie Cron,
cron , /etc/crontab ,
, ,
/var/spool/cron . ,
.
/etc/crontab , ,
.
.
. ,
.
223

, . ,
crontab , . :
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
#runparts
01****rootrunparts/etc/cron.hourly
024***rootrunparts/etc/cron.daily
224**0rootrunparts/etc/cron.weekly
4241**rootrunparts/etc/cron.monthly
crontab , , - SHELL, PATH
,MAILTO HOME, . runparts ,
.
:

(059).

(023).

( 131).

(112).

(06).

, ,
4:02, 4:22 ,
4:24.
.
.
cron ,
, .
cron crontab .
, cron , ,
cron , . :
$echo'3021***wallHello!'>crontab.eg
$crontabcrontab.eg
crontab.eg ,
, 21:30.
crontab .
crontab l ,
:
$crontabl
224

3021***wallHello!
C ,
u crontab :
#crontabluuser1
3021***wallHello!

crontabe .
, cron ,
.
. ,
.
:


: crontabl>crontab.eg .

: vicrontab.eg .

: crontabcrontab.eg .

,
crontabr . :
$crontabl
3021***wallHello!
$crontabr
$crontabl
crontab:nocrontabforuser1
crontab
/etc/cron.allow /etc/cron.deny . ,
/etc/cron.allow , , ,
crontab . ,
/etc/cron.deny , , ,
crontab .

10:30
, .
cron .

, .

,
, 9:30
.
225

16..
syslog.
GNU/Linux
, .
- /var/log . :
. syslog
, .
,
, ,
syslog .
- /var/log .
, , /var/log , syslog.
, ,
wtmp (. who last).
syslog syslogd ,
:
$psCsyslogd
PIDTTYTIMECMD
1246?00:00:00syslogd
syslogd
. GNU/Linux ,
, . ,
,
.
syslogd /etc/syslog.conf .
, # . ,
(
- ), :

(selector) - ,
. .

(action), .
- /var/log .

:
#SELECTOR

ACTION

#Logallkernelmessagestotheconsole.
#Loggingmuchelsecluttersupthescreen.
#kern.*

/dev/console

#Loganything(exceptmail)oflevelinfoorhigher.

226

#Don'tlogprivateauthenticationmessages!
*.info;mail.none;news.none;authpriv.none;cron.none

/var/log/messages

#Theauthprivfilehasrestrictedaccess.
authpriv.*
/var/log/secure
#Logallthemailmessagesinoneplace.
mail.*

/var/log/maillog

#Logcronstuff
cron.*

/var/log/cron

#Everybodygetsemergencymessages
*.emerg

#Savenewserrorsoflevelcritandhigherinaspecialfile.
uucp,news.crit
/var/log/spooler
#Savebootmessagesalsotoboot.log
local7.*

/var/log/boot.log

#
#INN
#
news.=crit/var/log/news/news.crit
news.=err/var/log/news/news.err
news.notice/var/log/news/news.notice

,
, . - (facility), -
(priority) .
, syslog .
syslog (facility):

auth (
, authpriv);

authpriv ;

cron at cron ;

daemon ;

kern ;

lpr ;

mail , ;

mark , ( syslog),
;

news ;

security , auth ;

syslog syslog;

user , ;

uucp uucp;

local0...local7 ,
227

, .
(priority),
:

emerg ;

panic , emerg ( );

alert ;

crit ;

err ;

error , err ( );

warning ;

warn - , warning ( );

notice , ;

info ;

debug .

, , ,
,
, . :
lpr.info

/var/log/lpr

, info ,
/var/log/lpr .
,
.
-
, :
daemon.info;daemon.!err

/var/log/daemons

info warning
/var/log/daemons , ,
err , .

,
:
daemon.=err

/var/log/daemons.err

228

/var/log/daemons.err
.
,
. :
kern.*;kern.!=info

/var/log/kernel

, .
, ,
, ,
:
authpriv.*

/var/log/messages

,
/var/log/messages .
- ,
none :
*.crit;lpr,cron,mail.none

/var/log/critical

/var/log/critical
, , , at
cron .
syslog logger,
syslog . , Test err
mail :
$loggerpmail.errTest

syslogd ,
local0 info
/var/log/mylog .

, syslogd
.
, /var/log/mylog .

,
.

/var/log/mylogpriv
authpriv . .
, ?
229

.

. logrotate ,
. ,
cron . :
$cat/etc/cron.daily/logrotate
#!/bin/sh
exec/usr/sbin/logrotate/etc/logrotate.conf
, logrotate
/etc/cron.daily , (
). /etc/logrotate.conf .
logrotate :

(
/var/log/messages ):
$lsw1/var/log/messages*
/var/log/messages
/var/log/messages.1.gz
/var/log/messages.2.gz
/var/log/messages.3.gz
/var/log/messages.4.gz
/var/log/messages.5.gz
1. ,
messages messages.1.gz.
2. messages.1.gz messages.2.gz ,
messages messages.1.gz .
3. messages.2.gz messages.3.gz
...
logrotate
. (
messages.1.gz ) ( messages.5.gz ).
230

/etc/logrotate.conf :
#rotatelogfilesweekly
weekly

#keep4weeksworthofbacklogs
rotate4
#createnew(empty)logfilesafterrotatingoldones
create
#uncommentthisifyouwantyourlogfilescompressed
compress
#RPMpackagesdroplogrotationinformationintothisdirectory
include/etc/logrotate.d
#nopackagesownwtmpwe'llrotatethemhere
/var/log/wtmp{
monthly
minsize1M
create0664rootutmp
rotate1
}
#systemspecificlogsmaybealsobeconfiguredhere.
, /etc/logrotate.conf
, .
,
/var/log/wtmp .
daily, weekly monthly ,
, , .
rotate
, create . ,
create
.
compress.
copy,
. ,
nocompress .
notifempty .
include ,
. ,
,
.
mail
.
231

prerotate postrotate ,
, , .
size ,
.

/var/log/mylog
/var/log/mylogauth, .
. .
gzip.

/var/log/mylog
100 .

232

17..
.
,
. x32/64 , BIOS
(Basic Input/Output Services -).
CMOS (Complemenary Metal-Oxyde Semiconductor
).
, ,
. ,
BIOS CMOS Setup. x32/64
, ,
.
, BIOS POST (Power On Self Test
).
(
). , ,
x32/64 POST
( BIOS ,
).
POST BIOS,
Bootstrap Loader ( ).
, CMOS Setup BIOS,
, , .
, .
MBR (Master Boot Record
).
(510 511 0
, , 0x1FE 0x1FF). 16 ,
, 0xAA55.
, .
MBR ,
, , .
512 , ,
, .
( GNU/Linux!) MBR
, .
, GNU/Linux LILO GRUB,
. , , MBR,
.
, ,
Linux ( )
(,
).
, GNU/Linux, Linux
. , Linux

233

, linuxrc.
,
GNU/Linux.
, , ,
, /sbin/init ,
/etc/inittab . , PID 1.

GNU/Linux, (,
).
System V UNIX
(runlevels).
/sbin/init ,
.
,
.
,
.

.
, /sbin/init getty
.
( login: ). - ,
, login .
( password: ),
(, /etc/shadow ).
, ,
/etc/passwd, , , .
login: /etc/issue
( /etc/issue.net, ).
/etc/motd (Message Of The Day
).

/etc/issue
, .

/etc/motd ,
.

GRUB.
GRUB . ,
LILO ,
, GRUB .
234

GRUB , , ext2, ext3, ext4, XFS, JFS.


GRUB , 1024 .
, .
GRUB , , GNU/Linux,
GNU/HURD, FreeBSD, Oracle Solaris . ,
, GRUB (chainload) ,
. GRUB
, zip.
GRUB ,
, ,
, .
GRUB TFTP
(Trivial File Transfer Protocol)
.
GRUB .
: (hd1) (fd0). (hd1)
, (fd0) . , hd
, fd . .
.
. ,
(hd0,1).
grub GRUB,
, ,
GRUB geometry,
. :
geometry(hd0)
GRUB
help.
root ,
, , . ,
root (hd0,1).
setup ,
MBR (Master Boot Record).
setup . , GRUB
MBR :
setup(hd0)
GRUB quit.
GRUB ,
Bash. GRUB
.
235

GRUB GRUB, ,
, .
GRUB c.
GRUB
b.
GRUB , /boot/grub.
/boot/grub/menu.lst
, .

/boot/grub/grub.conf, GRUB.
.
menu.lst
/ .
.
default .
menu.lst.
timeout.

splashimage.
, splashimage=(hd0,0)/boot/grub/pichture.xpm.gz
/boot ,
.
title,
,
, , root, , ,
initrd. :
default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
titleCentOS(2.6.18194.3.1.el5)
root(hd0,0)
kernel/vmlinuz2.6.18194.3.1.el5roroot=/dev/VolGroup00/LogVol00rhgbquiet
initrd/initrd2.6.18194.3.1.el5.img
title=Windows
root(hd0,1)
chainloader+1

.
LVM /dev/VolGroup00/LogVol00
.
MS Windows.
GRUB
setup. , setup(hd0) MBR.
GRUB Bash ( )
grubinstall,
236

. :
grubinstall/dev/hda
GRUB ,
/boot/grub/menu.lst,
GRUB - .

GRUB .

GRUB
/boot/grub/menu.lst.

.
GNU/Linux /sbin/init
. init PID=1
, . init
getty ( ),
login: /bin/login
.
GNU/Linux ,
init /etc/inittab.
GNU/Linux, System V (UNIX SYS V UNIX
, BSD ),
- runlevels.
, , .
Red Hat Linux :

0 (halt);

1 (single user mode);

2 NFS;

3 (multiuser);

4 ( );

5 X ( );

6 (reboot).

S. Red
Hat 1 S.
, init ,
/etc/inittab.
237

/etc/inittab :
id:runlevels:action:process
:

id /etc/inittab, 1-4
( 2-);

runlevels , ,
;

action , ;

process , .

,
/etc/inittab :

initdefault ;

sysinit
( , ,
init);

wait ,
init, ,
;

ctrlaltdel ,
Ctrl-Alt-Del, init SIGINT;

powerfail ,
(, UPS )
( );

powerokwait , init ,
init
;

respawn , .

/etc/inittab :
id:5:initdefault:
5-,
X .
, , /etc/rc.d/rc.sysinit
:

238

si::sysinit:/etc/rc.d/rc.sysinit
, ,
:
l0:0:wait:/etc/rc.d/rc0
l1:1:wait:/etc/rc.d/rc1
l2:2:wait:/etc/rc.d/rc2
l3:3:wait:/etc/rc.d/rc3
l4:4:wait:/etc/rc.d/rc4
l5:5:wait:/etc/rc.d/rc5
l6:6:wait:/etc/rc.d/rc6
: (0-6)
/etc/rc.d/rc ,
. ,
, . ,
/etc/rc.d/rc .
getty,
login: :
1:2345:respawn:/sbin/mingettytty1
2- 5-
. , ,
, mingetty.
,
/etc/inittab.
/etc/inittab ,
, /sbin/initq .
init (PID=1) SIGHUP.
, Red Hat Linux
/etc/rc.d/rc,
:
/etc/rc.d/rc#.d
SYS V /etc/rc.d
:
/etc/rc#.d
, ,
/etc/rc2.d 2- . Red Hat
239

/etc/rc#.d /etc/rc.d/rc#.d.
( 3-
):
$ls/etc/rc3.d/
K01dnsmasqK50ibmasmS05kudzuS26apmd
K02avahidnsconfdK50netconsoleS08ip6tablesS26haldaemon
K02NetworkManagerK50tuxS08iptablesS26hidd
K02oddjobdK50vsftpdS08mcstransS28autofs
K05conmanK69rpcsvcgssdS09isdnS50hplip
K05inndK73ypbindS10networkS55sshd
K05saslauthdK74nscdS11auditdS56cups
K05wdaemonK74ntpdS12restorecondS56rawdevices
K10dc_serverK80kdumpS12syslogS56xinetd
K10psacctK85mdmpdS13cpuspeedS80sendmail
K10tcsdK87multipathdS13irqbalanceS85gpm
K12dc_clientK87namedS13portmapS90crond
K15httpdK88wpa_supplicantS14nfslockS90xfs
K20nfsK89dundS15mdmonitorS95anacron
K20rwhodK89netplugdS18rpcidmapdS95atd
K24irdaK89pandS19rpcgssdS97yumupdatesd
K25squidK89rdiscS22messagebusS98avahidaemon
K30spamassassinK91capiS23setroubleshootS99firstboot
K35dovecotK99readahead_laterS25bluetoothS99local
K35smbS00microcode_ctlS25netfsS99smartd
K35vncserverS02lvm2monitorS25pcscd
K35winbindS04readahead_earlyS26acpid

lsl/etc/rc3.d , ,

/etc/init.d.
:
4. S , ,
K , - ( ,
- , );
5. ,
;
6. () .
, , S (start), -, ,
K (kill) .
- . ,
S80sendmail
S10network.
/etc/init.d . , ,
/etc/init.d/network
. , :
/etc/init.d/networkstart
:
/etc/init.d/networkstart
240

/etc/rc.d/rc ,
, , S,
start, .
, K stop, .
Red Hat
/sbin/service. :
servicenetworkstart
.
, ,
(
/etc/init.d) ,
/etc/rc#.d,
.
Red Hat chkconfig ,
.
,
:
chkconfiglist

chkconfig add, del.
, ,
level. , ,
2, 3, 4 5- :
chkconfiglevel2345networkon
, runlevel. :
#runlevel
N5
runlevel (
N) ( 5).

/sbin/init. , ,
:
/sbin/init1

241

, getty .

who.
.

,
. ?

,
.

, httpd.

.
,
, /sbin/init0 /sbin/init6.
halt reboot .
halt /var/log/wtmp ,
. shutdownhnow,
. halt f (force),
shutdown.
halt n,
. haltd
/var/log/wtmp .

haltp poweroff.
poweroff reboot
/sbin/halt.

/sbin/shutdown. ,
.
, . , ,
SIGTERM,
.
shutdown init
0- 6- , , h r. :
/sbin/shutdownhnow
,
now.
, :

242

/sbin/shutdownr17:00'Systemwillberebootedat17:00!'
(r) 17:00,
, .

. ,
t. :
/sbin/shutdownh+10
10 .
: t
, shutdown init
. , ,
shutdown .
, ,
.
, , shutdown.

C/fastboot,
.

C/forcefsck,
.

,.

shutdown
.

/forcefsck shutown ,
, F ?

,
poweroff.

243

18..
.
,
,
. :

.
.
-, , ,
. -,

(, ) - .

.

.
.

.
,
.


.
,
- ( ),
.

.
,
.
.
. ,
,
. .

,
.

.

.
.
, , ,
.

.

, (maintainers).
.
, ,
244


.
GNU/Linux ( )
, , Oracle.

. GNU/Linux, , Red Hat
Enterprise Linux SUSE Enterprise Linux Server,
. GNU/Linux
.

(tarballs).

(binaries).

(package)
(package manager).

(source package)

(package manager).


(
Gentoo, portage port FreeBSD).

GNU/Linux
.
. ,
www.distrowatch.org ,
:

RPM Red Hat Package Manager. Red Hat, Fedora


, SUSE .
( .rpm),
( .src.rpm , , .srpm).

Debian. Debian
, Ubuntu.
. .deb.

Gentoo.

.
(,
).
.

, SlackWare .

tar.

ArchLinux.
245

.
:

,
.

, ,
:

,
.

, ,
.

,
.

,
.

FHS ,
, :
/bin
/sbin
/lib
/usr/bin
/usr/sbin
/usr/lib
/usr/X11R6
/opt
/opt ,
( ). /usr/X11R6 ,
X Window.
,
, /usr/share/man,
/usr/share/doc.
,
, /usr/local.

246

, :
1. . , ,
SMTP (Simple Mail Transfer Protocol).
postfix , sendmail,
.
2. libc (glibc), , ,
, .
. , libc ,
GNU/Linux.
3. ,
.
4. .
(
) , ,
, .

/usr/local.

.

, , , .
, ,
:
1. .
2. .
3. README INSTALL.
4. .
5. .
6. .
,
DNS BIND (Berkeley Internet Names Daemon)
BIND 9.7.1.
FTP :
247

$wgethttp://www.isc.org/software/bind/971/download/bind971targz

wget
FTP .
(, , ).
:
$tarxzvfbind9.7.1.tar.gz
. bind
9.7.1. :
$cdbind9.7.1
$ls
acconfig.hconfig.threads.inHISTORYmake
aclocal.m4configureinstallshMakefile.in
binconfigure.iniscconfig.sh.1mkinstalldirs
bind.keyscontribiscconfig.sh.docbookREADME
CHANGESCOPYRIGHTiscconfig.sh.htmlutil
config.guessdociscconfig.sh.inversion
config.h.indocutillibwin32utils
config.h.win32FAQlibtool.m4
config.subFAQ.xmlltmain.sh

README INSTALL
.
. GNU/Linux
UNIX UNIX
make. , Makefile,
(target). , ,
make - .
, Makefile,
Makefile.in. , , -,
-, , -, ,
.
Makefile ,
, .
configure. - help.
(
, - ):
$./configurehelp|less
, ,
PATH.
- prefix.
248

.
- /usr/local
.
, , ,
, :
./configuredisablelargefilesdisableipv6
BIND disablelargefiles 64-
, disableipv6 IPv6.
Makefile
Makefile.in.
Makefile
make, . (targets)
. , , Makefile
all, all:.
make, ,
Makefile all.
$make
.
/usr/local ,
, .
su (
su). Makefile,
install.
$su
#makeinstall
/usr/local:
#ls/usr/local/sbin/
arpanamednsseckeygengenrandomnamedcheckconf
nsec3hashddnsconfgendnssecrevokeischmacfixup
namedcheckzonerndcdnssecdsfromkeydnssecsettime
lwresdnamedcompilezonerndcconfgendnsseckeyfromlabel
dnssecsignzonenamednamedjournalprint

,
. , , BIND:
#/usr/local/sbin/namedv
249

BIND9.7.1
BIND, v .
, ,
,
,
, , .

, , BIND
.

README.

BIND.

.

. ,
( ),
,
.

(linking).
:
1. (static library).
2. (shared library).
.a (archive),
- .so (shared object).
,
ar. ,
.
.

, ,
. ,
, ,
.

250

,
.
,
.
, ,
, . ,
,
. , ,
.
,
.
GNU/Linux gcc ,
C, .
,
Privet!. :
$catsimple.c
#include<stdio.h>
intmain()
{
printf("%s\n","Privet!");
return0;
}
printf(),
, .
. printf()
stdio.h.
:
$gccosimple.dynamicsimple.c
simple.dynamic
simple.c.
file :
$filesimple.dynamic
simple.dynamic:ELF32bitLSBexecutable,Intel80386,version1
(SYSV),forGNU/Linux2.6.9,dynamicallylinked(usesshared
libs),notstripped
, , ,
.
static
gcc:
251

$gccstaticsimple.cosimple.static
simple.static
:
$filesimple.static
simple.static:ELF32bitLSBexecutable,Intel80386,version1
(SYSV),forGNU/Linux2.6.9,staticallylinked,notstripped
:
$lslsimple.*
rwrr1useruser762823:04simple.c
rwxrxrx1useruser67932823:08simple.dynamic
rwxrxrx1useruser4858822823:08simple.static
, , ,
:
$./simple.static
Privet!
$./simple.dynamic
Privet!
: ,
? ldd:
$lddsimple.dynamic
linuxgate.so.1=>(0x00306000)
libc.so.6=>/lib/libc.so.6(0x00b1b000)
/lib/ldlinux.so.2(0x0014b000)
.
ldlinux (run-time linker).
, libc.so.6.
C, .
,
.
,
:
$ldd/bin/ls
linuxgate.so.1=>(0x00c7c000)
252

librt.so.1=>/lib/librt.so.1(0x00caa000)
libacl.so.1=>/lib/libacl.so.1(0x00200000)
libselinux.so.1=>/lib/libselinux.so.1(0x001b1000)
libc.so.6=>/lib/libc.so.6(0x00b1b000)
libpthread.so.0=>/lib/libpthread.so.0(0x00c91000)
/lib/ldlinux.so.2(0x0014b000)
libattr.so.1=>/lib/libattr.so.1(0x001f9000)
libdl.so.2=>/lib/libdl.so.2(0x00c8b000)
libsepol.so.1=>/lib/libsepol.so.1(0x00169000)
/bin/ls .
lib. ldd
,
, :
$lsl/lib/librt.so.1
lrwxrwxrwx1rootroot152314:04/lib/librt.so.1>librt2.10.1.so

librt.so.1, ,
librt2.10.1.so.
, , SO
name ( soname) .
. ,
SOname .
. , , SO
namelibrt.so.1 librt
2.10.1.so. ,
.
,
( gcc l) lib. ,
, librt.so.1 rt.
, ,
.
/etc/ld.so.cache. :
$file/etc/ld.so.cache
/etc/ld.so.cache:data
ldconfig.
. ,
: /lib /usr/lib,
, /etc/ld.so.conf:
$cat/etc/ld.so.conf
/usr/X11R6/lib/Xaw3d
/usr/X11R6/lib
253

/usr/lib/Xaw3d
/usr/local/lib
include/etc/ld.so.conf.d/*.conf
,
ldconfig.

, BIND
/usr/local/sbin/named, .

, SOname
.

-
(. /usr/local)?

RPM.
Red Hat Linux RPM.
RPM ,
/bin/rpm.
RPM:

. q query.

, . V
verify.

. K
checksig.

. i install.

. U upgrade.

. F
freshen.

. e
erase.

( q) , ,
:
$rpmqbash
bash3.224.el5
RPM.
254

- bash.
.
qi
:
$rpmqibash
Name:bashRelocations:(notrelocatable)
Version:3.2Vendor:CentOS
Release:24.el5BuildDate:22200906:16:53
InstallDate:20201022:14:11BuildHost:builder16.centos.org
Group:SystemEnvironment/ShellsSourceRPM:bash3.224.el5.src.rpm
Size:5349546License:GPLv2+
Signature:DSA/SHA1,09200906:45:18,KeyIDa8a447dce8562897
URL:http://www.gnu.org/software/bash
Summary:GNUBourneAgainshell(bash),3.1.
Description:
TheGNUBourneAgainshell(Bash)isashellorcommandlanguage
interpreterthatiscompatiblewiththeBourneshell(sh).Bash
incorporatesusefulfeaturesfromtheKornshell(ksh)andtheCshell
(csh).Mostshscriptscanberunbybashwithoutmodification.This
package(bash)containsbashversion3.1,whichimprovesPOSIX
complianceoverpreviousversions.

qi ,
, ( Size), ,
( Group).
, , ql :
$rpmqlnc
/usr/bin/nc
/usr/share/doc/nc1.84
/usr/share/doc/nc1.84/README
/usr/share/doc/nc1.84/scripts
/usr/share/doc/nc1.84/scripts/README
/usr/share/doc/nc1.84/scripts/alta
/usr/share/doc/nc1.84/scripts/bsh
/usr/share/doc/nc1.84/scripts/dist.sh
/usr/share/doc/nc1.84/scripts/irc
/usr/share/doc/nc1.84/scripts/iscan
/usr/share/doc/nc1.84/scripts/ncp
/usr/share/doc/nc1.84/scripts/probe
/usr/share/doc/nc1.84/scripts/web
/usr/share/doc/nc1.84/scripts/webproxy
/usr/share/doc/nc1.84/scripts/webrelay
/usr/share/doc/nc1.84/scripts/websearch
/usr/share/man/man1/nc.1.gz

, nc.
,
, qc ,
qd ,
.
qa, ,
. ,
255

. , ,
ftp :
$rpmqaftp\*
ftp0.1735.el5
$rpmqaftp|grep^ftp
ftp0.1735.el5
rpm ,
, grep.
:
$rpmqf/usr/bin/passwd
passwd0.731
qf .

qp, (
.rpm ):
$rpmqip/media/CentOS_5.5_Final/CentOS/krb5server1.6.136.el5_4.1.i386.rpm
Name:krb5serverRelocations:(notrelocatable)
Version:1.6.1Vendor:CentOS
Release:36.el5_4.1BuildDate:13201005:22:53
InstallDate:(notinstalled)BuildHost:builder16.centos.org
Group:SystemEnvironment/DaemonsSourceRPM:krb51.6.1
36.el5_4.1.src.rpm
Size:1119471License:MIT,freely
distributable.
Signature:DSA/SHA1,13201005:50:08,KeyIDa8a447dce8562897
URL:http://web.mit.edu/kerberos/www/
Summary:Kerberos5.
Description:
Kerberos.krb5server
,Kerberos5.
Kerberos5,
().

qip rpm ,
.
V rpm
. , , initscripts:
$rpmVinitscripts
..5....Tc/etc/inittab
: 5 -
256

md5, T - .
K .
, ()
. gpglistkeys.
, .
.
.
:
#rpmimport/media/CentOS_5.5_Final/RPMGPGKEY*
gpgimport RPMGPG
KEY, .

:
#rpmK/media/CentOS_5.5_Final/CentOS/krb5server1.6.136.el5_4.1.i386.rpm
/media/CentOS_5.5_Final/CentOS/krb5server1.6.136.el5_4.1.i386.rpm:(sha1)dsa
sha1md5gpg
#rpmKv/media/CentOS_5.5_Final/CentOS/krb5server1.6.136.el5_4.1.i386.rpm
/media/CentOS_5.5_Final/CentOS/krb5server1.6.136.el5_4.1.i386.rpm:
V3DSAsignature:OK,keyIDe8562897
SHA1:OK(5f810ab4b3e346810907e41c5e81993ef13afe29)
MD5:OK(5951187fcb9fa10738cef22a3b848ad4)
V3DSAsignature:OK,keyIDe8562897

.
:

i - ;

U - ,
. ;

F - .
, .

rpm
(.rpm ).
. test :
$catrpm.txt
$rpmivtestkrb5server1.6.136.el5_4.1.i386.rpm
::
krb5libs=1.6.136.el5_4.1krb5server1.6.136.el5_4.1.i386

, Kerberos
krb5libs.
test .
257


. , , sendmail:
$rpmetestsendmail
::
/usr/sbin/sendmail()redhatlsb3.112.3.EL.el5.centos.i386
smtpdaemon()mdadm2.6.93.el5.i386
smtpdaemon()fetchmail6.3.61.1.el5_3.1.i386
smtpdaemon()mutt1.4.2.23.0.2.el5.i386
sendmail=8.13.88.el5()sendmailcf8.13.88.el5.i386

, ,
sendmail.
, , ,
. nodeps.

RPM , ,
.

, , ,
RPM.

,
RPM?

, quota.

,
( ).

test samba?


(progress bar) ?

YUM.

rpm ,
, , .
Red Hat YUM (YellowDog Updater Modified),
,
.
yum YUM,
,
( WEB ), .
,
. , ,
258

yumrepolist:
$yumrepolistall
Loadedplugins:fastestmirror
base2599/2599
repoidreponamestatus
addonsCentOS5Addonsenabled:0
baseCentOS5Baseenabled:2599
c5mediaCentOS5Mediadisabled
centosplusCentOS5Plusdisabled
contribCentOS5Contribdisabled
extrasCentOS5Extrasenabled:327
updatesCentOS5Updatesenabled:94
repolist:3020

,
yumgrouplist :
$yumgrouplist
Loadedplugins:fastestmirror
SettingupGroupProcess
InstalledGroups:
AdministrationTools
DNSNameServer
DialupNetworkingSupport
Editors
FTPServer
GNOMEDesktopEnvironment
GamesandEntertainment
GraphicalInternet
Graphics
Java
LegacyNetworkServer
MailServer
MySQLDatabase
NetworkServers
NewsServer
Office/Productivity
PrintingSupport
ServerConfigurationTools
SoundandVideo
SystemTools
TextbasedInternet
WebServer
WindowsFileServer
XWindowSystem
YumUtilities
AvailableGroups:
AuthoringandPublishing
Base
Beagle
ClusterStorage
Clustering
DevelopmentLibraries
DevelopmentTools
Emacs
EngineeringandScientific
FreeNXandNX
GNOMESoftwareDevelopment
Horde
JavaDevelopment

259

KDE(KDesktopEnvironment)
KDESoftwareDevelopment
KVM
LegacySoftwareDevelopment
LegacySoftwareSupport
Mono
OpenFabricsEnterpriseDistribution
PostgreSQLDatabase
Ruby
Tomboy
Virtualization
XSoftwareDevelopment
XFCE4.4
Done

yum
list.
$yumlistzsh
Loadedplugins:fastestmirror
AvailablePackages
zsh.i3864.2.63.el5
base
, yumsearch,
,
:
$catyum.txt
$yumsearchSASL
Loadedplugins:fastestmirror
==============================Matched:SASL===============================
postfix.i386:PostfixMailTransportAgent
cyrusimapd.i386:AhighperformancemailserverwithIMAP,POP3,NNTPand
:SIEVEsupport
cyrussasl.i386:TheCyrusSASLlibrary.
cyrussasldevel.i386:FilesneededfordevelopingapplicationswithCyrus
:SASL.
cyrussaslgssapi.i386:GSSAPIsupportforCyrusSASL.
cyrussaslldap.i386:LDAPauxpropsupportforCyrusSASL.
cyrussasllib.i386:Sharedlibrariesneededbyapplicationswhichuse
:CyrusSASL.
cyrussaslmd5.i386:CRAMMD5andDIGESTMD5supportforCyrusSASL.
cyrussaslntlm.i386:NTLMsupportforCyrusSASL.
cyrussaslplain.i386:PLAINandLOGINsupportforCyrusSASL.
cyrussaslsql.i386:SQLauxpropsupportforCyrusSASL.
gnucryptosasljdk1.4.i386:GnuCryptoSASLAPI
phppearAuthSASL.noarch:PEAR:AbstractionofvariousSASLmechanism
:responses
phppearNetSMTP.noarch:ProvidesanimplementationoftheSMTPprotocol

. ,
:
$yumdisablerepo=\*enablerepo=c5medialistzsh
Loadedplugins:fastestmirror

260

Loadingmirrorspeedsfromcachedhostfile
*c5media:
c5media|1.1kB00:00
c5media/primary|920kB00:00
c5media2599/2599
AvailablePackages
zsh.i3864.2.63.el5c5media

disablerepo=\* ,
enablerepo=c5media
.
yuminstall.
:
#yumdisablerepo=\*enablerepo=c5mediainstallzsh
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile
*c5media:
SettingupInstallProcess
ResolvingDependencies
>Runningtransactioncheck
>Packagezsh.i3860:4.2.63.el5settobeupdated
>FinishedDependencyResolution
DependenciesResolved
============================================================================
PackageArchVersionRepositorySize
============================================================================
Installing:
zshi3864.2.63.el5c5media1.7M

TransactionSummary
============================================================================
Install1Package(s)
Upgrade0Package(s)
Totaldownloadsize:1.7M
Isthisok[y/N]:y
DownloadingPackages:
Runningrpm_check_debug
RunningTransactionTest
FinishedTransactionTest
TransactionTestSucceeded
RunningTransaction
Installing:zsh1/1
Installed:
zsh.i3860:4.2.63.el5
Complete!

zsh .
yumgroupinstall :
#yumdisablerepo=\*enablerepo=c5mediagroupinstall'DevelopmentTools'
Loadedplugins:fastestmirror
Loadingmirrorspeedsfromcachedhostfile

261

*c5media:
SettingupGroupProcess
Checkingfornewreposformirrors
c5media/group|920kB00:00
Package1:make3.813.el5.i386alreadyinstalledandlatestversion
Package1:pkgconfig0.212.el5.i386alreadyinstalledandlatestversion
Packagegettext0.14.64.el5.i386alreadyinstalledandlatestversion
Packagebinutils2.17.50.0.614.el5.i386alreadyinstalledandlatestversion
Packagepythonldap2.2.02.1.i386alreadyinstalledandlatestversion
ResolvingDependencies
>Runningtransactioncheck
()
c5media/filelists|2.9MB00:00
>Packagepyspi.i3860:0.6.11.el5settobeupdated
>Packagesystemtapruntime.i3860:1.13.el5settobeupdated
>Packagexorgx11serverXvfb.i3860:1.1.148.76.el5settobeupdated
>Runningtransactioncheck
>Packageglibcheaders.i3860:2.549settobeupdated
>ProcessingDependency:kernelheaders>=2.2.1forpackage:glibcheaders
>ProcessingDependency:kernelheadersforpackage:glibcheaders
>Runningtransactioncheck
>Packagekernelheaders.i3860:2.6.18194.el5settobeupdated
>FinishedDependencyResolution
DependenciesResolved
============================================================================
PackageArchVersionRepositorySize
============================================================================
Installing:
autoconfnoarch2.5912c5media647k
automakenoarch1.9.62.3.el5c5media476k
automake14noarch1.4p613.el5.1c5media200k
()
TransactionSummary
============================================================================
Install49Package(s)
Upgrade0Package(s)
Totaldownloadsize:69M
Isthisok[y/N]:y
DownloadingPackages:

Total895MB/s|69MB00:00
Runningrpm_check_debug
RunningTransactionTest
FinishedTransactionTest
TransactionTestSucceeded
RunningTransaction
Installing:xorgx11serverXvfb1/49
Installing:libgomp2/49
()
systemtapruntime.i3860:1.13.el5
xorgx11serverXvfb.i3860:1.1.148.76.el5
Complete!

yumgroupinstall
'Development Tools' .
, .

262

, .
:
$yumenablerepo=centosplussearchreiserfs
Loadedplugins:fastestmirror
centosplus|1.9kB00:00
centosplus/primary_db|184kB00:01
============================Matched:reiserfs=============================
reiserfsutils.i386:,
:ReiserFS.

centosplus ,
CentOS, ReiserFS.

, .

xfsprogs XFS.

Debian.
Debian
CD/DVD-ROM ,
,
FTP- Debian.


.
Debian GNU/Linux
FTP Debian.
Debian:

stable .

unstable , .

frozen , .

Debian .
:

, Debian.

,
.

, .
263

, .

Debian
:

main - , Debian.
, -
, .

contrib - ( Debian).

nonfree - , Debian.

, ,
nonUS. nonUS main, contrib non
free.
:

required .

important - , UNIX .

standard .

optional X Window.

extra , ,
.

Debian
:

dselect - ,
.
.

aptitude - ,
. ,
,
.

tasksel - , ,
( tasks - ).

, ,
- , , Python.

dpkg -
.
(.deb ).

aptget -
.
, ,
( ).
264

dselect, aptitude tasksel


, dpkg aptget.
Debian,
, dpkg aptget.
dpkg aptget ,
Debian /var/lib/dpkg.
, .
dselect (
):

, .

dselect, ,
/var/lib/dpkg/status.
dselect ,
. . :

+ - .

= - .

: - .

- .

_ - .

i I .

v V .

o O .

EIOM:

E Error .

I Installed state - .

O Old mark .

M Mark .

E :

.
265

R . .

I , .

I :

* .

U , (unpacked).

C - (half-configured).

I - (half-installed).

O M :

* - ( O) / ( M).

- ( O) / ( M).

= - ( O) / (
M).

_ - ( O) /
( M).

n .

dpkg Debian.
dpkg:

I - .

f - .

c - , .

x - .

i - .


, , :
$dpkgfDownload/rootstrap_0.3.171_i386.debDependsRecommends
Version
Version:0.3.171
Depends:python,usermodelinux(>=2.4.204um1),debootstrap
(>=0.1.16.4),dpkg(>=1.9.19)
Recommends:umlutilities

266

dpkg r.
.
, P.
dpkgl .
,
, :
$dpkglmc
Desired=Unknown/Install/Remove/Purge/Hold
|Status=Not/Installed/Configfiles/Unpacked/Failedconfig/Halfinstalled
|/Err?=(none)/Hold/Reinstrequired/X=bothproblems(Status,Err:uppercase=bad)
||/NameVersion
+++====================================
====================================================
pnmc<none>(nodescriptionavailable)

$dpkglbash
Desired=Unknown/Install/Remove/Purge/Hold
|Status=Not/Installed/Configfiles/Unpacked/Failedconfig/Halfinstalled
|/Err?=(none)/Hold/Reinstrequired/X=bothproblems(Status,Err:uppercase=bad)
||/NameVersion
+++====================================
====================================================
iibash2.05b14TheGNUBourneAgainSHell

,
mc bash.
, p dpkg.
:
$dpkgpmc
Package:mc
Priority:optional
Section:utils
InstalledSize:5360
Maintainer:AdamByrtek<alpha@debian.org>
Architecture:i386
Version:1:4.6.04.6.1pre11
Replaces:mccommon,manpagespl(<=20030210)
Depends:libc6(>=2.3.2.ds14),libglib2.00(>=2.2.3),libgpmg1(>=1.19.61)
Suggests:perl,mimesupport
Conflicts:mccommon,suidmanager(<<0.52)
Filename:pool/main/m/mc/mc_4.6.04.6.1pre11_i386.deb
Size:1970746
MD5sum:578d4690f972aa6ae7851362fd331e5b
Description:MidnightCommanderapowerfulfilemanager
GNUMidnightCommanderisatextmodefullscreenfilemanager.It
usesatwopanelinterfaceandasubshellforcommandexecution.It
includesaninternaleditorwithsyntaxhighlightingandaninternal
viewerwithsupportforbinaryfiles.AlsoincludedisVirtual
Filesystem(VFS),thatallowsfilesonremotesystems(e.g.FTP
servers)andfilesinsidearchivestobemanipulatedlikerealfiles.

mc.
,
L dpkg:
267

$dpkgLinfo
/.
/usr
/usr/bin
/usr/bin/info
/usr/bin/infokey
/usr/share
/usr/share/info
/usr/share/info/info.info.gz
/usr/share/info/infostnd.info.gz
/usr/share/man
/usr/share/man/man1
/usr/share/man/man1/info.1.gz
/usr/share/man/man1/infokey.1.gz
/usr/share/man/man5
/usr/share/man/man5/info.5.gz
/usr/share/doc
/usr/share/doc/info
/usr/share/doc/info/copyright
/usr/share/doc/info/changelog.gz
/usr/share/doc/info/changelog.Debian.gz
/usr/lib
/usr/lib/menu
/usr/lib/menu/info
, info.
, .
dpkg ,
. S:
$dpkgS/etc/bash.bashrc
bash:/etc/bash.bashrc
/etc/bash.bashrc bash.
dpkg, aptget .
, dpkg, aptget ,
( CD/DVD-ROM, FTP ..).
, , aptget,
, .
, .
aptgetupdate.
/etc/apt/sources.list .
:
debcdrom:[DebianGNU/Linuxtesting_Sarge_OfficialSnapshot
268

i386Binary1(20040410)]/unstablecontribmain
debhttp://security.debian.org/stable/updatesmaincontrib
- CD ,
- , .
(, CD-ROM), ,
/etc/apt/sources.list .
CD Debian,
aptcdromadd.
. netselect
. netselect
, .
aptget
aptgetinstall:
#aptgetinstalllynx
ReadingPackageLists...Done
BuildingDependencyTree...Done
ThefollowingNEWpackageswillbeinstalled:
lynx
0upgraded,1newlyinstalled,0toremoveand0notupgraded.
Needtoget0B/1855kBofarchives.
Afterunpacking4694kBofadditionaldiskspacewillbeused.
MediaChange:Pleaseinsertthedisclabeled
'DebianGNU/Linuxtesting_Sarge_OfficialSnapshoti386
Binary1(20040410)'
inthedrive'/cdrom/'andpressenter
Selectingpreviouslydeselectedpackagelynx.
(Readingdatabase...101279filesanddirectoriescurrently
installed.)
Unpackinglynx(from.../l/lynx/lynx_2.8.51_i386.deb)...
Settinguplynx(2.8.51)...
CD , apt
get
.
aptget:

check .

update - .

upgrade .

dselectupgrade status
.

distupgrade upgrade,
.
269

install .

remove .

clean /var/cache/apt/archives
/var/cache/apt/archives/partial, , ,
Debian , ,
, FTP-.

source - .

aptget:

d aptget , .

s ,
, , .

y , ,
aptget .

u .

aptcdrom .

aptget netselect.

, FTP Debian
.

270

19..

x86/64
:


. ,
,
, .
,
.
/,
:

IRQ ;

IO/Base /;

DMA .

(IRQ)
/, .

(interrupt
handler).
, ,
/proc/interrupts.
$cat/proc/interrupts
CPU0
0:223980XTPICtimer
1:118XTPICi8042
2:0XTPICcascade
5:1XTPICIntel82801AAICH
6:4XTPICfloppy
8:1XTPICrtc
9:35XTPICacpi,eth1
10:28XTPICehci_hcd:usb1,eth0
11:0XTPICohci_hcd:usb2
12:552XTPICi8042
14:10948XTPICide0
15:636XTPICide1
NMI:0
LOC:224056

271

ERR:0
MIS:0

, ,
, .
/, . .
. / IO/Base
/ .
/ .
/ /proc/ioports.
$cat/proc/ioports
0000001f:dma1
00200021:pic1
00400043:timer0
00500053:timer1
00600060:keyboard
00640064:keyboard
00700077:rtc
0080008f:dmapagereg
00a000a1:pic2
00c000df:dma2
00f000ff:fpu
01700177:ide1
01f001f7:ide0
03760376:ide1
03c003df:vga+
03f203f5:floppy
03f603f6:ide0
03f703f7:floppyDIR
0cf80cff:PCIconf1
40004003:ACPIPM1a_EVT_BLK
40044005:ACPIPM1a_CNT_BLK
4008400b:ACPIPM_TMR
40204021:ACPIGPE0_BLK
d000d00f:0000:00:01.1
d000d007:ide0
d008d00f:ide1
d020d03f:0000:00:03.0
d020d03f:pcnet32_probe_pci
d040d05f:0000:00:04.0
d100d1ff:0000:00:05.0
d100d1ff:Intel82801AAICH
d200d23f:0000:00:05.0
d200d23f:Intel82801AAICH

272

d240d25f:0000:00:08.0
d240d25f:pcnet32_probe_pci

- /
0x320?

Linux . Linux

. ,
" ".
,
Linux. .
.
/lib/modules/<>. /lib/modules
, .
, unamer .
$unamer
2.6.18194.3.1.el5
$catuname.txt
$lsF/lib/modules/
2.6.18194.3.1.el5/2.6.18194.el5/
$lsF/lib/modules/`unamer`
build@modules.depmodules.pcimapupdates/
extra/modules.ieee1394mapmodules.seriomapweakupdates/
kernel/modules.inputmapmodules.symbols
modules.aliasmodules.isapnpmapmodules.usbmap
modules.ccwmapmodules.ofmapsource@

kernel/.
$lsF/lib/modules/`unamer`/kernel
arch/crypto/drivers/fs/lib/net/sound/

273

2.6 kernel/ :

arch , ;

crypto ;

drivers ;

fs ;

lib , ;

net ;

sound .

, ,
/sbin/lsmod,
/proc/modules.
$/sbin/lsmod
ModuleSizeUsedby
nls_utf862081
autofs4292533
hidp231052
rfcomm424570
l2cap2950510hidp,rfcomm
bluetooth539255hidp,rfcomm,l2cap
lockd633370
sunrpc1466852lockd
()
ata_piix236210
libata1573171ata_piix
sd_mod252810
scsi_mod1419733scsi_dh,libata,sd_mod
ext31255132
jbd573211ext3
uhci_hcd254210
ohci_hcd250650
ehci_hcd338690

/sbin/modinfo.
$/sbin/modinfoext3
filename:/lib/modules/2.6.18194.3.1.el5/kernel/fs/ext3/ext3.ko
license:GPL
description:SecondExtendedFilesystemwithjournalingextensions
author:RemyCard,StephenTweedie,AndrewMorton,AndreasDilger,TheodoreTs'o
andothers

274

srcversion:4892892BC4F1C4BCF3E12BD
depends:jbd
vermagic:2.6.18194.3.1.el5SMPmod_unload686REGPARM4KSTACKSgcc4.1
module_sig:
883f3504bec39acbce1b286452b236112832e09f4afeea62d9d3ccc988a540b9c5221d69bde5682d09e386ec8
a19dac3e94c2cab04261ceaba7dccfb66

Linux
/sbin/insmod. .
insmod .
rmmod.
#ls/lib/modules/`unamer`/kernel/drivers/net/b44.ko
/lib/modules/2.6.18194.3.1.el5/kernel/drivers/net/b44.ko
#insmod/lib/modules/`unamer`/kernel/drivers/net/b44.ko
#lsmod|grepb44
b44290050
mii94092b44,pcnet32
#rmmodb44
#lsmod|grepb44

insmod b44.ko.
lsmod , mii, ,
. , b44 rmmod.
,
. ,
(/lib/modules/`unamer`), modules.dep
. modules.dep
/sbin/depmod.
insmod rmmod modprobe,
.
modules.dep ,
, .
.
#modinfoext4
filename:/lib/modules/2.6.18194.3.1.el5/kernel/fs/ext4/ext4.ko
license:GPL
description:FourthExtendedFilesystem

275

author:RemyCard,StephenTweedie,AndrewMorton,AndreasDilger,TheodoreTs'o
andothers
alias:ext4dev
srcversion:1F50CCEEA72207658D97CD5
depends:jbd2,crc16
vermagic:2.6.18194.3.1.el5SMPmod_unload686REGPARM4KSTACKSgcc4.1
parm:default_mb_history_length:Defaultnumberofentriessavedformb_history
(int)
module_sig:
883f3504bec39aabce1b286452b23611247909f43f02b12a5be1eef4ecd9b193818ba6a675edf909e2cc6ae53
bcc483ac7cbcab8fe64e38a13799f6
#modprobevext4
insmod/lib/modules/2.6.18194.3.1.el5/kernel/lib/crc16.ko
insmod/lib/modules/2.6.18194.3.1.el5/kernel/fs/jbd2/jbd2.ko
insmod/lib/modules/2.6.18194.3.1.el5/kernel/fs/ext4/ext4.ko

ext4.ko, ,
modprobe.
modprobe , r
, .
#modprobevrext4
rmmod/lib/modules/2.6.18194.3.1.el5/kernel/fs/ext4/ext4.ko
rmmod/lib/modules/2.6.18194.3.1.el5/kernel/fs/jbd2/jbd2.ko
rmmod/lib/modules/2.6.18194.3.1.el5/kernel/lib/crc16.ko

, ,
modprober .
modprobe ,
.
l. ,
.
#modprobele100\*
/lib/modules/2.6.18194.3.1.el5/kernel/drivers/net/e100.ko
/lib/modules/2.6.18194.3.1.el5/kernel/drivers/net/e1000/e1000.ko
/lib/modules/2.6.18194.3.1.el5/kernel/drivers/net/e1000e/e1000e.ko

a modprobe
, .
,
modprobe.

276

#modprobee1000speed=100

modprobe /etc/modprobe.conf.
, .
,
. ,
.
/etc/modprobe.conf .
aliaseth0e1000
optionse1000Speed=100
/etc/modprobe.conf , Ethernet- eth0
e1000. Intel Gigabit Ethernet, 100 /,
options.

, .

modinfo ?

, e1000.

e1000 .

e1000?

udev.
GNU/Linux .
: .
lsl : .
, ,
, .
$catdev.txt
brwr1rootdisk3,062010/dev/hda
brwr1rootdisk3,1614:30/dev/hda1
brwr1rootdisk3,262010/dev/hda2
brw1aberesdisk22,0614:30/dev/hdc
mknod
/dev.
, .
277

,
:

/dev (, Fedora
1 /dev 1800 !);

(hot-pluggable devices),
, USB.

,
/dev . UNIX-
devfs.
: , (
). ,
.
: , devfs,
,
. , USB-
/dev/sdb, /dev/sdc, ?
2.6.13 udev
devfs, ""
(rules).
Linux sysfs, /sys.
, udev
/dev.
udev :

udevd , udev;

udevcontrol udev;

udevinfo ;

ata_id, edd_id, scsi_id vold_id


;

udevmonitor ;

udevtest udev.

/dev
. /dev
/lib/udev/devices.
udev /etc/udev.
(rules), .
, , uevent
udevd,
/etc/udev/rules.d/*.rules .
MODALIAS.

. depmod
modules.alias .
278

modules.alias
, udev.
/dev ,
udev. udev
/sys uevent,
udev.
, udev,
udevinfo.
$udevinfon/dev/hdcqall
P:/block/hdc
N:hdc
S:cdrom
S:cdromhdc
S:dvd
S:dvdhdc
S:disk/byid/ataVBOX_CDROM_VB201700376
S:disk/bypath/pci0000:00:01.1ide1:0
E:ID_TYPE=cd
E:ID_MODEL=VBOX_CDROM
E:ID_SERIAL=VB201700376
E:ID_REVISION=1.0
E:ID_BUS=ata
E:ID_PATH=pci0000:00:01.1ide1:0

n udevinfo
, qall udev .
P:/block/hdc
sysfs.
$find/sysname\*block\*hdcls
30220lrwxrwxrwx1rootroot0616:52
/sys/devices/pci0000:00/0000:00:01.1/ide1/1.0/block:hdc>../../../../../block/hdc
$lsl/sys/block/hdc
0
rrr1rootroot4096616:57dev
lrwxrwxrwx1rootroot0616:57device>
../../devices/pci0000:00/0000:00:01.1/ide1/1.0
drwxrxrx2rootroot0614:30holders
drwxrxrx3rootroot0614:30queue
rrr1rootroot4096616:57range
rrr1rootroot4096616:57removable
rrr1rootroot4096616:57size
drwxrxrx2rootroot0614:30slaves

279

rrr1rootroot4096616:57stat
lrwxrwxrwx1rootroot0616:57subsystem>../../block
w1rootroot4096616:57uevent

uevent,
. udevadmmonitor.
#udevadmmonitorenv
monitorwillprintthereceivedeventsfor:
UDEVtheeventwhichudevsendsoutafterruleprocessing
KERNELthekerneluevent
KERNEL[1263115065.575286]add/devices/pci0000:00/0000:00:1d.7/usb2/22(usb)
UDEV_LOG=3
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/22

udev
USB .
, ,
dmesg.
#dmesg
[137937.482077]usb22:newhighspeedUSBdeviceusingehci_hcdandaddress5
...
[137939.043375]sd8:0:0:0:[sdb]AttachedSCSIremovabledisk

,
dmesg USB .

, udev.

udevinfo .

PCI.
PCI , ,
lspci.
$/sbin/lspci
00:00.0Hostbridge:IntelCorporation440FX82441FXPMC[Natoma](rev02)
00:01.0ISAbridge:IntelCorporation82371SBPIIX3ISA[Natoma/TritonII]

280

00:01.1IDEinterface:IntelCorporation82371AB/EB/MBPIIX4IDE(rev01)
00:02.0VGAcontroller:InnoTekSystemberatungGmbHVirtualBoxGraphicsAdapter
00:03.0Ethernetcontroller:AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
00:04.0Systemperipheral:InnoTekSystemberatungGmbHVirtualBoxGuestService
00:05.0Multimediaaudiocontroller:IntelCorporation82801AAAC'97AudioController
00:06.0USBController:AppleComputerInc.KeyLargo/IntrepidUSB
00:07.0Bridge:IntelCorporation82371AB/EB/MBPIIX4ACPI(rev08)
00:08.0Ethernetcontroller:AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
00:0b.0USBController:IntelCorporation82801FB/FBM/FR/FW/FRWUSB2EHCIController

, , .
$/sbin/lspcis00:03.0v
00:03.0Ethernetcontroller:AdvancedMicroDevices[AMD]79c970[PCnet32LANCE](rev40)
Subsystem:AdvancedMicroDevices[AMD]PCnetFast79C971
Flags:busmaster,mediumdevsel,latency64,IRQ10
I/Oportsatd020[size=32]
Memoryatf0000000(32bit,nonprefetchable)[size=4K]
Memoryatf0080000(32bit,nonprefetchable)[size=512K]

PCI
lspci v ( ) s ( ).

PCI .

IRQ lspci.

SCSI.
SCSI , Small Computer Systems Interface
. SAS (Serial Attached SCSI)
. SCSI-
.
SCSI- :

SCSI- - .

SCSI - .

SCSI ID . SCSI -
SCSI ID 7.

, SCSI BIOS, SCSI-


SCSI ID.

SCSI SCSI BIOS,


.

SCSI-.
281

SCSI Linux 2.6 (.


/usr/src/linux/Documentation/scsi/scsi.txt).
, (user space),
:

sd SCSI , sd_mod.ko;

sr SCSI CD/DVD-, sr_mod.ko;

st , st.ko;

sg SCSI , sg.ko.

SCSI- scsi_mod.ko.

SCSI -,

/lib/modules/`unamer`/kernel/drivers/scsi/.

CD-RW-, ,
SCSI CD SCSI.

Ethernet.

/lib/modules/`unamer`/kernel/drivers/net/.
x86/64
Ethernet PCI.
.
#/sbin/modprobeve100

Intel EtherExpress100.
Ethernet Linux eth0
, eth1 . . Linux
/dev.
- ,
/etc/modprobe.conf.
aliaseth0e1000
optionse1000speed=100
Intel PRO/1000
282

100 /.

lspci, PCI Ethernet.

, ,
Ethernet. 100 ?

.
2.6 ALSA,
OSS.
ALSA ISA ISA PnP,
isapnptools .
ALSA
/proc asound/.
ALSA snd.ko,
ALSA. ALSA snd.
PCM OSS sndpcmoss.ko.
USB ALSA sndusbaudio.ko.
ALSA.
$/sbin/lsmod|grepsnd
snd_pcm_oss516160
snd_mixer_oss190721snd_pcm_oss
snd_seq647520
snd_seq_device86201snd_seq
snd_hda_codec_conexant342401
snd_hda_intel316802
snd_hda_codec946882snd_hda_codec_conexant,snd_hda_intel
snd_hwdep87081snd_hda_codec
snd_pcm963243snd_pcm_oss,snd_hda_intel,snd_hda_codec
snd_timer259602snd_seq,snd_pcm
snd7523614
snd_pcm_oss,snd_mixer_oss,snd_seq,snd_seq_device,snd_hda_codec_conexant,snd_hda_intel,snd
_hda_codec,snd_hwdep,snd_pcm,snd_timer
snd_page_alloc106002snd_hda_intel,snd_pcm

, , dmesg.
?
283

/var/log/messages.

ALSA .

USB.
USB- /proc/bus/usb.
lsusb USB .
#lsusb
Bus001Device001:ID1d6b:0002LinuxFoundation2.0roothub
Bus002Device001:ID1d6b:0002LinuxFoundation2.0roothub
Bus002Device005:ID13fe:1f23KingstonTechnologyCompanyInc.
Bus003Device001:ID1d6b:0001LinuxFoundation1.1roothub
Bus003Device002:ID147e:2016UpekBiometricTouchchip/TouchstripFingerprintSensor
Bus004Device001:ID1d6b:0001LinuxFoundation1.1roothub
Bus005Device001:ID1d6b:0001LinuxFoundation1.1roothub
Bus005Device004:ID045e:00e1MicrosoftCorp.WirelessLaserMouse6000Reciever
Bus006Device001:ID1d6b:0001LinuxFoundation1.1roothub
Bus007Device001:ID1d6b:0001LinuxFoundation1.1roothub

.
#lsusbd147e:2016v
Bus003Device002:ID147e:2016UpekBiometricFingerprintSensor
DeviceDescriptor:
bLength18
bDescriptorType1
bcdUSB1.00
...

, ,
( ). d USB .

USB-. , ,
USB .

USB ().

284

20.Linux.
Linux.
Linux
, .
, ,
. , ,
,
.

.
,
Linux, :

, , ;

, ;

- ;

- ;

, ;

GNU- make;

, , (patches);

2 ;

2.6 ,
.
, . , 2.4.22
, 2.5.59 .
2.6.11, Linux ,
.
, .
, ,
.
.
www.kernel.org, ftp.kernel.org
.

285

$wgetftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux2.6.32.tar.bz2
$wgetftp://ftp.kernel.org/pub/linux/kernel/v2.6/patch2.6.32.3.bz2
$tarxjflinux2.6.32.tar.bz2


. 2.6.32 2.6.32.3
$cdlinux2.6.32
$bzcat../patch2.6.32.3.bz2|patchp1
patchingfile...
$head4Makefile
VERSION=2
PATCHLEVEL=6
SUBLEVEL=32
EXTRAVERSION=.3

2.6.32 2.6.32.3,
2.6.32.3, Makefile.
:

,
, , , 2.6.32.3 2.6.32,
2.6.32.2;

,
, , 2.6.30 2.6.31, 2.6.32.

README.
2.6 .

makemrproper (
Vanilla sources ).
!
.config.
.
.

.config
.
:

makeoldconfig
;

makesilentoldconfig , , ;

makemenuconfig ;

makexconfig ;

makegconfig , Gtk;
286

. README.

make .

su .

makemodules_installinstall
. /lib/modules,
/boot. .

makeclean
, , .

/boot /lib/modules.

,
. .
, ,
- ,
, .
#makeC/lib/modules/`unamer`/buildM=`pwd`modules
#makeC/lib/modules/`unamer`/buildM=`pwd`clean
#makeC/lib/modules/`unamer`/buildM=`pwd`modules_install

, , ,
.
.

kernel.org..

Linux, .

Linux.

, /lib/modules
.

21.DNSDHCP.
TCP/IP.
2 1969 . DARPA (Defense Advanced Research Project Agency)
ARPANET .
ARPANET . 25 1969 .
.
ARPANET
- .
287

ARPANET 70- : ,
. .

TCP/IP. BSD UNIX
DARPA Bolt Bearnek and Newman Inc. (BBN).
TCP/IP , 1983 .
ARPANET TCP/IP.
, , ,
90- .
TCP/IP ,
- . TCP/IP
-, Ethernet Token Ring .
, OSI
(Open System Interconnection).
, .
OSI :
1. (applicationlayer).
,
.
2. (presentationlayer).
, ,
, .
3. (sessionlayer). ,
, ,
.
4. (transportlayer).
- . ,
.
5. (Networklayer).
, .
6. (DataLink).
.
7. (Physicallayer).
,
, .
TCP/IP OSI, ,
:
1. . TCP/IP , :
HTTP, FTP, SMTP, POP3 .
.
2. . TCP/IP :
TCP (TransmissionControlProtocol),
, , UDP (UserDatagramm
288

Protocol).
3. . IP (InternetProtocol).
, ,
.
4. . TCP/IP
, ARP (AddressResolutionProtocol) RARP (Reverse
ARP).
,

, . , , HTTP,
, IP MAC
Ethernet ARP.


. , ,
, ,
().
:
.
, TCP/IP,
Internet . RFC (Request For
Comments). , .
, IP RFC 791, ICMP - RFC 792, TCP - RFC
793, UDP - RFC 768. ,
RFC.
.
RFC IETF (Internet Engineering Task Force)
www.ietf.org, www.rfc.net www.rfc-editor.org.
DARPA /etc/protocols.
:
#AssignedInternetProtocolNumbers
#
#DecimalKeywordProtocolReferences
#
#protocolnumaliases#comments
hopopt0HOPOPT#IPv6HopbyHopOption[RFC1883]
icmp1ICMP#InternetControlMessage[RFC792]
igmp2IGMP#InternetGroupManagement[RFC1112]
ggp3GGP#GatewaytoGateway[RFC823]
ip4IP#IPinIP(encapsulation)[RFC2003]
st5ST#Stream[RFC1190,RFC1819]
tcp6TCP#TransmissionControl[RFC793]
cbt7CBT#CBT[Ballardie]
egp8EGP#ExteriorGatewayProtocol[RFC888,DLM1]
igp9IGP#anyprivateinteriorgateway[IANA]
#(usedbyCiscofortheirIGRP)
bbnrccmon10BBNRCCMON#BBNRCCMonitoring[SGC]
nvpii11NVPII#NetworkVoiceProtocol[RFC741,SC3]
pup12PUP#PUP[PUP,XEROX]
argus13ARGUS#ARGUS[RWS4]
emcon14EMCON#EMCON[BN7]

289

xnet15XNET#CrossNetDebugger[IEN158,JFH2]
chaos16CHAOS#Chaos[NC3]

TCP/IP IMAP,
?

TV
Internet (,
TV )?

OSI ICMP (Internet


ControlMessageProtocol). , ,
.

IPv4.
TCP/IP
IP. IP .
IP , ,
. IP
. ( ) ,
- ( ).
,
(), , ,
.
- IP
, IP
, .
: IPv4, IP
4 (. RFC 791), IPv6,
16 (. RFC 2373).
IPv4 IPv6
IPv4, TCP/IP
.
IPv4 ,
dotted-decimal . .
IPv4 , dotted-decimal :
192.168.111.253
IP ,
. ,
0 255.
, , 0,
290

. , 1,
(broadcast address).
IPv4
, :

A ,
.
0, A
0 127. , 128
A. 24 2^24-2 (
, ),
16777214 . A: 10.0.0.1 .

B IP .
10.
B - 128 191.
2^14=16384 B, 2^16-2=65534 .
B: 172.30.30.20 .

IP .
110.
C 192 223. 2^21=2097152
C, 2^8-2=254 . C:
192.168.200.2 .

D -
(multicast). ,
IP , IP
, multicast.
1110,
- 224 239. D: 224.0.0.9 .

E.

A, B, C D . , IPv4,
. , 1, IP
, . , 0 ,
. A, B, C D
:

- 255.0.0.0 .

B - 255.255.0.0 .

C - 255.255.255.0 .

D - 255.255.255.255 .

( )
IP . ,
192.168.111.253 255.255.255.0 ( C),
:

291

IP

192.168.111.253

11000000101010000110111111111101

255.255.255.0

11111111111111111111111100000000

192.168.111.0

11000000101010000110111100000000

, IP
. IP
IP .
( ),
IP ,
,
.
.
, .
, ,
(defaultgateway).
, (
Internet).
(default) IP
0.0.0.0 . ,
(defaultgateway).
127.0.0.1 , A 127.0.0.0 ,
(loopbackinterface).
,

, .
,
Internet, RFC 1918.
. ,
.
:

: 10.0.0.010.255.255.255. .

B: 172.16.0.0172.31.255.255. .

C: 192.168.0.0192.168.255.255 . .

IP 63.127.33.254?

?
292

Ethernet.
,
( ). :
$/sbin/lsmod|greppcnet32
pcnet32352690
mii94091pcnet32
, ifconfig, .
GNU/Linux . Ethernet
eth0 - , eth1 -
. WiFi wlan.
ifconfig :
#ifconfigeth1192.168.56.101
IP .
ifconfig :
$/sbin/ifconfigeth1
eth1Linkencap:EthernetHWaddr08:00:27:C2:BF:FA
inetaddr:192.168.56.101Bcast:192.168.56.255Mask:255.255.255.0
inet6addr:fe80::a00:27ff:fec2:bffa/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:36errors:0dropped:0overruns:0frame:0
TXpackets:72errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:1000
RXbytes:5775(5.6KiB)TXbytes:11539(11.2KiB)
Interrupt:9Baseaddress:0xd240

ifconfig ,
. , IP ,
, . ,
(IRQ I/O Base).
. MTU
(Maximum Transfer Unit).
Ethernet (MAC ),
. ifconfig HWaddr.
- HWaddr08:00:27:C2:BF:FA .
a ifconfig
.

293

-
, , , netstat
i :
$netstati
KernelInterfacetable
IfaceMTUMetRXOKRXERRRXDRPRXOVRTXOKTXERRTXDRPTXOVRFlg
eth015000179000181000BMRU
eth1150006000095000BMRU
lo16436022340002234000LRU

RXOK TXOK , , (received)


(transmitted) . RXERR TXERR
.
(
) ping,
ICMP (Internet Control Message Protocol)
:
$pingc4192.168.0.1
PING192.168.0.1(192.168.0.1)56(84)bytesofdata.
64bytesfrom192.168.0.1:icmp_seq=1ttl=63time=3.61ms
64bytesfrom192.168.0.1:icmp_seq=2ttl=63time=0.993ms
64bytesfrom192.168.0.1:icmp_seq=3ttl=63time=3.76ms
64bytesfrom192.168.0.1:icmp_seq=4ttl=63time=0.758ms
192.168.0.1pingstatistics
4packetstransmitted,4received,0%packetloss,time3009ms
rttmin/avg/max/mdev=0.758/2.284/3.769/1.412ms
c4 ping, ICMP.
ping
, .

ifconfig
.

ping,
. ?

ping GNU/Linux ICMP


. ICMP ?

294

.
IP
-, . ,
IP ,
.
- ,
. ,
, (
). , IP
(forwarding).
, IP
. , IP
, .
netstatrn :
$netstatrn
KernelIProutingtable
DestinationGatewayGenmaskFlagsMSSWindowirttIface
192.168.0.00.0.0.0255.255.255.0U000wlan0
192.168.56.00.0.0.0255.255.255.0U000vboxnet0
127.0.0.00.0.0.0255.0.0.0U000lo
0.0.0.0192.168.0.10.0.0.0UG000wlan0

r netstat , n
IP
. ,
, (WiFi - wlan0 vboxnet0 Oracle Virtual
Box). wlan0 IP
192.168.0.1.
IP MAC
ARP. . ARP
arpan :
$/sbin/arpan
?(192.168.0.1)at00:0f:3d:30:2a:53[ether]onwlan0
ARP IP 192.168.0.1 ,
MAC 00:0f:3d:30:2a:53.

routeadddefaultgw , :
#routeadddefaultgw192.168.0.1

:
295

$pingwww.assignpro.ru
PINGwww.assignpro.ru(79.172.25.50)56(84)bytesofdata.
64bytesfromblack.assignpro.ru(79.172.25.50):icmp_seq=1ttl=58time=6.35ms
64bytesfromblack.assignpro.ru(79.172.25.50):icmp_seq=2ttl=58time=6.99ms
64bytesfromblack.assignpro.ru(79.172.25.50):icmp_seq=3ttl=58time=7.38ms
64bytesfromblack.assignpro.ru(79.172.25.50):icmp_seq=4ttl=58time=9.47ms
^C
www.assignpro.rupingstatistics
4packetstransmitted,4received,0%packetloss,time3003ms
rttmin/avg/max/mdev=6.357/7.551/9.472/1.169ms

GNU/Linux traceroute,
IP
.
$/usr/sbin/traceroutewww.assignpro.ru
traceroutetowww.assignpro.ru(79.172.25.50),30hopsmax,40bytepacketsusingUDP
1192.168.0.1(192.168.0.1)1.148ms1.241ms1.055ms
2***
3217.76.183.97(217.76.183.97)10.470ms9.353ms8.198ms
4arkenstone.ural.net(82.193.130.1)3.795ms2.843ms3.884ms
5eastgatebbov6.ural.net(87.251.181.41)4.147ms6.161ms7.272ms
6graendalov158.ural.net(87.251.181.17)8.431ms8.729ms8.484ms
7black.assignpro.ru(79.172.25.50)989.968ms988.971ms987.877ms

UDP
, IP
. - UDP , ,
, .

route
.

ping,
.
IP , .


ping .

traceroute .

.
, GNU/Linux,
hostname.
$hostname
newnote.assignpro.ru
296

,
RHEL /etc/sysconfig/network.
(FQDN - Fully Qualified Domain Name).
, .
- newnote.
- DNS , .
newnote
assignpro.ru. , newnote.assignpro.ru - .
.
IP .
,
IP . : IP
.
,
resolver.
:

/etc/hosts.
.

DNS (Domane Name Service).


Internet.

NIS, NIS+, LDAP .


.

IP -
. ,
/etc/hosts.
IP :
$cat/etc/hosts
127.0.0.1 localhost
192.168.1.1
mycomp.mynet.net
192.168.1.2
hercomp.mynet.net
192.168.2.1
mycomp.hernet.net

mycomp
hercomp

IP , resolver
:
$pingc3mycomp
PINGmycomp(192.168.1.1)56(84)bytesofdata.
64bytesfrommycomp(192.168.1.1):icmp_seq=1ttl=64time=0.245ms
64bytesfrommycomp(192.168.1.1):icmp_seq=2ttl=64time=0.091ms
64bytesfrommycomp(192.168.1.1):icmp_seq=3ttl=64time=0.088ms
192.168.1.1pingstatistics
3packetstransmitted,3received,0%packetloss,time1998ms
rttmin/avg/max/mdev=0.088/0.141/0.245/0.073ms

297

IP
/etc/networks. :
localnet 127.0.0
domanet
166.92.11
barbarize 200.19.1
resolver /etc/resolver.conf.
$cat/etc/resolv.conf
nameserver192.168.1.254
domainmydom.com
searchmydom.com,mydom.net
nameserver IP DNS , .
domain , .
- search ,
.
, IP
/etc/hosts,
DNS , IP /etc/resolv.conf.
,
resolver - /etc/host.conf /etc/nsswitch.conf. resolver
:
/etc/hosts DNS. /etc/host.conf
:
orderhost,bind
multion
resolver:
/etc/hosts, - DNS.
multion resolver , IP
.
/etc/nsswitch.conf (Name Service Switch)
resolver .
, , , NIS
NIS,
. ,
- .
/etc/nsswitch.conf
:

aliases sendmail.
298

ethers MAC Ethernet .

group .

hosts .

netgroup NIS.

network .

passwd .

protocols , .

publickey .

rpc (RPC - Remote


Procedure Call).

services .

shadow .


/etc/nsswitch.conf:
hosts:filesdns
networks:filesdns
:
/etc/hosts, - DNS. :
/etc/network, DNS.

/etc/hosts
ping, .

DNS /etc/resolv.conf.
ping .
?

RedHat.
RHEL, Fedora
- setup, . ,
( ).
1 .
,
systemconfignetwork. ,
.
2 .
299

1.
setup

2.
system-config-network

,
DHCP, 3.

3.
DHCP

300

4 , .

4.

DNS systemconfignetwork.
5.

5.
DNS

systemconfignetwork
/etc/sysconfig. DNS
/etc/sysconfig/network, .
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=c55.class.edu
/etc/sysconfig/network
scripts/ifcfgeth0 , DHCP .

301

$catifcfgeth0
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth0
BOOTPROTO=dhcp
HWADDR=08:00:27:59:74:11
ONBOOT=yes
TYPE=Ethernet
:
$catifcfgeth1
#AdvancedMicroDevices[AMD]79c970[PCnet32LANCE]
DEVICE=eth1
BOOTPROTO=none
ONBOOT=yes
HWADDR=08:00:27:c2:bf:fa
NETMASK=255.255.255.0
IPADDR=192.168.56.101
GATEWAY=192.168.56.1
TYPE=Ethernet

, .

/etc/init.d , .

.

.
:

/
( , , , ..).

IP .

ARP.

IP .

IP DNS IP
/etc/hosts.

IP .



302

. , ,
, ,
.

() ,
(link).
, . ,
, ,
,
.
PCI ,
/sbin/lspci.
$/sbin/lspci|grepieth
04:00.0Ethernetcontroller:BroadcomCorporationNetLinkBCM5787M
GigabitEthernetPCIExpress(rev02)
Ethernet ,
/sbin/lspci.

/sbin/lsmod.
, ,
, ,
.config . ,
/sbin/modinfo.
$/sbin/lsmod|greptg3
tg31162920
$/sbin/modinfodtg3
BroadcomTigon3ethernetdriver
, tg3
Broadcom Tigon3.
, ifconfig netstatrn,
IP .
ICMP ping
:
1. ping
127.0.0.1.
2. ping,
IP , .
3. , ping ICMP
.
.
303

4.
.
.
5. ICMP IP .
6.
resolver, ping .
#ifconfigeth0
eth0Linkencap:EthernetHWaddr00:03:0D:10:DD:C7
inetaddr:192.168.1.111Bcast:192.168.1.255Mask:255.255.255.0
inet6addr:fe80::203:dff:fe10:ddc7/64Scope:Link
UPBROADCASTRUNNINGMULTICASTMTU:1500Metric:1
RXpackets:0errors:0dropped:0overruns:0frame:0
TXpackets:10errors:0dropped:0overruns:0carrier:0
collisions:0txqueuelen:100
RXbytes:0(0.0b)TXbytes:756(756.0b)
Interrupt:20Baseaddress:0xcf00

#netstatrn
KernelIProutingtable
DestinationGatewayGenmaskFlagsMSSWindowirttIface
192.168.1.00.0.0.0255.255.255.0U000eth0
127.0.0.0127.0.0.1255.0.0.0UG000lo
0.0.0.0192.168.1.10.0.0.0UG000eth0

#pingc2192.168.1.1
PING192.168.1.1(192.168.1.1)56(84)bytesofdata.
64bytesfrom192.168.1.1:icmp_seq=1ttl=64time=0.257ms
64bytesfrom192.168.1.1:icmp_seq=2ttl=64time=0.090ms
192.168.1.1pingstatistics
2packetstransmitted,2received,0%packetloss,time999ms
rttmin/avg/max/mdev=0.090/0.173/0.257/0.084ms
#pingc2work
PINGwork(192.168.1.1)56(84)bytesofdata.
64bytesfromwork(192.168.1.1):icmp_seq=1ttl=64time=0.101ms
64bytesfromwork(192.168.1.1):icmp_seq=2ttl=64time=0.094ms
workpingstatistics
2packetstransmitted,2received,0%packetloss,time1004ms
rttmin/avg/max/mdev=0.094/0.097/0.101/0.010ms
IP ,
, ICMP resolver
.
ping - IP ,
ICMP , , , ,
ARP (Address Resolution Protocol). ARP
arpa :

304

#arpa
work(192.168.1.1)at00:0C:6E:1F:E8:FA[ether]oneth0
ARP IP MAC
, , arpa
.
arpd<>.
ICMP ( IP)
/ .
IP ,
2.4 , iptablesL :
#iptablesL
ChainINPUT(policyACCEPT)
targetprotoptsourcedestination
ChainFORWARD(policyACCEPT)
targetprotoptsourcedestination
ChainOUTPUT(policyACCEPT)
targetprotoptsourcedestination
L iptables
: (INPUT), (OUTPUT)
(FORWARD). -
. , ,
,
ACCEPT. ,
, .
DROP, , , .
ICMP , ping,
IP ,
, resolver . IP
DNS /etc/resolv.conf IP
/etc/hosts.
: host, dig nslookup,
DNS. ,
DNS, resolver - host.
host IP ,
, DNS, /etc/resolv.conf :
$hostwww.mail.ru
www.mail.ruhasaddress217.69.128.41
www.mail.ruhasaddress217.69.128.42
www.mail.ruhasaddress217.69.128.43
www.mail.ruhasaddress217.69.128.44
www.mail.ruhasaddress217.69.128.45
305

host DNS IP ,
. ,
IP .
host , DNS,
resolver /etc/resolv.conf, -
DNS. DNS
host. a
:
$hostawww.neiva.ru
Trying"www.neiva.ru"
;;>>HEADER<<opcode:QUERY,status:NOERROR,id:30029
;;flags:qrrdra;QUERY:1,ANSWER:1,AUTHORITY:0,ADDITIONAL:
1
;;QUESTIONSECTION:
;www.neiva.ru.

IN

ANY

;;ANSWERSECTION:
www.neiva.ru.
86399

IN

CNAME

;;ADDITIONALSECTION:
neiva.ru.
86399
IN

194.226.156.42

neiva.ru.

- DNS
whois,
Internet.
$whoisusi.ru
%BysubmittingaquerytoRIPN'sWhoisService
%youagreetoabidebythefollowingtermsofuse:
%http://www.ripn.net/about/servpol.html#3.2(inRussian)
%http://www.ripn.net/about/en/servpol.html#3.2(inEnglish).
domain:USI.RU
nserver:base.permonline.ru.
nserver:ns2.permonline.ru.
state:REGISTERED,DELEGATED,UNVERIFIED
org:JSC"Uralsviazinform"
phone:+73433762000
faxno:+73433768171
email:noc@gd.usi.ru
email:radiusmaster@permonline.ru
registrar:RUCENTERREGRIPN
created:1999.06.22
paidtill:2010.07.01
source:TCI
Lastupdatedon2010.06.0921:23:42MSK/MSD
306

# , IP DNS
/etc/resolv.conf. host ,
IP .

host, IP DNS
.

whois
. ?
.

22..
.
, Internet,
-. : .
,
.
(Application
Layer).
, - ,
,
0 65535 ( ). IANA (Internet Assigned
Numbers Authority).
1024
(Well Known Services). :

53 DNS;

20 , FTP;

21 FTP;

80 HTTP;

143 IMAP;

110 POP3;

25 SMTP;

139 NetBIOS;

119 NNTP;

161 SNMP;

22 - SSH;
307

23 Telnet.

/etc/services,
.
$sedn'20,30p'/etc/services
daytime13/udp
netstat15/tcp
qotd17/tcpquote
msp18/tcp#messagesend
protocol
msp18/udp#messagesend
protocol
chargen19/tcpttytstsource
chargen19/udpttytstsource
ftpdata20/tcp
ftp21/tcp
fsp21/udpfspd
ssh22/tcp#SSHRemoteLogin
Protocol
, 1024, .
, ,
.
1024 65535 ,
-
.

(socket). , netstat.
, ,
, a netstat.
TCP UDP , ,
, t u. , , TCP :
$netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:6000*:*LISTEN
tcp00*:ssh*:*LISTEN

, TCP.
6000 X Window.
SSH (Secure Shell).
LISTEN.
, ESTABLISHED:
#netstatta
308

ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:6000*:*LISTEN
tcp00sinix.netburg.:32771work:sshESTABLISHED
tcp00*:ssh*:*LISTEN

, , (
- ssh), , 32771,
, 22 ( ssh) ,
. , netstattan ( n
) ,
:
$netstattan
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp000.0.0.0:5150.0.0.0:*LISTEN
tcp000.0.0.0:370.0.0.0:*LISTEN
tcp00127.0.0.1:9020.0.0.0:*LISTEN
tcp00192.168.1.1:530.0.0.0:*LISTEN
tcp00127.0.0.1:530.0.0.0:*LISTEN
tcp00127.0.0.1:250.0.0.0:*LISTEN
tcp00127.0.0.1:9530.0.0.0:*LISTEN
tcp00192.168.1.1:22192.168.1.:32771ESTABLISHED

, ,
,
. , 6000, X Window,
.

8080TCP?

netstata.
?

- unixsockets /tmp?

UDP.

PID , ?

.
Linux :

, ,

/etc/init.d . (stand-alone).

inetd ( xinetd),
/etc/inetd.conf (/etc/xinetd.conf)
309

.
(stand-alone)
, .
.
, , ,
, . ,
,
.
.

:

start - ;

stop - ;

restart - .

SSH:
#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:6000*:*LISTEN

#/etc/init.d/sshdstart
*Startingsshd...

[ok]

#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:6000*:*LISTEN
tcp00*:ssh*:*LISTEN

#psef|grepssh
root250521115:27?00:00:00/usr/sbin/sshd
root2505625007015:27pts/100:00:00grepssh

/etc/init.d/sshdstart SSH sshd,


.

TCP UDP .

p netstat PID ,
. ?

310

inetdtcpd.
inetd ,
/etc/inetd.conf. ,
.
inetd - /etc/inetd.conf :
#ServiceSocketProtocolFlagsUserPathArgs
telnetstreamtcpnowaitroot/usr/sbin/tcpdin.telnetd
swatstreamtcpnowaitroot/usr/sbin/tcpdswat
imapstreamtcpnowaitroot/usr/sbin/tcpdimapd
pop3streamtcpnowaitroot/usr/sbin/tcpdipop3d
#shellstreamtcpnowaitroot/usr/sbin/tcpdin.rshd
#loginstreamtcpnowaitroot/usr/sbin/tcpdin.rlogind
#execstreamtcpnowaitroot/usr/sbin/tcpdin.rexecd
#pop2streamtcpnowaitroot/usr/sbin/tcpdipop2d
#talkdgramudpwaitnobody/usr/sbin/tcpdin.talkd
#ntalkdgramudpwaitnobody/usr/sbin/tcpdin.ntalkd

, inetd
/etc/inetd.conf. :
1. Service /etc/services.
2. Socket .
: stream TCP,
dgram UDP. raw, rdm
seqpacket.
3. Protocol , .
TCP, UDP RAW. , SUN-RPC (Remote Procedure
Call), /etc/rpc, : rpc/tcp
rpc/udp.
4. Flags dgram.
wait, nowait.
nowait. , dgram
,
nowait. (multi-treated).
(single-treated),
wait.
5. User UID , .
6. Path . Linux
tcpd (tcp wrapper).
7. Arguments , tcpd.
- ,
.
, , , , inted
tcpd telnet,
in.telnetd.
TCP, - stream.
311

telnetstreamtcpnowaitroot/usr/sbin/tcpdin.telnetd

/etc/inetd.conf
. , inetd

/etc/inetd.conf, SIGHUP
(-1) , . :
killall1inetd
,
inetd #
/etc/inetd.conf .

, inetd.

inetd telnet.

tcpd.
tcpd (TCP Wrapper) IP ,
IP , ,
inetd.
tcpd :

/etc/hosts.allow - ;

/etc/hosts.deny - .

:
1. /etc/hosts.allow -
, .
2. ,
/etc/hosts.deny. .
3. .
/etc/hosts.allow /etc/hosts.deny:
:

312

,
:

ALL .

EXCEPT .

KNOWN , IP
.

LOCAL .

PARANOID , IP
( IP ).

UNKNOWN , . ,
IP . ,
.

tcpd:
cat/etc/hosts.deny
ALL:mail.yahoo.com,.badspammers.org
ALLEXCEPTin.telnet:comp1.smallnet.ru,.rcpmk.ru
swat:ALLEXCEPTLOCAL
, mail.yahoo.com
badspammers.org. telnet comp1.smallnet.ru
rcmpk.ru. SMB Samba swat
, .
/etc/hosts.allow
/etc/hosts.deny , ,
tcpdchk:
$/usr/sbin/tcpdchk
warning:/etc/hosts.deny,line2:in.telnet:nosuchprocessnamein
/etc/inetd.conf

tcpdchk , in.telnet .
/etc/hosts.deny - :
in.telnetd.
tcpdmatch,
tcpd inetd.
.

313

/etc/hosts.deny ,
telnet, /etc/hosts.allow.
tcpdchk.

/etc/hosts.deny.
?

telnet ,
IP DNS?

xinetd.
GNU/Linux inetd
xinetd (extended Internet services daemon),
, inetd .
inetd, xinetd (multitreated), , (singletreated),
( UDP).
xinetd inetd
. xinetd
/etc/services.
xinetd :

, .

xinetd ,
:

, .

,
.

xinetd DoS , :


. ,
.

,
314

.
xinetd , :

xinetd
;

, xinetd,
;

xinetd inetd ,
RPC inetd.

xinetd
/etc/xinetd.conf. /etc/inetd.conf
/etc/xinetd.conf :
#itox</etc/inetd.conf>/etc/xinetd.conf
xinetd:
service<>
{
<><><><>...
...
}
<> :

= - ;

= - ;

=+ - .

/etc/xinetd.conf ,
. :
defaults
{
log_type=SYSLOGauthpriv
log_on_success=PIDHOST
log_on_failure=HOST
instances=25
per_source=5
only_from=127.0.0.1
}
315

includedir/etc/xinetd.d
: includedir

/etc/xinetd.d.
log_type .
syslog,
authpriv. (log_on_success)

, . (log_on_failure)
.
instances
, per_source
.
only_from=127.0.0.1
.
defaults /etc/xinetd.conf

/etc/xinetd.d. ,
/etc/services,
.
FTP,
vsftpd (Very Secure FTP Daemon).
cat/etc/xinetd.d/vsftpd
serviceftp
{
socket_type=stream
wait=no
user=root
server=/usr/sbin/vsftpd
server_args=/etc/vsftpd/vsftpd.conf
log_on_success+=DURATIONUSERID
log_on_failure+=USERID
nice=10
disable=yes
}
disable=yes xinetd
. ,
, disable=no SIGHUP
:
#cat/etc/xinetd.d/vsftpd

316

serviceftp
{
socket_type=stream
wait=no
user=root
server=/usr/sbin/vsftpd
server_args=/etc/vsftpd/vsftpd.conf
log_on_success+=DURATIONUSERID
log_on_failure+=USERID
nice=10
disable=no
}
#killall1xinetd
#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:6000*:*LISTEN
tcp00*:ftp*:*LISTEN

, ,
/etc/xinetd.d/vsftpd disable=yes
disable=no xinetd SIGHUP FTP
.
vsftpd ,
user=root. ,
nice=10.
vsftpd
/etc/vsftpd/vsftpd.conf.
log_on_failure log_on_success
: , USERID -
, , DURATION - .

xinetd echoudp .

9.00 10.30.

xinetd
?

317

23..
telnet.
telnet .
telnet, - in.telnetd.
telnet 23 TCP
.
telnet xinetd:
servicetelnet
{
socket_type=stream
wait=no
user=root
server=/usr/sbin/in.telnetd
log_on_success+=DURATIONUSERID
log_on_failure+=USERID
disable=yes
}
telnet ( disable
=yes), (disable=no)
SIGHUP .
#killall1xinetd
#netstattan
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp000.0.0.0:60000.0.0.0:*LISTEN
tcp000.0.0.0:230.0.0.0:*LISTEN

netstattan , telnet 23 .
telnet
telnet, :
$telnetbubuka.site.info
Trying10.0.0.1...
Connectedtobubuka.site.info.
Escapecharacteris'^]'.
Connectionclosedbyforeignhost.
telnet ,
Connectionclosedbyforeignhost. ,
xinetd tcpd .
318

only_from=127.0.0.1 xinetd /etc/xinetd.conf.


telnet. , :
servicetelnet
{
socket_type=stream
wait=no
user=root
server=/usr/sbin/in.telnetd
log_on_success+=DURATIONUSERID
log_on_failure+=USERID
only_from=10.0.0.0/24
disable=no
}
telnet,
10.0.0.0/24.
telnet:
$telnetbubuka.site.info
Trying10.0.0.1...
Connectedtobubuka.site.info.
Escapecharacteris'^]'.
Linux2.6.34(bubuka.site.info)
bubuka.site.infologin:apox
Password:
Lastlogin:WedJun422:34:19on:0
telnet /etc/issue.net - Linux2.6.34
(bubuka.site.info)
.
.
. :
apox@bubukaapox$who
apoxpts/2Jul100:04(bubuka)
apox@bubukaapox$netstattan
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp000.0.0.0:60000.0.0.0:*LISTEN
tcp000.0.0.0:230.0.0.0:*LISTEN
tcp0010.0.0.1:23198.11.11.20:32776ESTABLISHED

apox@bubukaapox$hostname
bubuka.site.info
319


telnet . escape ,
: Ctrl].
apox@bubukaapox$
telnet>help
Commandsmaybeabbreviated.Commandsare:
closeclosecurrentconnection
logoutforciblylogoutremoteuserandclosetheconnection
displaydisplayoperatingparameters
modetrytoenterlineorcharactermode('mode?'formore)
openconnecttoasite
quitexittelnet
sendtransmitspecialcharacters('send?'formore)
setsetoperatingparameters('set?'formore)
unsetunsetoperatingparameters('unset?'formore)
statusprintstatusinformation
toggletoggleoperatingparameters('toggle?'formore)
slcchangestateofspecialcharaters('slc?'formore)
zsuspendtelnet
!invokeasubshell
environchangeenvironmentvariables('environ?'formore)
?printhelpinformation
telnet>


(, exit), quit
telnet.
telnet>quit
Connectionclosed.
, telnet
telnet,
telnet , .
SSH (Secure Shell).
telnet, ,
, .
SSH, 22 TCP:
$telnetbubuka.site.info22
Trying10.0.0.1...
Connectedtobubuka.site.info.
Escapecharacteris'^]'.
^]
telnet>quit
Connectionclosed.
, telnet
320

, . 22 - SSH.

telnet. ,
.

telnet SMTP
( 25 TCP).

(rservices).
telnet
. AT&T BSD 4.2
.
r (remote - ),
r-.
:

rexec - ,
. - in.rexecd.

rlogin - .
- in.rlogind.

rsh - ,
rlogin, . - in.rshd.

rcp - .
- in.rshd.

, r- ,
xinetd:
serviceshell
{
socket_type=stream
wait=no
user=root
log_on_success+=USERID
log_on_failure+=USERID
server=/usr/sbin/in.rshd
disable=no
}
servicelogin
{
socket_type=stream
wait=no
user=root
321

log_on_success+=USERID
log_on_failure+=USERID
server=/usr/sbin/in.rlogind
disable=no
}
serviceexec
{
socket_type=stream
wait=no
user=root
log_on_success+=USERID
log_on_failure+=USERID
server=/usr/sbin/in.rexecd
disable=no
}
SIGHUP xinetd netstatta
:
$netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:exec*:*LISTEN
tcp00*:login*:*LISTEN
tcp00*:shell*:*LISTEN

rsh , rcp rlogin


. , ,
, ,
. /etc/hosts.equiv,
,
.rhosts , .
.rhosts :
#cat~user/.rhosts
elan.rakushka.ru
user .rhosts.

elan.rakushka.ru .
/etc/hosts.equiv
:
#cat/etc/hosts.equiv

322

+buddy
bubuka
elan.rakushka.ruroot
elan.rakushka.ru+susel
buddy
, bubuka .
elan.rakushka.ru susel
root.
rlogin :
$rloginbubuka.site.info
Lastlogin:FriMar1908:51:06ontty2
susel>hostname
bubuka.site.info
susel>netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:exec*:*LISTEN
tcp00*:login*:*LISTEN
tcp00*:shell*:*LISTEN
tcp00bubuka.netburg.:loginelan.rakushka:1023ESTABLISHED

susel>exit
rlogin:connectionclosed.
$
susel bubuka.site.info,
rlogin.
, .
rsh :
$rshbubuka.site.infols
Build
Desktop
GNUstep
LPI
Lab_9_FreeBSD.pdf
Lab_9_FreeBSD.rtf
Lab_9_FreeBSD.sxw
apache13.tar.gz
evolution
ps.remote
rcomms.txt
rcomms.txt~
323

tanya.rtf
rsh , ,
, ls
.
rcp
:
$rcpbubuka.site.info:~/tanya.rtf.
$ls*.rtf
tanya.rtf
, , ,
.
telnet, r- ,
.

Kerberos, .
, IP
(spoofing).
telnet r- SSH.

xinetd r-.

r-.

.rhosts rexec?

rcp ?

SSH.
SSH (Secure Shell)
r- telnet.
,
( ), IP
.
RHEL SSH - OpenSSH,
.
OpenSSH :

sshd - SSH, 22 TCP.

ssh - SSH, .
324

scp - .

OpenSSH :
sshd
/etc/ssh/sshd_config, ssh scp - /etc/ssh/ssh_config.
OpenSSH (stand-alone)
/etc/init.d, OpenSSH

. Red Hat - RHEL
chkconfig :
#chkconfigsshdon
OpenSSH
ssh,
IP :
$sshbubuka
Theauthenticityofhost'bubuka(10.0.0.1)'can'tbeestablished.
RSAkeyfingerprintis
ac:1d:51:58:6f:f4:3a:b9:a7:ac:82:b3:25:1e:3a:30.
Areyousureyouwanttocontinueconnecting(yes/no)?yes
Warning:Permanentlyadded'bubuka,10.0.0.1'(RSA)tothelistof
knownhosts.
user@bubuka'spassword:
Lastlogin:WedJun219:33:262010
$hostname
bubuka.site.info
$exit
logout
Connectiontobubukaclosed.
user ssh
bubuka.site.info.
.
, ,
OpenSSH ,
~/.ssh/known_hosts. ,
.
ssh l,
. :
susel>sshlapoxrestrict.nocom.com

325

susel
restrict.nocom.com apox, .
scp :
$scpbubuka:~/linux.tar/tmp
apox@bubuka'spassword:
linux.tar100%210KB0.0KB/s00:00
$ls/tmp/li*
/tmp/linux.tar
scp linux.tar
/tmp .
:
susel>scpwebadm@bubuka:/var/www/html/susel.php.
webadm@bubuka'spassword:
susel.php100%22KB0.0KB/s00:00
susel ,
webadm.
, ssh scp ,
.
. SSH
RSA DSA.
,
RSA - sshkeygen :
$sshkeygentrsa
Generatingpublic/privatersakeypair.
Enterfileinwhichtosavethekey(/home/spa/.ssh/id_rsa):
Createddirectory'/home/spa/.ssh'.
Enterpassphrase(emptyfornopassphrase):
Entersamepassphraseagain:
Youridentificationhasbeensavedin/home/spa/.ssh/id_rsa.
Yourpublickeyhasbeensavedin/home/spa/.ssh/id_rsa.pub.
Thekeyfingerprintis:
3b:51:43:a3:67:5b:5b:27:fa:f6:fc:84:c3:6c:9b:67
spa@bubuka.site.info
RSA. .ssh
, . id_rsa ,
. id_rsa.pub
,
326

.
, - .
, .
.

,
, - .
, ,
, -
, . ,
ssh, scp
.
$sshalgemna.ixt.biz
spa@algemna.ixt.biz'spassword:
Lastlogin:WedJul210:13:062010
spa%hostname
algemna.ixt.biz
spa%scpbubuka.site.info:~/.ssh/id_rsa.pubsecret.pub
id_rsa.pub100%22KB0.0KB/s
00:00
spa%catsecret.pub>>.ssh/authorized_keys;rmfsecret.pub
spa%chmod600.ssh/authorized_keys
spa%exit
spa
algemna.ixt.biz, .
, ,
algemna.ixt.biz.
,
.ssh/authorized_keys,
.

.

SSH.

ssh scp.

RSA .
-
327

24.FTP.
FTP.
FTP
(FTP - File Transfer Protocol). FTP FTP
.
FTP TCP 21, FTP
. FTP
,
FTP.
.
TCP 20.
, FTP TCP :

1024 (
30000) 21;
.

,
20 , 1024 ;
, ,
, FTP .

FTP ,
,
, , .
FTP.
20 TCP,
1024 1024. ,
,
.
GNU/Linux ,
FTP . : BSD ftpd, wuftpd, proftpd vsftpd.
(stand-alone),
. FTP
.
FTP .
: ftp, lftp, nftp wget.
FTP .
: anonymous ftp.
FTP
( , , ).
FTP
(download), (upload).
328

,
-
.
FTP :
(ascii) (binary). ,
- .

, FTP FTP .

FTP ?

FTP
FTP?

vsftpd.
vsftpd - /etc/vsftpd.conf.
vsftpd :
anonymous_enable=YES
dirmessage_enable=YES
connect_from_port_20=YES
xferlog_enable=YES
xferlog_std_format=YES
xferlog_file=/var/log/vsftpd/vsftpd.log
nopriv_user=nobody
:

anonymous_enable=YES FTP.

dirmessage_enable=YES -
FTP . .

20
FTP. connect_from_port_20=YES
FTP.

xferlog_enable.

xferlog_std_format=YES.

, ,
xferlog_file.

,
, nopriv_user.

/etc/vsftpd.conf :
329

local_enable=YES - FTP.

write_enable=YES - FTP
.

local_umask=022 - umask ,
.

anon_upload_enable=YES -
.

anon_mkdir_write_enable=YES -
.

chown_uploads=YES - ,
chown_username.

ascii_upload_enable=YES ascii_download_enable=YES
.

ftpd_banner - , .

deny_email_enable=YES - ,
e-mail , .

banned_email_file - e-mail
.

chroot_list_enable=YES -
(chroot).

chroot_list_file - ,
.

ls_recurse_enable=YES - R
ls, .

listen=YES - vsftpd (standalone).

background=YES -
( ).

vsftpd ,
. xinetd
/etc/xinetd.d :
serviceftp
{
socket_type=stream
wait=no
user=root
server=/usr/sbin/vsftpd
server_args=/etc/vsftpd.conf
log_on_success+=DURATIONUSERID
log_on_failure+=USERID
nice=10
330

disable=no
}
, ,
/var/ftp/pub. ftp,
, , . vsftpd
,
ftp.

/etc/ftpusers. , , FTP .

vsftpd
.
.

- .

FTP .

FTP.
ftp FTP. ,
, help :
$ftp
ftp>help
Commandsmaybeabbreviated.Commandsare:
!debugmdirsendportsite
$dirmgetputsize
accountdisconnectmkdirpwdstatus
appendexitmlsquitstruct
asciiformmodequotesystem
bellgetmodtimerecvsunique
binaryglobmputregettenex
byehashnewerrstatustick
casehelpnmaprhelptrace
cdidlenlistrenametype
cdupimagentransresetuser
chmodlcdopenrestartumask
closelspromptrmdirverbose
crmacdefpassiverunique?
deletemdeleteproxysend
ftp>quit

ftp :
8. open FTP ;
9. user FTP;
10.ascii ASCII ;
331

11.binary - -ASCII ;
12.ls FTP ;
13.dir FTP ;
14.cd FTP ;
15.get ;
16.mget FTP ;
17.put ;
18.mput ;
19.reget , ;
20.restart ;
21.size ;
22.prompt - ;
23.bye ;
24.close ;
25.exit ;
26.quit - ;
27.! - shell.
FTP :
$ftpsinix.mainfrank.de
Connectedtosinix.mainfrank.de.
220(vsFTPd1.2.0)
Name(sinix.mainfrank.de:susel):test1
530PleaseloginwithUSERandPASS.
SSLnotavailable
331Pleasespecifythepassword.
Password:
230Loginsuccessful.
RemotesystemtypeisUNIX.
Usingbinarymodetotransferfiles.
ftp>ls
200PORTcommandsuccessful.ConsiderusingPASV.
150Herecomesthedirectorylisting.
drwx31001100128Mar1714:37Desktop
226DirectorysendOK.
ftp>pwd
257"/home/test1"
ftp>lcd
Localdirectorynow/home/susel
ftp>!ls
Gentoo.buglsmod.aspsimple.dynamicUML
GNUstepMailsimple.static
ftp>putlsmod.asp
local:lsmod.aspremote:lsmod.asp
200PORTcommandsuccessful.ConsiderusingPASV.
150Oktosenddata.
226FilereceiveOK.
1305bytessentin5.1e05secs(2.5e+04Kbytes/sec)
ftp>bye
221Goodbye.

332

FTP ,
.
.
FTP wget. ,
FTP
.
.
wget :
$wgetftp://newnote.assignpro.ru/pub/*.stat*.
22:56:07ftp://newnote.assignpro.ru/pub/*.stat*
=>`.listing'
newnote.assignpro.ru...81.91.55.25
newnote.assignpro.ru[81.91.55.25]:21....
anonymous...!
==>SYST....==>PWD....
==>TYPEI....==>CWD/pub....
==>PORT....==>LIST....
[<=>]209
.K/s
22:56:07(1.18MB/s)`.listing'[209]
`.listing'.
22:56:07ftp://newnote.assignpro.ru/pub/simple.static
=>`simple.static'
==>CWD.
==>PORT....==>RETRsimple.static....
:485,882
100%[===============================================>]485,882.K/s
22:56:07(161.96MB/s)`simple.static'[485882]

wget URL .
wget :

b - ,
;

c - ;

v - (verbose);

q - (quiet);

i<file> - URL ;

Y<on/off> - proxy ;

r - ;

l<num> - num ;

x - ;
333

passiveftp - FTP.

, FTP .

ftp Linux ftp.kernel.org.

wget index.html www.assignpro.ru.

334

25.NIS,NFS,autofs.
NISNFS.
NIS (Network Information Service)
. NIS
. , ,
..
NFS (Network File System)
.
NIS NFS
.
, ,
.
NIS
, , ,
.
NFS
mount, NFS
.
NIS .

.

, NFS
/sbin/mount.nfs.

NISNFS.
NIS NFS . RPC
(Remote Procedure Call) - ,
.
, ,
, ,
.
- , ,
, , - .
, NIS/NFS, RPC :

NIS , ,
;

NFS .
335

, , ,
RPC , .
RPC
(datagram), .
, ,
. ,
, .
RPC UDP. ,
TCP.
RPC ,
. ,
,
.
RPC.
( /etc/services).
/etc/rpc RPC.
RPC ( /etc/rpc) (
/etc/services) portmap.
RPC portmap .
portmap ,
RPC.

/sbin/portmap?

? netstat.

lsofiUDP:111 .

NIS.
, NIS, NIS ,
(maps). NIS .
NIS :

, ,
NIS ;

, ,
.

NIS , , , .
NIS,
.
, NIS ,
NIS (default domain).
NIS :
336

NIS ;

ypserv - NIS;

NIS :

NIS ;

ypbind - NIS;

ypwhich NIS .

NIS Linux ,
:

/etc/group - ;

/etc/passwd - ;

/etc/shadow - ;

/etc/gshadow - ;

/etc/aliases - ;

/etc/hosts - IP ;

/etc/networks - ;

/etc/protocols - Internet ;

/etc/services - TCP/IP;

/etc/rpc - RPC ;

/etc/printcap - LPR;

/etc/netgroup - NIS ;

/etc/netid - NIS UNIX.

ypwhich ?

NIS.
Linux NIS :

NIS ;

- NIS;

NIS .

NIS domainname. :

337

domainnameclass
NIS class.
NIS
/etc/yp.conf. NIS ypbind .
NIS ingrid shevaree
/etc/yp.conf :
domainsevareeserveringrid
shevaree NIS ,
/etc/yp.conf ( NIS,
, ):
domainshevareeserveringrid
domainshevareeservertango
shevaree ingrid tango.
NIS shevaree,
:
domainshevareebrodcast
IP NIS /etc/hosts,
/etc/yp.conf :
ypserveringrid
NIS ingrid /etc/hosts.
NIS ypbind :

NIS ;

20 ypbind YPPROC_DOMAIN
NIS .
15 ypbind NIS,
. -
, ypbind .
NIS ypwich NIS, .
:
ypwich
338

NIS, /etc/yp.conf,
, .
, .
NIS, NIS,
ypcat, NIS. ,
:
ypcathosts
,
NIS /etc/nsswitch.conf
:
passwd:filesnis
shadow:filesnis
group:filesnis
hosts:filesnisdns
NIS
setup ( 1).
1.

NIS.



NIS



NIS
NIS
( 2).

2.

NIS.

339

/etc/nsswitch.conf.

NIS setup.

NIS.
NIS NIS, ypbind
.
/var/yp , NIS ,
, NIS , NIS.
Makefile, ,
make, .
Makefile :
all:passwdgrouphostsrpcservicesnetidprotocolsmail\
#netgrpshadowpublickeynetworksethersbootparamsprintcap\
#amd.homeauto.masterauto.homeauto.localpasswd.adjunct\
#timezonelocalenetmasks

, ypinit. ,
, .
shadow NIS,
Makefile.
Makefile:

B= - IP
, (
B=b);

NOPUSH= -
NOPUSH=true ( );

MINUID=500 - NIS UID


NIS UID<500;

MINGID=500 - ;

MERGE_PASSWD=true - shadow passwd (shadow


NIS );

MERGE_GROUP=true - gshadow.

, NIS ,
/var/yp/securenets. :
255.255.255.0192.168.1.0
192.168.1.0 255.255.255.0 ,
, , NIS .

340

/etc/ypserv.conf , ,
. (
, ):
host:map:security:mangle[:field]
host - IP ; map - ; security - none
, port <1024,
deny ; mangle[:field]
field ( - ) x , yes,
.
/etc/ypserv.conf xfr_check_port:yes,
NIS <1024.
/etc/ypserv.conf , ,
, SIGHUP.
:
/usr/lib/yp/ypinitm

NIS. .
^D.

ypinit /var/yp
, NIS . .
NIS, :

ypserv - , ,
;

yppasswdd - , ,
, .

ypserv yppasswdd Linux


.
NIS
- .
NIS ,
, .
NIS :
/usr/lib/yp/ypinits<NIS>

341

NIS.

ypinit.

NIS.

NFS.
NFS - /etc/exports.
, ,
.
NFS
:

, ,
, ,
;

,
.

NFS .
, -
NFS.
/etc/exports,
NFS :

, ,
.

/etc/exports , IP ,
, NIS.
, .
, /pub ,
DNS class.edu, /etc/exports:
/pub*.class.edu(rw)
class.edu
/pub -.
/etc/exports , ,
. , ,
, :
/hantukabsent(ro)eel(rw)

342

/hantuk absent , eel -


.
,
:

ro - ;

rw - ;

insecure - , >=1024;

secure - <1024;

all_squash -
;

squash_uids - ;

link_relative - ,
, ;

link_absolut - ;

noaccess - (
).

IP , : bamboo 10.1.1.128;

IP , :

192.168.1.126/255.255.255.128;

, , ?lena.my.net -
alena.my.net elena.my.net, *.chel.ru
gyb.chel.ru, glava.adm.chel.ru;

NIS , @, , @bubliky NIS bubliky.

NFS root

.
, root,
no_root_squash, .

, squash.
:
/var/netrogat(rw,squash_uids=0499)
UID<500 .
, , /etc/exports,
exportfs:

343

exportfsav
.
/etc/exports - ,
. a , ,
/etc/exports.

/home , root
.

NFS .

NFS.
NFS
, RPC :
#rpcinfop

1000002tcp111portmapper
1000002udp111portmapper
1000241udp878status
1000241tcp881status
1000111udp829rquotad
1000112udp829rquotad
1000111tcp832rquotad
1000112tcp832rquotad
1000032udp2049nfs
1000033udp2049nfs
1000034udp2049nfs
1000211udp43267nlockmgr
1000213udp43267nlockmgr
1000214udp43267nlockmgr
1000032tcp2049nfs
1000033tcp2049nfs
1000034tcp2049nfs
1000211tcp34689nlockmgr
1000213tcp34689nlockmgr
1000214tcp34689nlockmgr
1000051udp843mountd
1000051tcp846mountd
1000052udp843mountd
1000052tcp846mountd
1000053udp843mountd
1000053tcp846mountd

nfs, portmapper mountd.



showmount.
#showmountec55.class.edu
Exportlistforc55.class.edu:
/export/home*
344

NFS t
mount. NFS
. - . :
mounttnfsc55:/export/home/mnt/nfs
/export/home NFS srv1
/mnt/nfs.
NFS:

rsize - (, rsize=8192);

wsize - ;

hard - ,
;

soft -
;

timeo - (
);

retrans -
;

retry - ,
.

/etc/fstab
NFS . :
nfsserv1:/export/pub/pubnfsro,rsize=8192,timeo=14,intr00

/home NFS
/mnt.

NFSv4.
NFSv4
NFS . NFSv4
, TCP.
NFSv4 NFS,
,
.

345

/export

*(fsid=0,crossmnt,ro,root_squash,sync,no_subtree_check)
/export/pub
*(ro,root_squash,sync,no_subtree_check)
/export
/export/pub. ,
NFSv4, fsid=0. crossmnt
NFSv4 .
NFSv4 ,
.
mountbind/home/user1/eBook/export/pub
/home/user1/eBook NFSv4
/export/pub.
rpc.idmapd,
RHEL nfs-utils, NFS .
, NFSv4.
mounttnfs4netserv.class.edu:/pub/mnt
, NFSv4
. .

NFSv3 NFSv4.

AutoFS.
NFS
, ,
, NFS.
automount,
AutoFS. , AutoFS
NFS.
.
NFS
/etc/exports:
/export/home*(rw,insecure,sync)
/nfs/home
NFSv3. ,
346

NFS, :
test:x:502:502::/nfs/home/test:/bin/bash
/nfs/home/test
NFS /export/home/test test .
automount - /etc/auto.master,
:
#
#$Id:auto.master,v1.42005/01/0414:36:54ravenExp$
#
#Sampleauto.masterfile
#Thisisanautomountermapandithasthefollowingformat
#key[mountoptionsseparatedbycomma]location
#Fordetailsoftheformatlookatautofs(5).
#
/misc /etc/auto.misc
#
#NOTE:mountsdonefromahostsmapwillbemountedwiththe
#
"nosuid"and"nodev"optionsunlessthe"suid"and"dev"
#
optionsareexplicitlygiven.
#
/net
hosts
#
#Includecentralmastermapifitcanbefoundusing
#nsswitchsources.
#
#Notethatifthereareentriesfor/netor/misc(as
#above)intheincludedmastermapanykeysthatarethe
#samewillnotbeseenasthefirstreadkeyseentakes
#precedence.
#
+auto.master
#Remotehomedirectories
/nfs/home
auto_home

/etc/auto.master (maps)
, , .
(direct) (indirect).
.
:
/nfs/local

servnet:/usr/local

- /nfs/local.
servnet:/usr/local.
/nfs/home/test
NFS /export/home/test
.
/etc/auto.master:

347

/nfs/home auto_home
,/etc/auto_home
.
+auto_home
test c55.class.edu:/export/home/test
test/nfs/homeNFS
/export/home/testc55.class.edu.
,
NFS
.
,
:
+auto_home
*

c55.class.edu:/export/home/&

NFS.
test.
$sutest
:
[test@client~]$pwd
/nfs/home/test
[test@client~]$lsa
..bash_history.bash_profile.mozilla.zshrc
...bash_logout.bashrc.xauthKHEm6W
[test@client~]$dfh`pwd`
%
/export/home/test8,9G3,4G5,1G40%/nfs/home/test
[test@client~]$mount|greptest
/export/home/teston/nfs/home/testtypenone(rw,bind)
,NFS.

/nfs/home/test
348

NFS/export/home
test,
/etc/skel,,
useradd.

/export/home.

AutoFS.

26.SMB/CIFSSAMBA.
SAMBA.
SAMBA , SMB (Server
Message Block) UNIX/Linux . SMB - CIFS
(Common Internet File System) NetBIOS,
IBM. MS Windows ,
SAMBA UNIX/Linux Windows .
SAMBA, , UNIX/Linux
Windows .
Windows :

SAMBA 3.4.,
:

smbd - SMB, ;

nmbd - , NetBIOS
;

smbclient - ,
SMB, , ftp;

testparm - , SAMBA;

testprns - , ;

smbstatus - , SAMBA
;

nmblookup - , NetBIOS;

make_smbcodepage - ,
smbd;

smbpasswd - SAMBA ;

smbtar - ;

winbindd - , ,
NSS (Name Service Switch), MS Windows;
349

wbinfo - , winbindd;

rpcclient - MS Windows RPC (Remote Procedure


Calls);

findsmb - Perl SMB ;

smbcontrol - smbd nmbd;

smbspool - SMB ;

pdbedit - SAMBA ;

swat - SAMBA WEB


(SWAT - SAMBA Web Administration Tool).

SAMBA, .

SWAT?

SAMBA.
, smbd nmbd -
/etc/smb.conf ( GNU/Linux
/etc/samba /etc/samba/smb.conf).
SAMBA
smb.conf, ,
SWAT.
SWAT SAMBA, Web
. SAMBA
901 TCP, SWAT
. SWAT Web
901 (, http://localhost:901).
SAMBA,
Windows :
#Globalparameters
[global]
netbiosname=AXIS
workgoup=ITC
security=user
guestaccount=nobody
maptoguest=BadUser
nullpasswords=Yes
[homes]
Homedirectories
readonly=No
#Filessharing
350

[PUB]
comment=Publicshare(GuestOK!)
path=/home/samba/pub
readonly=No
guestok=Yes
[ACC]
comment=Accountant'sprivateshare.Hidden.
path=/home/samba/accountant
browseable=No
validusers=accountant
#Printerssharing
[PRN1]
comment=Company'sprinter.
path=/var/spool/cups/prn1
guestok=Yes
printable=Yes
SAMBA:

netbiosname - NetBIOS;

workgoup - NetBIOS;

security -
:

share -
, , ;

user - ,
(
Windows, SAMBA PDC);

domain - NT
PDC (Primary Domain Controller), ;

server - .

guestaccount - UNIX
() ;

maptoguest - SAMBA ,
(maptoguest=badpassword)
(maptoguest=baduser);

nullpasswords - ;

comment - , ;

path - UNIX ,
, ;

readonly - ;

guestok - ;

browseable - ;

printable - .

351

smb.conf , ,
. :

global - ;

printers - ;

homes - .

global NetBIOS
NetBIOS.
-
. UNIX,
.
,
. ,

.
homes .
%u - ,
. path=/home/%u
/home, .
smb.conf
.
:

PUB - ;

ACC - accountant.

PUB , ACC - . , ACC


.
- PRN1.
smb.conf
testparm, .
:
$testparms|less
smb.conf , testparm
. testparm
. s ,
Enter.

security ,

352

, , ?

,
ACC , users. ?

SAMBA.
smbd nmbd, SAMBA
(stand-alone) /etc/init.d.
:
#/etc/init.d/sambastart
Startingsamba...[ok]
#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:netbiosssn*:*LISTEN

smbd 139 TCP (netbios-ssn).


NetBIOS nmbd ,
nmblookup :
$nmblookupAXIS
queryingAXISon192.168.111.127
192.168.111.25AXIS<00>
nmblookup IP
, NetBIOS .
NetBIOS - ,
NetBIOS . PDC
, . PDC
. ,
:
$nmblookupM
querying__MSBROWSE__on192.168.111.127
192.168.111.25__MSBROWSE__<01>
SAMBA smbclient,
SMB . , ,
SMB:
$smbclientL//axis
addedinterfaceip=192.168.111.25bcast=192.168.111.127
353

nmask=255.255.255.128
Gotapositivenamequeryresponsefrom192.168.111.25
(192.168.111.25)
Password:
Domain=[ITC]OS=[Unix]Server=[Samba3.4.3]
SharenameTypeComment

homesDiskHomedirectories
PUBDiskPublicshare(GuestOK!)
PRN1PrinterCompany'sprinter.
IPC$IPCIPCService(Samba3.4.3)
ADMIN$DiskIPCService(Samba3.4.3)
manfredDiskHomedirectories
ServerComment

AXISSamba3.4.3
WorkgroupMaster

ITC
Enter,
SMB .
.
, ACC ,
browseable=no.
maptoguest=BadUser,
,
SAMBA smbpasswd. .
:
$smbclient//axis/pub
addedinterfaceip=192.168.111.25bcast=192.168.111.127nmask=255.255.255.128
Gotapositivenamequeryresponsefrom192.168.111.25(192.168.111.25)
Password:
Domain=[ITC]OS=[Unix]Server=[Samba3.4.3]
smb:\>help
?altnamearchiveblocksizecancel
cdchmodchowndeldir
duexitgethelphistory
lcdlinklowercaselsmask
mdmgetmkdirmoremput
neweropenprintprintmodeprompt
putpwdqqueuequit
rdrecurserenamermrmdir
setmodesymlinktartarmodetranslate
!
smb:\>ls
.D0FriJun1112:35:002010
..D0FriJun1112:29:562010
linux.tar215040FriJun1117:20:242010
38153blocksofsize262144.21261blocksavailable
smb:\>getlinux.tar
gettingfile\linux.tarofsize0aslinux.tar(104994.9kb/s)(average105000.0kb/s)
smb:\>quit

354

, smbclient
ftp , , help. SMB
get mget.
ACC accountant
SAMBA smbpasswd
. smbpasswd
, UNIX :
#useraddMd/home/samba/accountant/accountant
#smbpasswdaaccountant
NewSMBpassword:
RetypenewSMBpassword:
unabletoopenpassdbdatabase.
Addeduseraccountant.
accountant SAMBA.
smbpasswdfile.
/etc/samba/private/smbpasswd.
:
#cat/etc/samba/private/smbpasswd
accountant:1002:A98D69BC09864246AAD3B435B51404EE:7CD72AF5A8CC01C20
F546EDB9BF93E0B:[UX]:LCT40EE42FF:
accountant smbclient
, ACC. smbclient
U:
$smbclient//axis/accUaccountant
addedinterfaceip=192.168.111.25bcast=192.168.111.127nmask=255.255.255.128
Gotapositivenamequeryresponsefrom192.168.111.25(192.168.111.25)
Password:
Domain=[ITC]OS=[Unix]Server=[Samba3.4.3]
smb:\>ls
.D0FriJun1113:16:512010
..D0FriJun1112:29:562010
RURU_Navision360_Overview.pdf4878064FriJun1113:16:522010
38153blocksofsize262144.21243blocksavailable
smb:\>mget*.pdf
GetfileRURU_Navision360_Overview.pdf?y
gettingfile\RURU_Navision360_Overview.pdfofsize0asRURU_Navision360_Overview.pdf
(38729.5kb/s)(average38729.5kb/s)
smb:\>quit

. ,
,
.
,
SAMBA smbpasswd :
355

$smbclient//axis/manfred
addedinterfaceip=192.168.111.25bcast=192.168.111.127nmask=255.255.255.128
Gotapositivenamequeryresponsefrom192.168.111.25(192.168.111.25)
Password:
Domain=[ITC]OS=[Unix]Server=[Samba3.4.3]
smb:\>ls
.D0Jul1017:11:15
..D0Jul912:29:56
.qtDH0Jul1016:18:02
GvRD0Mar618:58:20
LPID0Jun1012:25:33
UMLD0Mar1822:22:05
smb:\>quit

manfred .
SAMBA
smbstatus :
#smbstatus
Sambaversion3.4.3
Serviceuidgidpidmachine

manfredmanfredmanfred12677newnote(192.168.111.25)Jun1018:07:452010
Lockedfiles:
PidDenyModeAccessR/WOplockName

12677DENY_FCB0x3RDWRNONE/home/manfred/.lsmod.asp.swp
Jun1018:08:142010

smbstatus SAMBA,
, .
.

smb.conf , SAMBA
/etc/samba/smb.conf.

ACC , ,
users.

ACC , ,
users, 660.

27.DNSBIND.
DNS.
DNS , (Domain Name Service).
/etc/hosts,
356

, ARPANET.
,
, .
,
.
DNS ,
. ,
. , , www.bamboo.be www.bamboo.de ,
- bamboo.be bamboo.de.
DNS BIND (Berkeley Internet Name Daemon) -
DNS Internet.
DNS,
IP . DNS ,
DNS.
DNS,
.
DNS , . .
() , (root domains).
:

(generic) - com, gov, mil, edu, net, org, int;

(geographic), , ru, su, be, uk, us, ua, kz ..;

, , , biz, tv info.

, . ,
, assignpro.ru - ,
com. . ,
, tjumen.assignpro.ru.
, , ,
, .
, .
,
.
DNS ,
,
(slave) . ,
, (master).
- ,
(Resource Records - RR).
(slave) - (master)
.
(zone transfer).
, -
DNS ( ).
, - ,
(authorative).
357

, ,
,
.
.
, ,
,
. , (root servers)
DNS (DNS
spoofing).
, DNS
(time to live - TTL).
- DNS
, . ,
, .
(non-authorative)
, ()
.
DNS , ,
,
( localhost 127.0.0.1 ).
(cache only).
- .

, (authorative)
. , ,
( ), IP .
Network Information Center (NIC),

.
.
.
-
. , ,
DNS, ,
.
BIND, named,
IP .
BIND named ,
-
.
:

. IP .

, IP .

in
358

addr.arpa. IP ,
. , , IP 212.193.90.0
90.193.212.inaddr.arpa.

.
DNS ,
.

- IP ?

BIND.
BIND.
BIND - /etc/named.conf. BIND,

/etc/named.boot .
/etc/named.conf BIND:
#
#named.conf
#
options{
pidfile/var/run/named/named.pid;
directory/var/named;
};
//
zone.{
typehint;
filedb.root;
};
//localhost127.0.0.1
zonelocalhost{
typemaster;
filedb.localhost;
};
//127.0.0.1localhost
zone0.0.127.inaddr.arpa{
typemaster;
filedb.127.0.0.1;
};
359

#
#,,

#
#
#,:
#
//class.edu
zoneclass.edu{
typemaster;
filedb.class.edu;
};
//
/*
zoneclassic.edu{
typeslave;
masters{192.168.1.254;};
fileslave/bak.classic.edu;
};
*/
//192.168.2
zone2.168.192.inaddr.arpa{
typemaster;
filedb.192.168.2;
};
named.conf :

# - Shell;

// - C;

/*...*/ - C.

options, , ,
PID ( pidfile), ,
( directory).
zone , .
, class.edu -
2.168.192.inaddr.arpa - .
( type):

hint - ;

master - , -;

slave - ;

stub - , .
360

master
file. DNS
IP , ,
.
slave stub IP -,
masters. classic.edu
( ).
, ,
- slave/.
(zone transfer).
hint
BIND IP . db.root (
- named.ca) IP .
: ftp://ftp.rc.internic.net.
BIND 9 ,
named.conf - namedcheckconf.

, BIND 212.193.90.0,
comp1.cheremiska.ru, comp2.cheremiska.ru, ..
comp254.cheremiska.ru. IP .
named.conf ?


namedcheckconf.

DNS.
DNS, . ,
,
IP .
named.conf .
zone. , ,
named.conf file.
(
named.conf), $ORIGIN :
$ORIGINclass.edu.
class.edu .

361

BIND @.
, , named.conf, $ORIGIN
@.
(resource record RR).
.
, -
; . , ,
BIND.
RR : , , , . "
" , TTL .
. .
IN (Internet), .

$TTL :
$TTL86400
, ,
.
:

SOA (Start of Authority) - .


RR, , , .

NS (Name Server) - DNS .

A (Address) - IP .
( IP )
.

PTR (Pointer) - IP DNS


. (
) .

CNAME (Canonical Name) - .


.

MX (Mail Exchanger) - (SMTP ),


.

localhost,
db.localhost :
$TTL86400
@
IN
SOA localhost.
2010062001
;
s/n
1W
;
refresh

root.localhost.

362

1D
2W
1H
)

;
;
;

retry
expire
negativeTTL

IN

NS

localhost.

IN

127.0.0.1

SOA ( SOA),
,
.
SOA :

-, . localhost, ,
localhost.

, @ , , @
.

(serial number), .
. ,
. .

-
(refresh).
. . : 1W - .

(retry). -
,
.

(expire). -
,
.

(negative
TTL).

NS, .
. (
), NS .
NS . BIND
RR.
- SOA. @, (
- localhost). NS , , :
localhost.

IN

NS

localhost.

, . , BIND
363

,
.
A
IP . , , ,
:
localhost.

IN

127.0.0.1

localhost 127.0.0.1.
127.0.0.1,
db.127.0.0.1 :
$TTL86400
@
IN
SOA localhost.
root.localhost.
2010062001
;
s/n
1W
;
refresh
1D
;
retry
2W
;
expire
1H
;
negativeTTL
)

IN

NS

localhost.

IN

PTR

localhost.

PTR, .
IP ,
. - 0.0.127.inaddr.arpa . , ,
:
1.0.0.127.inaddr.arpa. IN

PTR

localhost.

class.edu ,
db.class.edu :
$TTL86400
@
IN
SOA ns1
2010062001
1W
;
8H
;
1D
;
1H
;
)
IN
IN

NS
NS

root.ns1 (
;
s/n
refresh
retry
expire
negativeTTL

ns1.class.edu.
ns.provider.net.
364

IN

MX

10

ns1 IN
relay

A
IN

192.168.2.253
A
192.168.2.254

murr IN
www IN

A
192.168.2.252
CNAME
murr

$GENERATE 1251

relay.class.edu.

ws$

192.168.2.$

, . -
SOA - ns1.class.edu.
Internet , ( IP
, ).
MX , relay.class.edu. 10 ,
.
- .
A IP .
- murr.class.edu CNAME www.
$GENERATE
IP . A.
251 RR :
ws1 IN
ws2 IN
ws3 IN
...
ws251

A
A
A

192.168.2.1
192.168.2.2
192.168.2.3

IN

192.168.2.251

- db.192.168.2
192.168.2.0 ( 2.168.192.inaddr.arpa):
$TTL86400
@
IN
SOA ns1.class.edu. root.ns1.class.edu. (
2010062001
;
s/n
1W
;
refresh
8H
;
retry
1D
;
expire
1H
;
negativeTTL
)

254
253
252

IN

NS

ns1.class.edu.

IN
IN
IN

PTR
PTR
PTR

relay.class.edu.
ns1.class.edu.
murr.class.edu.

$GENERATE 1251

PTR

ws$.class.edu.
365

, PTR.

$GENERATE.
, -
db.root. :
;formerlyNS.INTERNIC.NET
;
.3600000INNSA.ROOTSERVERS.NET.
A.ROOTSERVERS.NET.3600000A198.41.0.4
;
;formerlyNS1.ISI.EDU
;
.3600000NSB.ROOTSERVERS.NET.
B.ROOTSERVERS.NET.3600000A128.9.0.107
;
;formerlyC.PSI.NET
;
.3600000NSC.ROOTSERVERS.NET.
C.ROOTSERVERS.NET.3600000A192.33.4.12
;
;formerlyTERP.UMD.EDU
;
.3600000NSD.ROOTSERVERS.NET.
D.ROOTSERVERS.NET.3600000A128.8.10.90
;
;formerlyNS.NASA.GOV
;
.3600000NSE.ROOTSERVERS.NET.
E.ROOTSERVERS.NET.3600000A192.203.230.10
;
;formerlyNS.ISC.ORG
;
.3600000NSF.ROOTSERVERS.NET.
F.ROOTSERVERS.NET.3600000A192.5.5.241
;
;formerlyNS.NIC.DDN.MIL
;
.3600000NSG.ROOTSERVERS.NET.
G.ROOTSERVERS.NET.3600000A192.112.36.4
;
;formerlyAOS.ARL.ARMY.MIL
;
.3600000NSH.ROOTSERVERS.NET.
H.ROOTSERVERS.NET.3600000A128.63.2.53
;
;formerlyNIC.NORDU.NET
;
.3600000NSI.ROOTSERVERS.NET.
I.ROOTSERVERS.NET.3600000A192.36.148.17
;
366

;temporarilyhousedatNSI(InterNIC)
;
.3600000NSJ.ROOTSERVERS.NET.
J.ROOTSERVERS.NET.3600000A198.41.0.10
;
;housedinLINX,operatedbyRIPENCC
;
.3600000NSK.ROOTSERVERS.NET.
K.ROOTSERVERS.NET.3600000A193.0.14.129
;
;temporarilyhousedatISI(IANA)
;
.3600000NSL.ROOTSERVERS.NET.
L.ROOTSERVERS.NET.3600000A198.32.64.12
;
;housedinJapan,operatedbyWIDE
;
.3600000NSM.ROOTSERVERS.NET.
M.ROOTSERVERS.NET.3600000A202.12.27.33
;EndofFile
,
IP
.
, BIND 9
namedcheckzone.
.


(cheremiska.ru).

namedcheckzone.

db.root .

DNSBIND.
BIND , stand-alone
/etc/init.d:
#/etc/init.d/namedstart
*Startingnamed...

[ok]

named
( named), u.

367

#psef|grepnamed
named2522425225001:20?00:00:00/usr/sbin/namedu
named
root2523112151001:22pts/100:00:00grepnamed
BIND 53 TCP UDP:
#netstattaup
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
PID/Programname
tcp00*:6000*:*LISTEN11950/X
tcp00localhost:domain*:*LISTEN25224/named
udp00localhost:domain*:*25224/named

BIND ,
rndc.
#rndcstatus
numberofzones:4
debuglevel:0
xfersrunning:0
xfersdeferred:0
soaqueriesinprogress:0
queryloggingisOFF
serverisupandrunning
#rndcstop
rndc BIND 9,
.

BIND .

BIND.

BIND .

BIND /etc/init.d ?

- .

DNS.
DNS :

nslookup - ,
DNS, - resolver.
368

host - , , ,
.

dig - (Domain Information Groupper).

nslookup :
$nslookupcmp.zombie.edu
Server:ns.zombie.edu
Address:192.250.250.2
Name:cmp.zombie.edu
Address:192.250.250.3
IP .
nslookup :
#nslookup
Note:nslookupisdeprecatedandmayberemovedfromfuturerelease
Considerusingthedigorhostprogramsinstead.Runnslookupwith
the`sil[ent]'optiontopreventthismessagefromappearing.
>server127.0.0.1
Defaultserver:127.0.0.1
Address:127.0.0.1#53
>localhost
Server:127.0.0.1
Address:127.0.0.1#53
Name:localhost
Address:127.0.0.1
>
, , nslookup
. , ,
:
, .
host :
#hostlocalhost127.0.0.1
Usingdomainserver:
Name:127.0.0.1
Address:127.0.0.1#53
Aliases:
localhosthasaddress127.0.0.1
.
(localhost), - IP
369

( - ).
l host :
#hostlvlocalhost127.0.0.1
Trying"localhost"
Usingdomainserver:
Name:127.0.0.1
Address:127.0.0.1#53
Aliases:
;;>>HEADER<<opcode:QUERY,status:NOERROR,id:38103
;;flags:qraara;QUERY:1,ANSWER:4,AUTHORITY:0,ADDITIONAL:0
;;QUESTIONSECTION:
;localhost.INAXFR
;;ANSWERSECTION:
localhost.604800INSOAns.localhost.
root.localhost.2009081601288001440060480086400
localhost.604800INNSns.localhost.
localhost.604800INA127.0.0.1
localhost.604800INSOAns.localhost.
root.localhost.2009081601288001440060480086400
Received137bytesfrom127.0.0.1#53in2ms
v .
:
;;QUESTIONSECTION:
;localhost.INAXFR
- ( - AXFR).
.
dig :
#dig@127.0.0.1localhost
;<<>>DIG9.6.3<<>>@127.0.0.1localhost
;;globaloptions:printcmd
;;Gotanswer:
;;>>HEADER<<opcode:QUERY,status:NOERROR,id:24791
;;flags:qraardra;QUERY:1,ANSWER:1,AUTHORITY:1,
ADDITIONAL:0
;;QUESTIONSECTION:
;localhost.INA
;;ANSWERSECTION:
localhost.604800INA127.0.0.1
370

;;AUTHORITYSECTION:
localhost.604800INNSns.localhost.
;;Querytime:1msec
;;SERVER:127.0.0.1#53(127.0.0.1)
;;WHEN:ThuJul2201:58:222004
;;MSGSIZErcvd:60
x dig :
#dig@127.0.0.1x127.0.0.1
;<<>>DIG9.6.3<<>>@127.0.0.1x127.0.0.1
;;globaloptions:printcmd
;;Gotanswer:
;;>>HEADER<<opcode:QUERY,status:NOERROR,id:27207
;;flags:qraardra;QUERY:1,ANSWER:1,AUTHORITY:1,
ADDITIONAL:1
;;QUESTIONSECTION:
;1.0.0.127.inaddr.arpa.INPTR
;;ANSWERSECTION:
1.0.0.127.inaddr.arpa.86400INPTRlocalhost.
;;AUTHORITYSECTION:
127.inaddr.arpa.86400INNSlocalhost.
;;ADDITIONALSECTION:
localhost.604800INA127.0.0.1
;;Querytime:1msec
;;SERVER:127.0.0.1#53(127.0.0.1)
;;WHEN:ThuJul2202:00:192004
;;MSGSIZErcvd:93
dig ,
/etc/resolv.conf IP dig
@.

DNS nslookup, host dig.

dig ?

371

28.WEBApache.
Apache.
WEB Apache
/etc/httpd/conf/.
httpd.conf.
httpd.conf :


, mime - .
httpd.conf include,
.
,
Apache . :

ServerType - Apache: (stand-alone),


standalone, - inetd;

ServerRoot - ,
Apache, , ;
UNIX Apache;

PidFile - , Apache PID


;

LoadModule - Apache,
(.so - Shared Object);

AddModule - ;

ClearModuleList -
AddModule;

Timeout - (timeout);

KeepAlive - ,
HTTP/1.1,
;

KeepAliveTimeOut - ,
;

MaxKeepAliveRequests - ,
;

StartServers - httpd,
Apache;

MinSpareServers -
372

httpd ( httpd,
);

MaxSpareServers -
httpd ( );

MaxClients - httpd,
;

MaxRequestsPerChild - ,
httpd,
.

httpd.conf (
LoadModule AddModule):
ServerTypestandalone
ServerRoot/etc/apache
PidFile/var/run/apache.pid
ScoreBoardFile/etc/apache/apache.scoreboard
Timeout300
KeepAliveOn
MaxKeepAliveRequests100
KeepAliveTimeout15
MinSpareServers4
MaxSpareServers10
StartServers4
MaxClients150
MaxRequestsPerChild500
LoadModulemmap_static_modulemodules/mod_mmap_static.so
LoadModuleenv_modulemodules/mod_env.so
LoadModuleconfig_log_modulemodules/mod_log_config.so
LoadModuleagent_log_modulemodules/mod_log_agent.so
LoadModulereferer_log_modulemodules/mod_log_referer.so
LoadModulemime_magic_modulemodules/mod_mime_magic.so
LoadModulemime_modulemodules/mod_mime.so
LoadModulenegotiation_modulemodules/mod_negotiation.so
ClearModuleList
AddModulemod_mmap_static.c
AddModulemod_env.c
AddModulemod_log_config.c
AddModulemod_log_agent.c
AddModulemod_log_referer.c
AddModulemod_mime_magic.c
AddModulemod_mime.c
AddModulemod_negotiation.c
,
LoadModule, Apache
. , ,
httpdl :

373

#/usr/sbin/httpdl
Compiledinmodules:
core.c
prefork.c
http_core.c
mod_so.c
:

Port - , Apache ,
Listen (Virtual Hosts);

Listen - Apache ;

User - , httpd;

Group - ,
httpd;

DocumentRoot - WEB ;

UserDir - WEB ;

DirectoryIndex - ,
;

AccessFileName - ,
;

TypesConfig - MIME;

DefaultType - MIME ;

UseCanonicalName - Apache
URL , ( URL),
;

CacheNegotiatedDocs - proxy , Apache


(Pragma:nocache);

MimeMagicFile -
MIME ;

HostnameLookups - IP
, ;

ErrorLog - , (),
Apache;

LogLevel - ;

LogFormat - , ;

CustomLog - ;

ServerSignature - ,
Apache, , ..

Alias - (
, );
374

ScriptAlias - , Alias, CGI ;

IndexOptions - ;

AddIcon - , ,

;

AddIconByEncoding - MIME ;

AddIconByType - MIME ;

DefaultIcon - ;

AddDescription -
(, .gzgzippeddocument);

ReadmeName - README,
(directory index);

HeaderName - HEADER,
(directory index);

IndexIgnore - , ;

AddEncoding -
(, gzip );

AddLanguage -
(, AddLanguageru.ru);

AddCharset -
;

LanguagePriority - ;

AddType - MIME;

AddHandler - ;

ErrorDocument - ;

BrowserMatch - .

httpd.conf
<IfModule>. Apache,
. :
<IfModulemod_alias.c>
Alias/doc/usr/share/doc
</IfModule>
doc /usr/share/doc.
mod_alias.c.
( )
WEB /usr/share/doc, URL:
http://localhost/doc.

375

<IfDefine>.
Apache,
. D
httpd.

Apache ? ,
StartServers MinSpareServers .

, Apache
bin . ,
Apache ?

.
Apache httpd.conf
:

- ;

, , ,
. ,
/usr/share/doc , doc (.
) :
<Directory/usr/share/doc>
OptionsIndexesFollowSymLinks
Orderdeny,allow
Denyfromall
Allowfrom127.0.0.1
</Directory>
/usr/share/doc,
URL http://localhost/doc,
doc, .
Indexes Apache
index.html. FollowSymLinks
.
Order
Deny, , Allow, .
/usr/share/doc Apache
.
Apache :
376

<Directory> - ,
(
~);

<DirectoryMatch> - , ,
( ~
);

<Files> - , (
~);

<FilesMatch> - , ,
( ~ );

<Location> - , URL;

<LocationMatch> - ,
URL;

<VirtualHost> - , ,
WEB , ,
IP ;

<Limit> - ,
HTTP (, GET POST);

<LimitExcept> - ,
;

<IfDefine> - ,
Apache (, SSL)
D httpd;

<IfModule> - ,
.

. , ,
Apache
mod_status.c :
<IfModulemod_status.c>
<Location/serverstatus>
SetHandlerserverstatus
Orderdeny,allow
Denyfromall
allowfrom127.0.0.1
</Location>
</IfModule>
<IfModule> <Location>,
mod_status.c
, http://localhost/serverstatus.
SetHandler, ,
, .
377

mod_status.c.

Apache ,
.

Apache ,
mod_info.c? ,
?


, .ht ?

Apache.
Apache (stand-alone) ,
- . ServerType,
standalone, inetd. ,
.
Apache ,
/etc/init.d :
#/etc/init.d/httpdstart
*Startinghttpd...

[ok]

#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:www*:*LISTEN

Apache 80 TCP, .
Apache apachectl2 :
#/usr/sbin/apachectl2start
/usr/sbin/apachectl2start:httpdstarted
Apache,
. :
#/usr/sbin/apachectlstatus
ApacheServerStatusforwurdalet.nikogo.net
Serverversion:Apache/2.2.13(Linux/SUSE)
Serverbuilt:Apr13201016:28:12
_________________________________________________________________
378

CurrentTime:Sunday,30Jun201002:25:54YEKST
RestartTime:Sunday,30Jun201002:23:09YEKST
ParentServerGeneration:0
Serveruptime:2minutes45seconds
1requestscurrentlybeingprocessed,3idleservers
W___............................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
ScoreboardKey:
"_"WaitingforConnection,"S"Startingup,"R"ReadingRequest,
"W"SendingReply,"K"Keepalive(read),"D"DNSLookup,
"L"Logging,"G"Gracefullyfinishing,"."Openslotwithnocurrent
process

:
#/usr/sbin/apachectl2configtest
SyntaxOK

Apache.

WEB .

WEB.
WEB
mod_userdir.c.
, DocumentRoot.
mod_userdir.c
WEB . URL .
:
<IfModulemod_userdir.c>
UserDirpublic_html
</IfModule>
WEB
public_html ,
URL http://hostname/~username .
379

,
WEB . , -,
(, 755), , -, Apache:
<Directory/home/*/public_html>
AllowOverrideAll
OptionsMultiViewsIndexesIncludesFollowSymLinks
Orderallow,deny
Allowfromall
</Directory>
AllowOverrideAll
.htaccess.
, WEB ,
Options :

MultiViews - ,
, , ,
mod_negotiation.c ;

Indexes -
index.html ;

Includes - SSI (Server Side Includes -


);

FollowSymLinks - .

http ( -
GID httpd ), .
public_html, http.
750, public_html - 2750
( SGID).

index.html (
) public_html.
.

public_html index.html.
?

public_html
. ?

WEB.
,
, . ,
380

.
mod_auth.c.
.htaccess
, . Apache
:
AccessFileName.htaccess
, ,
, AllowOverride
AuthConfig . , ,
/var/www/html/secret :
<Directory/var/www/html/secret>
OptionsIndexesFollowSymLinks
AllowOverrideAuthConfig
</Directory>
AllowOverrideAuthConfig ,
,
.htaccess. .htaccess
Apache.
, ,
, .htaccess
:
AuthNameUnauthorizedaccessisstronglyprohibited!
AuthTypeBasic
AuthUserFile/etc/httpd/htpasswd
Requirevaliduser
AuthName ,
. AuthType
, uuencode.
, . ,
AuthUserFile.
,
htpasswd.
:
#htpasswdc/etc/httpd/htpasswdwebuser
Newpassword:
Retypenewpassword:
Addingpasswordforuserwebuser

381

#htpasswd/etc/httpd/htpasswdweberus
Newpassword:
Retypenewpassword:
Addingpasswordforuserweberus
#cat/etc/httpd/htpasswd
webuser:Zi6v4CjM7y5J2
weberus:83Ygmk1dHcLzM
, htpasswd
c . c
, .

,
.

, ,
.

,
users ?

.
WEB
IP .
WEB , ,
.

(Name Based Virtual Hosting).
, -,
IP , Apache,
.
DNS, CNAME DNS (. ,
DNS).
-,
Apache ,
.
, CNAME DNS
, IP :

www.sovsem.net ;

web.sovsem.net .

382

Apache,
Apache, , WEB
:
NameVirtualHost*
<VirtualHost*>
ServerNamewww.sovsem.net
DocumentRoot/www/www.sovsem.net
</VirtualHost>
<VirtualHost*>
ServerNameweb.sovsem.net
DocumentRoot/www/web.sovsem.net
</VirtualHost>
, ServerName
, DocumentRoot WEB
.
NameVirtualHost* ,
IP , <VirtualHost*> ,
.

, ,
: www.machine.com site.machine.com.
Apache
.

site.machine.com .

29.Sendmail.
.
:

MUA (Mail User Agent);

MTA (Mail Transfer Agent);

MDA (Mail Delivery Agent).

MUA
,
383

MTA. MUA elm, mailx, Netscape ..


MTA
MUA .
MTA MTA, . MTA
Sendmail, Exim Postfix.
MDA .
,
- . MDA Linux
, , procmail.
.
.
: . , , ,
, , (Subject),
.
MTA
. SMTP (Simple Mail Transfer Protocol)
ESMTP (Extended SMTP).
UUCP (Unix-to-Unix copy).
X.400.

DNS. MTA,
. (RR Resource Records) - MX (Mail Exchanger).
MX DNS MTA
. MX
. :
mydom.edu.
mydom.edu.

IN
IN

MX
MX

5
10

mail.mydom.edu.
relay.myisp.net.

MX mydom.edu mail.mydom.edu - relay.myisp.net. MTA,


mail.mydom.edu .
MX ,
- . , MTA
.
, MTA
, :


,
, mail, mutt,
.

POP3.
POP3, ,
384

, .
- .

(
), , IMAP.
.

, ,
WEB .
IMAP, ,
, ,
WEB .

DNS , MTA
.

POP3 IMAP
?

(POP3 IMAP) ,
?

Sendmail.
Sendmail - MTA.
MTA
.
Sendmail - sendmail.cf.
Sendmail /etc/mail.
sendmail.cf .
(classes), (macros) (options):

,
.

Sendmail.

sendmail.cf ,
, .
#.
sendmail.cf:

C - ;

D - ;

F - , ;
385

H - ;

K - ;

M - ;

O - Sendmail;

P - ;

R - ;

S - .

, , Smart Host,
,
sendmail.cf :
DSmailrelay.provider.ru
Sendmail ,
mailrelay.provider.ru.
S,
mailrelay.provider.ru.
. :

$a - Date: ;

$b - Sendmail;

$c - MTA;

$d - UNIX;

$f - ;

$h - ;

$j - FQDN ;

$k - ;

$m - sendmail;

$n - PID sendmail;

$p - ;

$r - , ;

$s - ;

$t - ;

$u - ;

$v - Sendmail;

$w - , Sendmail;

$x - ;
386

$z - ;

$_ - ;

${bodytype} - ;

${client_addr} - IP SMTP ;

${client_name} - SMTP ;

${client_port} - TCP SMTP ;

${opMode} - (, );

${deliveryMode} - .

C ,
. :
Ccphrase1phrase2...phraseN
c - , phrase - , .
, . , ,
w ( ,
, ),
:
Cwlocalhost
,
sendmail.cf.
F. F :
Fcfilename
- , filename - , .
, C.
, SMTP (relay)
.
/etc/mail/relaydomains.
sendmail.cf :
FRo/etc/mail/relaydomains
R, , ,
/etc/mail/relaydomains.
.
387

K.
:
Kmapnamemapclassarguments
mapname - , mapclass -
(, hash), argument - .
, ,
(spam) access.db, MTA.
:
KaccesshashT<TMPF>o/etc/mail/access.db
access,
/etc/mail/access.db.
sendmail, o O ,
sendmail.cf.
O. O: Oovalue Ooption=value, o -
, option - .
, , :
OTimeout.connect=1m
sendmail.cf
, R
S.

sendmail.cf ,
(Smart Host ). ?

, ,
, Sendmail.

, alias.

Sendmailsendmail.mc.
Sendmail sendmail.cf
. , ,
Sendmail .
GNU/Linux Sendmail
388

, m4,
Sendmail, sendmail.cf.
m4 sendmail.mc,
m4 sendmail.cf.
:
m4sendmail.mc>sendmail.cf
, RH - /etc/mail
Makefile, make
, .
/etc/mail
:
makeall
, m4 ,
( -).
RPM :
$rpmqa|grepsendmail.*cf.*
sendmailcf8.13.88.el5
sendmail.cf
, , /usr/share/sendmailcf.
m4 .
sendmail.mc FEATURE DEFINE ,
, - `,
- '. :
OSTYPE(`linux')dnl
sendmail.cf
/usr/share/sendmailcf/ostype/linux.m4.
,
. ,
dnl m4 .
, ,
divert(1) divert(0). divert(1)
, . divert(0)
.
include
. :
389

include(`/usr/share/sendmailcf/m4/cf.m4')dnl
VERSIONID sendmail.cf.
DOMAIN , ,
, UUCP_RELAY. :
DOMAIN(`mydom.ru')dnl

:
DOMAIN(`generic')dnl
MAILER .
, ,
. :
MAILER(`procmail')dnl
SMTP
procmail:
MAILER(`smtp')dnl
MAILER(`procmail')dnl
define(MACRO,VALUE) MACRO
VALUE. ,
(Smart Host) sendmail.mc :
define(`SMART_HOST',`mailrelay.provider.ru')
SMART_HOST mailrelay.provider.ru.
sendmail.mc :
divert(1)dnl
include(`/usr/share/sendmailcf/m4/cf.m4')dnl
VERSIONID(`Simpleconfig')dnl
OSTYPE(`linux')dnl
define(`confDEF_USER_ID',``8:12'')dnl
define(`confTO_CONNECT',`1m')dnl
define(`confDONT_PROBE_INTERFACES',true)dnl
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl
390

define(`ALIAS_FILE',`/etc/aliases')dnl
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl
FEATURE(always_add_domain)dnl
FEATURE(local_procmail,`',`procmailtYa$hd$u')dnl
FEATURE(`accept_unresolvable_domains')dnl
MAILER(smtp)dnl
MAILER(procmail)dnl
:

define(`confDEF_USER_ID',``8:12'')dnl UID GID


, Sendmail ( mail).

define(`confTO_CONNECT',`1m')dnl
- 1 ;

define(`confDONT_PROBE_INTERFACES',true)dnl
Sendmail w,
.

procmail,
GNU/Linux ,
define(`PROCMAIL_MAILER_PATH',`/usr/bin/procmail')dnl.

define(`ALIAS_FILE',`/etc/aliases')dnl
.

Sendmail - smrsh
. smrsh
FEATURE(`smrsh',`/usr/sbin/smrsh')dnl.

FEATURE(always_add_domain)dnl
.

procmail

FEATURE(local_procmail,`',`procmailtYa$hd$u')dnl.

, DNS,
FEATURE(`accept_unresolvable_domains')dnl.

sendmail.mc ,
.

sendmail.mc sendmail.cf. ,
VERSIONID?

sendmail.cf sendmail.cf.old ,
FEATURE(always_add_domain)dnl.
sendmail.cf sendmail.cf.old.

391

Sendmail.
Sendmail ,
stand-alone /etc/init.d :
#/etc/init.d/sendmailstart
*Startingsendmail...

[ok]

Sendmail 25 TCP - SMTP:


#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00localhost:smtp*:*LISTEN
tcp00*:smtp*:*LISTEN
tcp00*:ssh*:*LISTEN

sendmail :

bd - ( );

bD - (run foreground);

bh - hoststat ;

bH - purgestat ;

bi - , newaliases;

bm - ( );

bp - mailq ;

bs - SMTP RFC821;

bt - ;

bv - ;

C - /etc/sendmail.cf;

d - ;

F - , From: ;

f - , From:
, ;

h - (hop count) MTA;

i - ( - );

N - ;

n - Sendmail
;

p - ;

q - .
, Sendmail
392

R
;

t - Sendmail ;

U - Sendmail MTA,
MUA;

v - Sendmail;

X - ;

O - sendmail Ooption=value;

o - sendmail oxvalue, x -
sendmail;

- , , ,
.

Sendmail /etc/init.d/sendmail
.

Sendmail , 30
.

sendmail
.

.
.forward,
,
.
~/.forward ,
. .
, , martini_e_rossi
.forward, :
lexa
ivanov
robertino@loretti.biz
, martini_e_rossi
ivanov, lexa robertino@loretti.biz.
~/.forward
, .
393

~/.forward .
/etc/aliases
. /etc/aliases
.
:

: name:alias1,alias2,...aliasN ;

: name:|program ;

: name:file ;

, : name::include:file .

:
adm:root
bin:root
daemon:root
exim:root
lp:root
mail:root
named:root
nobody:root
postfix:root
abuse:postmaster
ftp:root
hostmaster:root
news:usenet
noc:root
security:root
usenet:root
uucp:root
webmaster:root
www:webmaster
root:ivanov
rassyl:
sid@client.ru,bubuka@mail.ru,spamoed@net.domena.ru
,
, .
.
, , .
. ,
.
/etc/aliases.db
/etc/aliases newaliases,
sendmailbi.
:
394

#newaliases
/etc/aliases:14aliases,longest10bytes,152bytestotal

~/.forward ,
postmaster.

~/.forward ,
~/mail_archive.

/etc/aliases ,
maillist,
/etc/mail/maillist.

.
, ,
, /var/spool/mqueue.
,, , ,
MTA .

mailq sendmailbp. :
#mailqv
QueueIDSizeArrivalTimeSender/Recipient
477E7919EE370Aug114:31:29emerald@localhost.mistery.com
(Nameserviceerrorforname=bobin.orgtype=MX:Hostnotfound,tryagain)
robin@bobin.org
0Kbytesin1Request.

DNS ,
.
q sendmail . :
#sendmailq1h30mbd
Sendmail
.
q .
, , :

qI - ;

qR - ;

qS - .
395

Sendmail.
Sendmail telnet :
$telnetlocalhost25
Trying127.0.0.1...
Connectedtolocalhost.
Escapecharacteris'^]'.
220bblob.glott.comESMTPPostfix
HELOlocalhost
250bblob.glott.com
MAILFROM:uitzgen@localhost
250Ok
RCPTTO:robin@bobin.org
250Ok
DATA
354Enddatawith<CR><LF>.<CR><LF>
BolshojPrivet!
.
250Ok:queuedas477E7919EE
QUIT
221Bye
Connectionclosedbyforeignhost.
MTA
Sendmail SMTP.
SMTP,
:

HELO - SMTP ;

MAIL - ;

RCPT - ;

DATA - ;

SEND - ;

RSET - SMTP ;

VRFY - ;

EXPN - ;

HELP - ;
396

QUIT - .

HELO (
). MAILFROM: . RCPTTO:
. DATA ,
. QUIT .

mail.
SMTP.
mail
:
$mailmaximus@vergilius.it
Subject:Filioque
Cc:
Bcc:
Enddatawith.
.
.
mail .

Subject:. s mail. Cc:
Bcc:
. , .
mail .
mail ,
. , .
mail :

? - ;

- ;

+ - ;

n - ;

! - Shell;

P - ;

d - ;

u - ;

m - ;

r - ;

s - ;

w - ;
397

U - , ;

x - ;

q - .

mail . :
ls*.txt|mailejik.vtumane.ru
, ls*.txt
mail,
.
Sendmail
mail v.
:
$mailvemerald@susel.mistery.com<text.c
emerald...Connectingto[127.0.0.1]viarelay...
220susel.mistery.comESMTPSendmail8.13.8;2Aug200920:52:47
+0600
>>>EHLOsusel.mistery.com
250susel.mistery.comHellolocalhost.localdomain[127.0.0.1],
pleasedtomeetyou
250ENHANCEDSTATUSCODES
250PIPELINING
2508BITMIME
250SIZE
250DSN
250ETRN
250AUTHDIGESTMD5CRAMMD5
250DELIVERBY
250HELP
>>>MAILFrom:<emerald@susel.mistery.com>SIZE=16
AUTH=emerald@susel.mistery.com
2502.1.0<emerald@susel.mistery.com>...Senderok
>>>RCPTTo:<emerald@susel.mistery.com>
>>>DATA
2502.1.5<emerald@susel.mistery.com>...Recipientok
354Entermail,endwith"."onalinebyitself
>>>.
2502.0.0i72EqlMg001038Messageacceptedfordelivery
emerald...Sent(i72EqlMg001038Messageacceptedfordelivery)
Closingconnectionto[127.0.0.1]
>>>QUIT
2212.0.0susel.mistery.comclosingconnection
, v mail
(mail) (sendmail).
398

test ,
root. .

root.
?

mail, .

30..
CUPS.
RHEL CUPS (Common UNIX Printing System).
CUPS IPP (Internet Printing
Protocol),
HTTP. PPD (PostScript
Printer Description), .
CUPS - cupsd,
. CUPS /etc/cups.
:

cupsd.conf - ;

printers.conf - ;

classes.conf - () ;

client.conf - .

Apache,
.
CUPS
/etc/init.d service:
#servicecupsdstart

cupsd 631 TCP:


#netstatta
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00*:631*:*LISTEN
tcp00*:ssh*:*LISTEN

399

http://localhost:631 ,
CUPS,
, , .
/etc/cups/cupsd.conf
( ):
DocumentRoot/usr/share/cups/docs
LogLevelinfo
Userlp
Grouplp
Port631
SystemGrouplp
<Location/>
OrderDeny,Allow
DenyFromAll
AllowFrom127.0.0.1
</Location>
<Location/admin>
AuthTypeBasic
AuthClassSystem
OrderDeny,Allow
DenyFromAll
AllowFrom127.0.0.1
</Location>
:

DocumentRoot , CUPS.

LogLevel - .

User Group ,
.

Port - , .

SystemGroup - ,
.

<Location> .

, USB HP LJ1100.
/etc/cups/printers.conf :
<DefaultPrinterlaser>
InfoHP1100
LocationInmyroom
DeviceURIusb:/dev/usblp0
StateIdle
AcceptingYes
400

JobSheetsnonenone
QuotaPeriod0
PageLimit0
KLimit0
</Printer>
:

Info - ;

Location - ;

DeviceURI - ,
, USB , /dev/usblp0;

State - ;

Accepting -
;

JobSheets - ;

QuotaPeriod - ;

PageLimit - ;

KLimit - .

WEB .

,
100,
10.

CUPS.
CUPS - lp. , ,
test.txt :
$lptest.txt
requestidisdj1(1file(s))
lp :

d - , ;

h - ;

i - , , , ,
;

401

n - ;

q - ;

u - , ;

H - , ,
(, );

P - .

, , test.txt dj
:
lpddjn2test.txt
requestidisdj2(1file(s))
CUPS lpr. , ,
lpr :
lpr#2Pdjtest.txt

test.txt, laser,
trainer.

,
.

CUPS.
CUPS
,
http://localhost:631.
,
lpadmin. , ,
:
#lpadminplaserojobpagelimit=100
#cat/etc/cups/printers.conf
<DefaultPrinterlaser>
InfoHP1100
Location
DeviceURIusb:/dev/usblp0
402

StateIdle
AcceptingYes
JobSheetsnonenone
QuotaPeriod0
PageLimit100
KLimit0
</Printer>
lpadmin , laser (
p), 100.
/etc/cups/printers.conf .
,
:
#lpadminplaseruallow:bubuka
/etc/cups/printers.conf :
#cat/etc/cups/printers.conf
<DefaultPrinterlaser>
InfoHP1100
Location
DeviceURIusb:/dev/usblp0
StateIdle
AcceptingYes
JobSheetsnonenone
QuotaPeriod0
PageLimit100
KLimit0
AllowUserbubuka
</Printer>
,
PPD (PostScript Printer Definition).
:
#lpoptionsl
Resolution/OutputResolution:150dpi300dpi*600dpi1200dpi
Duplex/DoubleSidedPrinting:*NoneDuplexNoTumbleDuplexTumble
PageSize/MediaSize:LetterLegalExecutiveTabloidA3*A4A5B5
EnvISOB5Env10EnvC5EnvDLEnvMonarch
InputSlot/MediaSource:*DefaultTray1Tray2Tray3Tray4Manual
EnvelopeAuto
PageRegion/PageRegion:LetterLegalExecutiveTabloidA3A4A5B5
EnvISOB5Env10EnvC5EnvDLEnvMonarch
Option1/Duplexer:True*False
403

- PPD lpadmin :
#lpadminplaseroResolution=300dpi
#lpoptionsl
Resolution/OutputResolution:150dpi*300dpi600dpi1200dpi
Duplex/DoubleSidedPrinting:*NoneDuplexNoTumbleDuplexTumble
PageSize/MediaSize:LetterLegalExecutiveTabloidA3*A4A5B5EnvISOB5Env10
EnvC5EnvDLEnvMonarch
InputSlot/MediaSource:*DefaultTray1Tray2Tray3Tray4ManualEnvelopeAuto
PageRegion/PageRegion:LetterLegalExecutiveTabloidA3A4A5B5EnvISOB5Env10
EnvC5EnvDLEnvMonarch
Option1/Duplexer:True*False

300dpi.

10.

, lp, .

CUPS.
CUPS :
#lpstata
laseracceptingrequestssinceJan0100:00
, t lpstat:
#lpstatt
schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
laseracceptingrequestssinceJan0100:00
printerlaserisidle.enabledsinceJan0100:00
,
. , ,
. cupsdisable :
#cupsdisablelaser
#lpstatt
404

schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
laseracceptingrequestssinceJan0100:00
printerlaserdisabledsinceJan0100:00
Paused
, :
$lpdlaserlsmod.asp
requestidislaser1(1file(s))
$lpstat
laser1bubuka204826201001:06:39
$lpdlasersmbldaphowto.fr.html
requestidislaser2(1file(s))
$lpstat
laser1bubuka204826201001:06:39
laser2bubuka13926426201001:08:57

, .
reject :
#rejectr'Ushelnabazu!'laser
#lpstatt
schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
lasernotacceptingrequestssinceJan0100:00
Ushelnabazu!
printerlaserdisabledsinceJan0100:00
Ushelnabazu!
laser1bubuka204826201001:06:39
laser2bubuka13926426201001:08:57

r reject .
. , ,
laser2 :
#lpilaser2Himmediate
#lpstatububuka
laser2bubuka13926426201001:08:57
laser1bubuka204826201001:06:39

i lp , Himmediate -
.
cancel,
, . , ,
405

bubuka u :
#lpstatububuka
laser2bubuka13926426201001:08:57
laser1bubuka204826201001:06:39
#cancelububuka
#lpstatububuka

accept:
#lpstatt
schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
lasernotacceptingrequestssinceJan0100:00
Ushelnabazu!
printerlaserdisabledsinceJan0100:00
Ushelnabazu!
#acceptlaser
#lpstatt
schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
laseracceptingrequestssinceJan0100:00
printerlaserdisabledsinceJan0100:00
reasonunknown

cupsenable :
#cupsenablelaser
#lpstatt
schedulerisrunning
systemdefaultdestination:laser
deviceforlaser:usb:/dev/usblp0
laseracceptingrequestssinceJan0100:00
printerlaserisidle.enabledsinceJan0100:00

. ?

. ?

. ?

406

31.XWindow.
XWindow.
X Window 80-
(MIT) Athena,
IBM DEC.
,
. X - 11, 6,
X11R6.
X Window -.
-, , .
.
. X
,
, .
X X .
TCP/IP,
6000 TCP. X X . ,

.
X :

X (X applications). firefox,
PDF evince, emacs.

(Window Managers).

. Window Maker
( wmaker), Black Box (blackbox), Ice WM (icewm) twm.

(Desktop Environment),
, ,
,
. X ,
,
. KDE (K Desktop Environment)
GNOME (GNU Objects Model Environment).

(X Session Managers). ,
X
Shell. X
X .
xdm, kdm gdm. X XDMCP (X
Display Manager Control Protocol). X ,
.
Shell, , X , ,
(desktop) X .

X , , ,
407

.
X
. ,
,
(API - Application Program Interface). , , X
X
.
GNU/Linux X
:

Qt - KDE;

Gtk+ - X
GNOME.

X - X ( Xorg):
$lsl`whichX`
lrwxrwxrwx1rootroot42109:30/usr/bin/X>Xorg
$lslL`whichX`
rwsxx1rootroot18906921406:26/usr/bin/X
X Window X Font Server (xfs),
, , X . X
, .

X .

( wm)?

XWindow.
Xorg xorg.conf. GNU/Linux
/etc/X11.
,
.
Xorg Xconfigure,
.
/etc/X11/xorg.conf :
Section"ServerLayout"
Identifier"DefaultLayout"
408

Screen0"Screen0"00
InputDevice"Keyboard0""CoreKeyboard"
EndSection
Section"InputDevice"
Identifier"Keyboard0"
Driver"kbd"
Option
"XkbModel""pc105"
Option
"XkbLayout""us,ru"
Option
"XkbOptions""grp:shifts_toggle,grp_led:scroll"
EndSection
Section"Device"
Identifier"Videocard0"
Driver"vesa"
EndSection
Section"Screen"
Identifier"Screen0"
Device"Videocard0"
DefaultDepth24
SubSection"Display"
Viewport00
Depth24
EndSubSection
EndSection
, xorg.conf :

ServerLayout - X
;

InputDevice - , ,
;

Device - ;

Screen - , ,
.

:
Section"InputDevice"
Identifier"Keyboard0"
Driver"keyboard"
Option"Protocol""Standard"
Option"XkbModel""pc105"
Option"XkbRules""xfree86"
Option"XkbLayout""us,ru"
Option"XkbOptions""grp:shifts_toggle,grp_led:scroll"
EndSection

409

, Option"XkbModel"
"pc105". Option"XkbLayout""us,ru" ,
Option"XkbOptions""grp:ctrls_shift_toggle,grp_led:scroll"-
- Shift. ,
Scroll
Lock .
:
Section"InputDevice"
Identifier"DevInputMice"
Driver"mouse"
Option"Protocol""IMPS/2"
Option"Device""/dev/input/mice"
Option"ZAxisMapping""45"
Option"Emulate3Buttons""no"
EndSection

Emulate3Buttons.
, .
PS/2,
- IMPS/2. , , ,
, Option"ZAxisMapping""45".
, PS/2 /dev/psaux, USB
/dev/input/mice.
Files RGB:
RgbPath"/usr/X11R6/lib/X11/rgb"
Files :
FontPath"/usr/X11R6/lib/X11/fonts/cyrillic/"
. ,
. :
FontPath"unix/:1"
.

, :
FontPath"tcp/:192.168.1.1:7100"

410

TCP 7100.
Monitor :
Section"Monitor"
Identifier"Monitor"
HorizSync31.548.5
VertRefresh5090
Modeline"1024x768"651024103211761344768771777806
hsyncvsync
EndSection
VertRefresh ( )
HorizSync ( ). Modeline
,
.
xvidtune.
Device , , , PCI
, BusID"PCI:0:2:0".
, : Driver"i810".
Screen :
Section"Screen"
Identifier"Screen0"
Device"IntelCorp.|82852/855GMChipsetIntegrated
GraphicsDevice"
Monitor"Monitor"
DefaultColorDepth24
SubSection"Display"
Depth24
Modes"1024x768"
Virtual1024768
EndSubSection
EndSection
DefaultColorDepth , ,
. Display .

, X .


, .
411

.
X , ,
- xfs.
X , , ,
.
, X ,
, ,
X .
.
xfs
, stand-alone .
, ,
X Fonts :
Section"Files"
RgbPath"/usr/X11R6/lib/X11/rgb"
FontPath"unix/:1"
EndSection
,
:
Section"Files"
RgbPath"/usr/X11R6/lib/X11/rgb"
FontPath"tcp/:192.168.1.200:7100"
EndSection
xfs RHEL - /etc/X11/fs/config.
:
#
#xfsfontserverconfigurationfile
#
#allowamaxof10clientstoconnecttothisfontserver
clientlimit=10
#whenafontserverreachesitslimit,startupanewone
cloneself=on
#alternatefontserversforclientstouse
#alternateservers=foo:7101,bar:7102
#wheretolookforfonts
catalogue=/usr/share/X11/fonts/misc:unscaled,
412

/usr/share/X11/fonts/75dpi:unscaled,
/usr/share/X11/fonts/100dpi:unscaled,
/usr/share/X11/fonts/Type1,
/usr/share/X11/fonts/TTF,
/usr/share/fonts/default/Type1,
,
/usr/share/fonts/KOI8R/misc:unscaled,
/usr/share/fonts/KOI8R/75dpi:unscaled,
/usr/share/fonts/KOI8R/100dpi:unscaled,
/usr/share/fonts/KOI8R/misc,
/usr/share/fonts/KOI8R/75dpi,
/usr/share/fonts/KOI8R/100dpi
#in12points,decipoints
defaultpointsize=120
#75x75and100x100
defaultresolutions=75,75,100,100
#uselazyloadingon16bitfonts
deferglyphs=16
#Logerrorsviasyslog.
usesyslog=on
#Forsecurity,don'tlistentoTCPportsbydefault.
nolisten=tcp
xfs:

nolisten=tcp - TCP;

clientlimit - ;

cloneself=on - ,
;

catalogue - ;

defaultpointsize - ;

defaultresolutions -
;

usesyslog - syslogd .

/usr/share/X11/fonts/. :
$ls/usr/share/X11/fonts/cyrillic/
crox1cbo.pcf.gzcrox2tb.pcf.gzcrox4to.pcf.gzkoi10x20.pcf.gz
crox1cb.pcf.gzcrox2to.pcf.gzcrox4t.pcf.gzkoi12x24b.pcf.gz
crox1co.pcf.gzcrox2t.pcf.gzcrox5hbo.pcf.gzkoi12x24.pcf.gz
crox1c.pcf.gzcrox3cbo.pcf.gzcrox5hb.pcf.gzkoi5x8.pcf.gz
crox1hbo.pcf.gzcrox3cb.pcf.gzcrox5ho.pcf.gzkoi6x10.pcf.gz
crox1hb.pcf.gzcrox3co.pcf.gzcrox5h.pcf.gzkoi6x13b.pcf.gz
crox1ho.pcf.gzcrox3c.pcf.gzcrox5tbo.pcf.gzkoi6x13.pcf.gz
crox1h.pcf.gzcrox3hbo.pcf.gzcrox5tb.pcf.gzkoi6x9.pcf.gz
crox1tbo.pcf.gzcrox3hb.pcf.gzcrox5to.pcf.gzkoi7x14b.pcf.gz

413

crox1tb.pcf.gzcrox3ho.pcf.gzcrox5t.pcf.gzkoi7x14.pcf.gz
crox1to.pcf.gzcrox3h.pcf.gzcrox6hbo.pcf.gzkoi8x13.pcf.gz
crox1t.pcf.gzcrox3tbo.pcf.gzcrox6hb.pcf.gzkoi8x16b.pcf.gz
crox2cbo.pcf.gzcrox3tb.pcf.gzcrox6ho.pcf.gzkoi8x16.pcf.gz
crox2cb.pcf.gzcrox3to.pcf.gzcrox6h.pcf.gzkoi9x15b.pcf.gz
crox2co.pcf.gzcrox3t.pcf.gzcrox6tbo.pcf.gzkoi9x15.pcf.gz
crox2c.pcf.gzcrox4hbo.pcf.gzcrox6tb.pcf.gzkoi9x18b.pcf.gz
crox2hbo.pcf.gzcrox4hb.pcf.gzcrox6to.pcf.gzkoi9x18.pcf.gz
crox2hb.pcf.gzcrox4ho.pcf.gzcrox6t.pcf.gzkoinil2.pcf.gz
crox2ho.pcf.gzcrox4h.pcf.gzfonts.aliasproof9x16.pcf.gz
crox2h.pcf.gzcrox4tbo.pcf.gzfonts.dirscreen8x16b.pcf.gz
crox2tbo.pcf.gzcrox4tb.pcf.gzkoi10x16b.pcf.gzscreen8x16.pcf.gz

, X
.
, ,
mkfontdir,
, .
:
#lskwintv/
ledfixed.pcf
#mkfontdirkwintv/
#lskwintv/
fonts.dirledfixed.pcf
#xsetfprehash
kwintv
mkfontdir. xsetfprehash X
, .

, .

X TCP.

xfs (
cyrillic, koi8, cp1251 ..)?

X.
X - X X. :
$X:0.0&
XWindowSystemVersion7.1.1
ReleaseDate:12May2006
XProtocolVersion11,Revision0,Release7.1.1
BuildOperatingSystem:Linux2.6.1853.el5i686RedHat,Inc.

414

CurrentOperatingSystem:Linuxlocalhost.localdomain2.6.18194.3.1.el5#1SMP
ThuMay1313:09:10EDT2010i686
BuildDate:13May2010
BuildID:xorgx11server1.1.148.76.el5_5.1
Beforereportingproblems,checkhttp://wiki.x.org
tomakesurethatyouhavethelatestversion.
ModuleLoaderpresent
Markers:()probed,(**)fromconfigfile,(==)defaultsetting,
(++)fromcommandline,(!!)notice,(II)informational,
(WW)warning,(EE)error,(NI)notimplemented,(??)unknown.
(==)Logfile:"/var/log/Xorg.0.0.log",Time:ThuMay2722:55:482010
(==)Usingconfigfile:"/etc/X11/xorg.conf"
(WW)VESA(0):Failedtosetupwritecombiningrange(0xe0800000,0x400000)
(WW)VESA(0):Failedtosetupwritecombiningrange(0xe0000000,0xc00000)
TheXKEYBOARDkeymapcompiler(xkbcomp)reports:
>Warning:Multiplesymbolsforlevel1/group1onkey<I5F>
>UsingXF86Sleep,ignoringXF86Standby
>Warning:Symbolmapforkey<I5F>redefined
>Usinglastdefinitionforconflictingfields
ErrorsfromxkbcomparenotfataltotheXserver
FreeFontPath:FPE"unix/:7100"refcountis2,shouldbe1;fixing.

X:0.0& X . :0.0,
: X
(X:.).
,
. ,
X ,
. , , X
:
$X:1.0&
X
:
$netstattan
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp000.0.0.0:60000.0.0.0:*LISTEN
tcp000.0.0.0:60010.0.0.0:*LISTEN

X . , ,
, X
CtrlAltF7, : CtrlAltF8.
, X TCP 6000, - 6001.
X , X , ,
display:0.0 :
$xtermdisplay:0.0&

415

, , :
$xeyesdisplay:1.0&
X TCP, unix socket
, , nolisten
tcp :
$Xnolistentcp:0.0&
TCP X
, X X
.
X X
, startx - Shell,
xinit. xinit X
xterm.
$xinit
X - xterm.
.xinitrc, X ,
xterm.
~/.xinitrc :
xclockg50x500+0&
blackbox
X :
xclock ( ) blackbox. g
xclock ( X )
. , xclock .
xclock.
~/.xinitrc ,
xterm :
xtermgeometry+1+1nlogindisplay:0
n xterm .
X xinit - ,
~/.xserverrc. X
. :
416

execX:0.0nolistentcp
~/.xserverrc , xinit
X TCP .
xinit ,
X :
$xiniticewmX:0.0nolistentcp
X TCP,
icewm.
xinit X startx,
xinit.
$startx
startx xinit X .
startx xinit ,
xinitrc xserverrc. RHEL
/etc/X11/xinit.

X
.

X TCP
.

~/.xinitrc , X
twm xterm.

.

/etc/X11/xinit/xinitrc.

Xxdm.
X , Shell
startx .
X X X ,
.
417

GNU/Linux :

xdm - X ;

gdm - GNOME;

kdm - KDE.

X XDMCP (X Display Manager


Control Protocol). X X
, .
,
X . Red Hat -
X 5 .
xdm RHEL - /etc/X11/xdm/xdmconfig .
:
DisplayManager.errorLogFile:/var/log/xdm.log
DisplayManager.pidFile:/var/run/xdm.pid
DisplayManager.keyFile:/etc/X11/xdm/xdmkeys
DisplayManager.servers:/etc/X11/xdm/Xservers
DisplayManager.accessFile:/etc/X11/xdm/Xaccess
DisplayManager.willing:sunobodyc/etc/X11/xdm/Xwilling
DisplayManager*authorize:true
!Thefollowingthreeresourcessetupdisplay:0astheconsole.
DisplayManager._0.setup:/etc/X11/xdm/Xsetup_0
DisplayManager._0.startup:/etc/X11/xdm/GiveConsole
DisplayManager._0.reset:/etc/X11/xdm/TakeConsole
DisplayManager*resources:/etc/X11/xdm/Xresources
DisplayManager*session:/etc/X11/xdm/Xsession
DisplayManager*authComplain:true
DisplayManager.requestPort:0
.
xdmconfig
, xdm X , :

Xservers - X ;

Xaccess - xdm XDMCP;

Xsession - , X ;

Xresources - () xdm X
, Xsession.

/etc/X11/xdm/Xservers :
:0local/usr/X11R6/bin/X:0.0

418

xdm, ,
X .
Xaccess , X .
Xsession ,
xdm.
, ,
.
, xdm (,
) , Xsession,
Xresources. , X .

/etc/X11/xinit/Xresources ,
, xdm.

/etc/X11/xinit/Xsession
GNOME - gnomesession, KDE - startkde.
.

( RH) xdm
.

X.
X .
:

bg - X ;

fg - ;

bd - ;

bw - ;

display - , , X
X ;

fn - ;

geometry - X ;

iconic - , ;

name - ,
, ;

title - X ;

xnllanguage - , (,
ru_RU.KOI8R);

xrm - .
419

X X ,
GNU/Linux. X ,
X . ,
, :

xterm - , XFree86 Xorg;

rxvt - xterm ,
;

aterm - rxvt
;

Eterm Enlightenment;

gnometerminal - GNOME
, Shell
;

konsole - , KDE
.

, , xterm ,
:
$xtermbgnavyfgcyangeometry100x40+20+10&
, , xterm .
, ,
, xterm.
X , , ,
. , X
, , .
ps u,
, .
pstree, .
pstree,
kterm KDE:
|kdeinit+artsd
||evolutionalarm
||2*[kdeinit]
||kdeinitbashpstree
|`soffice.binsoffice.bin4*[soffice.bin]
|9*[kdeinit]
|kdm+X
|`kdmkde3.1.5startkdekwrapper

420

, , X
kdm, KDE. , KDE,
. , , soffice.bin,
Open Office.

xterm , , - .

gnomesession bg ?

.
:

(Sans Serif), , Helvetica Lucida.

(Serif), , Courier Times.

, , Symbol.

, , ,
, , .

, Times.

, , Courier. ,
, .

X Window ( )
, :

Foundry ;

FamilyName ;

WeightName : Medium , Bold Demibold


;

Slant : r (regular), i (italic), o


(oblique);

SetwidthName : normal ,
semicondensed condensed ;

AddStyleName ( );

Pixelsize ;

Pointsize ;

ResolutionX ;

ResolutionY ;
421

Spacing p, m ;

AverageWidth ;

CharsetRegistry ;

CharsetEncoding .

,
, . , ,
. :
*symbol*****240******
Symbol 24 .
, , X Window
.
X Window ,
.
xfontsel , ,
,
, .
xlsfontsfn .
$xlsfontsfn*lucida*i**12*****koi8*
b&hlucidaboldinormalsans121207575p79koi8r
b&hlucidaboldinormalsans121207575p79koi8r
b&hlucidamediuminormalsans121207575p71koi8r
b&hlucidamediuminormalsans121207575p71koi8r
, , lucida,
, 12 , KOI8R.
fn ,
X , :
xtermfn*courierbold****90****cyr*
Courier
9 .

xfontsel xlsfonts .

422

xterm (italic)
140 .

X.
X , KDE
GNOME, ,
. , ,
.
X , X Toolkit,
( , , ) .
- Xresources, xdm
.
X
/etc/X11/appdefaults , X
. x X
, ,
X. , , xterm /etc/X11/app
defaults/Xterm.
~/.Xresources,
X .
X , X
Toolkit, xlogo,
X Window. :
xlogofgred, X .
,
~/.Xresources :
XLogo*Foreground:red
, X
:
$xrdbmerge~/.Xresources
xlogo -
.
X :

, X Toolkit, ,
X (,
X ).

(,
emacs - Emacs). ,
423

x, (, xterm XTerm).

! , # -
. :
.

X . .
* ,
X .

man, X .

~/.Xresources , xterm -
, - .

140 xterm.

,
xterm.

X.
X Window -, X ,
, X ,
. , , X
, , ,
X , .
X X
X , X
X .
, , X
xhost.
, X ,
X .
$xhost
accesscontrolenabled,onlyauthorizedclientscanconnect
xhost , .
, X
, X .
X :
$xhost+
accesscontroldisabled,clientscanconnectfromanyhost
424

X .
:
$xhost
accesscontrolenabled,onlyauthorizedclientscanconnect
xhost ,
X , X :
$xhost+classfw
classfwbeingaddedtoaccesscontrollist
$xhost
accesscontrolenabled,onlyauthorizedclientscanconnect
INET:classfw.bubuka.biz
classfw.
/etc/hosts. , xhost
DNS .
X , X , ,
X .
X display. :
classfw:~>xtermdisplaybamboo.bubuka.biz:0.0&
X xterm, classfw
X , bamboo.bubuka.biz.
display
DISPLAY,
:
classfw:~>DISPLAY=bamboo.bubuka.biz
classfw:~>exportDISPLAY
classfw:~>xterm&
DISPLAY - X
X , .
xhost , .
xauth,
MIT-MAGIC-COOKIE-1. X
6000 , .
X
OpenSSH. .
425

X . ssh X,
X . , ssh
X , sshd ,
, DISPLAY :10.0.
, X OpenSSH.
xterm ,
, OpenSSH ( ),
, sshd.
sshXremote.host.infoxterm
remote.host.info sshd
, X .
xterm
ssh.

X xterm
, X ,
display.

DISPLAY.
xterm.

- X
X , X .

xdm.
xdm, gdm kdm X
XDMCP ( 177 UDP).
xdm X ,
177 UDP .
/etc/X11/xdm/xdmconfig :
!SECURITY:donotlistenforXDMCPorChooserrequests
!CommentoutthislineifyouwanttomanageXterminalswithxdm
DisplayManager.requestPort:0
DisplayManager.requestPort:0 xdm
.
( ).
XDMCP, , xdm,
, X :
426

Xquery<> -
X .

Xbroadcast -
XDMCP, .

Xindirect<> - XDMCP,
,
X (chooser).

, , XDMCP susel.ritter.org
:
$Xquerysusel.ritter.org
, ()
XDMCP, , :
$Xindirectsusel.ritter.org
XDMCP,
X .
XDMCP
/etc/X11/xdm/Xaccess.
xdm ,
- :
*
xdm, /etc/X11/xdm/Xaccess, ,
, XDMCP:
*.ritter.org
, ritter.org,
XDMCP.
, , ritter.org xdm
,
susel.ritter.org ejick.ritter.org,
/etc/X11/xdm/Xaccess :
*.ritter.org

CHOOSER

susel.ritter.orgejick.ritter.org

XDMCP,
427

. , ,
XDMCP, , /etc/X11/xdm/Xaccess
:
*

CHOOSER

BROADCAST

xdm
class.edu. X .

XVNC.
, X ,
VNC (Virtual Network Computing). : Xvnc
vncviewer. Xvnc
: X ,
, VNC. vncviewer VNC,
5900, .
VNC, 5901,
5902 .
VNC vncserver,
Xvnc. X .
$vncserver:1
New'c55.class.edu:1(aberes)'desktopisc55.class.edu:1
Startingapplicationsspecifiedin/home/aberes/.vnc/xstartup
Logfileis/home/aberes/.vnc/c55.class.edu:1.log
$netstattan
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp000.0.0.0:58010.0.0.0:*LISTEN
tcp000.0.0.0:59010.0.0.0:*LISTEN
tcp000.0.0.0:60010.0.0.0:*LISTEN
tcp00127.0.0.1:250.0.0.0:*LISTEN
tcp00:::6001:::*LISTEN
tcp00:::22:::*LISTEN

VNC 1, Xvnc
5901. , X 6001 5801, HTTP , Java VNC .
$telnet192.168.56.1015801
Trying192.168.56.101...
Connectedto192.168.56.101.
Escapecharacteris'^]'.
GET/
HTTP/1.1400BadRequest

428

Server:RealVNC/4.0
Date:Sat,12Jun201011:29:20GMT
LastModified:Sat,12Jun201011:29:20GMT
Connection:close
ContentType:text/html
<!DOCTYPEHTMLPUBLIC"//IETF//DTDHTML2.0//EN">
<HTML><HEAD>
<TITLE>400BadRequest</TITLE>
</HEAD><BODY><H1>
BadRequest
</H1></BODY></HTML>
Connectionclosedbyforeignhost.

HTTP VNC telnet.


VNC vncviewer.
tightvnc.
$vncviewer192.168.56.101:1
ConnectedtoRFBserver,usingprotocolversion3.8
PerformingstandardVNCauthentication
Password:
Authenticationsuccessful
Desktopname"c55.class.edu:1(aberes)"
VNCserverdefaultformat:
16bitsperpixel.
Leastsignificantbytefirstineachpixel.
Truecolour:maxred31green63blue31,shiftred11green5blue0
Warning:Cannotconvertstring"*helveticaboldr**16*******"totype
FontStruct
UsingdefaultcolormapwhichisTrueColor.Pixelformat:
32bitsperpixel.
Leastsignificantbytefirstineachpixel.
Truecolour:maxred255green255blue255,shiftred16green8blue0
ShmCleanupcalled
UsingsharedmemoryPutImage

1.

429

1.
vncviewer.

VNC vncserverkill,
.
$vncserverkill:1
KillingXvncprocessID3169
GNOME KDE ,
VNC. , , GNOME vinoserver
vino, VNC.
$rpmqif/usr/libexec/vinoserver
Name:vinoRelocations:(notrelocatable)
Version:2.13.5Vendor:CentOS
Release:9.el5_4BuildDate:18200915:08:10
InstallDate:20201022:30:58BuildHost:builder16.centos.org
Group:UserInterface/DesktopsSourceRPM:vino2.13.59.el5_4.src.rpm
Size:1137260License:GPL
Signature:DSA/SHA1,27201002:00:42,KeyIDa8a447dce8562897
URL:http://www.gnome.org
Summary:GNOME.
Description:
VinoVNCGNOME.
GNOME,VNC.

GNOME
, ( 2).

2.
.

430


.
, .
.
.
3 .

3.
.

GNOME , VNC
vinoserver.
#netstattanp
ActiveInternetconnections(serversandestablished)
ProtoRecvQSendQLocalAddressForeignAddressStatePID/Programname
tcp000.0.0.0:59000.0.0.0:*LISTEN2768/vinoserver
tcp00:::22:::*LISTEN2328/sshd

4 vncviewer GNOME.

431

4.
GNOME.

VNC
, .
X
. , ,
OpenSSH, .
ssh.
$sshfNL1024:192.168.56.101:5900192.168.56.101
aberes@192.168.56.101'spassword:
$psCsshocommand
COMMAND
sshfNL1024:192.168.56.101:5900192.168.56.101
$netstatt
ActiveInternetconnections(w/oservers)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00192.168.56.1:42371192.168.56.101:sshESTABLISHED

ssh f ,
N L .
L 1024, IP ,
, 5900 ,
, .
vncviewer IP
:
$vncviewerlocalhost:1024
ConnectedtoRFBserver,usingprotocolversion3.7
PerformingstandardVNCauthentication
Password:

432

Authenticationsuccessful
Desktopname"LibVNCServer"
VNCserverdefaultformat:
32bitsperpixel.
Leastsignificantbytefirstineachpixel.
Truecolour:maxred255green255blue255,shiftred16green8blue0
Warning:Cannotconvertstring"*helveticaboldr**16*******"totype
FontStruct
UsingdefaultcolormapwhichisTrueColor.Pixelformat:
32bitsperpixel.
Leastsignificantbytefirstineachpixel.
Truecolour:maxred255green255blue255,shiftred16green8blue0
ShmCleanupcalled
UsingsharedmemoryPutImage
Samemachine:preferringrawencoding

VNC .
$netstatt
ActiveInternetconnections(w/oservers)
ProtoRecvQSendQLocalAddressForeignAddressState
tcp00localhost:1024localhost:44415ESTABLISHED
tcp00192.168.56.1:42371192.168.56.101:sshESTABLISHED
tcp00localhost:44415localhost:1024ESTABLISHED

, VNC .

VNC .

GNOME .

OpenSSH VNC .

433

32.GNU/Linux.
GNU/Linux.
GNU/Linux
x86/64:

CD/DVD .

FTP/HTTP .

NFS .

SCSI, IDE CD/DVD . CD/DVD


.
FTP, HTTP NFS CD
. :

CD/DVD .

CD .

USB Pen Drive.

PXE.

USB Pen Drive CD Red Hat


:
$lsl/media/cdrom/images/
171863
rwrr1aberesroot99491843006:22boot.iso
rwrr1aberesroot125829123006:22diskboot.img
rwrr1aberesroot412958723006:25minstg2.img
drwxrxrx2aberesroot20483006:22pxeboot
rwrr1aberesroot6503006:22README
rwrr1aberesroot1121525763006:27stage2.img
rrr1aberesroot15413006:27TRANS.TBL
drwxrxrx2aberesroot20483006:23xen

USB Pen Drive , ,


(! , USB Pen Drive
dmesg):
ddif=/media/cdrom/images/diskboot.imgof=/dev/sdb

. , boot:
linuxmediacheck :
boot:linuxmediacheck
Red Hat anaconda,
434

.

GNU/Linux , ,
.


. ,

,
, .
GNU/Linux
,
( ).
, .
( ).
GNU/Linux x86/64,
, IBM Power.
i386 Xeon. ,
, AMD VIA.
, GNU/Linux
. , .
Red Hat Enterprise Linux 5 256 .
512 . 1
.
GNU/Linux x86/64
.
X Window Xorg.
GNU/Linux PATA, SATA, SCSI SAS . USB
, .
GNU/Linux ATAPI, SCSI USB CD/DVD .
, .
.

BIOS ?

USB ?

PXE?

GNU/Linuxx86/64.
GNU/Linux
(installation hardware checklist).
. :
435

1. .
2. .
3. (chipset).
4. BIOS:
4.1.;
4.2. ;
4.3. (>1024 );
4.4.
(IRQ, IO/Base, DMA);
4.5. UTC, .
5. :
5.1.;
5.2.;
5.3..
6. , :
6.1.PCI;
6.2.PCI-II;
6.3.PCI-E;
6.4.AGP;
6.5..
7. :
7.1. , , (9 25 );
7.2. ;
7.3.USB;
7.4.Firewire;
7.5.PC Card (PCMCIA);
7.6.PS/2;
7.7. SCSI SAS :
a) ;
b) ;
c) SCSI ;
d) ;
e) SCSI ID .
8. .
9. :
9.1. .

436

9.2. ( , , ).
9.3.IDE:
a) (Serial/Parallel ATA);
b) ;
c) Primary Secondary (
);
d) Master/Slave/Cable select.
9.4.SCSI SAS:
a) ;
b) (SE, LVD SAS);
c) SCSI ID.
9.5.RAID :
a) ;
b) : SCSI, SAS Fibre Channel;
c) SCSI ID LUN;
d) RAID .
9.6. ( , ,
, ).
9.7. :
a) RAID ( md) ;
b)LVM (Logical Volume Manager).
10. CD/DVD:
10.1.;
10.2. : PATA, SATA SCSI;
10.3. : SCSI ID Primary/Secondary Master/Slave PATA;
10.4. .
11. :
11.1. (PS/2, IrDA, USB, Blue Tooth ..).
11.2. .
11.3.:
a) ;
b);
c) (PS/2, IMPS/2);
d) .
11.4. (): , touch-pad .
12.:
12.1. , ;
437

12.2. ;
12.3. ;
12.4. ( ).
13. MIDI .
13.1. ;
13.2. .
14. :
14.1., , ;
14.2. TCP/IP:
a) ;
b) IP (IPv4 IPv6);
c) IP ;
d)IP ;
e) IP DNS .
,
.
GNU/Linux.
GNU/Linux
, .
,
.
GNU/Linux
:

, ,
, .

.
GNU/Linux
:

Kerberos;

NIS/NIS+ ;

LDAP;

SMB .

438

, .

.

.
du,
, .
.
GNU/Linux :
#dush/*
8,2M/bin
13M/boot
88K/dev
131M/etc
88K/export
9,5M/home
138M/lib
16K/lost+found
3,9G/media
0/misc
8,0K/mnt
0/net
8,0K/opt
0/proc
4,5M/root
35M/sbin
0/selinux
8,0K/srv
0/sys
276K/tmp
3,1G/usr
159M/var
:

/boot 100 ,
ext2 ext3, ;

/home ,

(, 10 10 = 100 );

/usr ,

500 5-10
;

/opt ,
,
,
1 ;
439

/var 300 ,
;

/tmp 200-300 ;

, ,
500 .
GNU/Linux
, .
, , ,
fdisk.

GNU/Linux. GRUB,
MBR, . .
GNU/Linux.

hardware checklist GNU/Linux .

GNU/Linux,
.

CentosCD/DVD.
Centos
boot: ( 1).

1.
.





<Enter>.




,
linuxtext.
<F2>
( 2).

440

2.
.

noprobe

mediacheck ;

rescue ;

dd ;

askmethod ;

update ;

memtest86 ;

autostep kickstart;

expert ;

graphical ;

ks kickstart;

lang ;

method=... - ;

noprobe ;

nostorage ;

nousbstorage USB ;

resolution ;

serial COM ;

text ;

vnc VNC.

<F3> ( 3).

441

3.

.


<F4>



( 4).

4.

.


<F5>

( 5).

5.

.



GNU/Linux

CD
DVD
.
,
( 6).

442

6.

.




( 7).


, ,
.
, .
RAID LVM.

7.

.




( 8).

8.

.




( 9).

443

9.
.

root ( 10).

10.
root.



(
11).

. ,



.

11.

.






(
12).

12.

.

444


( 13).

13.
.




,
14.

14.
.


,
.

kickstart.
Red Hat
kickstart.
,
. ks.cfg.
,
systemconfigkickstart.
ks.cfg
root anacondaks.cfg.
ks.cfg,
445

, .
install
cdrom
langru_RU.UTF8
keyboardru
xconfigstartxonboot
networkdeviceeth0bootprotodhcp
rootpwiscrypted$1$RulLlnPi$BlatyTmojParolTruLala/
firewallenabledport=22:tcp
authconfigenableshadowenablemd5
selinuxenforcing
timezoneAsia/Yekaterinburg
bootloaderlocation=mbrdriveorder=hdaappend="rhgbquiet"
#Thefollowingisthepartitioninformationyourequested
#Notethatanypartitionsyoudeletedarenotexpressed
#heresounlessyouclearallpartitionsfirst,thisis
#notguaranteedtowork
#clearpartlinuxdrives=hda
#part/bootfstypeext3size=100ondisk=hda
#partpv.2size=0growondisk=hda
#volgroupVolGroup00pesize=32768pv.2
#logvol/fstypeext3name=LogVol00vgname=VolGroup00size=1024grow
#logvolswapfstypeswapname=LogVol01vgname=VolGroup00size=384grow
maxsize=768
autostepautoscreenshot
%packages
@admintools
@base
@core
@dnsserver
@dialup
@editors
@ftpserver
@gnomedesktop
@games
@graphicalinternet
@graphics
@legacynetworkserver
@mailserver
@networkserver
@newsserver
@office
@printing
@russiansupport
@servercfg
@soundandvideo
@textinternet
@webserver
@smbserver
@basex
keyutils
kexectools
trousers
fipscheck
devicemappermultipath
libsanehpaio
vncserver
xorgx11serverXnest

ks.cfg
anaconda. :

CD DVD;

446

USB Pen Drive.

ks.cfg
:
linuxks=cdrom:/ks.cfg
anaconda .
ks.cfg - , anaconda
, .

ks.cfg
.

447