¡@

§@·~¨t²Î(¤@)

¡@

UNIX§@·~¨t²Î²¤¶¡B°ò¥»«ü¥O»PÀɮרt²Î

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¤¤µØ¥Á°ê¤K¤Q¤K¦~¤T¤ë¤G¤Q¥|¤é

°ê¥ß¤¤¿³¤j¾Ç¹q¤l­pºâ¾÷¤¤¤ß

§d½å©ú

woody@nchu.edu.tw

¡@

¡@

¡@

UNIX¨t²Î»P°ò¥»«ü¥O *

„c UNIX²¥v»P®a±Ú²¤¶(What is UNIX ? ) *

UNIX¯S©Ê(Why UNIX ?) *

UNIX°ò¥»¨Ï¥Î²¤¶(UNIX Basic ) *

UNIX Shell¤¶²Ð *

UNIXªº¤å¦r½s¿è¾¹ - vi -²¤¶ *

°ò¥»«ü¥O¨Ï¥Î²¤¶ *

±`¥Î¤§°ò¥»«ü¥O¡G *

¨ä¥L«ü¥O *

¿é¥X¡þ¤J»P¿ù»~°T®§­«¾É(Redirect) *

»PDOS«ü¥Oªº¤ñ¸û *

UNIXÀɮרt²Î *

„c Àɮרt²Î¬[ºc¡G *

UNIXÀɮ׺ØÃþ¡G *

UNIXÀɮשR¦W­ì«h¡G *

UNIX¯S®í¥Ø¿ý»P¸ô®|¦WºÙ¡G *

Àɮרt²Î¡G *

Àɮ׬ÛÃö°T®§¡G *

Àɮצs¨ú«OÅ@¡G *

ÀÉ®×Åv­­­×§ï¡G *

UNIXÀÉ®×layout *

UNIXµ{§Ç(process) *

¡@

UNIX¨t²Î»P°ò¥»«ü¥O

¡@

Purpose:¤F¸ÑUNIXµo®i­I´º¡BUNIX¯S©Ê¤Î¾Ç²ß¦p¦ó¶i¤J¡A¨Ã¨Ï¥Î³o­Ó¥D®_¤u§@¯¸¯Å¹q¸£§@·~Àô¹Òªñ¤G¤Q¦~ªº§@·~¨t²Î¡C

¡@

¡@

§@·~¨t²Î³Ì¥D­nªº¥\¯à¦b©óºÞ²z¡B¨ó½Õ¹q¸£µwÅé¸ê·½¹q¸£¡A¨Ï¨ä¥i¥H¥¿½TµL»~ªº§¹¦¨¨Ï¥ÎªÌ©Ò¤U¹Fªº¦UºØ«ü¥O«ü¥O¡A¦P®É½T«O¾ã­Ó¹q¸£¥i¥H¦b¤@­Óí©wªºª¬ªp¤U´£¨ÑªA°È¡C°ò¥»¤W§@·~²Î¥»¨­¬O¤@­Ó¬Û·í¯S®íªº¹q¸£µ{¦¡¡C

¡@



¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

UNIX Implementation

¨t²Î¨«¦V

UNIX Implementation

¨t²Î¨«¦V

SCO UNIX

System V/BSD

SunOS

BSD

Linux

BSD/System V

Solaris

System V/BSD

Digital UNIX

BSD/System V

HP-UX

System V/BSD

IRIX

System V/BSD

AIX

System V/BSD

¡@

¡@

¡@

¡@

¡@

¡@

¥i´£¨Ñ¤@¸s¨Ï¥ÎªÌ¦P®É¨Ï¥Î¡A¯à¦³®Ä±±¨î¨t²Î¸ê·½¹B§@¡A¨Ã´£¨Ñ¦w¥þ«OÅ@¡A³¡¨ü¥L¤H¹B§@¼vÅT¡C

¡@

¨t²Îdefaultªººô¸ô³q°T¨ó©w¡A§Y¬O¥Ø«eInternet©Ò±Ä¥ÎªºTCP/IP¡C¦UºØÂ×´Iªººô¸ôºÞ²z¤u¨ã«ü¥O»PÀ³¥Îµ{¦¡¡A½Ñ¦pºô¸ôÀɮתA°È(NFS)¡Bºô¸ô¦WºÙªA°È(NIS & DNS)¡BÀɮ׶ǰe(ftp)¡B¹q¤l¶l¥óªA°È(E-Mail)¡B»·ºÝñ¤J(Telnet)µ¥¡A§¡¬°¨t²Î¤º«Ø¡A³o¨Ï±oUNIX¦¨¬°·í¤µÁ¿¨D¸ê·½¦@¨É¡B¤À´²¦¡³B²z»P»·ºÝ¦s¨úªº¶}©ñ¦¡Àô¹Ò¤U¡A¨Ï¥Î³Ì¬°´¶¹Mªº§@·~¨t²Î¤§¤@¡C

¡@

UNIX¥»¨­©Ò´£¨Ñªº¨Ï¥ÎªÌ¬É­±¡A¥»¨­¬J¬O©R¥O¦C¡A¤]¬O¥\¯à±j¤jªº¸Ñͦ¡(¥æ½Í¦¡)ªºµ{¦¡»y¨¥¡A¥B¨ã¬yµ{±±¨î¡A¨Ï±o¾÷¾¹ªº¨Ï¥Î¤W¥i¥HÅܱo«D±`¦³®Ä²v¡C

¡@

¨t²Î´£¨Ñ¤W¦Ê­Ó¤½¥Îµ{¦¡¡A¨Ï¨Ï¥ÎªÌªº¤u§@±o¥H²¤Æ¡F¨Ò¦p±Æ§Ç¡B¸ê®Æ·j´M»P¤å®Ñ³B²zµ¥¡C

¡@

³z¹L¼Ð·ÇªºX-Windows¨ó©w¡A¨Ï¥ÎªÌ¥i©ó»·ºÝ¡A§Y¨Ï¨Ï¥Î¤£¦PªºµwÅ饭¥x¡A¤]¥i¥H§Y®É(Realtime)¦aÂ^¨ú¥»¦a¾÷¾¹À³¥Îµ{¦¡©ÒÅã¥Üªº¹Ï§Îµe­±¡C

¡@

¤ÁÂ_³nÅé»PµwÅ餧¶¡ªº¤£¥i¤ÀÂ÷Ãö«Y¡A¨Ï±oUNIX¥»¨­¥i¥H¦b¦UºØ¤£¦PªºµwÅ饭¥x¤W°õ¦æ¡C(From PC to Super Computer)

¡@

±N§@·~¨t²Î¼Ò²Õ¤Æ¥i¥H¨Ï§@·~¨t²Î®Ö¤ß(Kernel)Åܤp¡A¨Ï§@·~¨t²ÎÅܱo¤Q¤À¦³¼u©Ê¡A³o¬OUNIXªº³ÐÁ|¡FÁöµM¥Ø«e´X¥G¤w¬°©Ò¦³ªº§@·~¨t²Î©Ò±Ä¥Î¡C

¡@

¡@

¡@

¡@

¨Ï¥ÎUNIX¨t²Îªº²Ä¤@¥ó¨Æ±¡´N¬Oñ¤J¨t²Î¡AÂǥѨϥΪ̱b¸¹»P±K½XªºÀˬd¡A¨t²Î¥i¥H¨M©w¬O§_¤¹³\§A¨Ï¥Î¦U¶µ¹q¸£¤§¸ê·½¡Cñ¤J¦¨¥\«á¡A¨t²Î®Ú¾Ú§Aªº¨­¤À¡A½á¤©§A¤@©wªºÅv§Q¡A¨Ã¨M©w§A©Ò¯à°µªº¨Æ±¡¡A§Y¥i¥Îªº¸ê·½¼Æ¶q¡C¾E¤J¤è¦¡­p¦³:

    1. .¥Ñ²×ºÝ¾÷ñ¤J
    2. .¥Ñ¨t²Î¥D±±¯¸(Console)¶i¤J
    3. .¥Ñºô¸ô³s½u¶i¤J

¡@

¶i¤J¨t²Î§A¥²¶·¿é¤J¨Ï¥ÎªÌ¥N¸¹(User Name)¤Î¬Û¹ïÀ³¤§±K½X(Password)

¡C¶·ª`·Nªº¬O¡AUNIX¥»¨­¬°Case Sensitive¡A¤j¼g»P¤p¼g¦r¥À©Ò¥Nªí¤§·N¸q¤£¦P¡C¥H¤U¬O¤@­Ó¥Ñºô¸ôñ¤JUNIX¨t²Îªº¨Ò¤l¡G

¡@

¡@

c:\ncsa\>telnet woody.nchu.edu.tw

Linux 1.2.13 (woody.nchu.edu.tw) (ttyp0)

¡@

¡@ ¡@ ¡@
¡@ ¡@ ¡@

woody login:WOODY

Password:xxxxxx

Login incorrect

¡@

woody login:

woody login: woody

Password:xxxxxxx

Last login: Sat Jan 25 22:40:23 from 140.120.1.241

¡@

Welcome to

# # #### #### ##### # #

# # # # # # # # # #

# # # # # # # # #

# # # # # # # # # # #

## ## # # # # # # #

# # #### #### ##### #

Linux 1.2.13.

woody@woody: ~ 1 >

¡@

¡@

¡@

·í§A§¹¦¨©Ò¦³¤u§@¤§«á¡A§A¥²¶·­n°µªº¬Oñ¥X¨t²Î¡Cñ¥X¤§«á¡A¨t²Î·|±N§A©Ò¦û¥Îªº¨t²Î¸ê·½ÄÀ©ñ¡A¨Ñ¤U¤@­Ó¨Ï¥ÎªÌ¨Ï¥Î¡A¦P®É²×¤î©Ò¦³¸Ó²×¤îªºµ{¦¡(orµ{§Ç)¡Clogoutªº«ü¥O¬°¡¨exit¡¨©Îª½±µ«ö¤Uctrl + D¡C

¡@

UNIX´£¨Ñ§¹¾ãªº½u¤W«ü¥O»¡©ú¡A³z¹L³o­Ó¨D§U¨t²Î¡A¨Ï¥ÎªÌ¥i¥H«Üªº©úÁA«ü¥Oªº¨Ï¥Î¤èªk¤Î«ü¥O¬ÛÃöªº¦UºØ¿ï¶µ°Ñ¼Æ¡A°t¦X°Ñ¼Æ¨Ï¥Î¥i¥HÅý«ü¥Oªº¨Ï¥Î§ó¥[¦³®Ä²v¡C½u¤W¨D§U¨t²Î±Ò°Êªº«ü¥O¬°¡¨man¡¨¡C

¨Ï¥Î¡G

$>man command

¡@

Example¡G

woody@woody: ~ 3 >man pwd

Formatting page, please wait...

¡@

PWD(1L)

¡@

NAME

pwd - print name of current/working directory

¡@

SYNOPSIS

¡K¡K..

¡@

¡@

Shell¬OUNIX©Ò´£¨Ñ¡A¤¶©ó§@·~¨t²Î»P¨Ï¥ÎªÌ¤§¶¡ªº¤@­Ó©R¥O¬É­±¡C¨Ï¥ÎªÌ³z¹LShell»P§@·~¨t²Î·¾³q¡A¥H§¹¦¨¦U¶µ¤u§@¡CShell¨Ï±o§@·~¨t²Îªº´x±±Åܱo¸û¬°®e©ö¡C

¡@

UNIX Shell¥»¨­¬O¤@­Ó¥æ½Í¦¡ªº©R¥OÀô¹Ò¡A¤]¬O¤@­Ó¥\¯à±j¤jªº¸Ñͦ¡µ{¦¡»y¨¥(Interpreter)¡C¤@¯ë§Ú­Ì©Ò¿×ªºUNIX«ü¥O«üªº¬OShell«ü¥O¡C

¡@

UNIX ShellºØÃþ¤£¤U¤Q¼ÆºØ¡A¨ä¤¤³Ì±`¨Ï¥Îªº¦³¤TºØ¡A§YBorne Shell ( sh )¡BC Shell ( csh )©MKorn Shell ( csh )¡C«ü¥Oecho $SHELL§i¶D§A¥Ø«eShellªººØÃþ¡C

Borne Shell:

C Shell¬O¥H¨ä»yªk»PC»y¨¥¬Û·í±µªñ¦Ó±o¦W¡A¾A¦X§@¬°¥æ½Í¦¡©R¥Oªº¥Î³~¡C

Korn Shell¥i»¡¬OBorne ShellªºSuperset¡A¨ä¹ï©óBorne Shell¥æ½Í¦¡©R¥O¥Î³~ªº¥\¯à¯Ê¥¢¡A°µ¤F¬Û·íµ{«×ªº¸É±j¡C

¥t¥~±`¥ÎªºÁÙ¦³bash (Borne Again Shell)©Mtcsh¡C¨ä¤¤bash¬Oshªº§ï¨}¡Atcsh«h¬O¥Ñ­ì¨ÓªºC ShellÂX¥R¦Ó¨Ó¡C

¥H¤U©Ò¦³Shell©R¥O¤Î»¡©ú§¡¥Htcsh¬°¨Ò¡C

¡@

UNIX Shell ScriptÃþ¦üDOSªºbatch file¡A¤D¬O¤@²ÕShell (UNIX)«ü¥Oªº²Õ¦X¡C

¡@

DOS¨t²Î¶}¾÷«á¡A¨t²Î·|¦Û°Ê°õ¦æ®Ú¥Ø¿ý¤Uautoexec.batªº¤º®e¡C¦bUNIX¤U¨Ï¥ÎªÌñ¤J¨t²Î«á¡A¨t²Î¤]·|¦Û°Ê°õ¦æ¤@¨ÇShell Script¡A¥H³]©w¨Ï¥ÎªÌªºÀô¹Ò¡C³o¨Ç·|¦Û°Ê°õ¦æªºShell Script¥]¬A¨t²Î¹w³]¤§Shell Script¤Î¨Ï¥ÎªÌ­Ó¤H¦Û¦æ«Ø¥ß¤§Shell Script¡C«eªÌ¥Ñ¨t²ÎºÞ²zªÌ³]©w¡M«áªÌ«h¥i¥Ñ¨Ï¥ÎªÌ¨Ì¦Û¤v¤£¦P»Ý¨D§ó§ï¤§¡C¦Ó³o¨ÇScriptÀHShellºØÃþªº¿ï¾Ü¤£¦P¡A¦Ó¦³©Ò¤£¦P¡A¥H¤U¬O¤@­ÓSummary

¡@

¡@

ShellºØÃþ

¨t²Îªì©lScrip

¨Ï¥ÎªÌ¦Û©wScript

sh

/etc/profile

$HOMEµù/.profile

csh

/etc/csh.login

$HOME/.cshrc & $HOME/.login

ksh

/etc/profile

$HOME/.profile

tcsh

/etc/csh.login

$HOME/.tcshrc &$HOME/.login

or

$HOME/.tcshrc & $HOME/.login

µù¡G$HOME«üªº¬O¨Ï¥ÎªÌ©Ò¾Ö¦³¤§®a¥Ø¿ý¡A§Y¨ä¥»¨­¦b¶i¤J¨t²Î¤¤®É¤§©Ò¦b¥Ø¿ý¡C

¡@

¨Ï¥ÎªÌ¥i¨Ì¦Û¤vªº»Ý¨D¡A¤Î¶i¤J¨t²Î©Ò¨Ï¥Î¤§SHELLºØÃþ¡A¨Ã°Ñ¦Ò¤Wªí¡A ­×§ï¬ÛÃöÀÉ®×(shell script) ¡A¥H³]©w¥»¨­¶i¤J¨t²Î¤§ªì©lÀô¹Ò¡C¥H¤U¬O¤@¨Ç±`¨£ªºªì©lshell script³]©wªº¨Ò¤l(Under tcsh)¡G

¡@

#### ³]©w¤@¨Ç«ü¥O§O¦W####

alias ll ¡§ls -al¡¨ ## ³]©w§O¦Wll = ¡§ls ¡Val¡¨ ##

# ll

total 192

drwxr-x--x 2 root root 16384 Feb 2 14:22 .

drwxr-xr-x 19 root root 16384 Feb 16 1997 ..

-rw-r--r-- 1 root root 2541 Feb 16 17:25 .bash_history

-rw-r--r-- 1 root root 34 May 8 1993 .less

-rw-r--r-- 1 root root 114 May 8 1993 .lessrc

-rw-r--r-- 1 root root 1808 May 6 1996 lodlin16.txt

-rw-r--r-- 1 root root 95676 May 5 1996 lodlin16.zip

#

alias dir ¡§ls -l¡¨

alias del ¡§rm¡¨

¡@

####³]©w¨t²Î´£¥Ü²Å¸¹####

set prompt=¡¨woody:>¡¨ ## ³]©w¨t²Î´£¥Ü²Å¸¹¬° woody:> ##

The prompt will be(always):

# set prompt="woody>" ß ´£¥Ü²Å¸¹­ì¬° "#"

woody> ß ´£¥Ü²Å¸¹¤w§ï¬° "woody"

¡@

alias setprompt ¡¥set prompt=$HOSTNAME%~µù¡¨

setprompt

alias cd ¡¥chdir \!* && setprompt¡¦

±N¥H¤W¤T¦æ©ñ¤J.cshrc or .login¡A¨t²Î´£¥Ü²Å¸¹±N·|Åܬ°(epends on your current directory):

woody.nchu.edu.tw~:cd /var/spool

woody.nchu.edu.tw/var/spool:cd

woody.nchu.edu.tw~:cd /var/spool

woody.nchu.edu.tw/var/spool:cd /var/spool/mqueue

woody.nchu.edu.tw/var/spool/mqueue:

¡@

#### ³]©w«ü¥O·j´M¸ô®| ####

set path=¡¨$path /home/woody¡¨

¡@

µù¡G¦btcsh builtin¥H¤U¤§ÅܼơM¥i¨Ñ¨Ï¥ÎªÌ¹B¥Î

%~ ªí¥Ø«e©Ò¦b¥Ø¿ý¡M¨Ã¥H~ªí¥Ü®a¥Ø¿ý¡C

%/ ªí¥Ø«e©Ò¦b¥Ø¿ý©Ò¦b¤§¥þ¦W

%c or %.ªí¥Ø«e©Ò¦b¥Ø¿ý¤§³Ì«á¤@­Ó¤l¥Ø¿ý¦WºÙ

¡@

¨Ï¥ÎªÌ¦b¶i¤JUNIX¨t²Î«á¡A·|¦Û°Ê°õ¦æ.cshrc¤Î.login (for c shell)¡Alogout¨t²Î®É¤]·|¦Û°Ê´M§ähome directory¤U¬O§_¦s¦b.logoutÀɮסA¦pªG¦s¦b¡A¤]·|¦Û°Ê°õ¦æ§¹¦¹¤@µ{¦¡«á¡A¤~¯u¥¿Â÷¶}¨t²Î¡C

¡@

¡@

Example¡G

woody@golf: ~ 2 >cat .logout

echo "$LOGNAME ¤U¦¸¦A¨£¤F¡I¡I"

date

sync ## sync«ü¥O±N¥Ø«e¦s¦bbuffer¤¤ªº¸ê®Æ¼g¦^¨t²ÎºÏºÐ ##

woody@golf: ~ 3 >logout

woody ¤U¦¸¦A¨£¤F¡I¡I

DATE: 10/16/97

TIME: 10:50:28

¡@

¡@

¡@

¡@

¡@

¡@


¡@

¡@

¡@

¡@

±Ò°Êvi½s¿è¾¹ à ©R¥O¼Ò¦¡

©R¥O¼Ò¦¡ +( i, a, o, O,) à ´¡¤J¼Ò¦¡

©R¥O¼Ò¦¡ + ¡¨:¡¨ à last line¼Ò¦¡

last line¼Ò¦¡ + ¥ô¦ó«ü¥Oor KeyStroke à ©R¥O¼Ò¦¡

´¡¤J¼Ò¦¡ + ¡§Esc¡¨ à ©R©R¼Ò¦¡

¡@

$ vi filename

¡@

©R¥O¼Ò¦¡°ò¥»«ü¥O¥i¤À¬°´å¼Ð²¾°Ê¡N´¡¤J¤å¦r¡N§R°£¤å¦r¡N­×§ï¤å¦rµ¥´XÃþ¡M¼ô±x¦UºØ±`¥Î«ü¥O¡M¨Ãµ½¥[²Õ¦XÅܤơM¥i¨Ï¤å¦r½s¿èªº¤u§@Åܱo§Ö³t¦Ó¦³®Ä²v¡C

¡@

last line¼Ò¦¡¤§«ü¥O¤@¯ë¥Î©ó»²§U©R¥O¼Ò¦¡«ü¥O¤§¤£¨¬¡M¥D­n«ü¥O¦p¤U¡G

¡]§Ú­Ì¥i¥H±Nlast line¼Ò¦¡«ü¥Oµø¬°¡§:¡¨¶}ÀYªº©R¥O¼Ò¦¡«ü¥O¡^

:q ¤£Àx¦sÀɮפº®e¨ÃÂ÷¶}vi(¥¼ÅܧóÀɮפº®e)

:q! ¤£Àx¦sÀɮפº®e¨ÃÂ÷¶}vi(Àɮפº®e¤w³Q§ó°Ê)

:wq <filename> Àx¦sÀɮפº®e¨ÃÂ÷¶}vi

:w <filename> Àx¦sÀÉ®×

:= Åã¥Ü´å¼Ð¥Ø«e©Ò¦b¤§¦æ¼Æ

:.= Åã¥ÜÀÉ®×¥þ³¡Á`¦æ¼Æ

:n,ms/str1/str2/optt±q²Än¦æ·j´M¦Ü²Äm¦æ¡A¨Ã±N©Ò§ä¨ì¤§¦r¦ê¡¨str1¡¨¨ú

¥N¬°¡¨str2¡¨¡Copt=g¥þ³¡¨ú¥N¡Aopt=c½T»{¦A¨ú¥N

:r filename±N¥~³¡ÀɮפޥÎ(paste)¦Ü´å¼Ð©Ò¦b¦ì¸m¤§«á

:e filename½s¿è¥t¤@ÀÉ®×

:! Command °õ¦æSHELL command«áªð¦^¡C

¡@

´å¼Ð²¾°Ê«ü¥O

k

©¹¤W²¾¤@®æ

j

©¹¤U²¾¤@®æ

h

©¹¥ª²¾¤@®æ

l

©¹¥k²¾¤@®æ

w

©¹¤U²¾¤@­Ó¦r(word)

b

©¹¤W²¾¤@­Ó¦r(word)

| or 0

²¾¦Ü´å¼Ð©Ò¦b¦æ­º

$

²¾¦Ü´å¼Ð©Ò¦b¦æ­º

n G

²¾¦Ü²Än¦æ

G

²¾¦ÜÀɧÀ

¡@

´¡¤J¥»¤å

a

¦b´å¼Ð«á´¡¤J¤å¦r¡]¶i¤J´¡¤J¼Ò¦¡¡^

A

¦b¦æ§À´¡¤J¤å¦r¡]¶i¤J´¡¤J¼Ò¦¡¡^

I

¦b´å¼Ð«e´¡¤J¤å¦r¡]¶i¤J´¡¤J¼Ò¦¡¡^

I

¦b¥»¦æ«e´¡¤J¤å¦r¡]¶i¤J´¡¤J¼Ò¦¡¡^

o

¦b¥»¦æ¤§¤U¶}·s¤@¦æ¨Ã¿é¤J

O

¦b¥»¦æ¤§¤W¶}·s¤@¦æ¨Ã¿é¤J

<Ctrl> v

¿é¤J¯S®í¦r¤¸(¦b´¡¤J¼Ò¦¡¤U)

¡@

½s¿è«ü¥O

nyy

copy n¦æ¸ê®Æ©ñ¸m½w½Ä°Ï¤¤

y+´å¼Ð²¾°Ê«ü¥O

copy´å¼Ð²¾°Ê½d³ò¤§¸ê®Æ¦Ü½w½Ä°Ï¤¤

(e.g.:y3w: copy´å¼Ð¤§«á¤T­Ó¦r)

p

±N½w½Ä°Ï¤§¸ê®Æcopy¦Ü¥Ø«e´å¼Ð©Ò¦b

nx

§R°£´å¼Ð¤§«án­Ó¦r¤¸

ndd

©¹¤U§Rn¦æ

d+´å¼Ð²¾°Ê«ü¥O

copy§R°£´å¼Ð²¾°Ê½d³ò¤§¸ê®Æ

(e.g.:dw§R¤@­Ó¦r)

¡@

¨ä¥L

¡@

/¦r¦ê<CR>

´M§ä¦r¦ê©Ò¦b¦ì¸m¡]©¹¤U¡^

?¦r¦ê<CR>

´M§ä¦r¦ê©Ò¦b¦ì¸m¡]©¹¤W¡^

u

©ñ±ó¤W¤@­Ó«ü¥O°Ê§@

.

­«½Æ¤W¤@­Ó¥»¤å§ó§ï«ü¥O

¡@

Example

cc301:~> vi text

#### ±Ò°Êvi¡A¶i¤Jcommand mode ####

n

~

~

~

~

"text" [NEW FILE] 1 line, 1 char Command

####Áä¤Ji¶i¤Jedit mode¦AÁä¤JThis is a test file Enter ç Test Enter ç Test

Enter ç ####

This is test

Test

Test

~

~

~

"text" [NEW FILE] 1 line, 1 char Input

¡@

####Áä¤JEsc + : ¶i¤Jlastline mode¦AÁä¤JwqÀx¦sÀÉ®×#### ~

This is test

Test

Testn

~

~

~

:wq

cc301:~>

¡@

¡@

¡@

«ü¥O(Command) ¿ï¶µs(Options) °Ñ¼Æs(arguments)

¡@

    1. UNIX«ü¥O¤T¤j³¡¤À¤§¶¡¦Ü¤Ö¶·¦³¤@­ÓªÅ¥ÕÁä(Space) or <TAB> Áä°Ï¹j¤§¡C
    2. ¿ï¶µ¤@²v¥H - ¬°«e¾É¡C
    3. ¤T¤j³¡¤À¤§¶¶§Ç¤£¥i§ó°Ê¡C
    4. UNIX¨t²Î¤¤¡A«ü¥O¡B¿ï¶µ¤Î°Ñ¼Æ§¡¬°Case Sensitive¡A¥ç§Y¤j¤p¼g¤£¥i¥ô·N§ó´«¡C¨Ò¦p«ü¥Ols¤£¥i¼g¦¨LS¡C
    5. ¦P¤@¦æ¤¤¥i¿é¤J¤@­Ó¥H¤W¤§«ü¥O¡A¦ý«ü¥O¤§¶¡¥²¶·¥H¤À¸¹¡¨;¡¨¤À¹j¶}¡C

¡@

¡@

(1). ls [-¿ï¶µ] [¥Ø¿ýorÀɮצWºÙ]

¥\¯à¡G¦C¥X©Ò¦b©Î«ü©w¥Ø¿ýªº¤º®eorÀɮפ§¬ÛÃö¯S©Ê

¿ï¶µ¡G

-a : ¦C¥X©Ò¦³ÀɮצWºÙ¡A¥]¬A¥H¡¨.¡¨¶}ÀY¤§ÁôÂÃÀÉ¡A¦p.profile¡B.loginµ¥¡C

-d : ­Y°Ñ¼Æªº¬°¤@¥Ø¿ý¦WºÙ¡A«h¥u¦C¥XÀɮצWºÙ¦Ó«D¥Ø¿ý¤§¤º®e¡C

-l : ¦C¥XÀɮתº¸Ô²Ó¸ê®Æ¡A¥]¬AÀɮקκA¡B¦s¨úÅv­­¡B³sµ²¼Æ¥Ø¡B¾Ö¦³ ªÌ¦WºÙ¡B¸s²Õ¦WºÙ ¡Kµ¥¡C

¨ä¥L¿ï¶µ¡GRLCxmnogrtucpFbqisfl

¡@

Example:

cc301:/var/adm# ls

cron logins removed_packages/ syslog

debug messages removed_scripts/ utmp@

disk_contents/ mount/ scripts/ wtmp

lastlog packages/ setup/ xferlog

¡@

cc301:/var/adm# ls -a

./ disk_contents/ packages/ syslog

../ lastlog removed_packages/ utmp@

.ttt logins removed_scripts/ wtmp

cron messages scripts/ xferlog

debug mount/ setup/

cc301:/var/adm# ls -l

total 576

-rw-r--r-- 1 root root 0 Mar 30 1996 cron

-rw-r----- 1 root root 0 Apr 14 1995 debug

drwxr-xr-x 2 root root 2768 Mar 30 1996 disk_contents/

-rw-r--r-- 1 root root 16096 Jan 26 15:22 lastlog

-rw-r--r-- 1 root root 42 Apr 4 1995 logins

-rw-r----- 1 root root 139917 Jan 26 16:15 messages

drwxr-xr-x 2 root root 32768 Apr 21 1995 mount/

drwxr-xr-x 2 root root 32768 May 27 1996 packages/

drwxr-xr-x 2 root root 32768 Apr 21 1995 removed_packages/

drwxr-xr-x 2 root root 32768 Apr 21 1995 removed_scripts/

drwxr-xr-x 2 root root 32768 May 27 1996 scripts/

drwxr-xr-x 2 root root 32768 Mar 30 1996 setup/

-rw-r----- 1 root root 9905 Jan 25 11:07 syslog

lrwxrwxrwx 1 root root 13 Mar 30 1996 utmp -> /var/run/utmp

-rw-r--r-- 1 root root 27832 Jan 26 15:22 wtmp

-rw-r----- 1 root root 801 May 28 1996 xferlog

¡@

¡@

(2). pwd

¥\¯à¡G¦C¥X¨Ï¥ÎªÌ¥Ø«e©Ò¦b¥Ø¿ý(Current Directory)¦WºÙ

¡@

Example:

cc301:/var/adm# pwd

/var/adm

cc301:/var/adm#

¡@

¡@

(3).passwd [-¿ï¶µ] [username]

¥\¯à¡G§ó§ï¨Ï¥ÎªÌ±K½X¡C

¨ä¥L¿ï¶µ¡G[-l][-d][-f][-n min][-m max][-w warn]

¡@

Example:

cc301:/var/adm> passwd

Changing password for woody

Enter old password:

Enter new password:

Re-type new password:

Password changed .

cc301:/var/adm>

¡@

(4).who [-¿ï¶µ] and who am i (or whoami)

¥\¯à¡GÅã¥Ü¥Ø«eñ¤J¨t²Î¤§¨Ï¥ÎªÌ¤Î¬ÛÃö°T®§

¨ä¥L¿ï¶µ¡G[-abHlqsTu]

¡@

Example:

cc301:/var/adm> who ##¥Ø«e¦³½Ö¦b¨t²Î¤¤?##

woody ttyp0 Jan 26 15:22 (140.120.2.112)

root ttyp1 Jan 26 16:55 (justy.nchu.edu.t)

bbs ttyp2 Jan 26 16:56 (cc301.nchu.edu.t)

cc301:/var/adm> who am I ##¨Ï¥ÎªÌ¥Ø«e¨­¤À¬°¦ó¡H##

cc301!woody ttyp0 Jan 26 15:22 (140.120.2.112)

cc301:/var/adm>

¡@

¡@

(5).cd [directory]

¥\¯à¡G§ïÅܥثe¤u§@¥Ø¿ý¤§¦ì¸m¦Üdirectory¡A­Y[directory]²¤¤§¡A«hªð¦^¦Ü¨Ï¥ÎªÌ¤§Ã±¤J®É¤§¥Ø¿ý(Home Directory)¡C

¡@

Example:

cc301:/etc> pwd

/etc

cc301:/etc> cd /var/adm

cc301:/var/adm> pwd

/var/log

cc301:/var/adm> cd

cc301:~> pwd

/home/woody

cc301:~>

¡@

¡@

(6).cp [-¿ï¶µ] file1 [file2] [¡K] target

¥\¯à¡GÀɮ׽ƻs¡C­Ytarget¬°ÀɮצWºÙ¡A«hfile¥u¯à«ü©w¤@­ÓÀɮסA­Ytarget¬°¤@­Ó¥Ø¿ý¦WºÙ¡A«h·|±Nfile1¡Bfile2..¤À§O½Æ»s¦Ü¦¹¤@¥Ø¿ý¤§¤U¡C

¿ï¶µ¡G

-i : ­Ytarget¦s¦b¡A·|­n¨D¨Ï¥ÎªÌ½T»{½Æ»s¤§°Ê§@¡C

¨ä¥L¿ï¶µ¡G[-p][-r]

¡@

Example:

cc301:/var/adm# ls

cron messages scripts/ wtmp

debug mount/ setup/ xferlog

disk_contents/ packages/ syslog

lastlog removed_packages/ syslog.sav

logins removed_scripts/ utmp@

cc301:/var/adm# cp -i wtmp syslog

cp: overwrite `syslog'? n

cc301:/var/adm#

¡@

¡@

(7).mv [-¿ï¶µ] [file1][file2][¡K] target

¥\¯à¡G§ïÅÜÀɮצWºÙ©Î·h²¾Àɮצܨä¥L¥Ø¿ý¡Afile»Ptarget¤§­­¨î¦Pcp¤§»¡©ú¡C

¿ï¶µ¡G

-i : ­Ytarget¦s¦b¡A·|­n¨D¨Ï¥ÎªÌ½T»{·h²¾¤§°Ê§@¡C

¨ä¥L¿ï¶µ¡G[-f]

¡@

mv test test.sav ##±NÀÉ®×test§ó¦W¬°test.sav(ÀɮשҦb¦ì¸m¤£ÅÜ)##

mv tset /home/woody/ ##±NÀÉ®×test¥Ñ¥Ø«e©Ò¦b¥Ø¿ý·h²¾¦Ü/home/woody(ÀɦW¤£ÅÜ)##

¡@

¡@

(8).date [+format]

¥\¯à¡G[¥H«ü©w¤§format]Åã¥Ü¨t²Î¥Ø«e¤§®É¶¡»P¤é´Á¡Aformat¬O¥Ñ³æ¤Þ¸¹©Ò¥]§tªº¦r¦ê¡A¨ä¤¤¥]¬A¥i¦C¦L¦r¤¸»P±±¨î¦r¤¸¡C±`¥Î¤§±±¨î¦r¤¸¥]¬A¡G

%m ¤ë¥÷

%y ¦~¥÷

%D ¿é¥X®æ¦¡¬°mm/dd/yy

%H ¤p®É(00 ~ 23)

%M ¤ÀÄÁ(00 ~ 59)

%S ¬íÄÁ(00 ~ 59)

%T ¿é¥X®æ¦¡¬°HH:MM:SS

%j ¬Û·í©ó¸Ó¦~ªº²Ä´X¤Ñ

%w ¬P´Á¤Ñ¼Æ

%a ¬P´Á­^¤å¦W

%h ¤ë¥÷¬P´Á¦W

¡@

cc301:~# date

Sun Jan 26 17:46:30 CST 1997

cc301:~# date '+Month = %h, Date = %a, Year = %y'

Month = Jan, Date = Sun, Year = 97

cc301:~# date '+%D %T'

01/26/97 17:46:54

cc301:~# date '+%T %D'

17:47:02 01/26/97

cc301:~#

¡@

¥t¥~¨t²Îªº®É¶¡¤]¥i¥H³z¹L¦¹¤@«ü¥O§ó§ï¡]¸g¥Ñ¨t²ÎºÞ²zªÌªº¨­¤À¡^

§ó§ï¤§¤è¦¡¬°¡G

date mmddHHMMyy

¨ä¤¤mm¡Bdd¡BHH¡BMM¡Byy¤À§O¬°¤ë¥÷¡B¤é´Á¡B®É¡B¤À¡B¤Î¦~¥÷¡C

¡@

(9).echo [-¿ï¶µ][¥i¦C¦L¦r¦ê]

¥\¯à¡G±N[¥i¦C¦L¦r¦ê]¿é¥X¦Ü»È¹õ¡]¼Ð·Ç¿é¥X¡^¡A¦¹¤@«ü¥O¤@¯ë¥Î©óÅã¥Ü¤@¨ÇÅܼƤ§¤º®e¡A©Î©óshell script¼g§@®É¡A§@¬°µ{¦¡»P¨Ï¥ÎªÌ¤§¶¡¥æ½Í°T®§·¾³q¤§ºÞ¹D¡C

¿ï¶µ¡G

-n : ¿é¥X®É¤£¥[¤W´«¦æ¦r¤¸

¡@

cc301:~# echo $SHELL

/bin/tcsh

cc301:~#

cc301:~# echo "Hello, World.."

Hello, World..

cc301:~# echo -n "Hello World.."

Hello World..cc301:~#

¡@

¡@

(10).cal [¤ë¥÷] [¦~¥÷]

¥\¯à¡G¿é¥X«ü©w¤ë¥÷¤Î¦~¥÷¤§¤ë¾ä©ó»È¹õ¡]¼Ð·Ç¿é¥X¡^¡A­Y¥¼«ü©w¡A«h¿é¥X·í¤ë¥÷¤§¤ë¾ä

cc301:~# cal

January 1997

Su Mo Tu We Th Fr Sa

1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28 29 30 31

¡@

cc301:~# cal 2 97

February 97

Su Mo Tu We Th Fr Sa

1 2 3 4

5 6 7 8 9 10 11

12 13 14 15 16 17 18

19 20 21 22 23 24 25

26 27 28

cc301:~#

¡@

(11).rm [-¿ï¶µ] file ¡K or rm -r [-¿ï¶µ] directory file ¡K

¥\¯à¡G§R°£ÀɮשΥؿý¡Crm -r·|¥H»¼°jªº¤è¦¡§R°£©Ò«ü©w¤§¥Ø¿ý¤U¤§©Ò¦³Àɮס]¥]¬A¤l¥Ø¿ý¡^¡C

¿ï¶µ¡G

-f : ¤£²£¥Í¥ô¦ó­n¨D§R°£½T»{¿ù»~¤§°T®§¡C(Default)

-i : ¥H¥æ½Í¦¡¤§¤è¦¡§R°£ÀɮסC

¡@

Example:

cc301:~# rm -f ttt

cc301:~#

cc301:~# rm -i ttt

rm: remove `ttt'? y

cc301:~#

cc301:~# ls -l test

total 416

drwxr-xr-x 2 root root 32768 Jan 27 10:01 test1/

-rw-r--r-- 1 root root 115695 Jan 27 13:00 tt

-rw-r--r-- 1 root root 115695 Jan 27 13:00 tttt

-rw-r--r-- 1 root root 115695 Jan 27 13:00 ttttt

¡@

cc301:~# rm -r -i test

rm: descend directory `test'? y

rm: descend directory `test/test1'? n

rm: remove `test/tt'? y

rm: remove `test/tttt'? y

rm: remove `test/ttttt'? y

rm: remove directory `test' (might be nonempty)? y

rm: test: Directory not empty

cc301:~# ls -l test

total 32

drwxr-xr-x 2 root root 32768 Jan 27 10:01 test1/

cc301:~#

¡@

(12).cat [-¿ï¶µ] file ¡K

¥\¯à¡G¦L¥XÀɮפº®e¦Ü»È¹õ¡]¼Ð·Ç¿é¥X¡^©Î¦X¨Ö¦hÀÉ¡Ccat file1 file2 > file3¥i±NÀÉ®×file1¡Bfile2¤§¤º®e¨Ì¶¶§Ç¦X¨Ö¡A¨Ã±Nµ²ªG¦s¦Üfile3¡C

¨ä¥L¿ï¶µ¡G[-u][-s][-v[-t][-e]]

¡@

cc301:~# cat /etc/syslog.conf

# /etc/syslog.conf

# For info about the format of this file, see "man syslog.conf" (the BSD man

# page), and /usr/doc/sysklogd/README.linux.

#

# NOTE: YOU HAVE TO USE TABS HERE - NOT SPACES.

# I don't know why.

#

*.=info;*.=notice /usr/adm/messages

*.=debug /usr/adm/debug

*.warn /usr/adm/syslog

¡@

#

# This might work instead to log on a remote host:

# * @hostname

cc301:~#

¡@

¡@

¡@

mkdir dir1 dir2 ¡K.¡G«Ø¥ß·s¥Ø¿ý¡C

rmdir dir1 dir2 ¡K.¡G§R°£ªÅ¥Ø¿ý¡C

more file1 file2 ¡K.¡G¥H¤@¦¸¤@­¶(One Screen)¤§¤è¦¡Åã¥ÜÀɮפº®e¡C

grep <patterm> file1 file2 ¡K.¡G´M§äÀɮפ¤¬O§_¦³²Å¦X¦r¦ê<pattern>¤§¤º®e¡A¨Ã±N¸Ó¦r¦ê¥X²{¤§©Ò¦b¡A¾ã¦æ¦L¥X¡C

¡@

¡@

©Ò¿×¿é¥X­«¾É«üªº¬O±N¥»¨ÓÀ³¨t²Î¿é¥X¦Üªº°T®§¡A©Î¹Bºâµ²ªGÂà¦V¦Ü§Ú­Ì©Ò«ü©wªº¦ì¸m¡]¥i¯à¬OÀɮסA¤]¥i¯à¬O¥t¤@µ{¦¡ªº¿é¤J¡^¡F¿é¥X­«¾É¨Ï¥Î­«¾É²Å¸¹¡¨>¡¨or ¡§>>¡¨¡C

¡@

(1). With Symbol ¡§>¡¨

¡@

Example:

cc301:~> ls -l > list ##Redirec stdout to file ¡§list¡¨, if ¡§list¡¨ exist, overwrite it !##

cc301:~> cat list

total 32

-rw-r--r-- 1 woody users 0 Feb 11 17:46 list

drwxr-xr-x 2 woody users 32768 Feb 4 16:32 test/

cc301:~>

¡@

    1. .With Symbol ¡§>>¡¨

¡@

Example:

cc301:~> cat list

total 32

-rw-r--r-- 1 woody users 0 Feb 11 17:51 list

drwxr-xr-x 2 woody users 32768 Feb 4 16:32 test/

cc301:~> cat .kermrc >> list ##Redirec stdout to file list, if list exist, append output after it !##

cc301:~> cat list

total 32

-rw-r--r-- 1 woody users 0 Feb 11 17:51 list

drwxr-xr-x 2 woody users 32768 Feb 4 16:32 test/

set line /dev/modem

set speed 38400

set modem hayes

set file type bin

set file name lit

set rec pack 1000

set send pack 1000

set window 5

set prompt Linux Kermit>

cc301:~>

¡@

¡@

cc301:~> echo "date '+Month = %h, Date = %a, Year = %y'" > woody

cc301:~> sh < woody

Month = Feb, Date = Tue, Year = 97

cc301:~>

¡@

¡@

¡@

¡@

DOS«ü¥O

UNIX«ü¥O

dir/w

ls

dir/s

ls -lR

dir

ls -l

DOS«ü¥O

UNIX«ü¥O

type [file]|more

more [file]

copy

cp

del

rm

ren

mv

cd

cd

help

man

date

date

time

date

deltree

rm -r

¡@

¡@

¡@

UNIXÀɮרt²Î

¡@

UNIXÀɮרt²Î©MDOS¤@¼Ë¡A±Ä¶¥¼h¦¡(Hierarchy)©Î¾ðª¬(Tree)¤§¥Ø¿ý¬[ºc¡A³Ì¤W¤@¼h¥Ø¿ýºÙ¬°®Ú¥Ø¿ý(root)¡A¨C¤@¥Ø¿ý¤¤§¡¥i§t¦³ÀÉ®×»P¤l¥Ø¿ý¡A¸ô®|¦WºÙ¤¤¥Ø¿ý»P¥Ø¿ý¤§¤À¹j²Å¸¹¬°¡¨/¡¨¡C

¡@

¡@

­ì©lµ{¦¡¡B¤å¥ó¡B¸ê®Æ¡Kµ¥¡C

¡@

¥Ø¿ýÀɥΩó²[¬AÀɮסA¨ÏÀɮרt²Î§ó¥[²¼ä¡C

¡@

¥Nªí¬YºØ¯S®íµwÅé³]³Æ¡A¦p¡G¦Lªí¾÷¡BºÏºÐ¾÷¡BºÏ±a¾÷¡Kµ¥¡A³q±`¦s¦b©ó/dev¥Ø¿ý¤§¤U¡C¦¹ºØÀÉ®×Ãþ«¬¤S¥i°Ï¤À¬°°Ï¶ô(block)¤Î¦r¤¸(Character)¨âºØ¡C(UNIX§@·~¨t²Î¤U¡A©Ò¦³³]³Æ§¡¥iµø¬°ÀɮסA¨Ã¨ÌÀɮפ覡¹B§@)

¡@

¤º®e¬°¤@«ü¼Ð¡A«ü¦VÀɮצWºÙ©Ò¦b(«DÀɮפº®eÀx¦s©Ò¦b) ¡CÃþ¦üÀÉ®×§O¦W(But more tham that !!)¡C

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¡@

¥Ø«e©Ò¦b¥Ø¿ý¡A¥i¥Hpwd«ü¥OÅã¥Ü¤§¡C

¡@

±b¸¹«Ø¥ß¤§ªì¡AºÞ²zªÌ½á¤©¨Ï¥ÎªÌ¤§ªì©l¥Ø¿ý¡F³q±`³o¬O¨Ï¥ÎªÌ¶i¤J¨t²Î¤§«áªº²Ä¤@­Ó¤u§@¥Ø¿ý¡C¡¨cd¡¨¤£¥[¥ô¦ó°Ñ¼Æ¥i¨Ï¨Ï¥ÎªÌ¦^¦Ü®a¥Ø¿ý¡C

¡@

¡§.¡¨¥Nªí¥Ø«e©Ò¦b¥Ø¿ý¡A¡¨..¡¨«h¥Nªí¤W¤@¼h¥Ø¿ý¡C

¡@

¾ã­ÓUNIXÀɮרt²Î³Ì¤W¼h¤§¥Ø¿ý¡C

¡@

¥H¡¨/¡¨°_ÀY¤§¸ô®|¦WºÙ¡A¦p/usr/var/spool/mqueue¡CUNIX¤¤¡A¨C¤@­Ó¥Ø¿ý©ÎÀɮסA¬Ò¦³¤@­Ó°ß¤@ªºµ´¹ï¸ô®|»P¤§¹ïÀ³¡C

¡@

°_ÀY¤£¬O¡¨/¡¨ªº¸ô®|¡A¬Û¹ï¸ô®|¬O¥H¥Ø«e¤u§@¥Ø¿ý¬°°_ÂIªºÀɮשθô®|´y­z¡C¦p¡G°²³]¥Ø«e¤u§@¥Ø¿ý¬°/home/center¡A«h¬Û¹ï¸ô®|¡¨work1/papers/lect¡¨»Pµ´¹ï¸ô®|¡¨/home/center/work1/papers/lect¡¨ªºªí¥Ü¤èªk¡A©Ò«üªºÀɮ׬O¬Û¦Pªº¡C

¡@

¹êÅé¤W¦Ó¨¥(Physically)¡AUNIX¤¤©Ò¿×¡¨Àɮרt²Î¡¨¡A¬Û·í©óDOS¤¤ªºpartition¡C¤@­Ó¿W¥ßªºÀɮרt²Î¾Ö¦³¿W¥ßªºfile table(inode table)¡A¤@­ÓºÏºÐ¤¤¡A¥i¥H¤Á³Î¦¨¤@­Ó¤WªºÀɮרt²Î¡C¦ý¦bÅÞ¿è¤W¦Ó¨¥(Logically)¡A¤@­ÓUNIX¤¤¡A¶È¦³¤@­ÓÀɮרt²Î¡A¥ç§Y¡A¤@­ÓUNIX§@·~¨t²Î¤¤¶È¦³¤@­Ó¡§®Ú¥Ø¿ý¡§¡A¤@¤ÁÀÉ®×µ²ºc¨Ì¦¹®Ú¥Ø¿ý¡A©¹¤Uµo®i¡C

¡@

¡@

¡@

UNIX¨t²Î¤¤¹ï©ó¨C¤@­ÓÀɮסA§¡ºûÅ@¤@¨ÇÀÉ®×ÄݩʬÛÃö°T®§¡A³z¹L³o¨Ç°T®§¡A¥i¤è«K¨Ï¥ÎªÌ¹ï©óÀɮפ§ºÞ²z»PºûÅ@¡A³o¨Ç°T®§¥]¬A¦Ü¤Ö¥]¬A¥H¤U¤§¶µ¥Ø¡G

¡@

- : ¤@¯ëÀÉ®×

d:¥Ø¿ý

b:¯S®íÀÉ®×(°Ï¶ô)

c:¯S®íÀÉ®×(¦r¤¸)

l:²Å¸¹³sµ²ÀÉ

¡@

¨Ï¥ÎªÌ°Ï¤À:ÀÉ®×¾Ö¦³ªÌ¡B¸s²Õ¡B¨ä¥L

Åv­­°Ï¤À¡GŪ( r )¡B¼g( w )¡B°õ¦æ( x )

UNIX¦@¥Î¤E­Ó¦r¤¸¨Ó´y­z¤TºØ¨Ï¥ÎªÌ¤§¤TºØÅv§Q¡C

¡@

«ü¦V¦¹¤@Àɮפ§ÀɮצWºÙ(inode)¤§­Ó¼Æ¡A¦¹Ãìµ²­Ó¼Æ¤£¥]§t²Å¸¹Ãìµ²¡C

¡@

¾Ö¦³¦¹¤@Àɮפ§¨Ï¥ÎªÌ¦WºÙ¡C

¡@

¦¹¤@ÀɮשÒÄݤ§¸s²Õ¡C

¡@

³æ¦ì¬°byte¡C

¡@

¦¹Àɮ׳̫á¤@¦¸³Q­×§ï¤é´Á¡C

¡@

ÀɮצWºÙ

¡@

Example:¡]ÀÉ®×°T®§¡^

¡@

ls -l /etc/rc

-

rw-

rw-

r--

1

root

sys

3488

jan 20 17:00

/etc/rc

³o¬O¤@­ÓÀÉ®×

¾Ö

¦³

ªÌ

Åv

­­

¡@

¸s

²Õ

Åv

­­

¡@

¨ä

¥L

¤H

Åv

­­

¡@

Ãì

µ²

­Ó

¼Æ

¡@

¾Ö

¦³

ªÌ

¡@

¸s

²Õ

¡@

ÀÉ

®×

¤j

¤p

¡@

­×³Ì

§ï«á

¤é¤@

´Á¦¸

¡@

ÀɦW

¡@

¡@

ls -ld /etc

d

Rwx

rwx

r-x

41

root

sys

640

jan 23 17:30

/etc

³o¬O¤@­Ó¥Ø¿ý

¾Ö

¦³

ªÌ

Åv

­­

¡@

¸s

²Õ

Åv

­­

¡@

¨ä

¥L

¤H

Åv

­­

¡@

Ãì

µ²

­Ó

¼Æ

¡@

¾Ö

¦³

ªÌ

¡@

¸s

²Õ

¡@

ÀÉ

®×

¤j

¤p

¡@

­×

§ï

¤é

´Á

¡@

ÀɦW

¡@

ÀÉ®×Ãìµ²(File Link)¡G

¡@

¡@

¡@

¡@

«ü¥O¡Gln file1 file2

file1¬°¤w¦s¦b¤§ÀɮסAfile2«h¬O¥H¤W«ü¥O©Ò²£¥Í¤§ÀÉ®×Ãìµ²¡FHard Linkªºµ²ªG¬O¡¨¦bFile Table¤¤²£¥Í¤@­Ó·sªºÀɦW¡A«ü¦V¤@­Ó¤w¦s¦bªºinode¡¨¡C¦a¦ì¤Wfile1»Pfile2¬Û¦P¡Afile1»Pfile2¥²¶·¦P®É³Q§R°£¤~¯à¯u¥¿§R°£­ì¦³¤§ÀɮסC

Hard Link¤£¤¹³\¸ó¹Lfile system¤§Ãìµ²¡C

¡@

«ü¥O¡Gln -s file1 file2

file1¬°¤w¦s¦b¤§ÀɮסAfile2«h¬O¥H¤W«ü¥O©Ò²£¥Í¤§²Å¸¹Ãìµ²¡FSymbolic Linkªºµ²ªG¬O¡¨ ¦bFile Table¤¤²£¥Í¤@­Ó·sªºÀɦWfile2¡A«ü¦V¥t¤@­Ó¤w¦s¦b¤§ÀɦWfile2¡¨¡C°ò¥»¤W§R°£file2¸ÓÀɮפ§¤º®e«K¤w³Q§R°£¡A»Pfile2¬O§_¦s¦bµLÃö¡C

Symbolic Link¤¹³\¸ó¹Lfile system¤§Ãìµ²¡C

¡@

Example¡G

cc301:~/test> ls -l kerm*

-rwxrwxr-- 1 woody users 164 Feb 4 14:49 kerm*

cc301:~/test> ln kerm kerm1 ##²£¥Í¤@­ÓHard Link##

cc301:~/test> ls -l kerm* ##½Ðª`·Nlink¼Æ¤§§ïÅܤΨâ­ÓÀɮתºfile size##

-rwxrwxr-- 2 woody users 164 Feb 4 14:49 kerm*

-rwxrwxr-- 2 woody users 164 Feb 4 14:49 kerm1*

cc301:~/test> ln -s kerm kerm2 ##²£¥Í¤@­ÓSymbolic Link##

cc301:~/test> ls -l kerm* ##½Ðª`·Nkerm2¤§ªí¥Ü¤è¦¡»Pfile size##

-rwxrwxr-- 2 woody users 164 Feb 4 14:49 kerm*

-rwxrwxr-- 2 woody users 164 Feb 4 14:49 kerm1*

lrwxrwxrwx 1 woody users 4 Feb 4 16:26 kerm2 -> kerm*

cc301:~/test> ls -il kerm* ##½Ðª`·Nindoe number##

7134517 -rwxrwxr-- 1 woody users 164 Feb 4 14:49 kerm*

7134517 -rwxrwxr-- 1 woody users 164 Feb 4 14:49 kerm1*

7134520 lrwxrwxrwx 1 woody users 4 Feb 4 16:32 kerm2 -> kerm*

cc301:~/test> rm kerm

cc301:~/test> cat kerm2 ##§R°£kerm«ákerm2¤§¤º®e¥çÀH¤§®ø¥¢##

cat: kerm2: No such file or directory

cc301:~/test> cat kerm1 ##kerm1¤º®e¨ÌµM¦s¦b##

set line /dev/modem

set speed 38400

set modem hayes

set file type bin

set file name lit

set rec pack 1000

set send pack 1000

set window 5

set prompt Linux Kermit>

¡@

¡@

¡@

¡@

¡@

¨C¤@­ÓÀɧ¡¦³¤@­Ó¾Ö¦³ªÌ(owner)¡A¶È¦³owner¤Îsuper user¥i¥H§ó§ïÀɮפ§¦s¨ú«OÅ@¼Ò¦¡(with command chmod, »¡©ú®e¤U¤å±Ô­z)¡A¦Ó¤@¯ë«h¥u¦³super user¥i¥H§ó§ïÀɮפ§¾Ö¦³ªÌ(with command ¡§chown¡¨ )¡C

¡@

Ū¨ú(r)¡G¥iŪ¨úÀɮפº®e¡A½Æ»sÀɮפº®e¡C

¼g¤J(w)¡G¥i§ó§ïÀɮפº®e¡B¦WºÙ¡]·h²¾Àɮס^¡A§R°£ÀɮסC

°õ¦æ(x)¡G¥i°õ¦æÀɮסC(If it¡¦s a executable file¡A¥]¬Ashell program)

¡@

Ū¨ú( r )¡G¥iÂsÄý¥Ø¿ý¤º®e(ls directory)¡C

¼g¤J( w ):¥i¦b¥Ø¿ý¤¤«Ø¥ß©Î§R°£ÀɮסC

°õ¦æ( x )¡G¥i·j´M¦¹¥Ø¿ý¡A¨Ã¥i§ó§ï¤u§@¥Ø¿ý(cd)¦Ü¦¹¥Ø¿ý¡C¡¨ cat /var/spool/mqueue/syslog¡¨³o­Ó«ü¥Oªº°õ¦æ¡A´N¥²¶·¹ï/var/spool/mqueue³o­Ó¥Ø¿ý¨ã¦³°õ¦æ¤§Åv¤O¡C

¡@

Example:

~User woody~

cc301:~> ls -ld test

drwxr--r-- 2 woody users 32768 Feb 4 14:50 test/

## right ¡§Read¡¨ is granted, but ¡§Execute¡¨ not ##

cc301:~> ls -l test

total 224

-rwxrwxrwx 1 woody users 96466 Feb 4 14:41 hhh*

-rwxrwxrwx 1 woody users 96466 Jan 27 15:57 kdiffs-1.2.3-quota+acct*

-rwxrwxrwx 1 woody users 164 Feb 4 14:49 kerm*

## All rights granted for all files under test ##

cc301:~>

¡@

~User woody1~

cc301:~woody> whoami

woody1

cc301:~woody> cd test

test: Permission denied. ## Cannont cd to test##

cc301:~woody> cat test/kerm

rm: test/kerm: Permission denied

## Cannot read kerm, even though read is granted for file kerm ##

cc301:~woody>

¡@

~User woody~

cc301:~> chmod 755 test ##Grant execute for test to everyone##

cc301:~> ls -ld test

drwxr-xr-x 2 woody users 32768 Feb 4 14:50 test/

~User woody1~

cc301:~woody> whoami

woody1

cc301:~woody> cd test ## Ok Now!!! ##

cc301:~woody/test> pwd

/home/woody/test

cc301:~woody/test>

cc301:~woody/test> cd ..

cc301:~woody> cat test/kerm ## OK Now !!! ##

set line /dev/modem

set speed 38400

set modem hayes

set file type bin

set file name lit

set rec pack 1000

set send pack 1000

set window 5

set prompt Linux Kermit>

cc301:~woody>

¡@

**ª`·N¡A¦]/home/woody/testÀÉ®×¹ïgoup¤Îother¤§¼g¤JÅv¤O¨ÌÂÂ¥¼¥´¶}¡A§Y¨Ï/home/woody/test/kerm¤¹³\¼g¤J¡A¤@¯ëUser¨ÌµM¥u¯à­×§ïkerm¤º®e¡A¦ÓµLªkrm kerm¡CYou can try on that !!

¡@

¡@

¡@

¡@

chmod {a, u, g, o}{+,-}{r,w,x} filename(¬Û¹ïªí¥Üªk)

or

chmod x1x2x3 filename(µ´¹ïªí¥Üªk)

¨ä¤¤

a¡G©Ò¦³User

u¡GÀÉ®×¾Ö¦³ªÌ

g¡G¸s²Õ

o¡G¨ä¥LUser

+¡G¼W¥[Åv¤O

-¡G´î¤ÖÅv¤O

r¡GŪ¨ú

w¡G¼g¤J

x1x2x3¡Gx1¡Bx2¡Bx3§¡¬°¡§¤T­Ó¤G¶i¦ì¼Æ¦r©Ò²Õ¦¨¤§¤Q¶i¦ì¼Æ¦rªí¥Ü¡§¡]½d³ò0~7¡^¡Ax1ªíownerÅv­­¡Ax2ªí¸s²ÕuserÅv­­¡Ax3«hªí¨ä¥LUser¤§Åv­­¡C¨Ò¦p755 (=111 101 101)ªí¥ÜÀɮצs¨úÅv­­¬°: rwx r-x r-x¡C

¡@

cc301:~/test> ls -l kerm

-rwxr-xr-x 1 woody users 164 Feb 4 14:49 kerm*

cc301:~/test> chmod g+w,o-x kerm (= chmod 774 kerm)

cc301:~/test> ls -l kerm

-rwxrwxr-- 1 woody users 164 Feb 4 14:49 kerm*

cc301:~/test>

¡@

¡@

¡@

¤F¸Ñ¤@¯ëUNIXÀx¦sÀɮתº²ßºD¡A¤£¶È¦³§U©ó¨Ï¥ÎªÌÀô¹Ò³]©w¡A¦P®É¹ï©óºÞ²zªÌÀ³¦p¦ó¦w±Æ¦UºØ¦Û«Ø¥Ø¿ýªº©Ò¦b¡A¤]¬O«D±`­«­n¡C¨Ò¦p±N¨Ï¥ÎªÌ¥Ø¿ý¸m©ó/etc¤U«K¬O¬Û·í¤£´¼¡]¤j·§¤]³¡·|¦³¤H³o»ò§@§a!?¡^¡C¥H¤U¬OUNIXÀɮרt²Îªºlayout¡AÀHµÛ¦U­Ó¼t°Óª©¥»¤£¦P¦P¡A·|¦³¨Ç³\®t²§¡A¦ýÁ`¬O¤K¤E¤£Â÷¤Q¡C

¡@

Àx¦s¤@¯ë¨Ï¥ÎªÌ¨Ï¥Î«ü¥O(¦p: ls ¡Bcd¡Brm¡Bmore¡Bcat ¡K)¤Î¤u¨ãµ{¦¡(¦p:vi¡Bmail¡Bawk¡K)¡C¤@¨Ç¸û·sªº¨t²Î¬°©úÅã¦a»PºÞ²z«ü¥O§@¤@°Ï¹j¡A§¡¥H/usr/bin¨ú¥N¤§¡A¦Ó/bin«h¶È¥H«ü¦V/usr/bin¤§¤è¦¡¦s¦b¡C

¡@

Àx¦s¯S®íÀɮסC¦pterminal¡Bhard disk¡Btape¡Bprinterµ¥¡C

¡@

Àx¦s¨t²ÎºÞ²z©Ò»Ý«ü¥O(¦p:mount¡Bfsck¡Bshutdown¡Breboot¡Bwall¡K)¤Î¨t²Î¬ÛÃö¤§³]©wÀÉ®×(¦p:rc.local¡Binetd.conf¡Bsyslog.conf¡Bresolv.conf¡K)¡C¸û·sªº¨t²Î«h±N²Ä¤@³¡¥÷(ºÞ²z«ü¥O)²¾¦Ü/usr/sbin¡A¦Ó¥u«O¯dsymbolic link©ó/etc¥Ø¿ý¤¤¡C

¡@

´X¥G¨C¤@ºØunix§@·~¨t²Î¤¤§¡¦s¦b¦¹¤@¥Ø¿ý¡A¦¹¤@¥Ø¿ýÀx¦sªº¬O¦]ºÏºÐ¿ù»~©Î¤£¥¿±`Ãö¾÷©Ò²£¥Í¡¨µL¥DÀɮס¨(©Î©Ò¿×lost files)¡A¦¹¥Ø¿ý¤¤¤§Àɮפ@¯ë¬O¨t²Î±Ò°Ê®É¡A¥Ñfsck©Ò²£¥Í¡C

¡@

¼È¦s¥Ø¿ý¡C¤@¯ë¤¹³\¨Ï¥ÎªÌ±N¼È¦sÀÉ®×¼g¤J¡A¦ÓºÞ²zªÌ³q±`¥²¶·©w´Á²M°£¦¹¥Ø¿ý¤¤¤§ÀɮסA¨t²Î±Ò°Ê®É¤]·|¡]À³¡^¦Û°Ê²M°£¦¹¤@¥Ø¿ý¤§©Ò¦³ÀɮסC

¡@

¥D­nÀx¦s¨t²Î¤¤¤º®eÀH®É¥i¯àÅܰʪºÀɮסA¨Ò¦pAccounting¸ê®Æ(/var/adm)¡BE-Mail queue(/var/spool/mqueue)¡BJob Schedule File - cron ¡K

¡@

¦­´ÁUNIX±MÄÝ©óºÞ²zªÌ¤§¥Ø¿ý¡A·sªñª©¥»¤§UNIX§¡¤w±N¦¹¥Ø¿ý²¾¦Ü/var/adm¤§¤U¡C(¤@¯ë¤´«O¯dlink)

¡@

¤@¨Ç¸û·sªº¨t²Î¬°©úÅã¦a»PºÞ²z«ü¥O§@¤@°Ï¹j¡A§¡¥H/usr/bin¨ú¥N/bin¡A¥Î¥HÀx¦s¤@¯ë¨Ï¥ÎªÌ¨Ï¥Î«ü¥O(¦p: ls ¡Bcd¡Brm¡Bmore¡Bcat ¡K)¤Î¤u¨ãµ{¦¡(¦p:vi¡Bmail¡Bawk¡K)¡C

¡@

C»y¨¥¤§header file(¦p¡Gstdio.h¡K)

¡@

¼Ð·ÇC»y¨¥¤§¤½¥Îµ{¦¡®w¡]¦p¡Glibw.a ¡Blibc.a¡K¡^

¡@

ºÞ²zªÌ¦Û¦æ¦w¸Ë¡A«D§@·~¨t²Î¼t°Ó©Ò´£¨Ñ¤§³nÅéµ{¦¡©Î»y¨¥(§t¤½¥Î¤§Shell Script)¡C¡]Conventionally¡^

¡@

½u¤W¨D§U¡]Online Help¡^¸ê®ÆÀÉ¡C

¡@

UNIXµ{§Ç(process)

¡@

UNIX§@·~¨t²Î¤¤¡Aprocess«üªº¬O¤@­Ó¨ã¦³¿W¥ß°O¾ÐªÅ¶¡¡B¥i³æ¿W¹B§@ªº¡¨¤u§@ªÅ¶¡¡¨¡A²z½×¤W¨C¤@­Ó«ü¥O§¡·|¥Ñ¤@­Ó¤£¦Pªºprocess§¹¦¨¡A¥²­nªº®É­Ô¡Aprocess¥i¥H¦Û¦æ²£¥Í(fork)¤@­Ó¥þ·sªº¤lµ{§Ç(Child process)¡A¥H¨ó¤O§¹¦¨©Ò¦³³Q«ü©wªº¤u§@¡C

UNIX¨t²Î¤¤±Ò°Ê«á³Q¥s°_²Ä¤@­Óµ{§Ç¬°init (process id¬°1)¡AÂǥѷs¨t²Îµ{§Çªº²£¥Í¡Aºc¦¨¤@­Ó¥\¯à§¹¾ãªº§@·~¨t²Î¡C¨C¤@rocess¦b§¹¦¨¤u§@¤§«á·|¦Û°ÊÄÀ©ñ©Ò¦³¦û¥Îªº¨t²Î¸ê·½¡Aµ²§ô¨Ã¨t¶}¨t²Î¡C

UNIX¨C¤@­Óµ{§Ç³£¦³¤@­Ó°ß¤@ªºÃѧO¥N¸¹¡A§Ú­ÌºÙ¤§¬°µ{§Ç¥N¸¹(process id or pid)¡Apid¬O¤@­Ó«ü¦Vµ{§Ç¸ê®Æ(process information)°Ï°ìªº«ü¼Ð¡A©Ò¦³¸g¥Ñshellªºprocess operation (or process management)§¡»Ý³z¹L¦¹¤@¥N¸¹§@¬°°Ñ¼Æ¡C

ps ³o­Ó«ü¥OÅý§A¥i¥HÀH®Éª¾¹D¨t²Î¤¤¦³­þ¨Çµ{¦¡¡]every program in unix is a ¡§process¡¨¡^¥¿¦b°õ¦æ¡A¤Î°õ¦æªºª¬ªp¡]¥]¬A¤w¨Ï¥Îcpu¤§®É¶¡¡B¤w³r¯d¦b¨t²Îªº®É¶¡¡B¨Ï¥Î°O¾ÐÅ骬ªp¡Aµ¥µ¥¡^¡C§Q¥Î¥L¡A§Ú­Ì¥i¥Hª¾¹D¨t²Î¤¤©Ò¦³processªºid¡A¾Ú¦¹§Ú­Ì¥i¥H¡§³B¥÷¡§©Ò¦³¥¿¦b°õ¦æ¡AÄÝ©ó¦Û¤v©Î¨ä¥Luser¡]¦pªG§A¬Osuperuserªº¸Ü¡^ªºµ{¦¡¡C¡]¨Ò¦p²¾°£¡B¼È°±°õ¦æ¡B«ì´_°õ¦æ¡B´£°ª¡þ­°§Cµ¥¯Å¡^

¡@

Example: ¹î¬Ý¥Ø«e¨Ï¥ÎªÌ¤§µ{§Ç

woody@audi: ~ 7 >/usr/ucb/ps -lu

USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND

woody 24563 0.1 0.6 1228 1012 pts/1 S 18:32:07 0:00 -tcsh

¡@

Example: ¹î¬Ý¥Ø«e©Ò¦³µ{§Ç

woody@audi: ~ 8 >/usr/ucb/ps -aux

USER PID %CPU %MEM SZ RSS TT S START TIME COMMAND

root 150 2.1 8.2 1783215648 ? S Oct 11 585:36 /usr/sbin/rpc.nisd

root 3 0.8 0.0 0 0 ? S Oct 11 86:28 fsflush

root 140 0.8 1.0 2828 1820 ? S Oct 11 14:56 /usr/sbin/rpcbind

root 24778 0.4 0.5 1040 876 pts/1 O 18:38:31 0:00 /usr/ucb/ps -aux

root 24774 0.3 0.8 2148 1448 ? S 18:38:26 0:00 /usr/lib/sendmail

root 205 0.3 3.7 12644 7068 ? S Oct 11 23:36 /usr/sbin/nscd -S

root 18135 0.2 0.5 1832 804 ? S Oct 13 22:25 /WWW/cern_httpd_3.

root 24770 0.2 0.5 1316 972 ? S 18:38:13 0:00 rquotad

¡K.

¦b¥H¤U¤TºØ±¡§Î¤§¤U¡A·|³y¦¨¤@­Óprocessµ²§ô°õ¦æÂ÷¶}¨t²Î¡G

1.process§¹¦¨©Ò¦³À³§¹¦¨¤§¤u§@¡A¦ÛµMµ²§ô¡C

2.parent processµ²§ô°õ¦æ¡A©Ò¦³³o­Óprocess©Ò­l¥Íªºchild process·|¸òµÛµ²

§ô¡AÂ÷¶}¨t²Î(¤£ºÞ¬O§_¤w§¹¦¨¤u§@¡F¥Hnohop°õ¦æªºprocess¨Ò¥~)¡C

3.¥H¡¨kill¡¨«ü¥O±j¨îµ²§ôªºprocess¡C(For this, you must be a superuser or owner

of the process)

¨t²ÎÃö¾÷®É¡A·|¥H²Ä¤TºØ¤è¦¡µ²§ô©Ò¦³¥¿¦b¨t²Î¤¤°õ¦æªºµ{§Ç¡A¥HÁ×§K¨t²Î©ÎÀɮרt²Î¾D¨ì·lÃa¡C

¡@

Example:

woody@audi: ~ 32 >ps -ef | grep woody

owner PID PPID

woody 29715 29713 0 12:05:56 pts/1 0:01 -tcsh

woody 24196 24195 0 09:48:49 pts/2 0:00 rsh benz uptime

woody 24193 23090 0 09:48:48 pts/2 0:00 /bin/sh all uptime

woody 24202 23090 0 09:49:03 pts/2 0:00 grep woody

woody 24195 24193 0 09:48:49 pts/2 0:00 rsh benz uptime

woody 23090 23088 0 09:17:58 pts/2 0:01 ¡Vtcsh

woody@audi: ~ 33 >kill -9 24193

woody@audi: ~ 34 >stty: : Invalid argument

9:49am up 27 day(s), 20:28, 4 users, load average: 0.06, 0.03, 0.03

¡@

[1] Killed all uptime

woody@audi: ~ 34 >ps -ef | grep woody

woody 29715 29713 0 12:05:56 pts/1 0:01 -tcsh

woody 23090 23088 0 09:17:58 pts/2 0:01 -tcsh

woody@audi:~

¡@

¥H¤W¨Ò¤l:

process 24193ªºµ²§ô¬OÄÝ©ó²Ä¤TºØ¤è¦¡¡]±j¨îµ²§ô with ¡§kill¡¨¡^

process 24195 ¤Î24195 ªºµ²§ô¬OÄÝ©ó²Ä¤GºØ¤è¦¡(Stop after PPID)

process 24202ªºµ²§ô«h¬OÄÝ©ó²Ä¤@ºØ¤è¦¡(¤u§@§¹¦¨¡A¦ÛµMµ²§ô)