# Linux基本指令 ## 切換目錄 ### cd `cd 目錄` `cd ..` 往回一層目錄 `cd /`根目錄 `cd ~`家目錄 ## 查看路徑 ### pwd `pwd`查看目前路徑 ## 查看目錄內容 ### ls `ls`列出目錄中的檔案 `ls -F`列出檔案類型 `ls -l`列出檔案詳細資訊 `ls -a`列出隱藏檔案 `ls -ltr`按照檔案時間列出 `ls -ls`按照檔案大小列出 `ls -ld`只列出目錄 ## 查看檔案 ### cat `cat 路徑or檔名`輸出檔案 `cat --number`從1開始對每行輸出編號 `cat -E`每行最後加上`$`字號 ### 查找字串 ## grep `grep 字串 檔案`輸出有關該字串的整行文字 `grep 123 /home/*.conf`在`/home`找有123字串的`*.conf`檔案 ## diff補充 用`diff -y 檔案1 檔案2`比較兩個檔案不一樣的字串如下圖,有|是不同字串 ![](https://hackmd.io/_uploads/H1xahAgA3.png) ## 複製 ### cp ```cpp //把abc.txt複製到/copy/to目錄中 cp abc.txt /copy/to //把abc.txt複製到/copy/to目錄中並改名為test.txt cp abc.txt /copy/to/test.txt //把abc1.txt abc2.txt abc3.txt複製到/copy/to目錄中 cp abc1.txt abc2.txt abc3.txt /copy/to ```