# 寫一篇好懂的 Command Line 常用指令技術圖文筆記 相對於圖形化介面 (GUI=Graphical User Interface),**Command Line**是使用純文字與電腦溝通的方式。Mac使用者除了可以使用內建的軟體「terminal」處理這些指令文字,也可另外安裝「iterm2」與其他樣式版型外掛,使得操作指令的過程更舒適好閱讀。 ## pwd=print the current directory > 顯示目前目錄所在路徑  <br> ## ls=list directory contents > 列出目錄內所有內容  <br> ## cd=change directory > 進入下一層目錄。例如:``cd Keynote`` =進入名為Keynote之資料夾。 <br> ==留意以下``..``和 ~ 的前面有空格== - **``cd .. = 返回上一層目錄``** - **``cd ../.. = 返回上兩層目錄``** - **``cd ~ = 直接回到根目錄``** ### cd小技巧 輸入``cd``空格時,按鍵盤``tap``會自動列出底下的資料夾列表(就像是輸入``ls``,這個小訣竅等於是同時做「查詢」與「選擇」) - 輸入前幾個字母,再按``tap``會幫你自動補完資料夾名稱 - 可以用``tab``或是方向鍵選取想要的資料夾 - 選取好一個後可以再``tab``一次再繼續選下一層資料夾  * **若cd時遇到有空白或特殊符號的命名**([],!,$,&,*,;,|,)必須用**反斜線**``\``將空格隔開,才能正確選擇對象。例如:資料夾名稱為「empty space」,可以看到中間有個空格,若想使用cd指令進入此資料夾,必須輸入``cd emptey\ space``這項指令才能被正確執行   <br> ## mkdir = make diretory > 新增資料夾。例如新增一個名叫 cute 的資料夾: ``` mkdir cute ``` 和圖形化介面相對照,可看到確實新增了新資料夾。   <br> ## touch >新增檔案。例如:新增一個名為 hello 的 txt檔: ``` touch hello.txt ``` 於目前所在目錄中新增一個``hello.txt``檔案  <br> ## cat > 快速查看檔案內容 > ``` cat hello.txt ```  筆記本內文如下,可以看到 cat 把內文顯示出來了。  <br> ## rm = remove > 刪除檔案。例如:刪除名為 another 的 txt檔: ``` rm another.txt ```  <br> ## rmdir = remove directory > 刪除==空目錄==(空資料夾)。例如:刪除一個名為``empty space``的資料夾 ``` rmdir empty\ space ```  ###### 註:由於資料夾內還有東西不是空的,提示資料夾「not empty」無法刪除。 ## cp= copy >複製資料夾或是檔案。 - cp -fi 複製檔案 - cp -r 複製資料夾 ### cp -fi ``` cp -fi hello.txt beautiful ``` >將 hello.txt 複製到 beautiful 資料夾中。   <br> ### cp -r ``` cd -r cute ../ ``` >將名為 cute 資料夾複製到上一階層目錄中。  ## mv=move > 用來移動資料夾或檔案。例如:將 text.txt 移動至上一層目錄中。 ``` mv text.txt ../ ```  ###### 原本 text.txt 存放在 empty space 資料夾中,往上一層移動後來到 Documents 資料夾內了。  ## clear = 清空版面 
×
Sign in
Email
Password
Forgot password
or
Sign in via Google
Sign in via Facebook
Sign in via X(Twitter)
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
Continue with a different method
New to HackMD?
Sign up
By signing in, you agree to our
terms of service
.