1 / 19

Unix 指令 1

Unix 指令 1. 連上遠端主機 ssh(2/2). putty 載點 http://putty.cs.pu.edu.tw/download.html 詳細說明 http://ph302.cs.pu.edu.tw/putty.htm. 線上查詢指令. who 印出正在使用系統的使用者 finger 顯示特定使用者的資訊 date 顯示日期和時間 clear 清除螢幕 echo 重覆輸出自己的變數 man command-name 指令查詢. 快速鍵. Crtl+c 中斷正執行的程式 Ctrl+u 清除整列指令.

verdad
Télécharger la présentation

Unix 指令 1

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Unix 指令1

  2. 連上遠端主機 ssh(2/2) • putty載點http://putty.cs.pu.edu.tw/download.html • 詳細說明http://ph302.cs.pu.edu.tw/putty.htm

  3. 線上查詢指令 • who • 印出正在使用系統的使用者 • finger • 顯示特定使用者的資訊 • date • 顯示日期和時間 • clear • 清除螢幕 • echo • 重覆輸出自己的變數 • man • command-name 指令查詢

  4. 快速鍵 • Crtl+c • 中斷正執行的程式 • Ctrl+u • 清除整列指令

  5. 目錄指令(1/2) • ls • 顯示目錄的內容(List) • 參數說明 • -a顯示所有的檔案和目錄,但不含現行與上層目錄 • -l詳細資料(Long Format) • -f在檔名後面,列出檔案型態 • pwd • 顯示目前的目錄 • cd • 變換目錄 • mkdir • 建立一個新的目錄

  6. 目錄指令(2/2) • rmdir • 刪除一個空的目錄 • rm • 刪除一個檔案或目錄 • 語法 rm [-fir] 檔案或目錄 • 參數說明 • -f強制移除(force) • -i詢問同意動作(interactive) • -r遞回動作(recursive,刪除目錄及目錄下之子目錄) • cp • 複製檔案或目錄 • 語法 cp [-adpr] 來源檔 目的檔 • 參數說明 • -d若來源檔為連結檔屬性,則複製連結檔屬性而非檔案本身 • -p連同檔案的屬性一起複製,而非使用預設的屬性 • -r遞回動作 • -a等同於-dpr

  7. 新增/寫入檔案 • touch • 新增一個空白檔案 • touch test.txt • > • 將輸出資料寫成新檔案 • date > date.txt • >> • 將輸出資料寫入舊檔案中(不覆蓋) • date >> date_old.txt

  8. 檔案指令(1/3) • cat • 顯示檔案內容 • 語法 cat [參數] 檔名 • 參數說明 • -b列出行數,空白行除外 • -n列出行數,包括空白行 • head • 顯示檔案內容的前面行數 • 語法 head –行數 檔案 • tail • 顯示檔案內容的最後行數 • 語法 tail –行數 檔案

  9. 檔案指令(2/3) • mv • 移動檔案、更改檔名 • 語法 mv [-fiu] 來源 目的 • 參數說明 • -f強制移除(force) • -i若檔案存在,詢問是否覆蓋 • -n若檔案存在,則不覆寫

  10. 練習1 • 新增一個目錄Root_dir • 新增一個檔案Leaf_Class.txt • 將檔案LeafClass.txt更換路徑到目錄(Root_dir)中 • 顯示目前使用路徑 • 僅刪除一個目錄內的所有資料,不刪除目錄

  11. 練習2 • 利用echo與 >指令將自己的學號寫入OS/sid.txt中 • 將日期(date)、目前路徑(pwd)寫入sid.txt。

  12. 練習3 • 複製sid.txt檔案,新檔名為file.txt。 • 將詳細目錄內容(檔名屬性)寫入file.txt。 • 將線上使用者清單寫入sid.txt。 • 新增一個空的temp.txt檔案,將sid.txt的前10行(head)內容寫入temp.txt中。 • 將sid.txt重新命名為user.txt。 • 刪除temp.txt檔案。

  13. 鏈結(捷徑)(1/6) • ln • 語法 • ln <參數><來源目標><目的目標> • 參數說明 • -f : 檔案如果已存在則刪除原檔案後建立hard link • -s : 建立Symbolic Link • 範例 :ln –s src_filedest_file

  14. 鏈結(捷徑)(2/6) • 什麼是 Block ? 什麼是 inode ? • Block是紀錄「檔案內容資料」的地區 • inode則是紀錄「該檔案的屬性、及該檔案放置在哪一個Block之內」的資訊

  15. 鏈結(捷徑)(3/6)

  16. 鏈結(捷徑)(4/6) • Hard Link (硬式連結或實際連結) • 在某個目錄下新增一個該檔案的關連資料 • i-node與來源檔案相同 • 最大的好處就是『安全!』 • 不管哪一個檔案被刪除了,其實僅是移除一筆目錄底下的檔案關連性資料(i-node table)

  17. 鏈結(捷徑)(5/6) • Symbolic Link (符號連結,亦即是捷徑) • 建立一個獨立的檔案(i-node會不同) • 當來源檔被刪除之後,symbolic link 的檔案會『開不了』

  18. 鏈結(捷徑)(6/6)

  19. 練習4 • 請將Root_dir/Leaf_Class與Linkroot_dir/Linkleaf_hard建立hard link • 請將Root_dir /Leaf_Class與Linkroot_dir/Linkleaf_Sym建立Symboliclink

More Related