Linux, , .
, . - , .
, , Linux, . , , . " Linux System Administrator's Guide", Linux . , . , , .
, UNIX ,
, ,
(, , - ).
account ( ),
, ..
, (
:-) ,
. ""
- root
().
,
- (
), .
,
, ,
( /bin
/usr/bin
).
, ,
.
root.
root ,
, .
(root
) () ,
.
, ( ),
( root
), ,
, ,
. root ,
, - ,
.
,
/etc
,
. , root
, ,
, . ,
root. ,
:
root
.
root,
.
, ,
larry
,
root.
root
.
root- .bashrc
.login
, root
. , ``$
''
``#
''
root.
root
,
. , root-,
( root- ).
root, ., , root
. -
( ) .
:
root
, , root
.
, . Linus Torvalds ( linux) , . () . , , , .
-, root
,
,
, ,
. ( ),
,
.
.
UNIX,
- . UNIX
UNIX.
root
. ,
root - .
.
root ;
, , .
root
. root
,
root,
. "
",
,
"".
root
,
,
account ( ""),
- .
.
,
?
.
UNIX root
. ,
.
.
UNIX . " " - , . , , .
, , . " " . , , , . , "" . - - , . , , , . .
, ``'' , . , . " " - . , . , , . , , , .
- . , UNIX. , , . , . , , UNIX, . ... ', .
, , . , , . , .
, . , . , , , . , " " ( " ").
. , UNIX. , "" , , UNIX . . , , , .
, , . , 386- Cray. root ; . .
: , .
Linux `` '', Linux. Linux, , . ( rdev ; . ). , , , Slackware .
,
.
/Image
/etc/Image
.
/vmlinux
.
.
.
, /zImage
/etc/zImage
.
, ,
rdev
. :
rdev <kernel-name> <root-device>
<kernel-name>
; , a
<root-device>
-
Linux. ,
/etc/Image
/dev/hda2
# rdev /etc/Image /dev/hda2
rdev ,
SVGA,
. ``rdev -h
'' .
. , MS-DOS. , .
, /etc/Image
/etc/fd0
# cp /etc/Image /dev/fd0
Linux.
- LILO, , . , Linux , .
LILO ,
,
, (, Linux
MS-DOS) . LILO,
, ,
linux
'' ``msdos
'').
LILO -
/etc/lilo.conf
# /sbin/lilo
LILO ``stanza''("" -
, ).
, .
LILO
config. ,
Linux /dev/hda1
MS-DOS
/dev/hda2
.
# Tell LILO to modify the boot record on /dev/hda (the first
# non-SCSI hard drive). If you boot from a drive other than /dev/hda,
# change the following line.
boot = /dev/hda
# Name of the boot loader. No reason to modify this
# un less you're doing some serious hacking on LILO.
install = /boot/boot.b
# Have LILO perform some optimization.
compact
# Stanza for Linux root partition on /dev/hda1.
image = /etc/Image # Location of kernel
label = linux # Name of OS (for the LILO boot menu)
root = /dev/hda1 # Location of root partition
vga = ask # Tell kernel to ask for SVGA modes at boot time
# Stanza for MSDOS partition on /dev/hda2.
other = /dev/hda2 # Location of partition
table = /dev/hda # Location of partition table for /dev/hda2
label = msdos # Name of OS (for boot menu)
config
-
, LILO .
LILO,
.
, ,
, /sbin/lilo
,
.
,
``root =
'', rdev
. LILO .
Linux FAQ ( A)
, LILO Boot
Manager OS/2.
Linux - . , "reset" . - . , , .
. , (, ..). . , , , () .
,
shutdown
.
shutdown <time> <warning-message>
<time>
- ( hh:mm:ss -
::) <warning-message>
- ,
.
(<time>
) ``now
'',
. -r
.
, 8:00
# shutdown -r 20:00
halt
. halt
,
.
! , :
The system is halted
c "", shutdown
halt
.
, ,
Linux.
account
root
. , ,
account (
). ,
.
, account
. ,
.
.
,
. larry
,
karl
mdw
. ,
.
.
ID ( UID) - - , . , .
ID ( GID) - . 3.9 ; , . .
. passwd .
" " " "
. , schmoj
``Joe Schmo''
- ,
.
, /home
.
shell - shell,
. , ,
/bin/bash
/bin/tcsh
.
/etc/passwd
.
; :
username:encrypted_password:UID:GID:full_name:home_directory:login_shell
, :
kiwi:Xv8Q981g71oKK:102:100:Laura Poole:/home/kiwi:/bin/bash
, ``kiwi
'' - .
``Xv8Q981g71oKK
'' - .
.
. , ,
. .
Linux
" ",
/etc/shadow
. /etc/passwd
, /etc/shadow
.
,
..; .
, ``102
'', - (UID).
.
, ``100
'', (GID).
100.
/etc/group
.
4.4.5.
- , ``Laura Poole''.
-
(/home/kiwi
) shell (/bin/bash
) .
,
(username).
.
. ,
/etc/passwd
.
(GID),
.
. shell. ( , spool ).
(
), ,
- .
- ,
. useradd
adduser
, .
.
,
userdel
deluser
.
""
, ( account ),
(``*
'')
/etc/passwd
.
, kiwi
/etc/passwd
kiwi:*Xv8Q981g71oKK:102:100:Laura Poole:/home/kiwi:/bin/bash
kiwi
.
, .
- /etc/passwd
.
passwd.
,
# passwd larry
larry.
root
.
passwd, .
chfn
chsh
,
shell. ,
.
, . , 3.9. " " (``group ownership''), , , .
, ,
bin
, mail
sys
.
-
. .
, , ,
users. ,
,
student
, staff
faculty
.
/etc/group
.
group name:password:GID:other members
:
root:*:0:
users:*:100:mdw,larry
guest:*:200:
other:*:250:kiwi
, root
,
root. , users
,
. (GID) 100.
mdw
larry
. ,
/etc/passwd
( )
GID. ,
, (
/etc/group
). groups
,
.
, guest, , other ""
. kiwi
.
, "" /etc/group
.
. .
(
newgroup
) ("*
").
addgroup
groupadd
.
/etc/group
,
.
/etc/group
.
, () , , UNIX.
tar
. tar
tar <options> <file1> ... <fileN>
<options>
tar
,
a <file1> ... <fileN>
.
,
# tar cvf backup.tar /etc
, /etc
,
tar
backup.tar
. tar -``cvf'
,
() "" tar
. ``c
'' tar
. ``v
'' tar
. ``f
'' ,
- backup.tar
- .
tar
-
.
# tar xvf backup.tar
. , .
,
. ,
: /etc/hosts
, /etc/group
/etc/passwd
.
# tar cvf backup.tar /etc/hosts /etc/group /etc/passwd
/etc
. ,
:
# cd /
# tar xvf backup.tar
# cd /etc
# tar cvf hosts group passwd
.
``cd /etc
'' .
: ,
, .
# tar tvf backup.tar
"" . , .
MS-DOS, tar
.
, - ,
.
gzip
( tar
-)
# gzip -9 backup.tar
backup.tar
backup.tar.gz
, . -9
gzip
,
.
gunzip
"" .
``gzip -d
''.
gzip
- ,
UNIX. compress
.
, (
, , gzip
)
compress
.
compress
.Z
. , backup.tar.Z
-
backup.tar
, backup.tar.gz
- .
.z
(
``z
'').
(. :
) - .gz.
uncompress
,
compress
. gunzip
, .
, :
# tar cvf backup.tar /etc
# gzip -9 backup.tar
backup.tar.gz
.
:
# gunzip backup.tar.gz
# tar xvf backup.tar
, , .
UNIX,
# tar cvf - /etc | gzip -9c > backup.tar.gz
tar
-, /etc
,
``-
'', .
gzip
,
backup.tar.gz
. -c
gzip
, gzip
, backup.tar.gz
.
# gunzip -c backup.tar.gz | tar xvf -
, gunzip
backup.tar.gz
. tar
,
``-
'',
.
, tar
z
, - ,
gzip
.
, (. : )
# tar cvfz backup.tar.gz /etc
# tar cvf backup.tar /etc
# gzip backup.tar
# tar xvfz backup.tar.Z
# uncompress backup.tar.Z
# tar xvf backup.tar
tar
gzip
.
4.6
. (), ( , , ).
- (mount) .
,
tar
.
# tar cvfzM /dev/fd0 /
/dev/fd0
. ``M
''
(multivolume backup); ,
, tar .
# tar xvfzM /dev/fd0
.
(/dev/rmt0
).
.
"backflops
", tsx-11.mit.edu
.
- . "" . , - , . , , , .
find
,
- .
( shell)
sunsite.unc.edu
.
, . ,
# mke2fs /dev/fd0 1440
/dev/fd0. . high-density 3.5" - 1.44 M 1440 . high-density 5.25" - 1200 .
, , .
# mount -t ext2 /dev/fd0 /mnt
, /dev/fd0
/mnt
. , ,
/mnt
.
-t ext2
'' (ext2fs).
,
mount
.
" " (,
) ,
mount
. ,
mkdir
- .
, 4.8.
! / , . () , ( /). , ,
# umount /dev/fd0
, MS-DOS. , .
- .
Linux . , . Linux (upgrade) , , . : Linux. - .
, ? , , , , Slackware. Linux . . Slackware . 30 , 10% .
- : , , . : , , , , . Linux - " ", Linux.
, , , , , , , . , . , - "-" .
, , . , 0.96 MCC Interim installation. , . , " ". . MS-DOS Microsoft Windows. . , - . , . , , , . .
, ' , , gcc. , . .
-
. ,
, ,
,
. .
Linux-
FTP- ( C). sunsite.unc.edu
,
, pub/Linux/kernel/.
(kernel)
(patchlevel). , kernel version 0.99
patchlevel 11
0.99.pl11
,
0.99.11
.
tar-. ( patch- ("")
,
, patch. ,
, .
, , 0.99.pl11 -
linux-0.99.11.tar.gz
.
/usr/src
;
/usr/src/linux
, .
/usr/src/linux
.
, ,
/usr/include
.
# ln -sf /usr/src/linux/include/linux /usr/include/linux
# ln -sf /usr/src/linux/include/asm /usr/include/asm
,
, . ( 3.10 ).
,
gcc
g++
C C++.
,
4.7.3.
cd
/usr/src/linux
. make config
.
, "
". ,
/usr/src/linux/Makefile
. ,
ROOT_DEV
- ,
. :
ROOT_DEV = CURRENT
, , .
make dep
.
, . make Image
/usr/src/linux/Image
.
/usr/src/linux/arch/i386/boot/Image
(
intel, alpha, mips sparc.)make zImage
,
, .
( ``cp Image /dev/fd0
''),
, LILO
. 4.2.2 .
, , .
Incompatible library version
( )
, , . , , , . .
FTP- Linux. sunsite.unc.edu
/pub/Linux/GCC
. "" (``release'') ,
, .
, image-version.tar.gz
inc-version.tar.gz
,
, 4.4.1.
/lib
and
/usr/lib
. inc
include-
/usr/include
.
release-
version.tar.gz
'
(
).
.a
.sa
/usr/lib
.
.
,
libc.so.
version /lib
.
. ,
/lib
.
, libc
4.4.1
4. , - libc.so.4.4.1
.
libc.so.4
, ,
/lib
. ,
. , ,
libc.so.4
.
!
, . -
libc.so.4
,
( ls
cat
)
.
libc.so.4
,
libc.so.4.4.1
:
# ln -sf /lib/libc.so.4.4.1 /lib/libc.so.4
libm.so.
version
. ( )
, .
. (
3.10).
gcc
C C++
, - . gcc
FTP- Linux. sunsite.unc.edu
/pub/Linux/GCC
( ).
gcc, ,
.
, . Linux tar-, , , . , . make , .
USENET comp.os.linux.announce
-
, .
- ,
FTP-, (ls-lR
)
, grep
, .
, .
. ( , telnet
archie.rutgers.edu
, ``archie
''
``help
'').
.
Linux -
Slackware. .tgz
,
tar
-.
.tgz
Slackware
FTP- .
Slackware, setup
.
, Slackware . , , . , , , , . . : " - ". - .
- . ; .
,
. ,
, - .
, ,
, /mnt
, ,
( 4.6.2).
( ).
( /mnt
) ,
.
/mnt
,
, ,
/mnt
( ), "",
)./
.
, , /usr
- /usr
.
, ,
/usr
, .
mount
.
mount -av
/etc/rc
(
, 4.10.1).
ount -av
/etc/fstab
. fstab
.
# device directory type options
/dev/hda2 / ext2 defaults
/dev/hda3 /usr ext2 defaults
/dev/hda4 none swap sw
/proc /proc proc none
- ( ).
- . -
(, ext2
ext2fs minix
Minix filesystems). 4.1
, Linux.
1.1.37.
Second Extended Filesystem ext2 Linux
Extended Filesystem ext ext2
Minix Filesystem minix Minix;
Xia Filesystem xia ext2;
UMSDOS Filesystem umsdos Linux
MS-DOS
MS-DOS Filesystem msdos MS-DOS
/proc Filesystem proc
ps ..
ISO 9660 Filesystem iso9660 CD-ROM
Xenix Filesystem xenix Xenix.
System V Filesystem sysv System V
x86.
Coherent Filesystem coherent Coherent
HPFS Filesystem hpfs
HPFS (DoubleSpace).
4.1. Linux
; . 4.7.
fstab
(options) defaults
''.
,
/etc/fstab
.
"tt/none/",
"swap
". swapon -a
/etc/rc
,
/etc/fstab
.
fstab
/proc
. 3.11.1,
/proc
,
.. /proc
,
, ps .
! mount
root
.
. ,
.
,
(
) .
mount -av
,
( -
/dev/hda2
).
.
mount -av
.
# mount -t ext2 /dev/hda3 /usr
/dev/hda3
fstab
, .
. mount -av
/etc/rc
.
shutdown
halt
.
.
( /etc/rc
).
,
. ext2fs
(
), e2fsck
. ,
# e2fsck -av /dev/hda2
ext2fs
/dev/hda2
.
.
# umount /dev/hda2
/dev/hda2
,
. ,
. ,
boot/root (
4.11.1). ,
"" (``busy''), ..
. ,
,
.
``Device busy
'',
.
e2fsck
, efsck
xfsck
.
fsck
,
.
!
,
- . (
). ,
e2fsck
,
, shutdown -r
,
.
"" ,
e2fsck
.
/proc
. /proc
- ,
.
, , . , , Linux , .
Linux, . 8208 ( 8 ).
# dd if=/dev/zero of=/swap bs=1024 count=8208
. ``count=
''
.
# mkswap /swap 8208
swap
-;
- .
# /etc/sync
# swapon /swap
/swap
,
, , ,
.
,
swap
-, ,
. , ,
swap- .
swap- ,
swap-,
()
/ .
, swap
-,
-
,
, - .
.
, . , , .
, ,
swapoff
# swapoff /swap
.
# rm /swap
, ( ) 16 , 8 .
, - , , , .
.
, .
/etc/init
. init
- ,
(/etc/inittab
)
, .
inittab
-
/etc/getty
,
. getty
( )
login
. .
/etc/inittab
getty
,
.
, /etc/inittab
-
/etc/rc
,
,
/etc/rc.local
.
/etc/rc.local
, ,
- ( ).
rc.local
/etc/rc
/etc/inittab
.
-
,
- .
, :
``The dog''
- hostname
.
, - -
, goober.norelco.com
. ,
,
loomer.vpizza.com
, shoop.nowhere.edu
floof.org
.
-
/etc/hosts
, IP .
, -
/etc/hosts
. , TCP/IP
- floof.org
,
/etc/hosts
:
127.0.0.1 floof.org localhost
- floof.org
IP-
(loopback address) 127.0.0.1 (, localhost
.
TCP/IP, IP
- /etc/hosts
. ,
- goober.norelco.com
, IP 128.253.154.32,
/etc/hosts
:
128.253.154.32 goober.norelco.com
- /etc/hosts
,
. -
hostname
. ,
# hostname -S goober.norelco.com
- goober.norelco.com
.
hostname
, /etc/rc
/etc/rc.local
.
hostname
, - ;
- .
,
, root
.
- ! -
,
.
Linux
- . - , . , , . , . .
, . . " "! , . (maintenance diskette).
- ``boot/root disk'' - , Linux, . Boot/root disks - , , LILO . , . : Linux .
boot/root disk -
Slackware.
boot
root
).
boot/root disk, H.J Lu,
/pub/Linux/GCC/rootdisk
sunsite.unc.edu
-
.
, , . , , boot/root disk - .
boot/root disk .
root
( ).
,
. ,
# mount -t ext2 /dev/hda2 /mnt
ext2fs /dev/hda2
/mnt
.
, /
boot/root disk;
- , .
/etc/passwd
/mnt/etc/passwd
,
/mnt
.
root
- .
boot/root disk,
/mnt
root
/mnt/etc/passwd
, :
root::0:0:root:/:/bin/sh
root
;
, root
,
passwd
. , ,
vi
? boot/root disk, ,
Emacs , vi
.
- ,
e2fsck
( ,
ext2fs)
.
fsck
; 4.8.
, , .
-
. , "" (``header')' ,
, ,
..
(, - )
.
,
e2fsck
.
, ext2fs
" " (``block group'') ,
8K . , e2fsck
,
# e2fsck -b 8193 <partition>
<partition>
- ,
. -b 8193
e2fsck
, 8193 .
,
"" . ,
. ,
/bin/login
(
), boot/root ,
/mnt
# cp -a /bin/login /mnt/bin/login
-a
cp
. , ,
boot/root
floppy, . ,
.
/lib
, ,
, ( 4.7.2).
- boot/root,
/mnt/lib
.