← Writing

Terminal: Usual Commands and Shortcut

What is Terminal? Terminal is a simple textbased interface which lets you access the command line. 簡單來說,Terminal 是一個以文字為基礎的操作介面,所有的指令都必須以鍵盤輸入。初次接觸這個介面...

terminal

What is Terminal?

Terminal is a simple text-based interface which lets you access the command line.

簡單來說,Terminal 是一個以文字為基礎的操作介面,所有的指令都必須以鍵盤輸入。初次接觸這個介面工具就有種見到陌生人一樣,有些尷尬、需要時間磨合。對於所有指令操作都得靠鍵盤控制,是需要一點時間適應的!

以下以 macOS 環境來做說明:

Open Terminal Mac 有三種方式可以打開 Terminal:

  • Click the Launchpad in the Dock -> 🔍 search Terminal
  • Click the Finder -> open the /Applications/Utilities folder and click Terminal
  • Command ⌘ + Space bar open the Spotlight Search -> 🔍 search Terminal

不要害怕指令,更不要害怕錯,錯誤訊息就在眼前!

這裡隨記一些常使用到的指令,每次看就每次複習! 隨時記得,遇到錯誤先檢視錯誤訊息(請耐心仔細地看),通常錯誤訊息裡會給予方法去排除錯誤,所以,深呼吸、吐氣,培養耐心並有效解決問題!

Commands

cd [PATH]                - change the current directory
cd ..                    - change to the parent directory
cp A B                   - copy files or directory

ls                       - list all the folders' name
ls -a                    - show the hidden files

mkdir                    - make a new directory
mv A B                   - move files from one folder to another

pwd                      - print working directory -> current location

rm file_name             - remove the file (be careful with using this command! once you remove, remove forever!)

rmdir                    - remove directory

sudo                     - super user do (a prefix for some commands that only superusers are allowed to run.)

touch file_name          - create a file without any content.

當遇到 folder name 有空格或特殊符號 ([ ], !, $, &, *, ;, | ),要以” \ ”符號作為區隔。 e.g. folder name: Hello World! cd Hello\ World\ !

Keyboard Shortcut

"↑" (up key)             - repeat the previous command
tab (Tabulator key)      - finish the current word you are typing automatically

Ctrl+L                   - clear (wipe up the current view)
Ctrl+W                   - word (delete one word)
Ctrl+U                   - delete the whole line
Ctrl+R                   - search the recent history command