# Linux :::info 日期 : 2024/04/02,2025/05/24 更新 影片 : [Linux Operating System - Crash Course for Beginners](https://www.youtube.com/watch?v=ROjZy1WbCIA) Github : 無 ::: #### 精簡版 移動 ```bash cd <相對or絕對路徑> : 進入資料夾 cd .. : 回到上一層 . : 目前所在位置 / : 根目錄 ~ : 使用者(`root` 或 `/home/jen/`)的家目錄 ``` ![image](https://hackmd.io/_uploads/Hk16IybMel.png =30%x) 查找與建立 ```bash man <指令> : 顯示此指令的說明 pwd : 目前的工作目錄 ls : 列出資料夾內檔案 -l 詳細資訊 -a 所有檔案(包含隱藏檔案(開頭為. )) *指令可疊加 mkdir <資料夾名> : 建立新目錄 ``` 檔案 -> 複製 刪除 移動 ```bash cat <檔案名稱> : 印出檔案所有內容 cp <檔案> <新檔名> : 複製檔案內容到這個新檔名下 cp -r <資料夾> <新資料夾名> : 複製資料夾到新資料夾名下 rm <檔案>: 刪除檔案 rm -r <資料夾>: 刪除資料夾 mv <舊檔名> <新檔名>: 重新命名 mv <原檔案路徑> <新檔案路徑>: 移動檔案 ``` --- #### 完整版 * directory ```python man : 顯示手冊 pwd : 目前的工作目錄 cd (內建會回去/home/yujen) cd yujen/ : 進入 yujen 目錄,相對address(表示從目前所在的位置開始尋找 yujen 目錄) cd /home : 絕對路徑中的 /home 目錄。這是絕對地址,直接指定了根目錄(/)下的 home 目錄 ls : 列出目前工作目錄中的檔案和dir ls -l : 詳細格式 ls -la : 包含隱藏的 ls -lah : human readable ls <dir> : 去特定的directory看ls mkdir <檔案名> : 建立新目錄 mkdir -p <一串資料夾名> : 建立多層次的目錄 rmdir : remove empty directory rmdir -p <一串資料夾名> : 刪除目錄及其所有空的父目錄 clear : 清除終端機上的螢幕內容 ``` * file ```python file : 讀檔案類型 touch <file名稱.副檔名>: 創造空file rm <file名稱.副檔名>: 刪除檔案 rm -i 多個<file名稱.副檔名>: 刪除多個檔案 rm -rf <folder名稱>: 刪除資料夾 cp <舊檔名> <新檔名>: 複製dir或file cp <舊檔名> <新dir>: 複製file到新dir cp -r <舊dir> <新dir>: 複製dir mv <舊檔名> <新檔名>: 重新命名 mv <舊檔名> <其他dir/新檔名>: 移動檔案到新dir並重新命名 mv <舊dir> <新dir> : 重新命名dir ``` * file content ```python head (-行數) <檔名>: 看檔案裡面前幾行 tail <檔名>: 看檔案裡面後幾行 cat <檔名>: 印出全部內容 cat <檔名or檔名們..> >新檔案: 把檔案們內容 寫入新檔案 cat > 檔名 : 可以開始寫內容,寫完按ctrl + d跳出 echo 內容 >檔名: 寫入內容到檔案 more <檔名>: 印出每頁內容,有% ``` * 存甚麼 ```python cd /: 去到根 bin : 各種linux command boot : 重要 linux os dev : pysical device(usb..) etc : config file / 各種application儲存地點 home : user的資料 lib : library, program file folder mnt : place holder (mount external drive) tmp : 暫存檔 關機會刪掉 usr : user共用檔案 ``` * system ```python uptime : sys跑多久 free : 剩多少memory可以用 ps : 現在在跑的process有哪些(可以kill the process by id) df : disk space usage sudo fdisk -l: partition of the system lsblk : list block htop : display linux 執行中的 process、系統資源的使用量 ``` * network ```python ifconfig : 拿ip information ip a : 拿ip information ``` * package ```python sudo : super user do 類似administrator,需要輸密碼 apt : advanced package management tool sudo apt update : 更新cache裡面的package sudo apt upgrade sudo apt search <軟體名> : 找軟體 sudo apt install <軟體名> : 安裝軟體 sudo apt remove <軟體名> : 移除軟體 ``` * text editor ```python nano <檔案名>: 編輯文件,特殊指令在下面 ``` ------- 參考資料 [快速linux指令教學(mac, windows, ubuntu...等等適用)|工程師必備技能](https://www.youtube.com/watch?v=-fzO7iWCSWY)