1 / 17

Linux_20140324 檔案查看及 編輯

Linux_20140324 檔案查看及 編輯. http://ihsumlee.bounceme.net. http:// ihsumlee.bounceme.net. 打開 virtualbox -> 啟動 Fedora-> 啟動伺服器網路 • 查詢電腦 ip : 命令提示單元 -> ipconfig (windows) • 利用 pietty 以 root 登入 伺服器. 麻煩查看 / var /log/ dmesg. cat 檔案 : 查看檔案 cat –n 檔案 : 查看檔案 + 行號

fayre
Download Presentation

Linux_20140324 檔案查看及 編輯

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. Linux_20140324檔案查看及編輯 http://ihsumlee.bounceme.net

  2. http://ihsumlee.bounceme.net • 打開virtualbox->啟動Fedora->啟動伺服器網路 • •查詢電腦ip: 命令提示單元-> ipconfig (windows) • •利用pietty以root登入伺服器

  3. 麻煩查看 /var/log/dmesg • cat 檔案: 查看檔案 • cat –n 檔案: 查看檔案+行號 • head –n 行數 檔案 :查看檔案前面n行 • tail –n 行數 檔案:查看檔案後面n行 • more 檔案 : 以分頁模式查看檔案 • less 檔案: 以分頁模式查看檔案+搜尋字串功能 q: 離開, /字串:查詢字串, n:向下查詢, N:向上查詢

  4. 麻煩查看 /var/log/dmesg

  5. 找sendmail的字串 • 麻煩告訴我,sendmail字串在/root/install.log中的第幾行? • cat -n install.log | grepsendmail

  6. 5-6 文字編輯器vim • 所有UNIX與Linux都內建的文字編輯器 • 只要學好vim,在任何Linux都能夠利用它來編輯文字檔案

  7. 5-6 文字編輯器vim • 重要的三個模式 cd vim test

  8. 5-6 文字編輯器vim • 一般模式(Common mode) • 可以使用具有特殊意義的按鍵 • 在文件內容中移動、刪除、複製、貼上等功能 • 在一般模式中,按下i、o或a鍵可以進入編輯模式 • 按下冒號「:」則會進入命令模式 • 編輯模式(Insert mode) • 按下內容會新增在文件游標所在處 • 像打字一樣,按鍵不再具有特殊意義 • 按下[ESC]鍵可回到一般模式

  9. 5-6 文字編輯器vim • 命令模式(Command line mode) • 可以儲存、開啟檔案、結束vi、取代特定文字等檔案處理功能 • 按下ESC鍵可回到一般模式 • 觀察左下方是否出現「:」冒號

  10. 5-6 文字編輯器vim • 一般模式下的功能按鍵 • 瀏覽文件 • 利用以下按鍵,我們可以在vi內瀏覽文件內容: • h:游標向左移,與[左鍵]的功能相同。 • j:游標向下移,與[下鍵]的功能相同。 • k:游標向上移,與[上鍵]的功能相同。 • l:游標向右移,與[右鍵]的功能相同。 • PageUp:游標向上一頁 • PageDown:游標向下一頁 • G:游標移到文件最後一行。 • gg:游標移到文件第一行。

  11. 5-6 文字編輯器vim • 一般模式下的功能按鍵 • Ctrl+g:顯示游標目前位置的資訊,包括第幾行,第幾個字元,位於文件中的百分比。 • 顯示行號:按下冒號後,打入set nu • 取消顯示行號:按下冒號後,打入set nonu • 複製游標所在該行 • p:將先前複製的內容,貼在游標所在下行,原文字會往下移 • dd:刪除游標所在行,原該行下方資料往上移。 • u:復原上次做的更動 • .:重覆上一個動作

  12. 5-6 文字編輯器vim • 命令模式功能 • 開啟另一個檔案 :o 檔案名稱 • 儲存目前內容 :w • 將目前編輯內容另存為其他檔案 :w 檔名 • 離開q • 不存檔離開q!

  13. 本章結束 Q&A討論時間

  14. 以root登錄,建立一個資料夾dir1,在dir1下建立個檔案file1,file2以root登錄,建立一個資料夾dir1,在dir1下建立個檔案file1,file2 • 分別建立file1及file2軟連結及硬連結在家目錄中 • 查看目前硬碟及目錄容量大小 • 利用管線命令 | 查詢/usr/bin的分頁檔案 • 利用find查詢sendmail.mc的位置 • 查詢比file1還新的檔案.

  15. 使用cat看/var/log/messages ,並以有行號表示 • 使用head看/var/log/messages看前5筆資料 • 使用tail看/var/log/messages看後10筆資料 • 使用分頁模式看/var/log/messages

  16. 使用vim開啟一個新檔 newfile • 在編輯模式下輸入 This is just a test file for practicing vim editor. It is including edit, write, and so on. Gogogo!!! • 複製第一行放在第二和第三行中。

More Related