1 / 17

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 清除整列指令.

demont
Download Presentation

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) • pwd • 顯示目前的目錄 • cd • 變換目錄 • rmdir • 刪除一個空的目錄 • rm • 刪除一個檔案或目錄 • 語法 rm [-fir] 檔案或目錄 • 參數說明 • -f強制移除(force) • -i詢問同意動作(interactive) • -r遞回動作(recursive,刪除目錄及目錄下之子目錄)

  6. 目錄指令(2/2) • mkdir • 建立一個新的目錄 • cp • 複製檔案或目錄 • 語法 cp [-adpr] 來源檔 目的檔 • 參數說明 • -a等同於-dpr • -d若來源檔為連結檔屬性,則複製連結檔屬性而非檔案本身 • -p連同檔案的屬性一起複製,而非使用預設的屬性 • -r遞回動作

  7. 練習 • 新增一個目錄(名稱自取)。例如OS • 更換路徑到目錄(OS)中 • 顯示目前路徑 • 新增一個目錄test • 刪除一個目錄

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

  9. 檔案指令 • ls • 顯示目錄的內容(List) • 參數說明 • -a顯示所有的檔案和目錄,但不含現行與上層目錄 • -l詳細資料(Long Format) • -f在檔名後面,列出檔案型態 • cat • 顯示檔案內容 • 語法 cat [參數] 檔名 • 參數說明 • -b列出行數,空白行除外 • -n列出行數,包括空白行

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

  11. 檔案指令 • mv • 移動檔案、更改檔名 • 語法 mv [-fiu] 來源 目的 • 參數說明 • -f強制移除(force) • -i若檔案存在,詢問是否覆蓋 • -u若檔案存在,來源比較新時,才會更新(update) • head • 顯示檔案內容的前面行數 • 語法 head –行數 檔案 • tail • 顯示檔案內容的最後行數 • 語法 tail –行數 檔案

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

  13. 檔案權限 • 檔案權限說明 • 檔案類型 • d目錄 • -檔案 • l連結檔(link file) • b裝置檔裡面的可供儲存的周邊設備 • c表示為裝置檔裡面的序列埠設備

  14. 檔案權限 • 權限的意義 • 目錄檔案 • r 可讀取目錄內記錄的檔名 • w 可在該目錄內建立/刪除檔名 • x 可進入該目錄 • 一般檔案 • r 可讀取該檔案的內容 • w 可修改/編輯檔案的內容 • x 可執行該檔案

  15. 檔案權限 • 權限的應用 • 進入某目錄成為『可工作目錄』的基本權限 • 使用者可進入該目錄需具備 x 權限 • 使用者可在該目錄查閱檔名,需具備 r 權限 • 建立一個檔案的基本權限 • 使用者在該目錄要具有 w,x 的權限 • 進入某目錄並執行該目錄下的某個指令 • 使用者在該目錄至少要有 x 的權限 • 使用者在該檔案至少需要有 x 的權限

  16. 檔案指令(3/3) • chmod • 檔案權限的修改 • 語法 • 符號法 • 數字法 • rwx • 421 • 範例 • 讓所有人都可以執行 test.exe 程式 >> chmod a+x test.exe

  17. 練習 • 查看OS資料夾中所有檔案屬性。 • 將user.txt的屬性改為rwxrwxr-x • 將file.txt的屬性改為rwx------

More Related