選修 UNIX 入門的同學, 大都對 UNIX 感到陌生, 這感覺就好像到了外國一樣. 而要 熟悉陌生環境, 最好的方式就是用自己的眼睛去觀察, 用自己的手去觸摸. 也就是說修 這門課的同學要有動手做的精神. 首先各位必須先跨出第一步, 進入這陌生地, 也就是登入系統. 如同入境外國要先有 簽證, 要登入系統也要先有帳號及密碼. 但只有簽證並不能到外國, 你還要飛機或其他 交通工具(當然, 二隻腳也算), 而要登入系統你需要連線工具, 最常見的就是 telnet. 因此這第一步就是 telnet hostname. 連線成功後, 系統會要求你輸入帳號及密碼, 如同 海關會檢查你的護照及簽證一樣. --------------------------------------------------------------------------- klim@tima:~> telnet teto.csie.ncnu.edu.tw Trying 163.22.20.6... Connected to teto.csie.ncnu.edu.tw. Escape character is '^]'. SunOS 5.9 login: klim Password: Last login: Thu Sep 18 08:01:32 from tima.csie.ncnu. Sun Microsystems Inc. SunOS 5.9 Generic May 2002 klim@teto:~> PS1='$ ' $ --------------------------------------------------------------------------- 可以有 VIP 的待遇快速通關嗎? 哦, 是有方法可以讓你不用輸入帳號及密碼就進入系 統, 但請累積點數成為 VIP 時再說. 一旦登入成功後, 系統會印出提示符號, 然後等待你輸入命令. (Sir, your command?) 如上例中所示. 為方便下面的敘述, 上例中先把提示符號改成最陽春的錢號. (大家都缺錢, 不是嗎?) 以上就是你的下一步, 接下來你可以作什麼呢? 先四處看看再說, 這裡有那些東西呢? ls: listing directories --------------------------------------------------------------------------- $ ls 1013mdsc/ eclip92f.gif misc/ tmp/ Desktop/ gprolog-1.3.0/ music/ tree-embed/ ...... $ --------------------------------------------------------------------------- 這個鬼東西是啥? file: determine the type of a file --------------------------------------------------------------------------- $ file eclip92f.gif eclip92f.gif: GIF image data, version 87a, 479 x 640 $ file misc misc: directory $ --------------------------------------------------------------------------- 到別的地方看看. cd: change directory --------------------------------------------------------------------------- $ cd tree-embed $ ls pat t1.t t2.t t4.p t5.t tree-embedding.txt treeNoSave.py* t.py* t2.p1 t3.p t4.t t6.p tree.py* treeSaved.py* t1.p t2.p2 t3.t t5.p t6.t treeBin.py* $ --------------------------------------------------------------------------- 這東西裡面裝什麼? cat: dump the content of a file to stdout (your screen) --------------------------------------------------------------------------- $ cat tree.py #!/usr/bin/env python import string ########################################## # # tree's definition and its functions # ########################################## class Node: def __init__(self, label): self.val = label self.children = [] ...............................(many lines omitted) $ --------------------------------------------------------------------------- 哇, 螢幕捲太快了! more: show the contents of a file page by page less: more or less, these two commands do the same thing. --------------------------------------------------------------------------- $ more tree.py .... (try and you will know) $ less tree.py .... (try and you will know) --------------------------------------------------------------------------- 糟糕, 現在是在那裡? pwd: print current working directory 上一層怎麼走? (back to the parent directory) cd .. --------------------------------------------------------------------------- $ pwd /home/klim/tree-embed $ cd .. $ pwd /home/klim $ --------------------------------------------------------------------------- 回家吧! (go to home directory) just type `cd' --------------------------------------------------------------------------- $ cd tmp/lupu $ pwd /home/klim/tmp/lupu $ cd $ pwd /home/klim $ --------------------------------------------------------------------------- 肚子餓了. eat --------------------------------------------------------------------------- $ eat bash: eat: command not found $ --------------------------------------------------------------------------- 男人都跑那去了? man: show the manual of a command Please try: `man ls', `man man' 下次再逛吧! (登出) logout, exit, or just type ^D