指令 | 用法 |
tar | 打包:tar -cvf FileName.tar DirName 解包:tar -xvf FileName.tar |
zip | 壓縮:zip FileName.zip DirName 解壓縮:unzip FileName.zip |
find | 指定檔名搜尋: 。在目前的目錄底下,尋找檔案名稱為 main.c 的檔案,可以使用: find . -name main.c 。在 /home 目錄底下,不分英文大小寫,尋找檔案名稱為 main.c 的檔案: find /home -iname main.c 指定檔案類型搜尋: 。在根目錄底下搜尋名稱為 myDic 的目錄: find / -type d -name myDic 。列出目前目錄底下所有的 PHP 檔案: find . -type f -name "*.php" |
du | 檢視檔案與目錄的使用空間狀態 格式:du -參數 目錄或檔案 常用參數: -a:列出所有檔案,包含隱藏檔( 開頭為 . 的檔案),預設只有統計目錄下的檔案數量 -h:可將檔案容易以易讀式呈現(EX:GB、MB、 KB、…) -s:計算這個目錄下的所有檔案、資料夾總量大小(但不分別列出個資料夾與檔案大小) -S:計算並列出目錄下所有資料夾檔案大小 |
cp | 用來複製檔案與目錄 格式:指令:cp -參數 來源檔案 目標檔案 常用參數: -a:除了具有-p參數功能外,還能加入SElinux屬性 -i:如果要複製過去的位置已經有相同檔案,會在覆蓋前詢問是否持續進行 -p:將檔案本身屬性(權限、所有者、時間)同時複製過去(一般用於備份居多) -r:針對目錄下檔案做遞歸複製(白話:整個目錄下每一個檔案複製到你想要的位置) -s:複製成符號連結檔(symbolic link)(白話:複製成捷徑檔) |
Linux Commonly Used Commands | Linux 常用命令
previous post