110 likes | 239 Vues
Basic Command. 李爵樺. Kenduest@mail.cynix.com.tw. Basic Command(1). login 登入系統 (注意大小寫) logout 登出系統 dmesg 察看開機的訊息 (按 shift+PageUp、Shift+PageDown 翻頁) su 切換成為 root 系統管理員 一般使用者切換成為其他身份使用者需要輸入該欲切換 使用者密碼。若是執行者為 root 系統管理員的話,則 不需要輸入密碼即可切換。 使用方式: su –l [userid]
E N D
Basic Command 李爵樺 Kenduest@mail.cynix.com.tw
Basic Command(1) • login • 登入系統 (注意大小寫) • logout • 登出系統 • dmesg • 察看開機的訊息 (按 shift+PageUp、Shift+PageDown 翻頁) • su • 切換成為 root 系統管理員 • 一般使用者切換成為其他身份使用者需要輸入該欲切換 使用者密碼。若是執行者為 root 系統管理員的話,則 不需要輸入密碼即可切換。 • 使用方式: su –l [userid] • -l 或者是 – 參數為讀取該使用者環境變數
Basic Command(2) • passwd • 變更使用者密碼 • passwd [userid] : 設定 userid 該帳號密碼。 只有 root 能夠指定欲變更使用者的密碼 • 選擇密碼原則: • 不要與帳號一致 • 不要太短,不要與車牌、生日等等有關 • 建議數字、字母、大小寫配合使用 • shutdown • 進行關機或者是進入單人維護模式 • #: shutdown 直接進入單人維護模式 • #: shutdown –h now (關機後停止系統) • #: shutdown –r now (關機後重新開機) • #: shutdown –h +10 “System will reboot aftern ten min”
Basic Command(3) • who – 查詢目前有哪些人登入系統主機內 • # who • whoami – 查詢自己登入的帳號名稱 • # whoami • chsh – 設定或者是修改使用者所使用的 shell • # chsh [userid] • chfn – 設定或是修改使用者資料 • # chfn [userid]
File System • ls 顯示目錄檔案內容 • 使用方式: ls [參數] [檔案目錄名稱]ls –alls –F 檔案結尾顯示出型態 • . 開始的檔案目錄為隱藏檔案 • ls 顯示目錄檔案內容解釋drwxr-xr-x 15 root root 4096 Aug 28 12:00 home-rw-r--r-- 1 root root 249 Sep 25 1999 zprofile 1. 檔案特性與使用權限 2. 所含目錄數量 3. 擁有者 4. 群組 5. 檔案大小 6. 最後建立/修改時間 7. 檔案名稱
Basic Command(4) • halt • 關機。與 shutdown –h now 相同意思 • sync • 把在記憶體上緩衝區尚未寫入的資料強制寫入硬碟 • cp - 複製目錄檔案 • # cp <原始檔案> <目的> # cp –r <原始目錄> <目的位置> • # cp –i <原始檔案> <目的> • mv – 搬移目錄檔案 • mv <原始目錄檔案> <目的位置> • mkdir – 建立目錄 • mkdir <目錄名稱> ... • rm – 刪除目錄 • rm <file> • rm –rf <dir> / <dir>
Basic Command(5) • pwd – print working directory • 顯示目前工作目錄 • clear • 清除螢幕的資料 (類似於 dos cls 指令) • cd – change directory • 切換目錄 • 只輸入 cd 或者是輸入 cd ~ 會回到使用者家目錄 • cat • 顯示檔案內容 • # cat /etc/fstab • # cat /var/log/messages • # cat /etc/fstab /var/log/messages > /tmp/text.txt
Basic Command(6) • chown - 改變檔案目錄擁有者 • chmod root filename • chmod root.disk dirname • chgrp - 改變檔案目錄群組 • chgrp disk filename • chgrp mail dirname • chmod - 改變檔案權限 • chmod a+x filename • chmod g-or filename • man – 顯示 manual 使用文件 • # man ps • # man lilo.conf • # man –k printf
Basic Command(7) • less/more – 顯示檔案內容 • tail – 顯示檔案最後幾行 • tail –f /var/log/messages 預設 10 行 • tail –30 /var/log/messages • head – 顯示檔案開始幾行 • head –10 /var/log/messages • talk – 與線上某個使用者對談 • # talk user [tty-name] • # talk userid@hostname • write – 發訊息給某個人 • # write user [tty] • # msg [y/n] • wall – 對線上使用者廣播 • # wall [messages]
Basic Command(8) • finger – 查詢某主機上使用者資訊 • finger userid • finger userid@hostname • grep – 尋找符合的欲尋找的資料並顯示出來 • grep ‘dev’ /etc/fstab • grep –l ‘dev’ *.txt • find – 尋找檔案 • find / -name core –print • find /tmp –name –type f xyz –exec rm –rf {} \; • echo – 顯示一行訊息 • echo Hello World • echo “$PATH”
Basic Command(9) • wc 計算檔案內的字元數、字組數、行數 • wc [options] [file] • wc –c /etc/fstab • wc -w /etc/fstab • wc –l /etc/fstab • tar 檔案打包備份工具 • 用來把許多檔案目錄打包成為單一檔案 • 傳統是用來把資料備份到磁帶機上 • # tar cvpf test.tar /etc • # tar xvf test.tar • gzip / bzip2 檔案壓縮解壓縮工具 • gzip –9 text.txt • gzip –d text.txt.gz • gzip test.tar