UNIX §@·~Àô¹Ò¬[ºc

 

 

UNIX ªº¯S¦â¡G¤å¦r¤¶­±¡A¦h¤H¦h¤u¡Aºô¸ô§@·~

¤å¦r¤¶­±ªº·N«ä,¬O»¡¨Ï¥ÎªÌ¥D­n¹ï UNIX ¨t²Î©Ò¤U¹Fªº«ü¥O¬OÂǥѤå¦r¤Æªº«ü¥O²Å¸¹¡C(UNIX ©³¤Uªº X-window ®à­±¤WÁöµM¥i¨£¨ì¤@¨Ç¹Ï¥Ü¡A¦ý¨º¥D­n¬O¥Î¨Óµo°ÊÀ³¥Î³nÅé¡A»P¹ï§@·~¨t²Î¤U¥O¤´¦³¼h¦¸¤Wªº¤£¦P) Unix ªº¤å¦r«ü¥O¡A³£¬O¤@¨Ç«ü¥O­^¤åªºÁY¼g¡A¥H¤è«K´î¤ÖºVÀ»Áä½Lªº¦¸¼Æ¡C¦p cp (copy)¡Bls (list) µ¥¡C(¨t¤W¶R¤F¤£¿ùªº UNIX «ü¥OÃã¨å¡A¦b­pºâ¹êÅç«Çºô­¶¤W¡A½Ð¦h¦h§Q¥Î¡C)

¦h¤H¦h¤u¡A¬O«ü¦P¤@®É¶¡¨t²Î¥i¥H¦³¦h¦ì¨Ï¥ÎªÌ¨Ï¥Î¡A¥B¶i¦æªº¤u§@¥i¥H¬O¦h¶µ¤u§@¦P®É¶i¦æ¡C¦³¨Ç§@·~¨t²Î¬O³æ¤H³æ¤u¡A¦p¦­´Áªº DOS¡A¦³¨Ç¬O³æ¤H¦h¤u¡A¦p Windows¡A¤@­Ó¨Ï¥ÎªÌ¡A¥i¥H¤@Ãä¼½©ñ¼v­µ´CÅé¡A¤@Ãä³B²z¤å®Ñ¡C¦h¤u¬O²{¥N§@·~¨t²Î°_½Xªº­n¨D¡A¦]¬°µwÅé®Ä¯à°÷¦n¡A¤£³o¼Ë°µ«h¤u§@·|«Ü¨S¦³®Ä²v (¹L¥hªº¹q¸£µwÅé«h¬O¤£°÷¤j¨ì¾A¦X°µ¦h¤u)¡F¦Ó¦h¤H«h¬O¹q¸£¨t²Î­n°µ¬°¤½¥Î¸ê·½«h§Ú­Ì¬°§@·~¨t²Îªº°ò¥»­n¨D¡C¹L¥h¶] UNIX ªº¤j¹q¸£¡A³£¤£¬O¡©­Ó¤H¡ª¹q¸£¡C

µù¡G¦h¤u (multi-tasking) ¬O§Q¥Î CPU ¤À®É (time-sharing) ªº§@ªk¹F¨ìªº¡A¤]´N¬O»¡¡A¹q¸£ªº³B²z¾¹¦b¬Y¤@¤p¬q®É¶¡´À¬Y­Ó¤u§@¹B§@¡A¦Ó¤U¤@­Ó¤p®É¬q¤S´À¥t¤@­Óµ{¦¡¹B§@¡A¦ý¥Ñ©ó CPU °Ê§@«Ü§Ö¡A¦]¦¹¨Ï¥ÎªÌ (¾Þ§@ªÌ) ¤£®e©ö·P¨ü¨ì¹q¸£¤ÏÀ³®É¶¡¦³©Ò©µ¿ð¡C

UNIX §@·~¨t²Îªº³]­p¤@¶}©l´N¥Hºô¸ô§@·~ªº¥XµoÂI°µ¦Ò¶q¡A¦]¦¹¦³§¹¾ãªººô¸ôÀô¹Ò¤Î¥\¯à¡C ³z¹Lºô¸ô¸ê·½¡A°£¤F¼Ð·Ç«ü¥O¥i¨Ñ¨Ï¥ÎªÌ¦b¨ú»·ºÝÀɮפζi¤J»·ºÝ¨t²Î¥~ (¦p ftp¡Atelnet)¡A¥t¦³¾ãÅéºô¸ôªº¬[ºc¡A¥i¥H§â¨Ó¦Û¤£¦P¥D¾÷ªº¸ê·½¥i¥H¾ã¦X¦b¤@°_ (¦p NFS¡ANIS) ¡C

 

 

Shell : §â§@·~¨t²Î¥]°_¨Óªº "´ß¤l"

¨Ï¥ÎªÌ¦bµn¤J¨t²Î«á¡A¨Ï¥ÎªÌ»P§@·~¨t²Î¤§¶¡ªº¤¶­±¡A³z¹L¹ï shell ¤U«ü¥O¡A§@·~¨t²Î·|°õ¦æ¨Ï¥ÎªÌ¥æ¥Iªº¤u§@¡C

UNIX ªø®É¶¡ªºµo®i¡A²£¥Í¥X¤£¦Pªº shell¡A¨ä¹ê¦b¤£¦Pªº shell ¤U¡A©Ò¦³ UNIX ªº«ü¥O¤´¬O§¹¥þ¤@¼Ëªº¡A¬G¤@¯ëªº¨Ï¥ÎªÌ¾Þ§@°Ê§@¤£·|¨ü¨ì¥ô¦ó¼vÅT¡C¤£¦Pªº shell ¥u¦³¦b³]©wÀô¹ÒÅܼƥH¤Î¦Û°Ê¤Æªº«ü¥O¦³©Ò¤£¦P¡A¥H UNIX «ü¥O°t¦XÀô¹ÒÅܼƤΦU shell ±M¦³ªº±±¨î«ü¥O©Òºc¦¨ªº¦Û°Ê¤Æµ{¦¡¡A¥s°µ shell script¡C

°ò¥» UNIX «ü¥O¤@¼Ë¡AÀô¹ÒÅܼƪº³]ªk¤£¦P¡A¦]¦¹¼g script ªº»yªk´N¦³¤£¦P¡C§Y¨Ï¬O±M®a¤@¯ë¤]¥u»Ý­n·|¼g¤@ºØ§Y¥i¡A¼g¥X¨Óªº script ¬O¯Â¤å¾Ç®æ¦¡¡A¦A°õ¦æ«e¥ý­n chmod u+x filename ¦¨¥i°õ¦æ¡C¬°¤F¬Ù¥h¥Î script «e­n¥ý¶i¤J¸ÓºØ shell ªº³Â·Ð¡A¥i¥H¦b script ªº²Ä¤@¦æ¼g¤J #!/bin/tcsh ¡AÁöµM±q script ªº»yªk¦Ó¨¥¡A¤Z¬O¤@¦æªº«e­±¦³¤«¦r²Å¸¹ hash mark, # ªº¡A³£·í§@¬Oµù¸Ñ¥Î¦Ó¤£¬O¦³®Äªº«ü¥O¡A¦ý¦b shell script ³oùجO¯S®í¥Îªk¡A¥Nªí¶]³o­Ó©Ò script ®É§@·~¨t²Î©ÒÀ³¸Ó±Ä¨úªº shell¡C

¥H "UNIX shell script" ¬°ÃöÁä¦r¨ìºô¸ô¤W§ä§ä¡A·|¦³«Ü¦h±Ð§÷¨Ñ¤JªùªÌ¾Ç²ß¡A¨Ò¦p¡G

SHELL SCRIPTING ±Ð¾Ç»P¤ß±o http://www.mgt.ncu.edu.tw/~dino/script/

shellªº¤¶²Ð¤Î shell script programming http://www.mgt.ncu.edu.tw/~dino/unix/

UNIX Shell Programming (Borne Shell or /bin/sh) http://nmc.nchu.edu.tw/linux/shell_lspace.htm

ºô¸ô¹A¤Ò UNIX C Shell http://netlab.cse.yzu.edu.tw/~statue/freebsd/docs/csh/

²©öªº Shell Scripts
http://hw-driver-bal.nctu.cc:52833/pub/slime/tutorial/20060312-08.pdf

 

 

Àɮרt²Î»P¹êÅé¶J¦s¸Ë¸m

¥Ø¿ý¾ð

¤j®a¹ï©ó¾ðªKª¬¥Ø¿ýµ²ºcÀ³¸Ó¬O¼ô±xªº¡A¤Z¬O·Q­n¥H²M·¡¤ÀÃþ¬°¥Øªº¨Ó¦s©ñª«¥óªº³]­p¡A¦ÛµM·|¥Î¨ì¾ðª¬µ²ºc¡C

 

®Ú¥Ø¿ý¡A¾ðª¬¥Ø¿ýªº³Ì³»ºÝ

/¡A³o­Ó²Å¸¹¥s±×½u¡]slash¡^¡A¤£­n»P DOS ±`¥Îªº¥t¦³¤@²Å¸¹¤Ï±×½u \ ¡]back-slash¡^²V²c¡C

 

±¾¸ü¹êÅé¶J¦s¸Ë¸m¦¨¬°¤@­Ó¥Ø¿ý

¨Ò¦p§A¦³²Ä¤GÁû IDE µwºÐ¡A¬G¦b Linux ¤Uªº¸Ë¸mÃѧO¥N¸¹¬O /dev/hdb¡A­YùØ­±¦³¨â­Ó¤À³Î°Ï /dev/hdb1 ¤Î /dev/hdb2¡A¦Ó§A·Q­nÅý /dev/hdb1 ¨ä¤Wªº¸ê®Æ·Q¥X²{¦b /my_2nd_drive ³o­Ó¥Ø¿ý¤U¡A«h§A¶·­n¥HºÞ²zªÌÅv­­¥ý¦b®Ú¥Ø¿ý¥Î mkdir «ü¥O·s«Ø /my_2nd_drive ¤§ªÅ¥Ø¿ý¦W¡AµM«á¤U mount /dev/hdb1 /my_2nd_drive «ü¥O¡C

 

ºô¸ôÀɮרt²Î¡]Network File System¡ANFS¡^

¨ä¹ê¡A³z¹Lºô¸ôªºÁpô¡A¹êÅé¶J¦s¸Ë¸m¤]¤£¤@©w­n¦b¥»¾÷¤W¡C¥ÑºÞ²zªÌ¤U mount 123.45.67.123:/souce_dir /target_dir ´N¥i¥H§â»·ºÝ¥t¤@¥x IP ¬O 123.45.67.123 ³o¥x¹q¸£ªº /source_dir ¥Ø¿ý±¾¦b¥»¦aºÝªº /target_dir ¥Ø¿ý©³¤U¡]·íµM¡A»·ºÝ¶·¥ý§â¤¹³\¥»¦aºÝ±¾¸ü¯S©w¥Ø¿ýªºÅv­­¦b /etc/exportfs Àɤ¤³]©w°_¨Ó¡^¡C

 

 

 

±`¨£ªº¨t²Î¥Ø¿ý¤Î¨ä¥\¯à

/etc

°P¦h¦Í²Î³]©w¦s©ñªº¦a¤è¡A¹³¨Ï¥ÎªÌ²M³æ»P±K½X¡]passwd »P shadow¡^¡B±`¾nµ{¦¡ deamon ²Õ ºA

 

/etc/initd.d

±`¾nªA°Èµ{¦¡ deamon ©ñ¸m¤§³B¡A¨t²ÎºÞ²zªÌ¦³®É¶·±Ò°Ê¡B°±¤î©Î­«·s±Ò°Ê±`¾nªA°È®É¡A´N­n¥Î¨ì©ñ¦b³oùتº script¡C ¨Ò¦p¡A­«·s±Ò°Êºô­¶ªA°È®É¡A­n¤U /etc/initd.d/httpd restart ¡C

/etc/rc.d

¤@­Ó§¹¾ãªº UNIX §@·~¨t²Î¦w¸Ë¥]§t¤F´X­Ó¥i¥H¹B¦æªº¼Ò¦¡¡A¹³¬O³æ¤HµLºô¸ô©Î¦h¤Hºô¸ô¡]³£¤@©w¬O¦h¤u¦h¤u¡^¡A©Î¦h¤H X-µøµ¡µ¥¡C¤£¦Pªº¹B¦æ¼Ò¦¡·|¦³¤£¦Pªº±`¾nµ{¦¡ªA°È¡A¨ä³]©w¤À§O¦s¦b¦¹¥Ø¿ý¤¤¡C¥t¥~¡A¶}¾÷«á¤@©w­n±Ò°Êªºµ{¦¡¤]³]©w¦b³oùØ¡A¦p rc.local¡C

 

/etc/httpd/

©ñ¸mºô­¶¦øªA¾¹¨ç¦¡®w¡]/etc/httpd/modules¡^¤Î³]©w¡]/etc/httpd/conf¡^ªº¥Ø¿ý¡A¨ä¤¤/etc/httpd/conf/httpd.conf Àɤºªº DocumentRoot ³]©w¥i«ü©wºô­¶ÂsÄý¾¹«ü¨ì³o¥x¦øªA¾¹®É¡A¨ä¹ïÀ³ªº¸ê®ÆªÅ¶¡¬O±q¨º¤@­Ó¥Ø¿ý¶}©lªº¡A¤]´N¬Oºô­¶ÀɮתŶ¡ªº®Ú¥Ø¿ý¦ì¸m¡C¡]§ï¹L«á°O±o­«·s±Ò°Êºô­¶±`¾nªA°È¤~·|¥Í®Ä¡C¡^

/lib¡B/usr/lib¡B/usr/local/lib¡B/usr/X11R6/lib

¦s©ñ¦Í²Î°Æµ{¦¡®w¡]¤S¥s¨ç¦¡®w library¡^ªº¹w³]¸ô®|¡CùØ­±ªºÀɮצW¦r³£ªø±o¹³ lib***.a ©Î lib***.so ³oºØ¼Ë¤l¡C§Ú­Ì¼gªºµ{¦¡­n¬O¦³¥Î¨ì³o¨Ç¨ç¦¡®wùتºªF¦è¡A«h½sĶ (compile) ®É´N­n¦h¤U -l*** °Ñ¼Æ¡]ª`·N¥Î -l ®É¡A¨ç¦¡®w¦WÀY§Àªº lib ¤Î .a ©Î .so ¤@©w­n²¤¥h¡A­Y¤£·Q¨Ï¥Î -l¡A¨ä¹êª½±µµ¹¨ç¦¡®w¥þ¦W¡A¬Æ¦Ü§¹¾ã¸ô®|¥þ¦W¤]¥i¥H¡^

¨t²Î¤Î½sĶ¾¹¤@¯ë·|©w /lib¡B/usr/lib ¬°¹w³]·j´M¨ç¦¡®wªº¸ô®|¡A­Y°Æµ{¦¡®w¦b¨ä¥L¸ô®|¤U¡A«h¥i³]LD_LIBRARY_PATH Àô¹ÒÅܼơ]¥H C shell csh ©Î tcsh¬°¨Ò¡A¤U setenv LD_LIBRARY_PATH your_library_full_path¡^¨Ó«ü©w¡C

/usr/X11R6/lib ±M©ñ»P X-µøµ¡¦³Ãöªº¹Ï§Î¨ç¦¡¡A§Ú­Ì½Òµ{¤¤¨Ï¥Î pgplot ®É·|¥Î¨ì¡C¨Ò¦p f77 -L/usr/X11R6/lib -lX11 ...

/var

/var ©³¤U±`©ñ¤@¨Ç¨t²ÎªA°È©Ò»Ý­n¼È¦s¤Î°O¿ýªºÀÉ®×

/var/yp

NIS ¡]¦W yellow page¡^µ{¦¡¤Î³]©wªº Maikefile ¦s¦b³B¡A±q¸Ó Makefile ¤º¥i§ä¨ì±N¦@¨É¤§±K½XÀɪº¦ì¸m¡A¦³»Ý­n·s¼W user ¤§ ID »P±K½X®É¡A¥u¶·¥HºÞ²zªÌ¨­¥÷¥ý½s¿è¸Ó¦@¨É±K½XÀÉ¡A¤§«á¦b /var/yp ¤U¥´ make §Y¥i¡C

 

/var/www/html

RedHat ©ñºô­¶ªº¹w³]¥Ø¿ý¡A¤]´N¬O "http://¾÷¾¹¦W" ªº°_ÂI¡A¥Ñ /etc/httpd/conf/httpd.conf «ü©w¡A¤]¥i¥H±q¨ä¤¤ªº DocumentRoot §ó§ï¨ä¥Ø¿ý¡C

 

/var/spool

¦C¦L¡B¶l¥ó«H½cµ¥»Ý­n¥ý±Æ¶¤¦A¾ã§å§@·~ªºªA°È¡A¨ä¼È¦sÀÉ¥ý©ñ¦b³oùØ

 

/var/log

¨t²Î¹B§@¤¤¦U³¡¤À³£·|²£¥Í¬ö¿ýÀÉ¡A¦p¤°»ò¤H¶i¨Ó¹L wtmp ¡]¤@¯ë¨Ï¥ÎªÌ¥Î last «ü¥O¨Ó¬Ý¡^¡B¹ï¥~©Î¦Û¥~¶Ç¶i©Î¶Ç¥X¤°»òÀÉ®× xferlog¡B¶}¾÷ªº¸Ë¸m±Ò°Ê¸ê°T¡C

/usr/local

¤@­Ó©ñ¸m±`¥Î¤§¤½¥Î¦@µ{¦¡ªº¥Ø¿ý

/opt

¥t¤@­Ó©ñ¸m±`¥Î¤§¤½¥Î¦@µ{¦¡ªº¥Ø¿ý

 

/home ©Î /usr/people

¤@¯ë¨Ï¥ÎªÌªº home ¥Ø¿ý¡A¥i©ñ¦U¨Ï¥ÎªÌ¦Û¤wªºªF¦è¡C¤£¦Pªº¾÷¾¹©Î¾÷ºc¥i³]¬°¤£¦P¡A¹³§Ú­Ì­pºâª«²z¹êÅç«Ç´N³]¦b /NFS_home/ ¤§¤U¡C ¤j®a°O±o¦³­n«O¯dªºªF¦è­n³Æ¥÷°_¨Ó¡C

 

/tmp

¼È¦s¥Ø¿ý¡AùØÀYªºÀÉ®×·|³Q©w®É¦Û°Ê²M°£¡]¦ý¥Ø¿ý´ß¤l¤£²M°£·|¯dµÛ¡A­n¤p¤ß§O»~§P¡^¡C/tmp ¦pªGº¡ªº¸Ü¡A¦³¨Çµ{¦¡¡A¹³ vi¡A·|¨S¿ìªk¹B§@¡C

 

/dev

¸Ë¸mªºÃѧO¥N¸¹Á`¥Ø¿ý

/mnt

³\¦h¥~±µ¸Ë¸mªº±¾¸üÂI¡A¹³¬O USB ÀH¨­ºÐ

 

/bin¡B/usr/bin¡B/usr/sbin¡B/usr/local/bin

©ñ¸m«Ü¦h«ü¥O¡]¥»¨­´N¬O¤pµ{¦¡¡^ªº¦a¤è

 

 

´X­Ó§äªF¦è¡B§ä«ü¥Oªº«ü¥O

find

whereis

which

env

 

 

Âà¸ü¤å³¹¡GUNIX ¦w¥þºc¬[ªº¤EÂI¸gÅç