Udemy課程:[The Web Developer Bootcamp 2021(Colt Steele)](https://www.udemy.com/course/the-web-developer-bootcamp/) # 第 30 節: Mastering The Terminal ###### tags: `JavaScript` `Udemy` `The Web Developer Bootcamp 2021` 2021.10.14(Thu.)~2021.10.18(Mon.) ## ● 上課筆記 ## 0. Why Do We Need To Know Terminal Commands? * **Speed!<font color="red">Develope Faster</font>** The terminal takes some getting used to, but it can be MUCH faster than using a GUI. * **Access <font color="red">With Great Power</font>** The terminal provides a "mainline" into the heart of our computer, giving us access to areas we normally don't interact with. * **Tools!** Many of the tools we need are installed and used via the command line. We don't have much of a choice! ## 1. 易混淆名詞 > Terminal? Shell? Command Line? Console? Bash? > 參考網站:[命令行界面 (CLI)、终端 (Terminal)、Shell、TTY,傻傻分不清楚?](https://segmentfault.com/a/1190000016129862) * **Terminal** A TEXT-BASED INTERFACE TO YOUR COMPUTER. ORIGINALLY A PHYSICAL OBJECT, BUT NOW WE USE SOFTWARE TERMINALS 他是一種用於與電腦進行交互的輸入與輸出的設備,本身是不提供處理運算的功能。 * **Shell** THE PROGRAM RUNNING ON THE TERMINAL. 內核(Kernel)管理整台電腦的硬體,不過kernel處於系統的底層,是不能讓普通用戶隨意操作的,所以此時就需要一個專門的程式,讓它接受使用者輸入的指令,然後幫我們與kernel溝通,而這個提供使用者介面的程式就稱為"shell"。 * **Terminal與Shell的比喻** **Terminal:** 假如把Terminal比喻成ATM **Shell:** 那麼Shell就是在ATM中運行的軟體 * **Bash <font color="red">Shell 的一種</font>** ONE OF THE MOST POPULAR SHELLS (AND THE DEFAULT ON A MAC) ## 3. How to Install Git Bash on Windows 10 * 載點:[How to Install Git Bash on Windows 10](https://www.youtube.com/watch?v=qdwWe9COT9k) ## 4. Terminal的指令 > 參考網站:[Terminal 指令](https://kim85326.github.io/2019/01/16/Terminal-%E6%8C%87%E4%BB%A4/) * **LS**(List) 列出檔案清單 Use "ls" to list the contents of your current directory. * **PWD**(Print Working Directory) 顯示目前所在目錄 Prints the path to the working directory (where you currently are) * **CD**(Change Directory) 變換目前目錄 Use "cd" to change and move between folders Use "cd .." to "back up" one directory(代表回到上一層目錄,有點像我們按下「回到上一頁」) ``` ● 絕對路徑:路徑的寫法『一定由根目錄 / 寫起』 ● 相對路徑:路徑的寫法『不是由 / 寫起』 ``` * **touch** 建立檔案 Use "touch" to create a file (or multiple) * **mkdir**(make directory) 建立資料夾 "mkdir" will create a new directory (or directories) * **man pages** [善用 man 指令查詢 Linux 線上手冊(Man Page)](https://blog.gtwang.org/linux/linux-man-page-command-examples/) man 指令加上要查詢的說明主題來閱讀線上手冊,通常主題的名稱就是指令或是函數的名稱,例如查詢 ls 的用法:(會列出如何使用 ls 的規範文件) (按Q跳出說明) ``` man ls ``` * **rm** 刪除檔案 "rm" will delete a file or files <font color="red">It permanently removes them!</font> * **rm -rf** 刪除資料夾 use "rm -rf" to delete a directory (r = recursive, f = force) <font color="red">It permanently removes them!</font>