unix-linux usage - ver. 1.18(2)
DESCRIPTION
randomTRANSCRIPT
-
,
:
Unix/Linux
:
-
Unix/Linux
-
Unix/Linux i
2008
Unix/Linux 1.18
Unix/Linux,
.
, ,
.
:
) .
Unix/Linux
, Unix/Linux
.
) . Unix/Linux
.
, , . ,
, .
,
,
.
, ,
.
.
,
.
Linux, Fedora 8.
, GNOME.
-
ii Unix/Linux
2008
Unix/Linux 1.18
:
, ,
.
, ,
. ,
.
, .
,
.
,
,
.
. ,
Unix/Linux.
,
, .. [,
] | .
[ ] ,
[ ] .
| ,
|, .. | .
-
Unix/Linux iii
2008
Unix/Linux 1.18
.
.
.
.
.
,
,
.
.
.
,
, .
.
- 19.1
, .137- .
:
student student user user visitor visitor root rootpass
.
, .
, ,
.
, , /linux1
.
-
iv Unix/Linux
2008
Unix/Linux 1.18
( )
.
, , ,
Richard Lacroix,
.
Rami El Sabeh, .
.
.
, , .
, ,
. , ,
, .
.
.
.
, 2008
-
Unix/Linux v
2008
Unix/Linux 1.18
1. ............................................................................................. 13 2. ............................................. 19 3. ...................................................... 27 4. bash ................................................................. 31 5. , ..................................................... 39 6. vi ......................................................... 47 7. .......................................................................................... 53 8. ....................................................... 55 9. GNOME, KDE ............... 66 10. bash .............................................. 71 11. , ..... 81 12. vi & vim ................. 87 13. - ......................... 91 14. ................................ 97 15. .......... 103 16. .............................................................. 115 17. scripts bash ............................................ 123 18. .................................................. 135 19. ................................................................................. 137 20. ................................................................................... 147 21. Internet................................................................... 159 22. ..................................................................... 163 23. ......................................................................... 165 24. .............................................. 167
-
vi Unix/Linux
2008
Unix/Linux 1.18
1. ............................................................................................. 13 1.1. ........................................................................................................................................ 13 1.2. ................................................................................. 13
1.2.1. ..................................................................................................... 13 1.2.2. (..) ........................................................................................... 13 1.2.3. .. ......................................................................................................... 13 1.2.4. .. ................................................................................................. 13 1.2.5. Unix ............................................................................................... 14
1.3. Unix/Linux ......................................................................................................... 14 1.3.1. Unix ............................................................................................ 14 1.3.2. Unix ................................................................................................................. 14 1.3.3. GNU & FSF ..................................................................................................................... 15 1.3.4. Linux .......................................................................................... 15
1.4. ........................................................................................... 15 1.4.1. ................................................................................................................. 15 1.4.2. ........................................................................................................... 16 1.4.3. ............................................................................................................. 16 1.4.4. ...................................................................................................... 17 1.4.5. ..................................................................................... 17
2. ............................................. 19 2.1. ........................................................................................................................................ 19 2.2. Unix ........................................................................ 19 2.3. pwd ..................................................................... 19 2.4. cd ........................................................................................ 19 2.5. ls ............................................................ 20 2.6. (Home directory) ................................................................................... 20 2.7. ...................................................... 21
2.7.1. ............................................................................................................ 21 2.7.2. .............................................................................................................. 21
2.8. ..................................................................................................................... 22 2.9. cp ............................................................. 22 2.10. mv ................................................................................... 23 2.11. touch mkdir ....................... 23 2.12. rm ....................................................................................... 23 2.13. rmdir .......................................................................... 23 2.14. file ............................................... 23 2.15. cat, more less ........................ 23 2.16. locate slocate ............................................. 24 2.17. man ...................................................................................................... 24
2.17.1. man ..................................................................................................... 24 2.17.2. man ........................................................................................... 25 2.17.3. utilities .............................................................................................. 25
2.18. : ....................................... 25 3. ....................................................... 27
3.1. ........................................................................................................................................ 27 3.2. X-Window ............................................................... 27 3.3. GNOME ................................................................................................................................... 27 3.4. KDE .......................................................................................................................................... 27
-
Unix/Linux vii
2008
Unix/Linux 1.18
3.5. ......................................................................................... 27 3.6. GNOME & KDE .................................................................................... 28 3.7. nautilus ................................................................. 28 3.8. ......................................................................................... 28 3.9. .................................................................... 28 3.10. Web browsers ......................................................................................................................... 28 3.11. OpenOffice .................................................................. 29 3.12. ................................................................... 29 3.13. ..................................................................................... 29 3.14. .................................................................................................... 29 3.15. : .................................................. 30 4. bash ................................................................. 31
4.1. ........................................................................................................................................ 31 4.2. (shell) ............................................................................................................ 31 4.3. bash ............................................................................................... 31 4.4. ...................................................................................................... 31
4.4.1. (File globbing) ......................................................... 31 4.4.2. Tab ................................................................................................................ 32 4.4.3. history ....................................................................... 33
4.5. ........................................................................................... 33 4.5.1. ~ ............................................................................................................... 33 4.5.2. set .......................................................................................... 33 4.5.3. {} ......................................................................................................................... 34 4.5.4. ..................................................................................................... 35 4.5.5. ........................................................................................................ 35
4.6. ................................................................. 35 4.6.1. backslash (\) ........................................................................................... 35 4.6.2. .............................................................................................. 36
4.7. ..................................................................... 36 4.8. : bash .............................................................. 37 5. , ..................................................... 39
5.1. ........................................................................................................................................ 39 5.2. ..................................................................................................................................... 39 5.3. ...................................................................................................................................... 39 5.4. root ........................................................................................................................ 39 5.5. Unix/Linux ................................................................................ 40 5.6. ..................................................................................................................... 40 5.7. ............................................................................................ 40 5.8. ......................................................................................... 40
5.8.1. ........................................................................................................ 41 5.8.2. ............................................................................................. 41
5.9. (), ..................................... 41 5.10. .............................................................................................................. 43
5.10.1. ................................................................... 43 5.10.2. ..................................................................... 43
5.11. : , ................................................ 44 6. vi ......................................................... 47
6.1. ........................................................................................................................................ 47 6.2. vi vim ......................................................................... 47 6.3. vi vim ...................................................................................................... 47
-
viii Unix/Linux
2008
Unix/Linux 1.18
6.4. vi ............................................................................................ 47 6.5. .................................................................................................................. 48 6.6. .......................................................................... 48 6.7. .................................................................. 49 6.8. , ........................................................................................... 49 6.9. ............................................................................................................................... 49 6.10. .................................................................................................................. 50 6.11. ............................................................................................................... 50 6.12. ......................................................................................................... 50 6.13. ........................................................................................................................... 50 6.14. : vi.................................................... 51 7. .......................................................................................... 53
7.1. ........................................................................................................................................ 53 7.2. Unix/Linux ..................................................................................................... 53 7.3. ................................................................................................................. 53 7.4. Utilities ................................................................................................................. 53 8. ....................................................... 55
8.1. ........................................................................................................................................ 55 8.2. (filesystems) ............................................................ 55 8.3. Inodes ........................................................................................................................................ 55 8.4. .................................................................................................................. 56 8.5. cp inodes .......................................................................................................... 56 8.6. mv inodes .......................................................................................................... 56 8.7. rm inodes .......................................................................................................... 56 8.8. ................................................................................................................... 57
8.8.1. ...................................................................................................... 57 8.8.2. .......................................................................................................................... 58
8.9. ........................................................................................................................... 59 8.10. ......................................................................................................................... 59
8.10.1. df ................................................................................................................... 59 8.10.2. H du ................................................................................................................... 59
8.11. find ...................................................................................................................... 60 8.12. ......................................................................................... 60 8.13. ...................................................................... 60
8.13.1. mount umount .............................................................................. 60 8.13.2. ................................................................................................. 61
8.14. tar ........................................................................................... 61 8.15. .................................................................................................................. 62
8.15.1. .................................................................................................... 62 8.16. : .............................................. 63 8.17. : ................................................................................ 63 8.18. : find ........................................................... 64 8.19. : ........................................................ 64 9. GNOME, KDE ............... 66
9.1. ........................................................................................................................................ 66 9.2. X-Window .................................................................................... 66 9.3. (Window managers) ..................................................................... 66 9.4. GNOME ...................................................................................................... 66 9.5. KDE ............................................................................................................. 67 9.6. panel ............................................................................................................... 67
-
Unix/Linux ix
2008
Unix/Linux 1.18
9.7. nautilus ............................................................................................. 67 9.8. gnome-terminal ............................................................................ 67 9.9. ......................................................................... 67 9.10. email clients ............................................................................................................ 68 9.11. evolution ........................................................................................ 68 9.12. : GNOME ...................................................... 68 9.13. : gnome-terminal ................................. 69 9.14. : evolution .............................................. 69 10. bash .............................................. 71
10.1. ...................................................................................................................................... 71 10.2. () bash ........................................................ 71 10.3. ............................................................................................................................. 71 10.4. ................................................................................................................ 72
10.4.1. ......................................................................................... 72 10.4.2. PS1 ........................................................................................................... 72
10.5. (aliases) ............................................................................................................... 73 10.6. set shopt ................................................................................................. 73 10.7. : .................................................. 74 10.8. .................................................................................... 74
10.8.1. TERM ............................................................................ 74 10.8.2. PATH ............................................................................ 74
10.9. ............................................................... 75 10.10. ..................................................................................................... 75 10.11. login ......................................................................................................................... 76 10.12. : ............................................................................. 76 10.13. /etc/profile ........................................................................................................ 77 10.14. /etc/profile.d................................................................................................ 77 10.15. ~/.bash_profile ~/.bashrc ....................................................................... 77 10.16. ~/.bash_logout ................................................................................................. 77 10.17. : .................................................................... 78 10.18. : bash prompt ........................................................ 78 10.19. : .............................................................. 79 11. , ..... 81
11.1. ...................................................................................................................................... 81 11.2. & ............................................................................................... 81 11.3. /etc/passwd, /etc/shadow & /etc/group ...................................................... 81 11.4. .............................................................................. 81 11.5. su ................................................................. 82 11.6. ........................................................................... 82 11.7. umask ............................................. 82 11.8. ................................................................................................... 83
11.8.1. ................................................................... 83 11.8.2. ............................................................................... 84
11.9. : ............................................................................ 84 11.10. : .............................................. 84 11.11. : umask ......................... 85 11.12. : umask ..................................................................... 85 12. vi & vim ................. 87
12.1. ...................................................................................................................................... 87 12.2. ............................................................................................................ 87
-
x Unix/Linux
2008
Unix/Linux 1.18
12.3. ........................................................................................................... 87 12.4. ex: ................................................. 87 12.5. .......................................................................... 88 13. - ......................... 91
13.1. ..................................................................................................................................... 91 13.2. (standard input & output) ..................................................... 91 13.3. - ........................................................................................... 92
13.3.1. .................................................................................................. 92 13.3.2. .................................................................................................... 93 13.3.3. ................................................................................ 93 13.3.4. ................................................................................................. 93
13.4. ........................................................................ 93 13.4.1. tee ................................................................................................................. 94 13.4.2. mail ...................................................................................... 94
13.5. : - .................................................. 94 13.6. : .................................................................................... 95 14. ................................ 97
14.1. ..................................................................................................................................... 97 14.2. head ...................................................................................................................... 97 14.3. tail ...................................................................................................................... 97 14.4. wc ........................................................................................................................... 97 14.5. sort ...................................................................................................................... 98 14.6. cut ........................................................................................................................ 99 14.7. uniq ...................................................................................................................... 99 14.8. ..................................................................... 100 14.9. - diff ................................................................................. 101 14.10. aspell ............................................................... 101 14.11. ..................................................................................................... 102 14.12. : ...................................... 102 15. .......... 103
15.1. ................................................................................................................................... 103 15.2. (regular expressions) .................................................................. 103 15.3. (wildcards) ................................................................................... 104 15.4. Modifiers ............................................................................................................................... 104 15.5. Anchors ................................................................................................................................. 105 15.6. ................................................................................ 106 15.7. ............................................................................ 106 15.8. .............................................................................................................. 107 15.9. grep .................................................................................................................... 107 15.10. H sed ............................................................................................................... 108 15.11. less slocate - .......................................... 109 15.12. vi ...................................................................................... 109 15.13. ................................................................................ 110 15.14. awk ............................................................................................................... 110 15.15. : grep .......................... 111 15.16. : .... 111 15.17. : sed ........... 111 16. .............................................................. 115
16.1. ................................................................................................................................... 115 16.2. . ......................................................................................... 115
-
Unix/Linux xi
2008
Unix/Linux 1.18
16.3. ...................................................................................................... 115 16.4. ....................................................................................................... 116 16.5. ...................................................................................... 116 16.6. ...................................................................................................... 116 16.7. ................................................................................... 117 16.8. .................................................................................. 117 16.9. ................................................................................ 118 16.10. ....................................................................................... 118 16.11. ............................................. 118 16.12. ............................................................................ 119 16.13. ................................................................................................................. 119 16.14. ................................................................... 119 16.15. ..................................................................... 120 16.16. crontab crontab ................................................................... 120 16.17. : .................................................................. 121 17. scripts bash ............................................ 123
17.1. .................................................................................................................................... 123 17.2. shell script ........................................................................... 123 17.3. shell script ........................................................................................................ 123 17.4. ........................................................................................................ 124 17.5. ........................................................................................................ 125 17.6. ................................................................................................................ 125 17.7. shell scripts .................................................................................. 126 17.8. ............................................................................................................... 127 17.9. ....................................................................................................................... 127
17.9.1. ................................................................................................. 128 17.9.2. - if .................................................................................... 129 17.9.3. ........................................................................................................... 129 17.9.4. .............................................................................................. 130 17.9.5. if/else ...................................................................... 131 17.9.6. case .............................................................................. 131 17.9.7. for ........................................................................ 132 17.9.8. while until .......................... 132 17.9.9. continue & break ............................................................................ 133
17.10. script ..................................................................................... 133 18. .................................................. 135
18.1. .................................................................................................................................... 135 18.2. ssh ....................................................................................................................... 135 18.3. scp ....................................................................................................................... 135 18.4. telnet r ................................................................................... 135 18.5. ftp ...................................................................................................................... 135 18.6. mutt .............................................................................................................. 135 18.7. rsync ................................................................................................................. 136 18.8. wget .................................................................................................................... 136 18.9. ............................................................................................................ 136 19. ................................................................................. 137
19.1. .......................................................................................................... 137 19.1.1. 2-1 ........................................................................................................ 137 19.1.2. 2-2 ........................................................................................................ 137 19.1.3. 2-3 ........................................................................................................ 137
-
xii Unix/Linux
2008
Unix/Linux 1.18
19.1.4. 2-4 ........................................................................................................ 137 19.1.5. 4-8 ........................................................................................................ 138 19.1.6. 15-1 ...................................................................................................... 138
19.2. bash ............................................................................ 139 19.3. vi ...................................................................... 139 19.4. bash ........................................................................ 141 19.5. set bash ..................................... 143 19.6. shopt bash ................................ 144 19.7. .................................................................................................... 145 19.8. test ............................................................................................... 145 20. ................................................................................... 147 21. Internet ................................................................... 159 22. ..................................................................... 163 23. ......................................................................... 165 24. .............................................. 167
-
Unix/Linux 13
2008
Unix/Linux 1.18
1.
1.1.
Unix Linux .. Unix Linux
1.2.
1.2.1.
:
: :
(): .
1.2.2. (..)
,
,
.
1.2.3. ..
( ) (//) ( ) ( )
1.2.4. ..
(Job sequencing) (Job control language
interpretation)
(Error Handling)
-
14
2008
Unix/Linux 1.18
/ (I/O Handling) (Interrupt Handling) (Scheduling) (Resource control) (Protection) (Multi access) (interface) (accounting)
1.2.5. Unix
.. (multiuser): .. (multitasking): Timesharing: , .
( ).
To Unix/Linux .. (multiuser &
multitasking). ,
, (timesharing)
.
1.3. Unix/Linux
1.3.1. Unix
1965 Bell Labs, GE & MIT- MULTICS 1969 Ken Thompson & Dennis Ritchie, AT&T - Unix 1971 1973 Unix C 90% 1979 Unix v. 7 1983 Unix System V standard
1.3.2. Unix
, hardware
-
Unix/Linux 15
2008
Unix/Linux 1.18
(configuration)
() -utilities-
user interface
1.3.3. GNU & FSF
To GNU project 1984 Unix.
. 1990,
GNU, .. gcc, emacs. FSF (Free
Software Foundation) - GNU
project. Free Software: , , , ,
.
, .
1.3.4. Linux
1991, Linus Torvalds, Linux. Minix ( Unix)
(386).
Linux GNU, ..,
Unix, .
Linux , servers. servers supercomputers PDAs
, .
1.4.
1.4.1.
(
login). (username)
-
16
2008
Unix/Linux 1.18
(password). login
(GUI).
1.4.2.
, ,
1.4.3.
: Command [options] [arguments] [ ] : options (switches): .
Arguments: . (space).
; mkdir backups ; cp *.txt backups/ prompt,
.
: .
,
1-1. ,
.
.
date date +"Today is %A, %B %d, %Y. %nThe time now is %r,
%Z."
cal cal 11 2007
-
Unix/Linux 17
2008
Unix/Linux 1.18
1.4.4.
login. ,
passwd. , System,
Preferences, Personal, About Me, Change Password.
1.4.5.
: 6-255 , 1 -
, ,
, .
-.
-
Unix/Linux 19
2008
Unix/Linux 1.18
2.
2.1.
Unix/Linux , ,
2.2. Unix
. CD, ,
root / / (slash) case-sensitive (directory) (home directory, ~) .. (parent directory) . . path,
2.3. pwd
pwd
.
.
2-1.
, ;
19.1.1. 2-1, .137.
2.4. cd
:
-
20
2008
Unix/Linux 1.18
: cd/home/bob/work : cd project/docs : cd .. : cd, cd ~, cd ~bob : cd -
2.5. ls
ls :
ls, ls /, ls /etc, ls / /etc ls -a, ls -l, ls -R, ls -d,
2.6. (Home directory)
home directory, /home.
. ~.
login.
-
Unix/Linux 21
2008
Unix/Linux 1.18
2.7.
1. ""
2.7.1.
/, .
/usr/users/bob/data/index.html . (
), .
2-2.
1 (. 21).
index.html data;
19.1.2. 2-2, . 137.
2.7.2.
/, .
.., ., ~. .
.
/
usr
dev
etc
var
users
bob
data
-
22
2008
Unix/Linux 1.18
2-3.
1 (. 21). ,
/usr/users/bob/data/index.html
;
index.html
data/index.html
bob/data/index.html
users/bob/data/index.html
../usr/users/bob/data/index.html
~/data/index.html
~bob/data/index.html
../bob/data/index.html
19.1.3. 2-3, . 137.
2.8.
255 . /
.
< > | ? * " ' . -, FILE, file, File
, .
2.9. cp
cp [options] file destination
.
: , .
, ,
.
file1, file2 allfiles,
: cp file1 file2 allfiles. ,
.
, .
,
.
.
-
Unix/Linux 23
2008
Unix/Linux 1.18
2.10. mv
mv file1 file2, file1 file2 mv dir1 dir2, dir1 dir2 mv file(s) dir, dir
,
2.11. touch mkdir
: touch file. ,
.
, mkdir directory.
() , mkdir -p dir1/dir2
2.12. rm
( ) : rm [options] file1 files
rm -i, rm -f, ,
2.13. rmdir
: rmdir directory1 : rm r directory1 rm ri directory1
2.14. file
file [options] filenames. .
file (.. binary
). /usr/share/magic
2.15. cat, more less
Unix/Linux
.
cat ,
. cat [options] filenames , cat /etc/profile /etc/passwd
-
24
2008
Unix/Linux 1.18
H more ,
. . more [options] filenames, more /etc/profile /etc/passwd less ,
. . less [options] filenames less /etc/profile /etc/passwd
2.16. locate slocate
locate slocate e
() . slocate
. locate
[pattern] slocate [pattern]
2.17. man
man: . man man: man (manual) . man k keyword,
man (
keyword)
apropos keyword, man k keyword man f keyword, (
keyword)
whatis keyword, man f keyword 2-4. man, apropos, whatis
man k password man f
password;
19.1.4. 2-4, . 137.
2.17.1. man
To 1 User commands To 2 System calls
-
Unix/Linux 25
2008
Unix/Linux 1.18
To 3 Library calls To 4 Hardware (special files) To 5 Configuration files (File formats) To 6 Games To 7 Miscellaneous To 8 Administrative commands
man passwd passwd(1) passwd
man 5 passwd passwd(5) o /etc/passwd
2.17.2. man
NAME - SYNOPSIS - DESCRIPTION - OPTIONS - FILES - BUGS - EXAMPLES - SEE ALSO - ...
2.17.3. utilities
utilities --
help , .. cat --help. ,
Linux info.
/usr/share/doc.
2.18. :
login student.
home directory . .
home directory : ls,
ls-a, ls al. ;
home directory , ls al;
/linux1/lab2. .
touch .
-
26
2008
Unix/Linux 1.18
touch {report,graph}_{jan,feb,mar} .
.
ls. .
, .
. ,
. ,
pwd .
projects, projects/graphs, projects/reports
projects/backups. graph
projects/graphs. report_jan report_feb
projects/reports. /linux1/lab2.
backups (jan)
.
/linux1/solutions/2.18.txt
-
Unix/Linux 27
2008
Unix/Linux 1.18
3.
3.1.
3.2. X-Window
X-Window ( X 11) . X
, ,
standard
. X server .
X client. X X client.
Linux (desktop
environment) (window managers), GNOME KDE
3.3. GNOME
o window manager GNOME
System. Red Hat Fedora
(: abiword, gnumeric, mrproject, gnomemeeting, gedit, ggv)
3.4. KDE
window manager KDE. Red Hat Fedora
(: konsole, konqueror, kmail,
kdevelop)
3.5.
.
, login. login
display manager. ,
startx.
.
. O
-
28
2008
Unix/Linux 1.18
3.6. GNOME & KDE
window manager ,
(logout) ,
Session GNOME KDE.
window manager .
3.7. nautilus
nautilus (file manager) web browser.
Compute students home nautilus.
, html.
nautilus, (preferences)
. (system settings). html
ftp .
3.8.
GNOME gnome-
terminal, KDE konsole.
window manager (
, ). (,
, shells).
3.9.
gvim, vim xemacs, emacs gedit, GNOME kwrite, KDE
3.10. Web browsers
mozilla konqueror, KDE file manager web browser (GNOME & KDE)
-
Unix/Linux 29
2008
Unix/Linux 1.18
3.11. OpenOffice
open source StarOffice.
ooffice
oowriter, ooimpress, oodraw, oomath, oocalc .
OpenOffice, oosetup,
spadmin.
3.12.
:
, X. X ()
, , workspaces , menu (Red Hat Fedora),
3.13.
:
, , ,
,
(
, ).
3.14.
(),
panel (. 9.6. panel, . 67)
eyboard indicator. panel, eyboard
indicator, , ..
(layout options,
layout switching).
-
30
2008
Unix/Linux 1.18
3.15. :
login , student.
nautilus students home
. /linux1/lab3
passwd. nautilus
.
back .
+ . View as
icons View as list.
+ . gnome-terminal
/linux1/lab3. gnome-terminal
touch newfile.
nautilus .
newfile Move to Trash. gnome-terminal
. .
Trash .
newfile . nautilus.
gnome-terminal .
. rm newfile.
nautilus
Trash. nautilus Trash. logout
.
-
Unix/Linux 31
2008
Unix/Linux 1.18
4. bash
4.1.
4.2. (shell)
. prompt, ,
. ,
.
, ,
.
4.3. bash
bash: Bourne Again Shell. GNU project Bourne shell (sh), Unix C shell (csh), : , ,
Korn shell (ksh), C shell Enhanced C shell (tcsh), command-line editing Bourne Again Shell (bash), csh,
ksh tcsh, , ,
command-line editing
4.4.
bash .
:
4.4.1. (File globbing)
File globbing: wildcards (
-)
*,
-
32 bash
2008
Unix/Linux 1.18
?, () [a-z], [^a-z],
echo
, .
4-1. Wildcards
/linux1/exersices/4-1. .
rm *.doc. ,
doc . echo ??ee*.txt ls
??ee*.txt. ??ee*.txt
rm ??ee*.txt.
/linux1/solutions/4-1.txt
4.4.2. Tab
Tab (
)
4-2. To tab bash
/linux1/exersices/4-2. .
ls myf.
myf
.
ls p.
tab .
ls pe
p
.
.
: .
.
-
Unix/Linux 33
2008
Unix/Linux 1.18
4.4.3. history
.
,
history. :
!!, !c, abc !5, 5 !?abc, abc !-5, 5 ^old^new, old
new
4-3. bash
/linux1/exersices/4-3. .
files . file1.txt files.
(^) ,
, file2.txt, file2.doc, onemorefile
files.
(!) , files.
/linux1/solutions/4-3.txt
4.5.
4.5.1. ~
~ (tilde) home directory.
home directory, ~/.bash_profile, , ,
, home directory , , ~bob/.bash_profile
.bash_profile home directory bob.
home directory path
.
4.5.2. set
, $,
. bob cd $HOME/public
-
34 bash
2008
Unix/Linux 1.18
$HOME home directory
( /home/bob) cd /home/bob/public.
,
set. , : name = Nikolas
4-4.
/linux1/exersices. cd $HOME
home directory . set
. N SEMINAR
Linux LEVEL 1. echo
.
/linux1/solutions/4-4.txt
4.5.3. {}
{ } .
(,).
, .
H echo x{a,b} echo xa xb
H cp file.txt{,-save} cp file.txt
file.txt-save.
4-5. { }
() /linux1/exersices/4-5.
. mkdir p
work/{in,out,hold}/{low,normal,high}
nautilus /linux1/exersices/4-5
.
()
{ }. :
. :
. ,
.
/linux1/solutions/4-5a.txt.
() /linux1/solutions/4-5b.txt
/linux1/solutions/4-5c.txt.
-
Unix/Linux 35
2008
Unix/Linux 1.18
4.5.4.
,
backquotes ` $( ). echo "This machine is named:
`hostname`" echo " This machine is named: $(hostname)"
. hostname
.
4-6.
/linux1/exersices. echo " This machine is
named: $(hostname)" echo "Long listing of files under /linux1: $(ls l /linux1)".
4.5.5.
.
expr:, .. echo Area: `expr $X \* $Y`. expr
.
$[ ]: echo Area: $[$X*$Y], echo Area: $[ $X *
$Y ] echo Area: $[ $X*$Y ] ,
. : (+),
(-), (*), (/), (**),
(%). bash man, ARITHMETIC EVALUATIONS,
.
19.2.
bash, . 139.
4-7.
/linux1/exersices/4-7.
2 3 . , $ [ ], A+B, A-
B, A*B, A/B **.
/linux1/solutions/4-7.txt
4.6.
.
4.6.1. backslash (\)
echo Your cost: \$5.00 (
$).
-
36 bash
2008
Unix/Linux 1.18
foo.
find / -name foo*,
*
. foo
foo .
find / -name foo\*
4.6.2.
, .. echo \*\*\* SALES \*\*\*. (
) .
.
$, $(), $[], `, \, !.
.
4-8. ` "
() echo "The current date is
`date`" () echo 'The current date is `date`'; ,
. ;
()
()
19.1.5.. 4-8, . 138.
4.7.
, < Ctrl+e>, o < Ctrl+u>, < Ctrl+k>,
-
Unix/Linux 37
2008
Unix/Linux 1.18
4.8. : bash
/linux1/lab4.
, : touch{report,memo,graph}_{sep,oct,nov,dec}_{a,b,c}_{1,2,3} ls
. .
a_reports, september, october, november
december. a_reports, one two
three. dec_b december.
dec_b_ december.
december.
b (september, october , november).
a_reports.
a_1 one. one
sep. , a_2
two .
, a_3 three
.
/linux1/lab4 .
c. c1 c2
/tmp/archive ( ).
.
/linux1/lab4.
ls *c* ls Fd *c* .
.
/linux1/solutions/4.8.txt
-
Unix/Linux 39
2008
Unix/Linux 1.18
5. ,
5.1.
Unix/Linux ()
5.2.
.
(user ID - UID User Identification). UID
/etc/passwd. home directory
. (, ,
), .
5.3.
. .
(group ID - GID Group
Identification). /etc/passwd
/etc/group.
.
. newgrp
.
(user private group): .
,
.
5.4. root
root .
(,
, ). superuser.
-
40 ,
2008
Unix/Linux 1.18
root .
.
, root, .
5.5. Unix/Linux
.
.
login.
. () ,
.
5.6.
.
() (owner user), () (group) ()
(others). : ,
.
5.7.
,
:
,
, ,
,
5.8.
ls -l.
10
. ,
. d
, ( ).
-
Unix/Linux 41
2008
Unix/Linux 1.18
5.8.1.
: (user, owner,
u), (group, g) (others,
o).
5.8.2.
: r (read,
), w (write, ), x (execute, )
. , ,
: () (read)
cat less, () (write)
, () (execute)
, .
, , ,
: () (read)
( ls), () (write)
, () (execute)
( cd)
ls l.
(write) ,
.
5.9. (),
ls l:
2,3 4 ,
5,6 7 ,
8,9 10 ,
5-1.
-
42 ,
2008
Unix/Linux 1.18
/linux1/exercises/5-1. ls l f*.
:
-rwxr-xr-x 1 root root 0 2008-01-28 00:30 file1
-rw-rw-r-- 1 root student 0 2008-01-28 00:30 file2
: file1,
( root) , (rwx),
( root) (r-x)
(r-x). file2,
( root) (rw-),
( student) (rw-)
(r--).
, fred mary.
.
fred fred staff
mary mary staff, admin
ls l [dtp]*. :
-rw-rw-r-- 1 root staff 0 2008-01-28 00:30 distribution
-rwxr-xr-- 1 fred fred 0 2008-01-28 00:30 penguin
-rw-r--r-- 1 mary admin 0 2008-01-28 00:30 tux
,
:
distribution, mary fred
( staff).
penguin, fred , .
mary ,
( mary fred,
).
tux, mary . fred,
staff, .
-
Unix/Linux 43
2008
Unix/Linux 1.18
5.10.
chmod.
chmod
. chmod
. chmod ,
. chmod R (recursive),
.
5.10.1.
,
: () , () () .
: u (user/), g (group/), (others/ ) a (all/
).
: + ( ), - ( ), = ( ).
: r (read/), w (write/), x (execute/)
s t ( 11.8. ).
chmod g+w .bashrc, , .bashrc
chmod go-rw .bashrc, ,
.bashrc
chmod u=rw,a+x .bashrc, ( )
(, , )
.bashrc
5.10.2.
.
, .
(4),
-
44 ,
2008
Unix/Linux 1.18
(2) (1).
, .
2.
chmod 664 file, ,
chmod 660 file, ,
chmod 600 file, ,
chmod 444 file, ,
( cd).
chmod 755 directory, ,
chmod 770 directory, ,
chmod 700 directory, ,
chmod 555 directory,
5.11. : ,
/linux1/lab5.
file chmod
.
.
.
-
Unix/Linux 45
2008
Unix/Linux 1.18
file000 000
file111 111
file555 555
file600 600
file644 644
file700 700
file711 711
file731 731
file755 755
file777 777
newfile 755.
r-xr--r--; ( ).
, cmdfile, .
( ) ;
/linux1/solutions/5.11.txt
-
Unix/Linux 47
2008
Unix/Linux 1.18
6. vi
6.1.
vi ,
6.2. vi vim
vi Unix
Unix. vim: vi
improved ( vi ).
editor Unix, ed (ed ex vi vim).
6.3. vi vim
, vi filename,
, vi newfilename. vim
vi. vi \vi .
vi vim, unalias vi.
vi m file, vi R file, :w! vi n file,
vi r file, vi x file,
6.4. vi
vi : (command mode),
(insert mode) (ex mode).
Command mode: , vi, .
: , , ,
, , .
-
48 vi
2008
Unix/Linux 1.18
Insert mode: , . Ex mode: , , .
6.5.
, vi
h j k l w b ( ) { }
:
. Hello!, she said. :
Hello !, she Said .
1 2 3 4 5 6
6.6.
.
a i A I O
-
Unix/Linux 49
2008
Unix/Linux 1.18
6.7.
, . ,
. vi,
.
6.8. ,
, (copy
vi yank). w, (, ), { }
. c, d y
:
(change) c (delete) d (yank) y
cc dd yy
cl dl yl
cw dw yw
c( d( y(
c) d) y)
c{ d{ y{
c} d} y}
cc ,
.
cl
, cw
.
H yank () (, , ,
) buffer (put).
6.9.
vi vim, put ( paste,
). p P.
, p
-
50 vi
2008
Unix/Linux 1.18
, P
. , , p
, P
6.10.
u, . U, ,
, u
6.11.
/text, ?text, n, ,
6.12.
vi. (ex mode)
(command mode) :,
ex :
vi :wq :q :q!
vi :w :e!
:wq! :w!.
19.3. vi ,
vi (. 139).
6.13.
vi .
:
-
Unix/Linux 51
2008
Unix/Linux 1.18
dtc, c ( ).
5dd, 5 (dd). , ,
x, rx,
x
R,
6.14. : vi
/linux1/lab6. vi
GPL_V2. , Preamble,
/Preamble. ,
vi :wq.
vi .
vi
-
Unix/Linux 53
2008
Unix/Linux 1.18
7.
7.1.
utilities
7.2. Unix/Linux
, .
(queues).
,
.
. , ,
(job).
.
.
7.3.
lpr, lpq, lprm,
7.4. Utilities
enscript, a2ps, PostScript xpdf, pdf ggv, pdf PostScript ps2pdf, PostScript pdf pdf2ps, pdf PostScript mpage,
-
Unix/Linux 55
2008
Unix/Linux 1.18
8.
8.1.
inodes find
8.2. (filesystems)
(partitions).
(filesystem).
.
Linux ext3 ext2. Linux
.
8.3. Inodes
inodes (index nodes )
filesystem ext2/3. inode.
inode , inode (inode number),
. inode - -
:
( , , .) (
inode
(user ID) (group ID) (timestamps),
-
56
GNOME, KDE
2008
Unix/Linux 1.18
8.4.
.
,
( ) inodes
( ..). ,
.. , inode
number ,
, , ,
. ls i inode number
8.5. cp inodes
, , inodes.
, inode
. , .
8.6. mv inodes
, mv,
,
, . inode
. .
8-1. cp, mv inodes
/linux1/exersices/8-1.
ls li. file1 file2 cp.
. inodes
;
file2 file3 mv.
. inodes
;
/linux1/solutions/8-1.txt.
8.7. rm inodes
:
, inode ( )
-
Unix/Linux 57
2008
Unix/Linux 1.18
blocks . ,
blocks .
8.8.
Unix/Linux .
(links hard links) (symbolic links soft
links).
8.8.1.
.
,
.
,
.
, rm,
.
password
/etc/passwd ln s /etc/passwd password.
:
inode. ,
, .
l ( link) -,
.
rwxrwxrwx (,
). ,
.
, .
.
(
) .
/etc/passwd 11 bytes,
-
58
GNOME, KDE
2008
Unix/Linux 1.18
/etc/passwd.
.
8.8.2.
(hard link) ,
inode. .
,
. fedora
fedora_core, ln fedora fedora_core.
:
, , inode.
, .
, , .
(1).
, ,
,
inode.
: () ,
, ,
inode ()
.
8-2. (symbolic) (links)
/linux1/exercises/8-2.
ls li. password
/etc/passwd. .
;
fedora redhat.
. ;
/linux1/solutions/8-2.txt
-
Unix/Linux 59
2008
Unix/Linux 1.18
8.9.
: (-), (d)
(l). Unix/Linux .
:
c, character special file: (hardware) , ..
b, block special file: (hardware) block, ..
p, named pipe: . ,
.
s, socket: .
8.10.
df du
.
8.10.1. df
df (disk free) ,
, .
h .
8.10.2. H du
du (disk usage) ( KB)
. s
. h
df.
8-3. du df
/linux1. df df h
. du du h
/linux1 .
/linux1/solutions/8-3.txt.
-
60
GNOME, KDE
2008
Unix/Linux 1.18
8.11. find
find
.
find
find /etc/sysconfig.
name
, find . name "*.hmtl".
find :
-atime [+n|-n|n], n ( n / n )
-mtime [+n|-n|n], n ( n / n )
-uname user, user -group gname, gname
8.12.
find (-exec)
find.
H ,
( )
html. find . name "*.hmtl" exec cat {} \;
{}
find. \;
(cat file1 ; cat file 2; ).
8.13.
(mount),
(unmout),
.
8.13.1. mount umount
CD , Unix/Linux.
, mount.
-
Unix/Linux 61
2008
Unix/Linux 1.18
mount /mnt/floppy mount /mnt/cdrom,
umount /mnt/floppy umount /mnt/cdrom .
CD , ,
eject, CD .
8.13.2.
.
.
, fdformat /dev/fd0H1440.
:
mkfs t ext2 /dev/fd0, ext2 mke2fs /dev/fd0, ext2 mkfs t vfat /dev/fd0, fat
.
8.14. tar
( tar file).
,
. tar, ,
, ,
,
.
tar.
H tar cvf archive_name files.
tar . (files)
, , .
H , tar xvf
archive_name.tar. tar
,
.
, tar
tf archive_name.tar.
-
62
GNOME, KDE
2008
Unix/Linux 1.18
tar .
,
(mount) , tar czvf /dev/fd0 mydir.
tar xzvf /dev/fd0.
tar:
c, v, f archive name, x, t, z, gzip j, bzip2
8.15.
, email, .
75% .
. tar .
8.15.1.
Unix/Linux ,
.
gzip (), gunzip (): gz. gunzip compress.
bzip2 (), bunzip2 (): bz2. , gzip.
zip ( ): winzip, pkzip Windows. gzip bzip2
.
tar gzip.
, .tgz .tar.gz.
.tgz .tar.
8-4.
-
Unix/Linux 63
2008
Unix/Linux 1.18
/linux1/exersices/8-4. .
file compress v file
uncompress file, gzip v file gunzip file, bzip2 v file
bunzip2 file.bz2
.
/linux1/solutions/8-4.txt.
8.16. :
/linux1/lab8.16.
/usr/shar/dict/words .
. ls
. words
; words ;
words .
linux.words; , root,
linux.words;
ls inodes .
soft hard
words /linux1/lab8.16.
words.
ls stat, .
hard soft
data blocks
links
(UID/GID)
/linux1/solutions/8.16.txt
8.17. :
df, h H
.
h H;
-
64
GNOME, KDE
2008
Unix/Linux 1.18
/linux1/solutions/8.17.txt
8.18. : find
find.
Permission denied,
, : 2> /dev/null (
13. - ).
() /var/lib games.
() /var root
mail.
() ls l,
root, bin
student.
() ls l,
/usr/bin
100.000 .
() file /etc/mail.
() ls l,
/tmp
student.
() (),
120 .
() (), .
find , (
2> /dev/null, )
.
/linux1/solutions/8.18.txt
8.19. :
,
.
/linux1/lab8.19. find,
/home student,
-
Unix/Linux 65
2008
Unix/Linux 1.18
tar
/tmp. /etc /tmp.
ls .
gzip ,
.
, bzip2
.
/linux1/solutions/8.19.txt
-
66
GNOME, KDE
2008
Unix/Linux 1.18
9. GNOME, KDE
9.1.
X-Window GNOME KDE , gnome-terminal
evolution
9.2. X-Window
X-Window
, .
.
,
.
:
Window manager: , , menu .
Desktop environment: panels, window managers.
: .
9.3. (Window managers)
window manager X client. window manager
GNOME metacity, KDE kwm.
window manager : ,
, ,
, (toolbars) , ..
9.4. GNOME
GNOME System / Preferences.
o GNOME ,
.. , , screen saver, .
-
Unix/Linux 67
2008
Unix/Linux 1.18
CD/DVD,
, .
9.5. KDE
KDE Kmenu / Control
Center. ,
GNOME, ,
, , ..
9.6. panel
panel . To
panel GNOME KDE .
panel,
Properties ( GNOME) Configure panel ( KDE). ,
, ..
9.7. nautilus
nautilus
nautilus Edit/ Preferences.
,
(.. ), ..
9.8. gnome-terminal
gnome-terminal, Edit / Current
Profile. , Edit/Profiles/New.
gnome-terminal , ,
, ,
buffer .
9.9.
GNOME,
.
GNOME, gnome-terminal
. ,
, . log out Save
-
68
GNOME, KDE
2008
Unix/Linux 1.18
current setup. ,
logout.
9.10. email clients
, , email clients, evolution,
kmail, mozilla mail. , email
clients email servers, imap, pop smtp.
9.11. evolution
evolution
.
, PDA, .
.
.
9.12. : GNOME
GNOME.
System Preferences.
() Look and Feel, Appearance, Background
.
() Look and Feel, Appearance, Fonts
, .
.
() Look and Feel, Appearance, Screen Saver screen saver
.
() Look and Feel, Appearance, Theme
.
() Hardware, Removable Drives and Media Storage,
CD .
() Hardware, Mouse
.
-
Unix/Linux 69
2008
Unix/Linux 1.18
9.13. : gnome-terminal
gnome-terminal (Applications --> System Tools --> Terminal).
Open Terminal.
.
gnome-terminal .
. Default.
Edit --> Edit current profile...,
(tabs). General. Use the
system fixed width font. font,
. , (bold)
12. OK. Colors. Use colors
from system theme. Built-in schemes White on Black. Close.
. Edit --> Profiles,New.
Small Create.
, Small.
(File --> Open Tab --> Small).
gnome-terminal. , Small (Terminal -->
Profile --> Small).
9.14. : evolution
evolution
. home directory
ls aF .
evolution, evolution
Applications, Internet, Email.
evolution, wizard .
Forward.
. ,
email student@localhost. , Server Type
Standard Unix mbox spool file Path
/var/spool/mail/student. Forward
-
70
GNOME, KDE
2008
Unix/Linux 1.18
evolution . , Server
Type Sendmail Forward. Apply.
(student@localhost)
Send/Receive. evolution.
evolution home directory .
ls aF. ; evolution ;
-
Unix/Linux 71
2008
Unix/Linux 1.18
10. bash
10.1.
10.2. () bash
, :
set shopt
, ,
. ,
, .
10.3.
,
.
.
, , .
. , shell script (,
) $HOME,
home directory . ,
home directory script.
: (local variables,
shell variables)
(environment variables)
.
-
72 bash
2008
Unix/Linux 1.18
,
.
set, env
echo. set , env
echo .
10.4.
( )
. .
shell scripts, .
, VARIABLE=VALUE. ,
.
. ,
("), ..WELCOME="Welcome to Fedora".
, echo, .. echo
$WELCOME.
:
$ .
, Shell variables
bash man.
10.4.1.
HISTFILESIZE: HISTFILE:
HISTSIZE:
COLUMNS: ( ) LINES: ( )
10.4.2. PS1
PS1 (prompt).
: PS1="\u@\h:\w\$".
-
Unix/Linux 73
2008
Unix/Linux 1.18
(escape sequences)
o prompt :
\d \h \t \u \w \! \$ ( #)
( $)
, (PS1=" \u@\h:\w\$ ") prompt :
adam@ekdd-srv-01:/tmp $
escape sequences PROMPTING
bash man.
10.5. (aliases)
.
,
.
alias c=clear alias dir='ls -FCa' alias rm="rm -i"
rm, alias (rm i),
\: \rm r Junk
, alias ,
, alias
: alias dir
10.6. set shopt
, set shopt. set
.
set shopt, SHELL
BUILT-IN COMMANDS bash man.
19.5. set bash
-
74 bash
2008
Unix/Linux 1.18
(.143) 19.6. shopt bash (.
144).
10.7. :
.
,
EDITOR,
.
export. bash
. EDITOR=/usr/bin/vim
export EDITOR
: export EDITOR=/usr/bin/vim
10.8.
o :
HOME, home directory LANG,
PWD, EDITOR, text editor LESS, less SHELL, login USER,
10.8.1. TERM
TERM .
, ..
, reset.
10.8.2. PATH
PATH .
, ,
-
Unix/Linux 75
2008
Unix/Linux 1.18
.
which
. , which less,
less. less
which,
, .. ./less.
bash,
19.4. bash, 141.
10.9.
.
:
, tab, , : , , |, &, ;, (, ),
{ } ~ (~, ~bob,
~/files)
. $, ${ }, $ (( )), $ [ ], $ ( )
(file globbing) , >, >>,
10.10.
shell startup scripts ( )
.
. , ,
(, ) (
) . shell startup
scripts, .
-
76 bash
2008
Unix/Linux 1.18
,
.
startup scripts home directory .
10.11. login
O login ,
.
login, .. bash
login (no-login shell). login no-login shells
(startup scripts).
10.12. :
login shells , , startup scripts:
/etc/profile /etc/profile.d ~/.bash_profile ~/.bashrc /etc/bashrc
script script.
PATH script /etc/profile , ,
~/.bash_profile.
no-login shells , , startup scripts:
~/.bashrc /etc/bashrc /etc/profile.d
, no-login shells script login
shells .
startup scripts :
, PS1 , PATH LESS
script
-
Unix/Linux 77
2008
Unix/Linux 1.18
umask ( umask 11)
10.13. /etc/profile
/etc/profile login shell. no-
login shells script . ,
login shell
Bourne ( sh bash).
script PATH, USER, LOGNAME, MAIL,
HOSTNAME, HISTSIZE INPUTRC.
/etc/profile scripts /etc/profile.d
10.14. /etc/profile.d
/etc/profile.d shell scripts. scripts
. script,
Bourne ( sh) C ( csh). scripts
, .. ls
.
10.15. ~/.bash_profile ~/.bashrc
~/.bash_profile ~/.bashrc .
, ,
shell. ~/.bash_profile login shells ,
~/.bashrc login no-login shells.
~/.bashrc script , ..
date. script ~/.bash_profile .
10.16. ~/.bash_logout
~/.bash_logout .
login shell, .
.
:
-
78 bash
2008
Unix/Linux 1.18
10.17. :
.
clear c.
.
, lr. lr,
ls .
() ls (long listing)
() To
() (indicator) ,
() ,
(modification time)
()
man ls.
, .
, .
~/.bashrc #User specific aliases and functions,
. .
.
/linux1/solutions/10.17.txt
10.18. : bash prompt
(prompt).
bash man ( PROMPTING).
, . () Fedora
->. >
.
()
(hostname) $.
()
.
-
Unix/Linux 79
2008
Unix/Linux 1.18
()
, .
()
:
() ~/.bashrc
. ,
.
H /linux1/solutions/10.18.txt
10.19. :
metacity.
metacity-message.
metacity-window-demo.
backquotes (` `),
(` `)
.
ls l nautilus.
H /linux1/solutions/10.19.txt
-
Unix/Linux 81
2008
Unix/Linux 1.18
11. ,
11.1.
,
11.2. &
, user ID (UID)
, group ID (GID). ,
(UID) (GID)
.
11.3. /etc/passwd, /etc/shadow & /etc/group
.
/etc/passwd
(username) (UID). /etc/group
(groupname) (GID).
/etc/shadow password
.
/etc/passwd : , , UID,GID
, , home directory, login shell.
/etc/group : , (group
password), GID,
,
:
11.4.
(root),
Unix/Linux,
. , ,
-
82 ,
2008
Unix/Linux 1.18
server (.. web server). UID
GID 500.
, , .
11.5. su
su .
, o root. ,
, login shell.
( root).
root .
11.6.
. :
whoami, groups, id group users, who, w, last,
11.7. umask
, umask, ,
(rw-rw-rw- 666) ,
, (rwxrwxrwx 777).
,
umask. H umask
. , umask 0002,
664 775.
,
umask.
. ,
, umask.
umask 0002, root 0022.
umask script. umask ,
~/.bashrc umask .
-
Unix/Linux 83
2008
Unix/Linux 1.18
11.8.
, ,
, (special
permissions). set user ID ( SUID), set group ID
( SGID) sticky bit. ,
:
SUID SGID sticky bit SGID
, chmod,
, .
, 4 SUID, 2 SGID 1 sticky bit.
chmod 3775 groupdir, SGID sticky bit
groupdir.
11.8.1.
SUID ,
. passwd.
passwd
/etc/shadow. , /etc/shadow, .
,
; /usr/bin/passwd ( passwd, )
SUID, passwd,
( , root).
/etc/shadow (, ,
passwd), .
ls l, SUID s
. SUID,
, S.
-
84 ,
2008
Unix/Linux 1.18
, SGID,
. SGID
. SGID,
same-gnome.
11.8.2.
sticky bit ,
root,
. To sticky bit, t,
.
, sticky bit, .
sticky bit, /tmp.
SGID ,
,
.
11.9. :
.
X-Window.
. login visitor.
whoami, groups, id, users, who, w.
. login student.
whoami, groups, id, users, who, w.
.
11.10. :
()
visitor. id pwd.
()
visitor. su student, id pwd.
()
visitor. su student (!,
), id pwd.
-
Unix/Linux 85
2008
Unix/Linux 1.18
.
;
11.11. : umask
/linux/lab11.11.
umask . umfile1
umdir1. umask 027. umfile2
umdir2.
,
.
/
umfile1
umdir1
umfile2
umdir2
, .
/linux1/solutions/11.11.txt
11.12. : umask
/linux/lab11.12.
umask. , ,
umask.
umask
002
022
007
027
077
-
86 ,
2008
Unix/Linux 1.18
umask
. ,
.
/linux/solutions/11.12.txt
-
Unix/Linux 87
2008
Unix/Linux 1.18
12. vi & vim
12.1.
,
..
12.2.
G, nG, n , , , ,
12.3.
H, M, L, z,
z-,
12.4. ex:
vi vim ,
sed ( sed, . 15.10 H sed, .
108). sed , ,
, vi vim
-
88 vi & vim
2008
Unix/Linux 1.18
. ,
:1,$s/Unix/Linux/g
, : ex mode, 1,$
, s/Unix/Linux
Unix Linux g
( sed).
Unix Linux (..
8 18), , :8,18s/Unix/Linux/g Unix Linux
, :.,.+10s/Unix/Linux/g Unix Linux
, , :s/Unix/Linux/g
12.5.
:r newfile, newfile
:r !commandname, commandname
:1,20w xfile, 1-20 xfile :.,$w yfile,
yfile
:1,20w >> zfile, 1-20 zfile
19.3. vi ,
vi (. 139).
-
Unix/Linux 89
2008
Unix/Linux 1.18
-
Unix/Linux 91
2008
Unix/Linux 1.18
13. -
13.1.
13.2. (standard input & output)
Unix/Linux ,
. , ,
,
. ,
.
, (standard output) .
,
. ,
.
(standard input) .
, , .
(standard error),
(warnings), (error messages)
.
, .
, stdin,
stdout stderr .
(file descriptors) 0, 1 2 .
-
92 -
2008
Unix/Linux 1.18
13.3. -
, ,
(pipe).
. ,
, . ,
, , .
:
> command > file
>> command >> file
()
< comman