Академический Документы
Профессиональный Документы
Культура Документы
Gentoo
......................................................................10
........................................................10
.........................................................................10
Daniel Robbins...................................................................10
Chris Houser.......................................................................10
Aron Griffis.........................................................................11
.....................................................................11
1. BASH, ....................................12
bash.................................................................12
...........................................................................12
bash?.......................................................12
bash.................................................................................12
cd..........................................................12
...................................................................................13
..............................................................13
........................................................13
.................................................................13
.......................................14
.......................................................................14
cd ..............................................14
...............15
...........................16
Linux...........................................16
ls..................................................................16
....................................16
..................................................17
.....................................17
..................................................................17
mkdir..................................................................................18
touch..................................................................................19
echo....................................................................................19
cat cp...............................................................................19
mv.......................................................................................20
, ...........21
..............................21
................................................................21
.........................................................21
..........................................................22
rm.......................................................................................23
rmdir...................................................................................24
Glob-.............................................................26
.................................................26
..................................................26
..................................................26
: * ?................................................27
[]........................................................27
..........................................28
...........................................................29
....................................................................................29
2. ......................................30
....................................................30
?...............................30
................................................30
............................................................30
.......................................30
....................................................................31
[]...............................................................31
[^].............................................................31
................................................32
*....................................................................32
.....................................................33
...............................................33
FHS ..........................................................33
...........................33
FHS.........................34
/usr...............................................34
....................................................................34
PATH...................................................................................35
PATH...............................................................35
which............................................................35
which -a..............................................................................36
whereis...............................................................................36
find.....................................................................................36
find ..................................................................36
find........................................37
find ..........................................37
find ...........................................................37
find mtimes.....................................................................37
-daystart.................................................................38
- size.......................................................................38
.........................................38
locate..................................................................................39
updatedb..................................................39
slocate................................................................................39
...................................................41
...................................................41
xeyes.......................................................................41
..........................................................41
fg bg.................................................................................41
"&"...........................................................42
........................................42
..........................................................42
SIGTERM SIGINT.............................................................43
...............................................................43
nohup.................................................................................43
ps .................43
.........................................44
u l ps..............................................................44
top............................................................45
nice.....................................................................................45
renice..................................................................................45
.............................46
..............................................................46
.................................46
()........................................46
.................................................46
..............................................................47
!.................................47
! ..............................49
">>"...........................................................49
......................................................................51
......................................................................51
, uname......................................................51
uname...........................................................51
.........................................................................51
...................................................................................51
...................................................52
........................................................52
lsmod..................................................................................52
................................................................52
............................................................53
depmod ..........................................................53
........................................................53
depmod....................................................54
............................................54
insmod vs. modprobe..........................................................54
rmmod modprobe .........................................54
modinfo modules.conf......................55
modules.conf....................................................55
................................................................55
.................................................................................55
..............................................................................56
3. .....................................................57
................................57
Linux..........................57
.......................................................57
-........................................................57
-.....................................58
.........................................................58
apropos................................................................58
MANPATH...........................................................................59
GNU info.............................................................................59
/usr/share/doc.....................................................................59
Linux Documentation Project.............................................60
LDP..........................................................................60
..............................................................60
...................................................61
...............................................................61
..........................................61
62
...........................................................................................62
........................................................63
Linux............................................63
, .....................................63
ls -l..............................................................63
........................................................................63
?.................................................................................64
?...............................................64
...............64
..........................................65
chmod..........................................................65
,
..............................................................................65
............................................................65
............................................................66
...................................66
umask.................................................................................66
suid sgid...................................................67
suid.....................................................................................68
suid/sgid.............................................68
suid sgid.......................................................69
.........................................................69
sgid....................................................69
....................................................69
................................................70
Linux......................................71
Linux......................................71
, /etc/passwd..................................................71
/etc/passwd, ........................................71
/etc/shadow........................................................................71
/etc/group...........................................................................72
.....................................................72
........................73
/etc/passwd.............................................73
/etc/shadow............................................73
..............................................................74
/etc/group...............................................74
....................................74
............74
......................76
......................76
fortune.....................................................76
.bash_profile.......................................................................76
.................................................................76
--login............................................................77
.........................................77
/etc/profile /etc/skel........................................................77
export.................................................................................78
........................................78
Export set -x....................................................................79
set.........................................79
Unset vs. FOO=...................................................................79
..................................................................................80
env........................................................80
.................................................................80
.................................................................................80
...............................................................................80
4. ,
...................................................................................................82
, ......82
......................................82
..................................................82
.............................................................................82
fdisk................................................................83
fdisk.......................................................................83
.............................83
..................................................................84
..................................................................84
fdisk ..................84
......................84
..................................................85
..................................................................85
..................................86
.......................................86
.............................................87
........................................................87
...............................87
.............................................88
ext2.....................................................88
ext3.....................................................88
ReiserFS..............................................89
XFS......................................................89
JFS.......................................................89
.............................89
.............................................90
ext2, ext3, ReiserFS..............90
XFS JFS.............................90
....................................91
.........................................92
.......................................................92
fstab.............................................................93
fstab.....................................................................93
...............................94
fsck..................................................................94
fsck................................................................95
Linux,
Linux Professional Institute 101.
bash (
Linux),
Linux, ls, cp mv,
, ,
.
,
Linux. (8 ),
. , ,
,
.
Daniel Robbins
Gentoo
Gentoo Linux.
-
. Funtoo,
IBM developerWorks,
Intel Developer Services C/C++ Users Journal.
Chris Houser
UNIX c 1994 ,
(, ),
.
, -,
, UNIX .
Sentry Data Systems.
,
Gentoo Linux Clojure, The Joy of Clojure.
Aron Griffis
,
Hewlett-Packard
, UNIX- Tru64,
Linux, Xen KVM ,
HP ePrint.
,
,
.
1. BASH,
bash
Linux , ,
,
:
$
, ,
. , ,
, .
, ,
: , ,
( . shell ,
. .), ,
, 'bash'.
bash?
, bash, :
$ echo $SHELL
/bin/bash
,
, , .
,
bash, 101.
bash
- ( Bourne/born . .),
Linux. ,
Linux-. ,
, (exit)
(logout),
.
, bash
control-D .
cd
, , ,
bash .
,
.
( $):
$ cd /
bash,
/, , ;
, / , ..
( , ,
. .). cd
, ,
.
bash
:
$ pwd
/
cd, / . cd
. , /
, ,
.
:
/dev
/usr
/usr/bin
/usr/local/bin
,
, /. , ,
/usr/local/bin cd, ,
/ , usr
, local bin, .
/ .
. bash, cd,
.
/. , /usr:
$ cd /usr
,
local/bin, /usr/local/bin:
$ cd local/bin
$ pwd
/usr/local/bin
..
".." . ".." ;
. , :
$ pwd
/usr/local/bin
$ cd ..
$ pwd
/usr/local
, /usr/local.
, .
, ".."
,
,
:
$ pwd
/usr/local
$ cd ../share
$ pwd
/usr/share
.
,
,
.
$ cd /bin
$ cd ../usr/share/zoneinfo
$ cd /usr/X11R6/bin
$ cd ../lib/X11
$ cd /usr/bin
$ cd ../bin/../bin
. ;)
.
cd,
, . -,
".",
. cd,
, :
$ ./myprog
myprog, .
cd
, :
$ cd
cd
, /root ,
/home/username ( username
..) . ,
?
myprog.
, :
$ ./myprog /home/drobbins/myfile.txt
, ,
. , ~
(), :
$ ./myprog ~/myfile.txt
Bash ~
,
.
,
fredsfile.txt fred,
:
$ ./myprog ~fred/fredsfile.txt
, ls, mkdir, touch, mv, cp,
echo cat.
.
Linux
ls
, ls.
, ,
ls
:
$ cd /usr
$ ls
X11R6
doc
sbin
ssl
bin
gentoo-x86
share tmp
distfiles i686-linux
src
i686-pc-linux-gnu
lib
man
include
libexec
portage
info
local
portage.old
-a, ,
, ".".
, ls -a
"." "..":
$ ls -a
.
bin
share tmp
..
distfiles
portage.old src
X11R6 doc
ssl
gentoo-x86
include
libexec
i686-linux
info
local
i686-pc-linux-gnu
lib
man
portage
sbin
ls. , ls
. , ls
. -l ,
, ,
.
-l
/usr:
$ ls -l /usr
drwxr-xr-x
7
drwxr-xr-x
2
drwxr-xr-x
2
distfiles
lrwxrwxrwx
1
share/doc
drwxr-xr-x
62
x86
drwxr-xr-x
4
linux
drwxr-xr-x
4
linux-gnu
drwxr-xr-x
54
lrwxrwxrwx
1
share/info
drwxr-xr-x
28
drwxr-xr-x
3
drwxr-xr-x
8
lrwxrwxrwx
1
share/man
lrwxrwxrwx
1
-> gentoo-x86/
drwxr-xr-x
60
portage.old
drwxr-xr-x
3
drwxr-xr-x
46
drwxr-xr-x
8
drwxr-xr-x
6
lrwxrwxrwx
1
-> ../var/tmp
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
root
11 Dec
root
root
1864 Dec
root
root
root
root
root
root
root
root
root
root
3096
1144
328
176
10
Dec
Nov
Dec
Dec
Dec
Dec
Dec
Nov
Dec
26
25
22
22
00:31
00:34
20:57
20:57
lib
libexec
local
man ->
8 07:59 portage
8 07:55
22
24
26
24
22
20:57
15:32
00:07
14:25
20:57
sbin
share
src
ssl
tmp
. ,
.
,
.
, . .
(mtime) . ,
.
, -> ,
.
,
. -d, ls
, :
$ ls -dl /usr /usr/bin /usr/X11R6/bin ../share
drwxr-xr-x
4 root
root
96 Dec
drwxr-xr-x
17 root
root
576 Dec
drwxr-xr-x
2 root
root
3192 Dec
/usr/X11R6/bin
drwxr-xr-x
2 root
root
14576 Dec
18 18:17 ../share
24 09:03 /usr
26 12:52
27 08:56 /usr/bin
-d
,
-R
: ,
!
( ),
ls -R ls -Rl,
.
, -i
:
$ ls -i /usr
1409 X11R6
13394 sbin
1417 bin
13408 share
8316 distfiles
314258 i686-linux
1513 i686-pc-linux-gnu
1517 include
43090 libexec
5120 local
776 man
23779 src
43 doc
1386 info
36737 ssl
70744 gentoo-x86
1585 lib
portage.old
784 tmp
93892 portage
5132
, .
,
.
"." "..",
. ,
"..",
/usr/local:
$ ls -id /usr/local
5120 /usr/local
/usr/local 5120.
/usr/local/bin/..:
$ ls -id /usr/local/bin/..
5120 /usr/local/bin/..
, /usr/local/bin/.. ,
/usr/local! ,
. ,
/usr/local . , ,
5120, ,
, ( ),
. /usr/local, /usr/local/bin/..
5120- .
,
.
,
, 5120 , ls -dl:
$ ls -dl /usr/local
drwxr-xr-x
8 root
/usr/local
root
, ,
/usr/local ( 5120) .
:
/usr/local
/usr/local/.
/usr/local/bin/..
/usr/local/games/..
/usr/local/lib/..
/usr/local/sbin/..
/usr/local/share/..
/usr/local/src/..
mkdir
mkdir,
.
, tic, tac, toe,
/tmp:
$ cd /tmp
$ mkdir tic tac toe
, mkdir
;
() . ,
won/der/ful,
mkdir:
$ mkdir won/der/ful
mkdir: cannot create directory `won/der/ful': No such file or
directory
$ mkdir won
$ mkdir won/der
$ mkdir won/der/ful
, mkdir -p,
mkdir
, :
$ mkdir -p easy/as/pie
. mkdir
man mkdir .
, ( man ls),
cd, bash.
touch
cp mv,
.
touch, /tmp:
$ cd /tmp
$ touch copyme
touch mtime (
. .) ,
( ls -l).
, , .
/tmp/copyme .
echo
, ,
. echo,
. , echo :
$ echo "firstfile"
firstfile
, echo,
:
$ echo "firstfile" > copyme
echo
copyme. ,
, , . ls -l,
, copyme 10 ,
firstfile :
$ ls -l copyme
-rw-r--r-1 root
root
cat cp
,
cat:
$ cat copyme
firstfile
,
cp copiedme
copyme:
$ cp copyme copiedme
, ;
:
$ ls -i copyme copiedme
648284 copiedme
650704 copyme
mv
mv
copiedme movedme.
; , , , .
$ mv copiedme movedme
$ ls -i movedme
648284 movedme
,
, .
.
mv, ,
. mv,
,
. ,
/var/tmp/myfile.txt /home/drobbins
( ), (
~ . .):
$ mv /var/tmp/myfile.txt /home/drobbins
myfile.txt
/home/drobbins/myfile.txt. /home/drobbins
, /var/tmp, mv
myfile.txt
. , myfile.txt
, myfile.txt
. ,
.
mv
. ,
myfile1.txt myarticle3.txt /home/drobbins,
:
$ mv /var/tmp/myfile1.txt /var/tmp/myarticle3.txt /home/drobbins
,
,
rm rmdir.
,
( )
( ,
, ). Linux
. , ,
.
.
,
, Linux .
ln:
$
$
$
$
cd /tmp
touch firstlink
ln firstlink secondlink
ls -i firstlink secondlink
15782 firstlink
15782 secondlink
, ,
. Linux ,
. ,
, .
-, ; "." ".."
, (
root)
. ,
. ,
/usr/bin/bash
/bin/bash / /usr
( . .).
, ( ,
.) , .
,
, .
; ,
, , , .
-s.
ln
$ ln -s secondlink thirdlink
$ ls -l firstlink secondlink thirdlink
-rw-rw-r-2 agriffis agriffis
firstlink
-rw-rw-r-2 agriffis agriffis
secondlink
lrwxrwxrwx
1 agriffis agriffis
thirdlink -> secondlink
0 Dec 31 19:08
0 Dec 31 19:08
10 Dec 31 19:39
ls -l
. -, l
. -,
(secondlink ). ,
"->".
, .
, . ,
( ),
. ,
.
, /tmp,
/usr/local/bin. :
$ ln -s /usr/local/bin bin1
$ ls -l bin1
lrwxrwxrwx
1 root
root
-> /usr/local/bin
14 Jan
1 15:42 bin1
16 Jan
1 15:43 bin2
, :
$ ln -s ../usr/local/bin bin2
$ ls -l bin2
lrwxrwxrwx
1 root
root
-> ../usr/local/bin
,
. ,
- ,
- :
$ ls -l bin2
lrwxrwxrwx
1 root
root
16 Jan
-> ../usr/local/bin
$ mkdir mynewdir
$ mv bin2 mynewdir
$ cd mynewdir
$ cd bin2
bash: cd: bin2: No such file or directory
1 15:43 bin2
, /tmp/usr/local/bin ,
bin2; , bin2
.
,
, . ,
.
/usr/bin:
# ls -l /usr/bin/keychain
-rwxr-xr-x
1 root
root
/usr/bin/keychain
keychain, , kc. root-,
"#" bash.
root- ,
/usr/bin.
keychain
:
# cd /usr/bin
# ln -s /usr/bin/keychain kc
# ls -l keychain
-rwxr-xr-x
1 root
root
/usr/bin/keychain
# ls -l kc
lrwxrwxrwx
1 root
/usr/bin/keychain
root
kc, /usr/bin/keychain.
, ,
, /usr/bin/keychain /usr/bin/kc
/usr/local/bin:
# mv /usr/bin/keychain /usr/bin/kc /usr/local/bin
# ls -l /usr/local/bin/keychain
-rwxr-xr-x
1 root
root
10150 Dec 12 20:09
/usr/local/bin/keychain
# ls -l /usr/local/bin/kc
lrwxrwxrwx
1 root
root
/usr/bin/keychain
kc,
/usr/bin/keychain,
/usr/bin/keychain /usr/local/bin.
, kc .
,
, , ,
. ,
, ,
. ,
:
# cd /usr/bin
# ln -s keychain kc
# ls -l kc
lrwxrwxrwx
1 root
keychain
root
# mv keychain kc /usr/local/bin
# ls -l /usr/local/bin/keychain
-rwxr-xr-x
1 root
root
/usr/local/bin/keychain
# ls -l /usr/local/bin/kc
lrwxrwxrwx
1 root
root
keychain
8 Jan
5 12:40 kc ->
, keychain
/usr/local/bin/kc. /usr/local/bin/kc keychain
, kc.
rm
, cp, mv ln,
, .
rm.
, :
$ cd /tmp
$ touch file1
$ ls -l file1
-rw-r--r--rw-r--r--
file2
file2
1 root
1 root
root
root
0 Jan
0 Jan
1 16:41 file1
1 16:41 file2
$ rm file1 file2
$ ls -l file1 file2
ls: file1: No such file or directory
ls: file2: No such file or directory
, Linux, ,
.
-i,
. -i rm
. :
$ rm -i file1 file2
rm: remove regular empty file `file1'? y
rm: remove regular empty file `file2'? Y
rm
. ,
y enter, .
n, . , - ,
Control-C rm -i
, -
.
rm,
~/.bashrc,
(logout) (login) . ,
, rm, bash
rm -i. , rm
:
alias rm="rm -i"
rmdir
rmdir :
$
$
$
$
mkdir mydir
touch mydir/file1
rm mydir/file1
rmdir mydir
.
- ,
rm -rf,
.
(recursive
force) rm,
, :
$ rm -rf mydir
, rm -rf
.
, rm -rf,
: . =)
Glob-
,
,
(wild cards) *, [] ?
. , .
Linux ,
( rm)
.
,
, :
$ rm file1 file2 file3 file4 file5 file6 file7 file8
,
Linux .
globbing ( ;
.
.), ,
. Bash Linux
, . ,
file1 file8 ,
:
$ rm file[1-8]
file, file,
:
$ rm file*
"*"
, . , glob-
,
, .
/etc, g, g,
:
$ ls -d /etc/g*
/etc/gconf /etc/ggi
mime-magic /etc/gpm
, ,
.
/usr/bin, asdf jkl,
asdfjkl:
$ ls -d /usr/bin/asdf*jkl
ls: /usr/bin/asdf*jkl: No such file or directory
. , ,
, bash
. , , bash
. ,
ls /usr/bin/asdf*jkl
.
:
glob-
. ,
.
: * ?
, globbing,
.
:
*
. : ,
. :
/etc/g*
g g;
/etc,
/tmp/my*1 /tmp,
my 1, my1.
? . :
myfile? ,
myfile - ;
/tmp/notes?txt , , /tmp/notes.txt
/tmp/notes_txt, .
[]
?, .
, , ,
[].
. "-",
, .
:
myfile[12] myfile1 myfile2.
;
[Cc]hange[Ll]og Changelog, ChangeLog,
changeLog
changelog.
,
;
ls /etc/[0-9]* /etc,
;
ls /tmp/[A-Za-z]* /tmp,
.
[!]
[],
,
, ,
[! ]. :
rm myfile[!9] myfile
, myfile9.
. bash
(?, [, ] *)
, ,
, .
, ,
"[fo]*",
:
$ echo [fo]* > /tmp/mynewfile.txt
[fo]* -
,
/tmp/mynewfile.txt, [fo]*. ? ,
,
bash
:
$ echo '[fo]*' > /tmp/mynewfile.txt
,
[fo]* , . ,
,
bash, [, ] * ,
:
$ echo \[fo\]\* > /tmp/mynewfile.txt
(
) .
,
, , \
, ,
\\ ( \).
:
,
bash .
, ,
.
man 7 glob.
bash, man 1 bash
QUOTING.
LPI,
. =)
;
Linux! ,
Linux. ,
, bash,
Linux,
,
, ,
,
, .
,
LPIC Level 1 Linux Professional
Institute. ,
, ,
,
.
2.
?
( . regular expression, .
regexp regex,
. .)
. Linux-
,
.
, ,
(globbing),
. ,
, .
-,
, .
,
, .
grep, ,
.
grep ,
, :
$ grep bash /etc/passwd
operator:x:11:0:operator:/root:/bin/bash
root:x:0:0::/root:/bin/bash
ftp:x:40:1::/home/ftp:/bin/bash
, grep, regex;
. grep /etc/passwd
regex- bash
. , grep
; , .
, ,
, -
. ,
+, ., *, [, ] \,
,
.
:
/tmp ( /tmp)
"\[box\]" ( [box])
"\*funny\*" ( *funny*)
"ld\.so" ( ld.so)
,
, .
"." (),
:
$ grep dev.sda /etc/fstab
/dev/sda3
/
/dev/sda1
/boot
noauto,noatime,notail 1 2
/dev/sda2
swap
#/dev/sda4
/mnt/extra
reiserfs
reiserfs
noatime,ro 1 1
swap
reiserfs
sw 0 0
noatime,rw 1 1
dev.sda
/etc/fstab. , grep
dev.sda, dev.sda . ,
"." .
, "." ,
"?" glob-.
[]
, ".",
[ ] ( ),
:
$ grep dev.sda[12] /etc/fstab
/dev/sda1
/boot
noauto,noatime,notail 1 2
/dev/sda2
swap
reiserfs
swap
sw 0 0
, ,
"[]" glob . ,
:
, glob-,
.
[^]
^
[.
. ,
[^] , [!]
glob:
$ grep dev.hda[^12] /etc/fstab
/dev/hda3
/
#/dev/hda4
/mnt/extra
reiserfs
reiserfs
noatime,ro 1 1
noatime,rw 1 1
,
. , "."
,
"." , 1 2 . , "."
,
, "\".
/etc/fstab
dev.sda, :
$ grep dev[.]sda /etc/fstab
, :
$ grep "dev\.sda" /etc/fstab
/etc/fstab .
*
, .
, * (),
. , , *
, .
,
glob:
ab*c abbbbc, abqc ( glob, .
?)
ab*c abc, abbqbbc ( ,
glob-,
)
ab*c ac, cba ( ,
ac, cba )
b[cq]*e bqe be (glob-
bqe, be)
b[cq]*e bccqqe, bccc (
,
)
b[cq]*e bqqcce, cqe (
glob-)
b[cq]*e bbbeee (
)
.* (glob-
".")
foo.*
foo ( glob-
,
foo.)
, : ac
ab*c ,
(b) .
, , *
, * glob.
, , ^
$,
, . ^
regex, .
, ^#,
#:
$ grep ^# /etc/fstab
# /etc/fstab: static file system information.
#
^ $ ,
. ,
#,
".",
:
$ grep '^#.*\.$' /etc/fstab
# /etc/fstab: static file system information.
,
$ . $
, grep
.
FHS
(Filesystem Hierarchy
Standard . FHS)
Linux-. FHS
,
. FHS
( ):
/ ( )
/boot ( )
/dev ( )
/etc ( )
/lib ( )
/mnt ( )
/opt ( )
/sbin ( )
/tmp ( )
/usr ( )
/var ( )
FHS
FHS
:
, .
;
(,
, ).
; (
).
, ,
. ,
:
/usr
/opt
/etc
/boot
/var/mail
/var/spool/news
/var/run
/var/lock
/usr
/usr ,
. /usr
,
()
CD-ROM
().
Linux /usr,
/usr.
,
.
.
Linux.
: http://www.pathname.com/fhs/.
Linux- .
, ,
, ,
- .
Linux .
.
PATH
, bash
. , ls,
bash , ls
/usr/bin. ,
PATH,
. PATH:
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin.
PATH ( ) bash
/usr/local/bin, /usr/bin
ls. , ls /usr/bin,
bash .
PATH
PATH,
:
$ PATH=$PATH:~/bin
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin:/hom
e/agriffis/bin
PATH,
,
$PATH.
PATH , :
$ PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:~/bin
$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/agriffis/bin
PATH
, ,
export:
$ export PATH
which
,
PATH which. ,
PATH , sense
:
$ which sense
which: no sense in
(/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11R6/bin)
, ls :
$ which ls
/usr/bin/ls
which -a
, -a, which
PATH:
$ which -a ls
/usr/bin/ls
/bin/ls
whereis
,
whereis:
$ whereis ls
ls: /bin/ls /usr/bin/ls /usr/share/man/man1/ls.1.gz
ls
, /bin /usr/bin. ,
,
/usr/share/man. man- ,
man ls.
whereis
(
,
. .).
. man-
.
find
find
. find
; ,
. ,
/usr/share/doc, README:
$ find /usr/share/doc -name README
/usr/share/doc/ion-20010523/README
/usr/share/doc/bind-9.1.3-r6/dhcp-dynamic-dns-examples/README
/usr/share/doc/sane-1.0.5/README
find
glob-
-name,
(
, bash'
).
README :
$ find /usr/share/doc -name README\*
/usr/share/doc/iproute2-2.4.7/README.gz
/usr/share/doc/iproute2-2.4.7/README.iproute2+tc.gz
/usr/share/doc/iproute2-2.4.7/README.decnet.gz
/usr/share/doc/iproute2-2.4.7/examples/diffserv/README.gz
/usr/share/doc/pilot-link-0.9.6-r2/README.gz
/usr/share/doc/gnome-pilot-conduits-0.8/README.gz
/usr/share/doc/gimp-1.2.2/README.i18n.gz
/usr/share/doc/gimp-1.2.2/README.win32.gz
/usr/share/doc/gimp-1.2.2/README.gz
/usr/share/doc/gimp-1.2.2/README.perl.gz
[ 578 ]
find
, :
$ find /usr/share/doc -name '[Rr][Ee][Aa][Dd][Mm][Ee]*'
, :
$ find /usr/share/doc -iname readme\*
,
-iname .
find
,
-regex
. -iname,
-iregex find
. :
$ find /etc -iregex '.*xt.*'
/etc/X11/xkb/types/extra
/etc/X11/xkb/semantics/xtest
/etc/X11/xkb/compat/xtest
/etc/X11/app-defaults/XTerm
/etc/X11/app-defaults/XTerm-color
, find
,
. ,
.*; xt
.
find
-type
. -type : b
( ), c ( ), d (),
p ( ), f ( ), l (
), s (). ,
/usr/bin, vim:
$ find /usr/bin -name '*vim*' -type l
/usr/bin/rvim
/usr/bin/vimdiff
/usr/bin/gvimdiff
find mtimes
-mtime
. mtime
24- ,
( )
( ). , :
$ ls -l ?
-rw------1 root
root
-rw------1 root
root
-rw------1 root
root
-rw------1 root
root
$ date
Tue Jan 7 18:14:52 EST 2003
0
0
0
0
Jan
Jan
Jan
Jan
7
6
5
4
18:00
18:00
18:00
18:00
a
b
c
d
,
24 :
$ find . -name \? -mtime -1
./a
24-
:
-daystart,
,
. ,
:
$ find . -name \? -daystart -mtime +0 -mtime -3
./b
./c
$ ls -l b c
-rw------1 root
root
0 May 6 18:00 b
-rw------1 root
root
0 May 5 18:00 c
- size
! , find
-exec.
, ;,
{} .
:
$ find /usr/bin -type f -size -50c -exec ls -l
-rwxr-xr-x
1 root
root
27 Oct
/usr/bin/krdb
-rwxr-xr-x
1 root
root
35 Nov
/usr/bin/run-nautilus
-rwxr-xr-x
1 root
root
25 Oct
/usr/bin/sgmlwhich
-rwxr-xr-x
1 root
root
26 Sep
/usr/bin/muttbug
'{}' ';'
28 07:13
28 18:26
21 17:51
26 08:00
, find .
UNIX Linux. find
. man-.
locate
updatedb
updatedb .
,
. :)
slocate
Linux , locate
slocate.
locate, ,
. slocate locate ( . secure
locate . .).
, ,
, .
slocate locate,
.
,
, ,
,
. . ,
bg, fg, jobs, kill, nohup, nice, renice, ps top.
xeyes
, -
. ,
X ( . .)
:
$ xeyes -center red
xeyes ,
. , ,
.
, Control-C
( Ctrl-C ^C):
, xeyes
. , .
Control-C,
Control-Z:
$ xeyes -center red
Control-Z
[1]+ Stopped
$
bash'a, xeyes
. ,
, . xeyes
,
, .
. .
fg bg
,
fg (
. foreground . .):
$ fg
(test it out, then stop the process again)
Control-Z
[1]+ Stopped
xeyes -center red
$
bg (
. backgroud . .):
$ bg
[1]+ xeyes -center red &
$
! xeyes
, bash.
"&"
xeyes
( Control-Z bg),
"&" () xeyes:
$ xeyes -center blue &
[2] 16224
xeyes.
jobs:
$ jobs -l
[1]- 16217 Running
[2]+ 16224 Running
,
bash . (+)
, ,
fg.
;
, fg 1 xeyes.
pid,
-l. ,
Running ()
.
, , , Linux
,
. ,
, , - . ,
, Control-C,
Control-Z, bg fg bash
.
kill id
(pid):
$ kill -s SIGSTOP 16224
$ jobs -l
[1]- 16217 Running
[2]+ 16224 Stopped (signal)
, kill ,
. -s, kill
. Linux ,
SIGINT, SIGSTOP,
SIGCONT . ,
;
.
man' SIGNALS.
SIGTERM SIGINT
, . , kill SIGTERM,
SIGINT Control-C,
:
$ kill 16217
$ jobs -l
[1]- 16217 Terminated
[2]+ 16224 Stopped (signal)
, SIGTERM SIGINT,
, , ,
- . ,
SIGKILL.
SIGKILL:
$ kill 16224
$ jobs -l
[2]+ 16224 Stopped (signal)
$ kill -s SIGKILL 16224
$ jobs -l
[2]+ 16224 Interrupt
nohup
,
. (
bash -), SIGHUP
, .
, nohup
:
$ nohup make &
[1] 15632
$ exit
ps
jobs,
,
bash. ,
ps a x:
$ ps ax
PID TTY
1 ?
2 ?
3 ?
4 ?
5 ?
STAT
S
SW
SWN
SW
SW
TIME
0:04
0:11
0:13
2:33
0:00
COMMAND
init [3]
[keventd]
[ksoftirqd_CPU0]
[kswapd]
[bdflush]
5 ,
.
, ,
. ,
ax, ,
, .
ps x , ,
. ps a,
.
. --forest
,
.
,
. --forest,
, :
$ ps x --forest
PID TTY
STAT
927 pts/1
S
6690 pts/1
S
26909 pts/1
R
19930 pts/4
S
25740 pts/4
S
TIME COMMAND
0:00 bash
0:00 \_ bash
0:00
\_ ps x forest
0:01 bash
0:04 \_ vi processes.txt
u l ps
u l
a, x
:
$ ps au
USER
PID %CPU %MEM
COMMAND
agriffis
403 0.0 0.0
-bash
chouser
404 0.0 0.0
-bash
root
408 0.0 0.0
0:00 /sbin/agetty 3
agriffis
434 0.0 0.0
0:00 /bin/sh /usr/X
chouser
927 0.0 0.0
bash
$ ps al
F
UID
PID PPID PRI
TIME COMMAND
100 1001
403
1
9
0:00 -bash
100 1000
404
1
9
0:00 -bash
000
0
408
1
9
0:00 /sbin/ag
000 1001
434
403
9
0:00 /bin/sh
000 1000
927
652
9
0:00 bash
VSZ
RSS TTY
STAT START
TIME
2484
72 tty1
2001
0:00
2508
92 tty2
2001
0:00
1308
248 tty6
2001
1008
4 tty1
2001
2540
96 pts/1
2001
NI
VSZ
RSS WCHAN
STAT TTY
2484
72 wait4
tty1
2508
92 wait4
tty2
1308
248 read_c S
tty6
1008
4 wait4
tty1
2540
96 wait4
pts/1
0:00
top
, ps
, ,
top. top
,
:
$ top
10:02pm up 19 days, 6:24, 8 users, load average: 0.04, 0.05,
0.00
75 processes: 74 sleeping, 1 running, 0 zombie, 0 stopped
CPU states: 1.3% user, 2.5% system, 0.0% nice, 96.0% idle
Mem:
256020K av, 226580K used,
29440K free,
0K shrd,
3804K buff
Swap: 136544K av,
80256K used,
56288K free
101760K cached
PID USER
PRI
TIME COMMAND
628 root
16
91:43 X
26934 chouser
17
0:00 top
652 chouser
11
3:52 gnome-termin
641 chouser
9
2:13 sawfish
NI
SIZE
213M
31M
2304 S
1.9 12.5
1272 1272
1076 R
1.1
0.4
0 12016 8840
1604 S
0.5
3.4
1416 S
0.1
1.0
2936 2808
nice
,
Linux CPU.
,
nice:
$ nice -n 10 oggenc /tmp/song.wav
, nice,
, , nice
(nice , ; . .) ,
CPU. -, 0,
10 oggenc ,
.
, , oggenc
,
, oggenc.
NI ps top
.
renice
nice
.
, renice:
$ ps l 641
F
UID
PID PPID PRI NI
VSZ RSS
TIME COMMAND
000 1000
641
1
9
0 5876 2808
2:14 sawfish
$ renice 10 641
641: old priority 0, new priority 10
$ ps l 641
F
UID
PID PPID PRI NI
VSZ RSS
TIME COMMAND
000 1000
641
1
9 10 5876 2808
2:14 sawfish
WCHAN
STAT TTY
do_sel S
WCHAN
STAT TTY
do_sel S
Linux.
- bash.
,
>,
, :
$ echo "firstfile" > copyme
,
(). ,
. :
$ echo "hi there" | wc
1
2
9
|
, . ,
echo hi there
. ,
wc,
, .
()
:
$ ls -s | sort -n
, ls -s
, .
, sort -n,
. ,
.
,
, .
, ,
. ,
,
Linux.
,
:
$ bzip2 -d linux-2.4.16.tar.bz2
$ tar xvf linux-2.4.16.tar
,
. tar
( ),
:
$ bzip2 -dc linux-2.4.16.tar.bz2 | tar xvf -
!
.
:
$ cat myfile.txt | sort | uniq | wc -l
cat myfile.txt
sort. sort ,
,
uniq. uniq (
uniq, )
wc -l. wc ,
. -l,
,
. ,
.
.
.
!
Linux
.
,
. ,
man- ( man echo,
) ,
. ,
,
.
, . , . :)
echo .
-e
; echo -e 'foo\nfoo' foo,
, foo.
-n echo
, -.
cat .
, , cat foo.txt | blah.
sort ,
, . , sort
. man sort
,
.
uniq
( ) .
wc ,
( ). man wc
, .
head .
-n, ,
.
tail .
-n, ,
.
tac cat,
, ,
.
expand
. -t .
unexpand
. -t .
cut
, . (
echo 'abc def ghi jkl' | cut -d ' ' -f2,2 . .)
nl .
.
pr ;
.
tr () ;
.
sed -
. sed
Funtoo:
Sed , 1 (En)
Sed , 2 (En)
Sed , 3 (En)
LPI,
.
awk
.
awk Funtoo:
Awk , 1 (En)
Awk , 2 (En)
Awk , 3 (En)
od
, .. .
split
, .
fmt ,
. ,
,
, .
paste
, .
.
join paste,
(-
).
tee
. ,
-, .
!
> , <
, .
, .
.
Bash herefile.
.
:
$ sort <<END
apple
cranberry
banana
END
apple
banana
cranberry
, apple,
cranberry banana, END
. sort
.
">>"
, >> - <<,
. ,
, >. :
$ echo Hi > myfile
$ echo there. > myfile
$ cat myfile
there.
! Hi! :
$ echo Hi > myfile
$ echo there. >> myfile
$ cat myfile
Hi
there.
Linux. ,
,
.
, uname
uname
. ,
, uname -a, uname
:
$ uname -a
Linux inventor 2.4.20-gaming-r1 #1 Fri Apr 11 18:33:35 MDT 2003
i686 AMD Athlon(tm) XP 2100+ AuthenticAMD GNU/Linux
uname
, ,
uname
MDT 2003"
-s
-n
-r
-v
"Linux"
"inventor"
"2.4.20-gaming-r1"
"#1 Fri Apr 11 18:33:35
-m
-p
-i
-o
"i686"
"AMD Athlon(tm) XP 2100+"
"AuthenticAMD"
"GNU/Linux"
! uname -a ?
. uname -r
,
.
/lib/modules !
, ! OK,
,
/lib/modules, ,
.
Linux , Linux
,
.
,
, SCSI IDE, RAM,
. ,
.
, ?
, .
,
.
,
,
.
,
,
.
,
. ,
,
- .
lsmod
lsmod:
# lsmod
Module
vmnet
vmmon
nvidia
mousedev
hid
usbmouse
input
usb-ohci
ehci-hcd
emu10k1
ac97_codec
sound
usbcore
hcd]
Size
20520
22484
1547648
3860
16772
1848
3136
15976
13288
64264
9000
51508
55168
Used by
Tainted: PF
5
11
10
2
0 (unused)
0 (unused)
0 [mousedev hid usbmouse]
0 (unused)
0 (unused)
2
0 [emu10k1]
0 [emu10k1]
1 [hid usbmouse usb-ohci ehci-
,
. vmnet vmmon ,
VMWare Workstation,
.
nvidia NVIDIA corporation
3D- Linux.
,
USB mousedev, hid, usbmouse,
input,
usb-ohci,
ehci-hcd
usbcore.
USB .
? USB plug and play (
) USB ,
USB ,
,
.
-.
/lib/modules/2.4.20-gaming-r1/,
modules.:
$ ls /lib/modules/2.4.20-gaming-r1/modules.*
/lib/modules/2.4.20-gaming-r1/modules.dep
/lib/modules/2.4.20-gaming-r1/modules.generic_string
/lib/modules/2.4.20-gaming-r1/modules.ieee1394map
/lib/modules/2.4.20-gaming-r1/modules.isapnpmap
/lib/modules/2.4.20-gaming-r1/modules.parportmap
/lib/modules/2.4.20-gaming-r1/modules.pcimap
/lib/modules/2.4.20-gaming-r1/modules.pnpbiosmap
/lib/modules/2.4.20-gaming-r1/modules.usbmap
. ,
.
, emu10k1
. ,
PCI
IDs ,
.
, hotplug (
)
.
depmod
, .
, depmod -a. depmod
/lib/modules
.
/lib/modules symbols
.
, ? 2.4,
/lib/modules
".o" ( 2.6 ".ko" . .).
/lib/modules, :
# find /lib/modules -name '*.o'
/lib/modules/2.4.20-gaming-r1/misc/vmmon.o
/lib/modules/2.4.20-gaming-r1/misc/vmnet.o
/lib/modules/2.4.20-gaming-r1/video/nvidia.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/vfat/vfat.o
/lib/modules/2.4.20-gaming-r1/kernel/fs/minix/minix.o
[ ]
insmod vs. modprobe
, ?
, insmod
, :
# insmod /lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
# lsmod | grep fat
fat
29272
0 (unused)
,
modprobe. , modprobe
. ,
.
rmmod modprobe
fat.o
modprobe:
# rmmod fat
# lsmod | grep fat
# modprobe fat
# lsmod | grep fat
fat
29272
(unused)
, rmmod
modprobe,
.
modinfo modules.conf
modinfo,
:
# modinfo fat
filename:
description:
author:
license:
/lib/modules/2.4.20-gaming-r1/kernel/fs/fat/fat.o
<none>
<none>
"GPL"
/etc/modules.conf.
modprobe
modprobe. ,
/ ,
, .
modules.conf
modules.conf
, ( man
modules.conf ),
, .
-,
,
/etc/modules.d/. , Gentoo Linux ,
update-modules
/etc/modules.d/ /etc/modules.conf. ,
/etc/modules.d/
update-modules, Gentoo. Debian,
, ,
/etc/modutils/.
2.6
etc modprobe.conf modprobe.d .
, man modprobe.conf
.
Linux!
Linux.
,
, , ,
.
, . ,
,
LPIC
Level 1 Linux Professional Institute.
LPIC,
,
,
.
. :
Regular Expressions Reference
Regular Expressions Explained
(Filesystem
Hierarchy
Standard)
http://www.pathname.com/fhs/.
Bash ,
bash .
( )
LPIC Level 1.
sed Sed
( ). LPI
, .
awk, Awk
( ).
vi,
Vi the cheat
sheet method. ,
. ,
,
vi.
3.
,
,
Linux Professional Institute's 101 (2- ).
,
Linux.
, ,
Linux,
.
Linux
Linux
: (), info-
/usr/share/doc.
,
,
.
, man ( . manual
) , -,
UNIX Linux.
, ,
. , ,
Linux
.
, ,
.
man, .
- (, less
more) . , ,
q. ,
ls, :
$ man ls
. ,
:
NAME ()
SYNOPSIS ()
DESCRIPTION ()
EXAMPLES ()
SEE ALSO ( )
( -)
,
/usr/share/man ( /usr/man ).
,
:
man1
man2
man3
man4
man5
man6
man7
whatis,
:
$ whatis printf
printf
printf
(1)
(3)
, man printf -
1 ( ).
C,
3 ( ).
, printf(3) :
$ man 3 printf
-
. man -k
-. ,
-,
man -k ls, !
:
$ man -k whatis
apropos
strings
makewhatis
whatis
complete words
(1)
(8)
(1)
apropos
. -,
apropos man -k. (
, .
man -k, apropos). -,
makewhatis,
Linux whatis
apropos. - ,
:
# makewhatis
man
, -
:
$ man man
MANPATH
, man -
/usr/share/man, /usr/local/man, /usr/X11R6/man,
/opt/man. ,
. , /etc/man.conf
:
MANPATH /opt/man
,
/opt/man/man* . ,
makewhatis,
whatis.
GNU info
,
,
. GNU
:
-. GNU
-.
- info:
$ info
info .
, (
) Enter q.
Emacs,
, .
Emacs,
$ info diff
-,
-.
:
$ info info
/usr/share/doc
Linux.
, :
, PDF, PostScript, HTML.
usr/share/doc ( /usr/doc ).
,
.
,
-,
.
,
:
$ cd /usr/share/doc
$ find . -type f | wc -l
7582
!
(3791) . ,
. ;-)
,
Linux. "Linux
Documentation Project" (LDP) ,
Linux.
Linux
, .
LDP
LDP :
Guides () ,
, The Linux Programmer's Guide
( Linux)
HOWTOs , DSL
HOWTO
FAQs ,
Brief Linux FAQ
Man pages (
, ,
man).
,
,
, .
LDP
, Linux Gazette Linux Weekly News,
.
, ,
Linux.
,
.
,
.
, Linux Kernel Mailing List
( Linux).
,
.
,
.
,
.
LKML FAQ
, ,
,
.
, . ,
!
(. newsgroups)
, ,
NNTP (Network News Transfer Protocol,
),
. ,
NTTP-, slrn pan.
,
, ,
:-)
comp.os.linux.
LDP.
Linux
,
,
,
. :
Redhat Linux
Ubuntu Linux
Debian Linux
Gentoo Linux
SuSE Linux
Caldera
Turbolinux
,
Linux
. ,
Linux,
, , Linux
, ,
Linux-. :
IBM Linux
HP Linux
Sun Linux
Oracle Linux.
Linux
. ,
Linux. ,
.
Linux
,
Linux
(ownership). ,
.
Linux. ,
ls
-l.
$ ls -l /bin/bash
-rwxr-xr-x 1 root wheel 430540 Dec 23 18:27 /bin/bash
/bin/bash
root wheel.
,
.
ls -l
ls -l.
:
$ ls -l /bin/bash
-rwxr-xr-x 1 root wheel 430540 Dec 23 18:27 /bin/bash
-rwxr-xr-x
. (-)
, .
:
'd'
'l'
'c'
'b'
'p'
's'
-
-
FIFO
$ ls -l /bin/bash
-rwxr-xr-x 1 root wheel 430540 Dec 23 18:27 /bin/bash
.
,
.
"rwx"
"r-x"
"r-x"
r , (
) , w
( , ) x
( ).
,
, (root)
.
,
root .
?
,
, ,
. su ,
, .
su,
.
, whoami:
# whoami
root
# su drobbins
$ whoami
drobbins
?
groups:
$ groups
drobbins wheel audio
, drobbins,
wheel, audio. ,
,
.
$ groups root daemon
root : root bin daemon sys adm disk wheel floppy dialout tape
video
daemon : daemon bin adm
(
) chown chgrp .
,
.
# chown root /etc/passwd
# chgrp wheel /etc/passwd
chown :
# chown root:wheel /etc/passwd
chown
, chgrp ,
- ,
chown chgrp
-R,
. :
# chown -R drobbins /home/drobbins
chmod
chown chgrp
,
, chmod,
, ,
ls -l. chmod
: ,
,
:
$ chmod +x scriptfile.sh
+x.
, +x chmod,
,
.
, :
$ chmod -x scriptfile.sh
,
, chmod
,
.
. ,
, , +
. u , g o
.
$ chmod go-w scriptfile.sh
,
.
, ,
/,
.
chmod, :
$ chmod =rx scriptfile.sh
.
, ,
:
$ chmod u=rx scriptfile.sh
,
chmod.
. ,
,
. , 1777, 777
, , ,
. 1
,
( ).
.
rwx
rw-
r-x
r--
-wx
-w-
--x
---
,
:
$ chmod 0755 scriptfile.sh
$ ls -l scriptfile.sh
-rwxr-xr-x 1 drobbins drobbins 0 Jan 9 17:44 scriptfile.sh
0755,
-rwxr-xr-x.
umask
, ,
.
0666 ( ),
, .
, , Linux ,
, umask.
umask
- .
umask umask
:
$ umask
0022
Linux- umask
0022,
( ), .
, umask:
$ umask 0077
umask ,
,
. , umask?
, umask
.
:
Rwx
rw-
R-x
r--
-wx
-w-
--x
---
,
0077 ---rwxrwx. ,
umask , .
,
,
.
suid sgid
. , ,
( bash)
. bash
,
. , ,
,
. , ,
,
,
. ,
passwd
root:
$ ls -l /etc/passwd
-rw-r--r-- 1 root wheel 1355 Nov 1 21:16 /etc/passwd
,
/etc/passwd .
, ?
suid
, Linux
, suid sgid.
suid,
, ,
. /etc/passwd.
passwd, ,
root:
$ ls -l /usr/bin/passwd
-rwsr-xr-x 1 root wheel 17588 Sep 24 00:53 /usr/bin/passwd
, x
s.
suid .
passwd
root (
), , .
passwd ,
/etc/passwd .
suid/sgid
suid, sgid
.
, .
!
, suid
sgid. -, suid sgid ls -l.
x , s (
). , x S (
).
!
: suid sgid ,
. suid
. passwd , suid.
suid sgid
suid sgid
. suid:
# chmod u+s /usr/bin/myapp
sgid .
, sgid :
# chmod g-s /home/drobbins
.
, .
,
.
,
;
, ;
,
.
.
,
,
.
sgid
, sgid,
, ,
. ,
. :
# mkdir /home/groupspace
# chgrp mygroup /home/groupspace
# chmod g+s /home/groupspace
mygroup
/home/groupspace
mygroup.
umask
,
mygroup.
Linux
.
. ,
,
.
,
, /tmp /var/tmp,
. ,
,
! , /tmp
,
rm -rf /tmp/*
.
, Linux
sticky . /tmp sticky
( chmod +t), ,
/tmp
.
, .
sticky, suid sgid:
suid
sgid
sticky
on
on
on
on
on
off
on
off
on
on
off
off
off
on
on
off
on
off
off
off
on
off
off
off
, 4-
,
:
# chmod 1775 /home/groupfiles
1755
. :)
Linux
Linux
, /etc/passwd
Linux /etc/passwd,
, .
/etc/passwd, less
/etc/passwd. /etc/passwd
. /etc/passwd:
drobbins:x:1000:1000:Daniel Robbins:/home/drobbins:/bin/bash
, .
, ":".
(drobbins),
x. Linux-
,
, Linux-
,
,
; ,
1000. ,
.
,
.
/etc/passwd,
,
, /etc/passwd,
, .
, Linux
. ,
(uid) 100,
/bin/false. ,
,
..
.
/etc/shadow
,
/etc/passwd. Linux /etc/passwd
- /etc/shadow. , /etc/passwd,
.
/etc/shadow:
drobbins:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:1:0
, ":".
,
.
.
:
3 01.01.1970 ,
4 ,
(0 )
5 ,
("-1" )
6
, ("1" )
7
,
("-1" )
8 ,
("-1" )
9
/etc/group
/etc/group,
Linux. :
drobbins:x:1000:
/etc/group :
,
, x,
.
( )
.
, /etc/passwd
1000.
drobbins drobbins,
drobbins
/etc/group.
:
-
, ( ).
-
.
.
,
.
,
.
.
EDITOR
:
# echo $EDITOR
vim
,
EDITOR, -, :
# export EDITOR=/usr/bin/emacs
# vipw
/etc/passwd .
passwd group vipw vigr.
,
.
/etc/passwd
, /etc/passwd,
:
testuser:x:3000:3000:LPI tutorial test
user:/home/testuser:/bin/false
testuser
3000.
, .
,
. ,
LPI tutorial test user,
"/home/testuser", "/bin/false",
. ,
"/bin/bash". ,
.
/etc/shadow
/etc/shadow
. vipw -s.
/etc/shadow.
(,
)
drobbins:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:1:0
(
) :
testuser:$1$1234567890123456789012345678901:11664:0:-1:-1:-1:1:0
. ,
.
# passwd testuser
Enter new UNIX password: (enter a password for testuser)
Retype new UNIX password: (enter testuser's new password again)
/etc/group
/etc/passwd /etc/shadow
/etc/group. , :
# vigr
/etc/group ,
. ,
,
/etc/groups.
, ,
:
testuser:x:3000:
.
testuser':
#
#
#
#
cd /home
mkdir testuser
chown testuser:testuser testuser
chmod o-rwx testuser
. .
, vipw
/bin/bash, ,
.
, ,
, Linux. -
, .
-
man-.
LPIC 101 ,
.
newgrp , ,
, ,
, /etc/passwd.
,
newgrp thisgroup thisgroup. ,
thisgroup.
chage chage
,
/etc/shadow.
gpasswd
groupadd/groupdel/groupmod
// /etc/group
useradd/userdel/usermod
// /etc/passwd.
.
man .
pwconv/grpconv passwd
group shadow passwords.
, Linux shadow passwords,
.
fortune
,
.
,
, ,
.
.
,
.
, fortune:
$ fortune
No amount of careful planning will ever replace dumb luck.
( fortune ,
, apt-get install fortune
. .)
.bash_profile
fortune
.
.bash_profile .
, .
:
fortune
.
, xdm, gdm kdm,
, :
bash .bash_profile
,
.
(file sourcing).
Bash
, . ,
,
/etc/profile, ~/.bash_profile.
bash
. :
bash -bash.
:
$ ps u
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
chouser 404 0.0 0.0 2508 156 tty2 S 2001 0:00 -bash
, , ,
, -bash .
, ,
.
--login
bash
login.
( xterm)
bash .
. --login
,
.
,
,
. bash ,
, /etc/profile ~/.bash_profile
~/.bashrc.
Interactive
login
profile
rc
yes
yes
source
ignore
yes
no
ignore
source
no
yes
source
ignore
no
no
ignore
ignore
bash ~/.bashrc
,
rsh scp.
, fortune ,
bash.
PS1
:
if [ -n "$PS1" ]; then
fortune
fi
/etc/profile /etc/skel
,
/etc/profile.
, .
,
.
, , ,
, , ,
.
/etc/skel.
useradd ,
/etc/skel .
, , , .bash_profile
.bashrc /etc/skel
.
export
bash ,
. ,
(export). bash
bash:
$ export
declare -x
declare -x
declare -x
declare -x
declare -x
declare -x
declare -x
declare -x
EDITOR="vim"
HOME="/home/chouser"
MAIL="/var/spool/mail/chouser"
PAGER="/usr/bin/less"
PATH="/bin:/usr/bin:/usr/local/bin:/home/chouser/bin"
PWD="/home/chouser"
TERM="xterm"
USER="chouser"
,
.
,
export:
$ FOO=foo
$ BAR=bar
$ export BAR
$ echo $FOO $BAR
foo bar
$ bash
$ echo $FOO $BAR
bar
FOO BAR,
BAR .
bash FOO.
bash,
FOO BAR .
$ exit
$ echo $FOO $BAR
foo bar
Export set -x
,
~/.bash_profile /etc/profile
, ,
.
,
~/.bashrc .
set:
$ set -x
-x bash ,
:
$ echo $FOO
$ echo foo
foo
. -x,
set +x. man
set.
set
set
,
. bash set
FOO=foo , FOO=foo.
unset:
$ FOO=bar
$ echo $FOO
bar
$ unset FOO
$ echo $FOO
Unset vs. FOO=
,
, .
set ,
:
$ FOO=bar
$ set | grep ^FOO
FOO=bar
$ FOO=
$ set | grep ^FOO
FOO=
$ unset FOO
$ set | grep ^FOO
set
export , set
,
.
. , bash,
, .
, man PAGER,
.
$ PAGER=less
$ export PAGER
$ man man
PAGER less,
,
.
PAGER cat, ,
.
$ PAGER=cat
$ man man
env
, PAGER
less, man ( )
.
PAGER cat ,
env:
$ PAGER=less
$ env PAGER=cat man man
$ echo $PAGER
less
PAGER
cat man,
PAGER bash.
3-
.
,
Linux,
.
c Linux ,
, Linux
Documentation Project, , FAQ,
. Linux
Weekly News.
The Linux System Administrators guide
.
"Unix and
Internet Fundamentals HOWTO".
Vi
"Vi intro the cheat sheet
method tutorial".
Vi. ,
Vi.
Emacs,
the developerWorks, "Living in Emacs".
4. ,
,
.
fdisk,
fstab.
Linux , ,
.
,
Linux.
.
, ,
IDE Linux, : /dev/hda
SCSI (, ,
libATA . .),
: /dev/sda
.
,
, : IDE, SCSI, - .
,
512
Linux ()
mkfs ( mke2fs, mkreiserfs, .),
.
, ,
, /dev/hda
/dev/sda, ,
.
, .
fdisk,
,
. ,
.
fdisk
fdisk,
.
:
: cfdisk, parted
partimage. cfdisk ( ,
fdisk) . .
.
fdisk /dev/hda
# fdisk /dev/sda
!
-
, ,
. , ,
.
fdisk
fdisk, ,
:
Command (m for help):
p
:
Command (m for help): p
Disk /dev/hda: 240 heads, 63
Units = cylinders of 15120 *
Device Boot
Start
/dev/hda1
1
/dev/hda2
15
/dev/hda3
50
/dev/hda4
71
/dev/hda5
71
/dev/hda6
210
/dev/hda7
349
/dev/hda8
627
/dev/hda9
905
Command (m for help):
Linux ( ,
Linux), (
Linux swap).
,
, /dev/hda1 /dev/hda9.
,
( ).
,
.
, 4-
. ,
. . ,
.
hda5 .
hda1 hda4
.
, c hda1 hda3
. hda4 ,
hda5 hda9.
/dev/hda4
hda5 hda9.
, ,
"Id", . ,
, ,
. 83
Linux, 82 .
t fdisk. Linux
.
fdisk
,
Linux, ,
Linux.
, .
,
Linux .
!
, ,
, , ,
. ,
, Linux
( . .),
.
,
,
:
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot
Start
End
Blocks
Id
/dev/hda1
*
1
14
105808+ 83
/dev/hda2
15
81
506520
82
/dev/hda3
82
3876 28690200
83
Command (m for help):
System
Linux
Linux swap
Linux
, ,
. (/dev/hda1)
, .
,
GRUB, Linux ().
, .
. SCSI (
libATA . .),
, , /dev/sda1.
(
) .
, ,
LILO ,
1024 .
(/dev/hda2) .
, .
, 512 . SCSI (
libATA . .)
/dev/sda2.
(/dev/hda3)
. ,
Linux.
SCSI ( libATA . .)
/dev/sda3.
, ,
fdisk /dev/hda fdisk /dev/sda ,
IDE SCSI ( libATA
. .) . p
. - ,
? , . ,
.
!
!
- , ,
. ,
.
.
, d Enter.
, .
/dev/hda1
:
Command (m for help): d
Partition number (1-4): 1
.
, p, ,
.
, q, Enter,
.
, ,
, p,
, d
. :
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot
Start
End
Blocks
Id System
Command (m for help):
, ,
. , n
, p
fdisk, . , 1
.
Enter.
+100M 100 .
:
p,
:
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
Units = cylinders of 15120 * 512 = 7741440 bytes
Device Boot Start End Blocks Id System
/dev/hda1 1 14 105808+ 83 Linux
, .
n , p
fdisk .
2 , /dev/hda2
.
, Enter,
, +512M
, 512 . , ,
t , 82
Linux swap. ,
p ,
:
Command (m for help): p
Disk /dev/hda: 30.0 GB, 30005821440 bytes
240 heads, 63 sectors/track, 3876 cylinders
.
/dev/hda1 ,
a 1 .
p, /dev/hda1 * Boot.
.
w Enter.
Linux.
:
fdisk , , ,
.
. Linux,
/
.
, ,
.
, ,
. ,
/home /var .
hda2 ,
.
hda5, hda6, hda7 (
hda2),
.
/, /home
/var
, , .
, ,
,
.
.
;
.
ext2, ext3, XFS, JFS
ReiserFS .
,
Linux.
. .: , ,
2003 ,
,
, , ext4 btrfs. , ,
.
ext2
ext2 Linux,
,
,
.
,
,
, .
,
(, . .).
ext3
ext3 ext2,
, ,
. ext3 .
.
, , ,
, ,
.
, ,
ext3 .
ext3 ,
ext2
ext3 .
Linux, ext2.
ReiserFS
ReiserFS , B-,
ext2 ext3
( 4 ), 10-15 . ReiserFS
.
2.4.18 , ReiserFS
,
, ,
,
, ,
. ReiserFS
.
XFS
XFS
.
.
Linux
SCSI / Fibre Channel
.
XFS ,
(. . ,
(
)) ,
.
JFS
JFS IBM
.
,
,
.
, ext3.
ReiserFS; ext3
ReiserFS ,
.
:
# mke2fs -j /dev/hda1
# mkswap /dev/hda2
# mkreiserfs /dev/hda3
ext3
/dev/hda1,
.
mkswap /dev/hda2
.
/dev/hda3 ReiserFS,
.
.
mkswap :
# mkswap /dev/hda2
,
. ,
swapon:
# swapon /dev/hdc6
Linux
. ,
swapon, ,
,
.
, cat /proc/swaps.
ext2, ext3, ReiserFS
ext2
mke2fs:
# mke2fs /dev/hda1
ext3,
mke2fs -j:
# mke2fs -j /dev/hda3
ReiserFS
mkreiserfs:
# mkreiserfs /dev/hda3
XFS JFS
XFS
mkfs.xfs:
# mkfs.xfs /dev/hda3
: mkfs.xfs :
-d agcount=3 -l size=32m. -d agcount=3
. XFS
4 , , ,
20, agcount=5. -l
size=32m 32 ,
.
. : .
, , , 6 ,
(allocation group) XFS .
JFS,
mkfs.jfs:
# mkfs.jfs /dev/hda3
,
, mount:
# mount /dev/hda3 /mnt
,
.
.
/mnt .
, .
,
/mnt
ReiserFS, .
,
/mnt. , :
# mkdir /mnt/boot
# mount /dev/hda1 /mnt/boot
,
/mnt/boot. /mnt/boot,
ext3 ,
/dev/hda1. /mnt,
/mnt/boot, ReiserFS
/dev/hda3.
/mnt,
( ),
Linux .
, mount .
mount Linux ,
,
:
/dev/root on / type reiserfs (rw,noatime)
none on /dev type devfs (rw)
proc on /proc type proc (rw)
tmpfs on /dev/shm type tmpfs (rw)
usbdevfs on /proc/bus/usb type usbdevfs (rw)
/dev/hde1 on /boot type ext3 (rw,noatime)
cat /proc/mounts. /dev/hda3
/dev/hda3.
/dev/hda3, /dev/root
, , :
# ls -l /dev/root
lr-xr-xr-x 1 root root 33 Mar 26 20:39 /dev/root ->
ide/host0/bus0/target0/lun0/part3
# ls -l /dev/hda3
lr-xr-xr-x 1 root root 33 Mar 26 20:39 /dev/hde3 ->
ide/host0/bus0/target0/lun0/part3
, /dev/ide/host0? , ,
devfs
/dev,
,
Linux
,
/dev/ide/host0/bus1/target0/lun0/part7
/dev/hdc7, /dev/hdc7
() .
devfs,
/dev/.devfsd; devfs
.
mount
,
.
, -t, :
# mount /dev/hda1 /mnt/boot -t ext3
. ,
ro:
# mount /dev/hdc6 /mnt -o ro
/dev/hdc6 ,
/mnt .
/
,
remount
:
# mount /mnt -o remount,ro
,
, . . mount
/mnt /dev/hdc6.
,
/:
# mount /mnt -o remount,rw
,
, /mnt -
.
mount Linux, man mount.
fstab
. ,
Linux, ,
? ,
Gentoo Linux .
,
/dev/hda3? - ,
, ,
?
,
Linux
,
, Linux
. , Linux
, /etc/fstab
.
.
fstab
/etc/fstab:
<fs> <mountpoint> <type>
<opts>
/dev/hda1
/boot
ext3
1 1
/dev/hda3
/
reiserfs
0 0
/dev/hda2
none
swap
0 0
/dev/cdrom
/mnt/cdrom
iso9660
0 0
# /proc should always be enabled
proc
/proc
proc
0 0
<dump/pass>
noauto,noatime
noatime
sw
noauto,ro,user
defaults
/etc/fstab
, ,
, ,
. ,
dump. ,
dump ,
.
fsck,
.
fsck .
/dev/hda1; , /dev/hda1
ext3, /boot.
opts.
noauto /dev/hda1
; /dev/hda1
/boot .
noatime,
atime ( )
. ,
atime
.
/proc defaults.
defaults,
. . . /etc/fstab
,
.
/dev/hda2 /etc/fstab.
/dev/hda2 .
,
. /etc/fstab,
/dev/hda2 ,
.
/dev/cdrom, /etc/fstab CDROM . :
# mount -t iso9660 /dev/cdrom /mnt/cdrom -o ro
:
# mount /dev/cdrom
, /etc/fstab
user.
,
.
, CD-ROM.
, root
CD-ROM.
,
.
,
.
, .
, , ,
- . ,
umount,
:
# umount /mnt
# umount /dev/hda3
, /mnt,
, .
fsck
- ,
.
,
, fsck ,
, /etc/fstab.
!
, fsck,
pass ( ) /etc/fstab. ,
1, ,
. ,
, pass 2 .
, ReiserFS,
0, (
fsck) .
, , fsck
.
, , ,
fsck ,
.
fsck ,
.
, y () ,
fsck .
fsck
fsck ,
,
(
) ,
. , ,
fsck .
, ,
, .
. ,
.
,
.
,
,
.
Linux.
Funtoo Filesystem Guide,
part 1: Journaling and ReiserFS.