UNIX

University of Seoul Computer Science Park Jong wook
E-mail: niceilm@gmail.com MSN: niceilm@hanmail.net

UNIX?
UNIX
± Bell ± ý ± C

UNIX
± ± ± I/O : q : Mail, News, WWW

UNIX

2

UNIX
(Multi-Tasking) (Multi-User) (Portability)

UNIX

3

UNIX Utilities
UNIX Utilities
spell dc, bc ed, vi, ex, emacs, pico roff, nroff, groff, troff mail, elm, pine, mutt man date, time, cal cc, gcc, g++, f77 lpr sed sh, csh, bash, tcsh, ksh, zsh uucp, wall, talk lex, yacc cd, chgrp, chown, cp, diff, find, ln, ls

UNIX

4

UNIX
UNIX
± ± ± ±

,

UNIX Version

AT&T, UNIX System V Interface Definition IEEE, POSIX (Portable Operating System Interface for UNIX) Unix International, Inc. Open Software Foundation

UNIX Version
± ± ± ± ± ± UNIX System V R 4.0 SCO UNIX SunOS, Solaris HP-UX Digital Unix AIX

UNIX

5

UNIX (1) Applications Shells Utilities X window Operating System Kernel Hardware UNIX 6 .

chown.UNIX Kernel ± UNIX ± ± ± UNIX . « : cc. as. « 7 . mkdir. « : chmod. rm. ý System Call Interface Shell ± Utilities ± ± ± ± UNIX : cp. « : ftp. ld. (2) . telnet.

UNIX Login ± ± ± : 8 (1) UNIX ( . ) UNIX 8 .

UNIX (2) ± ± ± Login 6 passwd UNIX 9 .

³Everybody knows what is my password´ EbKWImp UNIX 10 .8 ± . r 6 2 1 3 .UNIX (3) ± ± ± ‡ ‡ ‡ ‡  . .

UNIX Logout ± ± Logout ‡ exit ‡ <Ctrl+d> (4) UNIX 11 .

colsole: lp*: null: sd*: scsi tty*: ttyS*: . q ‡ ± ± ± ± ± ± q UNIX 12 .UNIX File System (1) ± UNIX ± ‡ ‡ ± . .

UNIX File System (2) inode (Information Node) ± ± ± ± ± ± ± ± q UNIX 13 .

etc. man. tmp UNIX 14 . src. lib.UNIX File System (3) UNIX / bin dev etc lib proc sbin usr var bin. include.

q UNIX ± /var : UNIX cron 15 .UNIX File System (4) UNIX ± /: ± /bin : Binaries ± /dev : ± /etc : ± /proc : UNIX ± /sbin : ± /usr : ‡ /usr/bin: /bin ‡ /usr/include: C ‡ /usr/man: man page .

q .UNIX File System (5) (Path) ± ‡ / /usr/local/bin/vim /usr/include/ ± ‡ ‡ q . UNIX 16 ..

cd ± Print Working Directory ± cd ± Change Directory ± ± UNIX 17 .File. Directory pwd .pwd.

´ ‡ -i : ‡ -x : ‡ -F : ‡ -R : ‡ -t : ‡ -r : I-node UNIX 18 .ls ± List contents of directory ± ± ‡ -l : File mode.File. last modified ‡ -a : ³. Username. Directory ls . Group name. bytes. Link count.

File. UNIX 19 .cat ± Concatenate and display files ± ± ‡ -s : ‡ -v : ‡ -t : TAB ‡ -e : ‡ -n : ^I $ . Directory cat .

File.pg File string prompt ý q ‡ +line_number : line_number UNIX 20 . Directory pg ± ± more ± ‡ -number : pg ‡ -p string : ‡ -c : ‡ -e : ‡ -s : .

Directory pr ± Print files ± ± ± ‡ +page : ‡ -column : ‡ -n : ‡ -d : ‡ -w width : ‡ -l length : 1 ‡ -h header : 1 page .pr column width length header UNIX 21 .File.

File. Directory grep .grep ± Global Regular Expression & Print ± q ± ‡ -c : ‡ -i : ‡ -l : ‡ -n : ‡ -v : q q q q UNIX 22 .

mkdir (Permission) umask UNIX 23 .File. Directory mkdir ± Make Directory ± ± ± ‡ -m mode : ‡ -p : .

Directory rmdir ± Remove Directory ± ± . ± ‡ -p : ‡ -s : -p .File.rmdir UNIX 24 .

Directory rm ± Remove ± ± ‡ -f : ‡ -r : ‡ -i : .rm UNIX 25 .File.

File. Directory cp ± Copy ± ± ‡ -i : ‡ -r : .cp overwrite UNIX 26 .

Directory mv ± Move ± ± ‡ -i : .File.mv overwrite UNIX 27 .

File. Directory ln ± Make Link to files ± ± Hard Link ‡ ‡ .ln Hard Link % ln file1 file2 ± Symbolic Link ‡ ‡ MS Windows % ln ±s file1 file2 UNIX 28 .

File Processing .df (1) Display number of free disk blocks and files ± ± ‡ -l : local file system ‡ -t : ‡ -k : i-node kilo bytes free i-node UNIX 29 .

df (2) UNIX 30 .File Processing Example .

UNIX 31 .File Processing Summarize disk usage ± ± ‡ -s : ‡ -a : ‡ -r : .du (1) .

File Processing Example .du (2) UNIX 32 .

find (1) N q ± ‡ -name file : ‡ -type c : file type c ± b : block special file ± c : character special file ± d : directory ± p : fifo (pipe) ± f : general file file q ‡ -links n : n link 33 UNIX .File Processing Find files ± .

find (2) uname gname n command UNIX 34 .File Processing ± ‡ -user uname : ‡ -group gname : ‡ -size n[c] : ‡ -atime n : ‡ -mtime n : ‡ -print : ‡ -exec command : n n .

File Processing Example .find (3) UNIX 35 .

file Example UNIX 36 .File Processing Determine file types ± .

UNIX 37 .wc (1) . .File Processing Display word count ± ± ‡ -l : ‡ -w : ‡ -c : .

File Processing Example .wc (2) UNIX 38 .

tail (1) Display first (last) few lines of files ± ± ‡ +number : ‡ -number : number number UNIX 39 .head.File Processing .

tail (2) UNIX 40 .head.File Processing Example .

paste (1) Merge corresponding or subsequent lines of files ± ± ‡ -d list : ‡ -s : UNIX 41 .File Processing .

paste (2) UNIX 42 .File Processing Example .

UNIX 43 .File Processing .diff (1) Display line-by-line differences between pairs of text files ± ± ‡ -b : ‡ -e : ed ‡ -f : -e ‡ -h : ‡ -w : white space .

File Processing Example .diff (2) UNIX 44 .

File Processing Compare two files ± ± ‡ -l : ‡ -s : 0: 1: 2: .cmp (1) UNIX 45 .

cmp (2) UNIX 46 .File Processing Example .

q q UNIX 47 .cut (1) Cut out selected fields of each line of a file ± ± ‡ list : ‡ -c list : list ‡ -f list : list ‡ -d char : ‡ -s : .File Processing .

File Processing Example .cut (2) UNIX 48 .

or sequence check text files ± ± ‡ -c : ‡ -m : ‡ -u : ‡ -f : ‡ -r : r UNIX 49 .sort (1) Sort.File Processing . merge.

sort (2) UNIX 50 .File Processing Example .

rwx rwx rwx UNIX 51 .Permission (1) ± Multi-User .

Permission (2)

±
‡ -: ‡ b: ‡ c: © ‡ d: ‡ l : Symbolic Link

±
‡ r (Read) : ‡ w (Write) : ‡ x (Execute) :

UNIX

52

Permission

- chmod (1)

Change the permissions mode of a file
± ± ±
‡ who : u ( ‡ op-code : + ( ‡ mode : r ( ), w ( ), g ( ), - ( ), x ( ) ), o ( ) ), a ( )

(Symbol Format),

(Absolute Format)

% chmod uo-w file1

UNIX

53

Permission
±
‡ 4: ‡ 2: ‡ 1: (Read) (Write) (Execute)

- chmod (2)

% chmod 755 file1

UNIX

54

Permission

- chown, chgrp

Change file (group) ownership
± ( )

Example

UNIX

55

Process

- ps (1)

Report process status
± ±
‡ -e : ‡ -a : ‡ -f : ‡ -l : ‡ -u uid : ‡ -g gid : uid gid full list long list

UNIX

56

Process ± ‡ F: ± 00 : ± 01 : ± 08 : ± 10 : .ps (2) (1) flag lock ‡ S: ± O: ± S: ± R: ± I : Idle ± Z : Zombie UNIX 57 .

ps (3) (2) UID : ID GID : ID PID : ID PPID : C: PRI : NICE : nice ADDR : SZ : WCHAN : sleep TTY : TIME : ID SXBRK UNIX 58 .Process ± ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ .

Process Example .ps (4) UNIX 59 .

Process .kill Terminate or Signal processes ± ± Signal 9 ( ) Example UNIX 60 .

nohup Run a command immune to hangups ± ± ± nohup.Process .out UNIX 61 .

UNIX 62 .Process .nice Invoke a command with an altered scheduling priority ± ± ± nice ± ± 0~39 incremental incremental 1~19 .

. UNIX 63 .time (1) Time a simple command ± ± ± : .Process .

Process Example .time (2) UNIX 64 .

wait Await process completion ± ± id .Process . 0 Example UNIX 65 .

Process .sleep Suspend execution for an interval ± ± Example UNIX 66 .

Shell (1) Shell ± ± q ± UNIX ± Shell ‡ sh. bash ‡ csh. tcsh ‡ ksh UNIX 67 .

Shell (2) Shell ± ± ± ± ± ± ± ± ± History ± Alias † UNIX 68 .

Environmental Variables (1) = f Example UNIX 69 .

Environmental Variables (2) UNIX 70 .

Environmental Variables (3) ksh VISUAL HISTSIZE HOME MAIL MAILCHECK MAILPATH PS1 PS2 SHELL TMOUT ( ) 2 ( ( : $ ) : > ) ( : 10 ) q ( : 128) UNIX 71 .

Parameter & Quotation (1) (Parameter) ( ± Parameter ± $ ) ( ± ) . UNIX 72 .

Parameter & Quotation (2) (` `) ± \ Escape ± \c ‡ c ± \<return> ‡ UNIX 73 .

Standard Input/Output & Redirection (1) Shell ± ‡ ‡ ( (Standard Input) (fd: 0) ) ± ‡ ‡ (Standard Output) (fd: 1) (CRT ) ± ‡ ‡ (Standard Error) (fd: 2) (CRT ) UNIX 74 .

Standard Input/Output & Redirection (2) < file ± file <<word ± word UNIX 75 .

Standard Input/Output & Redirection (3) > file ± file UNIX 76 .

Standard Input/Output & Redirection (4) >> file ± file > . >& file ± file UNIX 77 .

bash. tcsh ± HISTSIZE ± HISTFILE UNIX 78 .History (1) ksh.

History (2) UNIX 79 .

History (3) History ± ksh ‡ fc ± tcsh. bash ‡ ! history UNIX 80 .

Alias ± alias ± unalias ± ± ef UNIX 81 .

Job Control (1) ± Foreground job ‡ ‡ fg Background job Foreground job ± Background job ‡ ‡ bg Foreground job Suspended job Background job UNIX 82 .

Job Control (2) Example UNIX 83 .

Pipe & Filter Example UNIX 84 .

File Editing (1)
vi
± UNIX ± ex Display

vi
± ý ± ± ± q

UNIX

85

File Editing (2)

±
‡ vi ‡ ý , ,

±
‡ i, a, o ‡ ‡ ESC

UNIX

86

vi
vi
±

±

±

UNIX

87

vi
vi

ZZ :wq :w :w filename :w! filename :q :q! vi ZZ

vi

UNIX

88

(1)

± Ctrl-f
‡

± Ctrl-b
‡

± Ctrl-d
‡

± Ctrl-u
‡

± Ctrl-e
‡

± Ctrl-y
‡

UNIX

89

(2) ý ± <Enter> ‡ ± h ‡ ± j ‡ k h j l ± k ‡ ± l ‡ UNIX 90 .

(3) ± w ‡ ± b ‡ ± e ‡ ý q ± 0 ‡ ± ^ ‡ ± $ ‡ UNIX 91 .

(4)

± H
‡

± M
‡

± L
‡

± G
‡ (:$ (:35 ) )

± 35G
‡ 35

UNIX

92

± /pattern
‡ ý q pattern q

± ?pattern
‡ ý q pattern q

± n
‡

± N
‡

UNIX

93

± i (insert)
‡ ý q

± a (append)
‡ ý

± o (open)
‡ ý

± O
‡ ý q

UNIX

94

q
± r
‡ q q ý q q

± R
‡

± cw
‡

q
± cc
‡

± C
‡ ý ý q q q

± s
‡

UNIX

95

± x
‡ ý q q q ý ý ý q q q

± X
‡ ý

± dd
‡ ý

± D
‡

± dw
‡

± db
‡

UNIX

96

± yw ‡ ý ý ý ý ý q q q n ± yy ‡ ± nY ‡ ± p ‡ ± P ‡ UNIX 97 .

‡ UNIX 98 . ± u ‡   ± U ‡ ± .

a+<Enter> ‡ ý q UNIX 99 .± J ‡ ± i.

± :r filename ‡ ý ± :-r filename ‡ ý ± :1.8w filename ‡ 1 8 UNIX 100 .

CHANGE MODE UNIX 101 .vi vi ± :set ± :set all . ± :set tabstop=4 ‡ 4 ± :set number ‡ ‡ :set nonumber ± :set showmode ‡ INSERT. . REPLACE.

vi clones vi clones ± nvi ± elvis ± vim ± vile UNIX 102 .

vi ± vitest1 (1) vi % vi vitest1 ± Ctrl-f ± 1G ( :1) ý ± M 0 ý UNIX 103 .

vi ± (2) i iceize ± 10 10G ( :10) ý ± 2cw iceize ± 9 9G ( :9) ý UNIX 104 .

vi ± (3) sample program A sample program append ± 9 9G ( :9) /sample dw sample ± 8 8G ( dd :8) UNIX 105 .

vi ± 7 (4) coffee break 7G ( :7) cc coffee break ± 7 7G ( o test vi :7) test vi ± 7 7G ( 4yy 13G ( p UNIX 10 :7) :13) 13 106 .

vi ± 1 1G ( 5dd (5) 5 :1) ± 6 6G ( 5dd G( p 10 :6) :$) ± /iceize UNIX 107 .

vi ± 1 (6) 20 :1.20s/test/sample/g test sample ± 1 1G ( J :1) ± 1 10 :1.10w vitest2 vitest2 ± vitest2 :e vitest2 UNIX 108 .

vi ± (7) :set number ( :se nu) ± vitest1 :e vitest1 ± :f q ± 10 10G ( 3dd 12 :10) UNIX 109 .

vi ± u (8)  ± ý 0 ± ý $ ± ZZ ( :wq) vi UNIX 110 .

export Determine the characteristics for environmental variables ± ± Example UNIX 111 .Shell .

readonly Protect the value of the given variable from reassignment ± Example UNIX 112 .Shell .

Shell . PS2. PS1. MAILCHECK.unset Determine the characteristics for environmental variables ± ± (PATH. IFS) unset Example UNIX 113 .

Shell .set Determine the characteristics for environmental variables ± ± ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ allexport : bgnice : errexit : ignoreoof : markdirs : noclobber : noexec : nounset : trackall : export exit exit / q alias table  UNIX 114 .

Shell .eval Execute other commands ± q Example UNIX 115 .

exec Execute other commands ± ± exec Example UNIX 116 .Shell .

trap (1) Respond to hardware signals ± ± Signals trap Signals 1 2 3 8 11 15 HUP INT QUIT FPE SEGV TERM Hangup Interrupt Quit Floating Point Exception Segmentation Violation Software Kill Signals UNIX 117 .Shell .

Shell Example .trap (2) UNIX 118 .

echo (1) Echo arguments ± ± Escape Escape Escape \a \b \n \t \\ \nnn Bell (alert) Backspace Newline Tab Back-slash ASCII nnn UNIX 119 .Shell .

Shell Example .echo (2) UNIX 120 .

print (1) Output characters to the screen or window ± ± ‡ -: ‡ -n : ‡ -r : echo ‡ -R : -n ‡ -s : ‡ -un : ‡ -p : |& (History) n args ( : 1) Escape Sequence (\) UNIX 121 .Shell .

print (2) UNIX 122 .Shell Example .

Shell .read (1) Read a line from standard input ± ± ± ± ?prompt ± ± ‡ -r : ‡ -s : ‡ -un : (History file) n ( : 0) \ vars prompt REPLY UNIX 123 .

read (2) UNIX 124 .Shell Example .

ulimit (1) Set limitations on the system resources available ± ± ‡ ‡ ‡ ‡ -a : -c : -d : -f : (Core Dump) n blocks n Kbytes (Child) n blocks ‡ -m : n Kbytes ‡ -s : ‡ -t : n Kbytes n seconds UNIX 125 .Shell .

ulimit (2) UNIX 126 .Shell Example .

umask Get or set the file mode creation mask ± ± ± Permission mode : 777(rwxrwxrwx) : 666(rw-rw-rw-) Example UNIX 127 .Shell .

Shell . filename ± ± µ.¶. µ:¶ filename : ± null Example UNIX 128 .

Shell .let Evaluate one or more arithmetic expressions ± ± ± : . . Example UNIX 129 .

« ${nn} UNIX 130 .Shell Parameters (1) ± ± e _ = f q ± ± ± $9 $0 $1. $2.

$3. $2. « q ($@ ) ± $0 ‡ ± $$ ‡ ± $! ‡ Background ± $‡ UNIX 131 .Shell Parameters (2) ± $# ‡ ± $* ‡ $1.

null UNIX 132 . ${parameter} ± q ${parameter:-value} ± Parameter value q null q .Shell Parameter (1) $parameter.

Shell Parameter ${parameter:=value} ± Parameter q null (2) q parameter . null value UNIX 133 .

null value UNIX 134 .Shell Parameter ${parameter:?value} ± Parameter null (3) q .

Shell Parameter ${parameter:+value} ± Parameter q null (4) value q null UNIX 135 .

${#array[@]} ± q UNIX 136 .Shell Parameter ${#parameter} ± q (5) ${#array[*]}.

Shell Parameter ${parameter#pattern} ± q (6) pattern ${parameter##pattern} ± pattern UNIX 137 .

Shell Parameter ${parameter%pattern} ± pattern (7) ${parameter%%pattern} ± pattern UNIX 138 .

File Input/Output ± exec ± I/O ± 0~9 Example UNIX 139 .

Comment. Return value Comment ± #  Return value ± 0~255 ± $? 0 1 129~160 UNIX 140 .

Parallel Process ± ± ± ± e|&´ UNIX 141 .

script_filename ± (1) q UNIX 142 .Shell Script .

Shell Script (2) ksh script_filename ± ± script_filename UNIX 143 .

Shell Script (3) chmod a+x script_filename ± script_filename UNIX 144 .

(1) ± -r file ‡ ± -w file ‡ ± -x file ‡ ± -f file ‡ ± -d file ‡ ± -s file ‡ 0 ± -L file ‡ Symbolic Link UNIX 145 .

(2) ± string ‡ string null null null string2 string2 ± -n string ‡ string ± -z string ‡ string ‡ string1 ‡ string1 ± string1 = string2 ± string1 != string2 UNIX 146 .

(3) ± int1 -eq int2 ‡ int1 ‡ int1 ‡ int1 ‡ int1 ‡ int1 ‡ int1 int2 int2 int2 int2 int2 int2 ± int1 -ge int2 ± int1 -gt int2 ± int1 -le int2 ± int1 -lt int2 ± int1 -ne int2 UNIX 147 .

(4) ± !expr ‡ expr ‡ expr1 ‡ expr1 FALSE TRUE TRUE expr2 expr2 TRUE (AND TRUE (OR ) ) ± expr1 ±a expr2 ± expr1 ±o expr2 UNIX 148 .

!= : . % : . & : AND ^ : Exclusive OR | : OR && : Logical AND || : Logical OR = : Assignment Shift UNIX 149 . . >. +. <<.(unary minus) ~ : NOT !: *. <=.(1) ± ksh ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ -: .: . >= : ==. . /. <. >> : Shift.

(2) let UNIX 150 .

(3) (( expression )) ± let ³expression´ expr ± UNIX 151 .

(4) Integer variable ± ± UNIX 152 .

Array (1) 1 (0~511 ) (1) ± ${ } UNIX 153 .

Array (2) (2) ± 0 ± ± ( + 1) UNIX 154 .

Array (3) ± UNIX 155 .

Function Definition ± ± typeset export UNIX 156 .

(1) -u Uppercase : -l Lowercase : -i or -ibase : (base ) UNIX 157 .

(2) -L or -Lwidth : width 0 width -LZ or -LZwidth : 0 UNIX 158 .

(3) -R or -Rwidth : width 0 width -Z or -Zwidth. -RZ or -RZwidth : -Z width 0 0 width UNIX 159 .

(4) -r : -x : export UNIX 160 .

] ± ± c-¶ ± c!¶ ± Example ‡ [123] : ‡ [12][01] : ‡ [!2-4] : ‡ [1-3] : ‡ [A-Za-z] : 2.Pattern (1) [.. 2 . 2. 3 1. 1 q † UNIX 161 . 3. 4 1. 0.. 2. 3 1.

chap2. chapa.Pattern (2) ? ± q ‡ chap? : chap1. chapU. « * ± ‡ x*y : x 0 ‡ chap* : chap y q UNIX 162 .

para q q +(pattern[|pattern] . para31.) ± 1 pattern ‡ para+([0-9]) : para q q UNIX 163 .) ± 0 pattern q q ‡ para?([345]|99)1 : para1. para991 *(pattern[|pattern] . . . .) ± 0 pattern ‡ para*([0-9]) : para.Pattern (3) ?(pattern[|pattern] . para41. . . . para51.

paragraph !(pattern[|pattern] .) ± pattern q q ‡ para@(chute|graph) : parachute. .[0-9]) : para . .. q q UNIX 164 . . .) ± pattern ‡ para!(*.Pattern (4) @(pattern[|pattern] .

. . . then . .Conditional Clause (1) if . . fi (1) if test ±f $1 then echo $1 exist fi UNIX 165 . . else .

then .Conditional Clause (2) if . else . fi (2) if test ±f $1 then echo $1 exist else echo $1 does not exist fi UNIX 166 . . . . . . .

. . else . . . then . . .Conditional Clause (3) if . fi (3) if (( score < 65 )) then grade=F elif (( score < 80 )) then grade=C elif (( score < 90 )) then grade=B else grade=A fi UNIX 167 .

Conditional Clause (4) if . . . fi (Example) if print µPlease enter your name: \c¶ read ±r name then if mail ³$name´ < mailfile then : else print ³Cannot mail to $name´ fi Else print µend-of file¶ exit 1 fi UNIX 168 . . else . then . . . .

. ) compound-list .Conditional Clause (5) case case word in [(] pattern [ | pattern . ] . . ] esac ± word q pattern compound-list UNIX 169 . . . .

esac UNIX 170 . ³´) print ±r ±u2 ± ³x must have a value´.Conditional Clause (6) case (Example) case $x in -d*) dflag=1.. *) if test ! ±r ³$x´ then print ±r ± ³$x: no read permission´ fi... -e*) eflag=1..

Loop Clause (1) for for identifier [ in word . ] do compound-list done ± word do done UNIX 171 . . .

Loop Clause (2) for (Example) for i in apple banana mango do echo ³$i\t´ done UNIX 172 .

. .Loop Clause (3) select select identifier [ in word . ] do compound-list done ± ± word PS3 UNIX 173 .

. *) print ³Invalid number´. esac done UNIX 174 .. exit) print ³Selecting exit job´ exit...Loop Clause (4) select (Example) PS3=³Please enter a number: ³ select i in add delete exit do case $i in add) print ³Selecting editing file´ break. delete) print ³Selecting removing job´ break.

Loop Clause (5) while while test-clause or command-execution do compound-list done ± test UNIX 175 .

Loop Clause (6) while (Example) while [ $line ±le $maxline ] do echo >> $BUFFER lines=`expr $lines + 1` done UNIX 176 .

Loop Clause (7) until until test-clause or command-execution do compound-list done ± test UNIX 177 .

Loop Clause (6) until (Example) until who | grep klog > /dev/null do echo Waiting 5 seconds sleep 5 done echo klog has logged on UNIX 178 .

while.Flow Control (1) break [n] ± n for. until for i in * do for j in foo bar bam do if test ³$j´ = ³$i´ then break 2 fi done done UNIX 179 .

Flow Control (2) continue [n] ± continue for i in * do if test ±d ³$i´ then continue fi print ±r ± ³$I is not a directory´ done UNIX 180 .

root daemon Level 1 ± ± ± root mount UNIX 181 . mount .System Run-Level (1) RunLevel 0 ± Level s ± ± ± umount .

NFS (Network File System) Level 4 ± ± UNIX 182 . daemon Level 3 ± Level2 ± .System Run-Level (2) RunLevel 2 ± ± mount .

System Run-Level (3) RunLevel 5 ± ± Console X-window Level 6 ± UNIX 183 .

Making a ufs File System Construct a file system ± mkfs root lost+found # mkfs ±F ufs [-o bsize=n. fragsize=n. free=n] special-device size ‡ bsize : ‡ fragsize : ‡ free : ‡ special-device : ‡ size : free ( : 10%) Character UNIX 184 .

Mount a File System Mount file systems and remote resources ± # /sbin/mount [-F FSType] [-v] [-r] [-o arguments] device dirname ‡ -F FSType : ‡ -v : ‡ -r : ‡ device : ‡ dirname : read-only q Block ‡ -o arguments : ro. nosuid. remount UNIX 185 .

Umount a File System Unmount file systems and remote resources ± # /sbin/umount [-v] [special | dirname] ‡ -v : ‡ special dirname : Block UNIX 186 .

Using vfstab Table of file system defaults ± ± vfstab ‡ special : Block ‡ fsckdev : special ‡ mountp : ‡ fstype : ‡ fsckpass : ‡ automnt : ‡ mntopts : Character UNIX 187 .

File System Check & Repair (1) ± df UNIX 188 .

File System Check & Repair (2) ± ý ‡ /var/adm/wtmp : History of system logins ‡ /var/adm/sulog : History of su command ‡ /var/cron/log : History of actions of /usr/sbin/cron ± ± ± core ± UNIX 189 .

free list UNIX 190 . # fsck [-F s5] [generic_options] [-y] [-n] [-p] [-sX] [-SX] [-t file] [-l] [-q] [-D] [-f] ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ -y : -n : -p : -sX : free list -SX : -t file : -l : inode -D : yes no .File System Check & Repair (3) ± Fsck ± /etc/vfstab fsckpass 1 .

File System Check & Repair (4) ± ‡ Phase 1 : Checking Blocks and Size ± i-node list ‡ Phase 2 : Check Pathname ± 1 i-node ‡ Phase 3 : Check Connectivity ± 2 ‡ Phase 4 : Check Reference Counts ± 2 3  ‡ Phase 5 : Check Free list ± Free-block UNIX 191 .

Group & User Administration (1) ± Group name ‡ ± Group ID (gid) ‡ UNIX 192 .

ID ( 65535) ± User ID (uid) ‡ ‡ 100 ± Primary Group ‡ ± Supplementary Group ‡ UNIX 193 .Group & User Administration (2) ± Comments ‡ ‡ login ± Login ‡ ‡ 1~8 .

Group & User Administration (3) ± Home Directory ‡ ‡ HOME cd ± Shell ‡ ‡ ‡ ‡ /sbin/sh y . /bin/csh ± Login Inactivity 0 ± Login Expiration Date ‡ mm/dd/yy UNIX 194 .

/etc/shadow ± /etc/shadow ‡ Crypted UNIX 195 .Files for Managing Users ± /etc/group ‡ (gid) ± /etc/passwd ‡ ‡ .

daemon sys::3:orot.daemon lp::8:root.sys.bin.bin.adm.adm adm::4:root.lp ± ± ± ± Group name : 13 Encrypted Password : Group ID : User list : UNIX 196 ./etc/group root::0:root other::1: bin::2:root.

/etc/passwd root:x:0:1:0000-Admin(0000):/: daemon:x:1:1:0000-Admin(0000):/: adm:x:4:4:0000-Admin(0000):/var/adm: lp:x:7:8:0000-LP(0000):/home/lp:/sbin/sh listen:x:37:4:Network Admin:/usr/net/nls: sysadm:x:0:0:administration:/usr/admin:/usr/sbin/sysadm ± ± ± ± ± ± ± User Login name : 1~8 Password : µx¶ User ID : Group ID : Comments : Home Directory : Command (Shell) : /etc/shadow q UNIX 197 .

c:7571:0:168:7::: daemon:NONE:7571:::::: listen:np:7571:::::: sysadm:dohsd/YFGSKOW:7602:0:168:7::: ± ± ± ± ± ± ± ± ± User Login name : /etc/passwd Encrypted Password : Last Changed : 1970 1 1 Minimum : Maximum : Warn : Inactive : Login Expire : Login Not Used : Login UNIX 198 ./etc/shadow root:NWWH/IZLPwa.

.groupadd Add (create) a new group definition on the system ± # groupadd newgrp ± Group ID (gid) newgrp # groupadd ±g 100 newgrp ± Group ID (gid) 100 newgrp UNIX 199 .

groupdel Modify or Delete a group definition on (from) the system ± # groupmod ±n testg testc ± testg testc # groupdel newgrp ± newgrp UNIX 200 ..groupmod.

.useradd (1) Administer a new user login on the system ± ± ‡ -b base_dir : ‡ -c comment : comment line ‡ -d dir : ‡ -e expire : login ‡ -f inactive : ‡ -g group : ‡ -m : group ( : /etc/skel) ‡ -k skel_dir : skeleton login full path UNIX 201 .

.useradd (2) Example # useradd -m guest ± guest . (/home/guest) # useradd ±d /usr1/abc guest # useradd ±m ±d /usr1/abc guest UNIX 202 .

userdel.. usermod Delete or modify a user s login from (on) the system ± # userdel login_name ± login_name # userdel -r login_name ± login_name # usermod -f n login_name ± n inactive # usermod -f 0 login_name ± inactive UNIX 203 .

Password (1) Change login password and password attributes ± ± ‡ -f login_name : ‡ -x 84 ±n 7 login_name : ‡ -x 7 ±n 10 login_name : ‡ -x ±1 login_name : max ‡ -w 14 login_name : ‡ -l login_name : 14 lock aging lock aging ( 7 . 84 ) UNIX 204 .

Password Example (2) # passwd -f 7 login_name ± 7 # passwd -w 10 login_name ± expiration 10 # passwd -x 10 login_name ± 10 # passwd -l login_name ± ± /etc/shadow *LK* UNIX 205 .

User & Group List user and system login information ± ± ‡ -l login1 login2 : ‡ -g group_list : ‡ -d : ‡ -p : ‡ -x : login ID ‡ -m : supplemental UNIX 206 .

TERMCAP ± ± /etc/motd ± del.Customizing (1) System profile (/etc/profile) ± LOGNAME. PATH. TERM. eYou have mail´ UNIX 207 . echo ± ± umask . kill.

Customizing (2) User profile ± $HOME/profile ± UNIX 208 .

Network? ± ± q ± ± UNIX TCP/IP.« ± ± OSI 7 Layers UNIX 209 . FTP . TELNET.

OSI 7 Layers Application Layer Presentation Layer Session Layer Transport Layer Network Layer Datalink Layer Physical Layer . . N UNIX 210 . .

Network Connection Media (1)

Ethernet (CSMA/CD) IEEE 802.3 Token Bus Token Ring Frame Relay X.25 FDDI IEEE 802.4 IEEE 802.5 ANSI T1.6170SI ITU-T Series ANSI X.3T9

UNIX

211

Network Connection Media (2)
Ethernet
± Xerox 1970 ± 500 ± 10Mbps broadcast BUS ± MAC : CSMA/CD LAN

CSMA/CD (802.3)
± Carrier Sense
‡ Listen Access

± Multiple Access
‡

± Collision Detection
‡

UNIX

212

Network Connection Media (3)
Token Passing Bus (802.4)
± ± ± ± Data Point

ARCNET

Token Passing Ring (802.5)
± ± ± IBM

Ring-LAN

UNIX

213

Network Connection Media (4)
Transceiver
± Ethernet Cable
‡ Single Port : ‡ Multi Port : 4 8

N

q

Repeater
± Cable ± 500
‡ Bit Repeater : ‡ Buffer Repeater : Ethernet

UNIX

214

Network Connection Media (5)
Bridge
±
‡ Source : LAN Ethernet, FDDI FDDI

‡ Transparent : Ethernet ‡ Encapsulation : ‡ Converting :

UNIX

215

Network Connection Media (6) Router ± Bridge ± . N N ‡ Multi Protocol : ‡ Multimedia : ‡ BROUTER : Router Bridge Gateway ± OSI ± IBM N N SNA (System Network Architecture) Gateway UNIX 216 .

TCP/IP OSI 7 N TCP/IP TELNET FTP SNMP SMTP TCP UDP IP ICMP ARP RARP Ethernet FDDI X.25 ISDN Application Layer Presentation Layer Session Layer Transport Layer Network Layer Datalink Layer Physical Layer UNIX 217 .

Data Transmission using TCP/IP TCP Header Application Layer TCP Header IP Header Transport Layer TCP Header IP Header Ethernet Header Network Layer TCP Header IP Header Ethernet Header DataLink Layer UNIX 218 .

Network Layer Network Layer ± ± ± ‡ IP : Internet Protocol ‡ ICMP : Internet Control Message Protocol ‡ ARP : Address Resolution Protocol ‡ RARP : Reverse Address Resolution Protocol N UNIX 219 .

IP (1) Internet Protocol ± IP ± 32 ± 4 ± 2 UNIX 220 .

0.0 16. 0.777.0.214 UNIX 221 .0 127.0.IP (2) Class A 0 ± ± ± ± ± ± 7 bits 0 3 8 bits 8 bits 8 bits : 0 ~ 127 .0.

128.IP (3) Class B 1 0 ± ± ± ± ± ± 6 bits 8 bits 10 8 bits 8 bits .0 : 128.0 ~ 191.534 UNIX 222 .255 65.255 128.

255.0 ~ 223.255 223.0 254 : 192. 192.0 UNIX 223 .255.0.255.IP (4) Class C 1 1 0 5 bits ± ± ± ± ± ± 8 bits 110 8 bits 8 bits .0.0.

255.IP (5) Class D 1 1 1 0 ± ± ± ± IP 1110 28 bits : 224.255.255 (Multicast ) UNIX 224 .0.0.0 ~ 239.

0.255.255.IP (6) Subnet Mask ± IP Class Class A Class B Class C Subnet Mask 255.0.0.0 255.0 255.255.0 UNIX 225 .

255 : 0 : 255 UNIX 226 .2. 157.255.IP (7) Broadcast ± Network ± Broadcast ± ± © .2.0.0 157.

IP TTL (Time To Live) 0 Echo Request UNIX 227 .ICMP Internet Control Message Protocol ± ± IP ± N q IP ICMP Message Destination Unreachable IP Time Exceeded .

ARP Address Resolution Protocol ± Network Layer : IP ± Datalink Layer : MAC ± MAC ‡ ‡ 3 3  ± IP MAC UNIX 228 .

RARP Reverse Address Resolution Protocol ± ARP ± MAC ± BOOTP IP UNIX 229 .

TCP Transmission Control Protocol ± ± ± ± q N UNIX 230 .

(1) ) .TCP ( ± ± . ± ± ACK SEND 1 ACK 1 SEND 2 ACK 2 UNIX 231 . . .

TCP (2) ± ± : ACK ACK ± ± : UNIX 232 .

UDP User Datagram Protocol ± ± ± N UNIX 233 .

. 21 23 53 80 . TCP MUX RJE TCP FTP TELNET NAMESERVER HTTP UNIX 234 ..Port Number (1) TCP Port Number 0 1 5 ...

42 53 69 161 .. ECHO DISCARD NAME NAMESERVER TFTP SNMP SNMP UNIX 235 .Port Number (2) UDP Port Number 0 7 9 ....

UNIX 236 .Services using TCP/IP N ± TELNET ‡ ± FTP ‡ File Transfer Protocol. ± SMTP ‡ Simple Mail Transfer Protocol. ± NNTP ‡ ± SNMP ‡ Simple Network Management Protocol.

« TCP/IP ± named ‡ Domain name system ‡ /etc/hosts ± routed. ftp. gated ‡ ± timed ‡ ± rwhod ‡ UNIX 237 . telnet. rlogin.conf . rcp.TCP/IP Network Service Daemon UNIX ± inetd ‡ TCP/IP ‡ /etc/inetd.

rlogin login login Example UNIX 238 .Network Remote login ± ± ‡ -l username : .

Network .telnet User interface to a remote system using the TELNET protocol ± ± ^] (Ctrl-^) telnet Example UNIX 239 .

ftp (1) File transfer program ± Example UNIX 240 .Network .

Network ± ftp ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ .ftp (2) open host : ftp close : ! [command] : local machine ls [remote-directory] : remote machine cd remote-directory : remote machine bye : get remote-file [local-file] : remote file local machine mget remote-files : remote-files local machine put local-file [remote-file] : local-file remote machine mput local-files : local-files remote machine prompt : hash : ascii : binary : 241 UNIX .

rhosts ± scp (rcp using Secure Shell) UNIX 242 .equiv $HOME local machine .Network Remote file copy ± ± Remote machine ± Remote machine .rcp /etc/hosts.

Network Remote shell ± ± Remote machine .rsh local ± ssh (Secure Shell) UNIX 243 .

rusers Who is logged in on remote machines ± Example UNIX 244 .Network .

. Example UNIX 245 .Network -w Display information about currently logged-in users ± .

finger (1) Display information about local and remote users ± ± ‡ ‡ ‡ ‡ ‡ ‡ Login Shell Login mail idle time UNIX 246 .Network .

finger (2) Example UNIX 247 .Network ± ‡ -m : ‡ -l : ‡ -s : .

Network .ping Send ICMP ECHO_REQUEST packets to network hosts ± N Example UNIX 248 .

Network .traceroute Print the route packets take to network host ± Example UNIX 249 .

Network .netstat (1) Show network status ± ± ‡ -i : ‡ -r : local routing table ‡ -rs : UNIX 250 .

IP IP UNIX 251 .Network Example (1) .netstat (2) ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ ‡ Name : Mtu : Net/Dest : Address : Ipkts : Ierrs : Opkts : Oerrs : Collis : .

netstat (3) ‡ ‡ ‡ ‡ ‡ Destination : Gateway : Flags : U ( Refs : Use : ).Network Example (2) . H ( ) UNIX 252 . G ( ).

ifconfig Configure network interface parameters ± Example UNIX 253 .Network .

Network .route Manually manipulate the routing tables ± ± ‡ add : ‡ delete : ‡ -f : ‡ destination : ‡ gateway : ‡ metric : Hop IP IP . UNIX 254 .

Network .arp Address resolution display and control ± ARP ± ‡ hostname : ‡ -a : ‡ -s : ‡ -f filename : filename ARP ARP hostname ARP ARP ‡ -d hostname : ARP UNIX 255 .

Domain Name System Root Domain root Top Level edu com org net kr uk jp ca Second Level ac re go co or nm Third Level company Hosts and Subdomain host1 host2 UNIX 256 .

BIND Berkely Internet Name Domain System ± Caching only ‡ ‡ /etc/resolv.conf IP ± Primary ‡ IP ± Secondary ‡ ‡ Primary Primary UNIX 257 .

NFS Network file system ± NFS ‡ /etc/vfstab : NFS ‡ /etc/exports : NFS ± NFS Daemon ‡ nfsd : ‡ rpc.mountd : ‡ rpc.lockd : ‡ rpc.statd : lock ‡ portmap : exports UNIX 258 .

400 Delivery Agent Local Area Network SMTP Delivery Agent Telephone Line UUCP Local Mail Boxes Local Mailer 259 .400 Network X.400 Network Open Mail Delivery Agent X.SMTP Simple Mail Transfer Protocol (sendmail) ± User Agents ‡ ‡ ‡ ‡ ‡ mailx mail elm pine mutt ± Delivery Agents ‡ ‡ ‡ ‡ ‡ UNIX OpenMail X.

Sendmail Server Mode hosts1 $ mail user01$host2 LAN WAN hosts2 $ mail mail mail sendmail Network Mailbox Mail queue /var/spool/mqueue/* sendmail UNIX 260 .

Sendmail Client Mode (Remote Mode) hosts1 Mail Server LAN WAN Mail Server hosts2 $ mail user01$host2 $ mail mail sendmail --------------------- mail sendmail Mailbox /var/mail/* Mail queue /var/spool/mqueue/* sendmail UNIX 261 .

End UNIX 262 .

Sign up to vote on this title
UsefulNot useful