:::info # OS 講師:sicc 時間:8/26 13:30~16:30 Linux 連結: [連結](https://drive.google.com/file/d/1H4b-beTXsHhVFHQ7OIL5EVx570c8t6Mh/view?usp=sharing) 課程簡報: [簡報](https://slides.com/d/LD8XdK8/live) 課程簡報 PDF: [課程簡報](https://drive.google.com/file/d/1LE_wmBHz8E6Hgh4McsSwL_9piT5qqpD7/view?usp=sharing) ::: [Virtual Box](https://www.virtualbox.org/wiki/Downloads) 虛擬機:模擬硬體行為 ## Linux - 一個開放原始碼、類Unix(Unix-like)的作業系統  **為甚麼要使用Linux** 1. 完全免費 2. 開放原始碼,更新快 3. 安裝方便 4. 壞掉就重灌 [Ubuntu Download](https://ubuntu.com/download) [Kali Linux](https://www.kali.org/) ## shell  - 連接 user 和 kernel Turing's Bombe ## System Call 作業系統提供的 function Linux 與 Wiodows 不同 ## File System 樹狀結構 - `/` - `/bin`:執行檔 - `/home` == `~` - `/tmp`:放暫存檔案 - `/boot`:開機有關的檔案 - `/usr` - `/var` ## Command ### who ```shell nisra@nisra-VirtualBox:~/Desktop$ who nisra seat0 2024-08-26 13:31 (login screen) nisra tty2 2024-08-26 13:31 (tty2) ``` ``` 使用者 連接方式 時間 ``` ## whoami 顯示使用者名稱 ## pwd **p**rint **w**ork **d**irectory,印出目前工作目錄。 ## ls 印出目錄內容 ### flags - `-a`:印出目錄所有內容,包括隱藏檔案 - `-l`:印出目錄內容的詳細資料 - `-al`:組合技 ## cd **c**hange **d**irectory,切換目錄 - `cd 路徑`:到路徑 - `cd .`:回到目前資料夾 - `cd ..`:切換至父目錄 - `cd -`:回到上一個目錄 - `cd ~`:切換至家目錄 ## Cat concatenate,印出檔案 ```shell echo "./可以執行檔案" ``` 再 terminal 裡面按 `tab` 會自動補全命令 `ctrl`+`c` 可以終止程式 `ctrl`+`l` 會清空畫面 ## clear 清空畫面指令 ## mkdir **m**ake **d**irectories,創建一個空的目錄 ## rmdir remove directories,只能刪除空的資料夾(目錄) ## touch change file timestamps,新增空檔案 ## mv 移動(重新命名)檔案 - `-i`:覆寫前詢問 - `-f`:強制 ## cp 複製檔案/目錄到指定地點 - `-r`:遞迴,子目錄的東西也複製 - `-f`:強制 ## rm 刪除檔案或目錄 - `-f`:強制刪除 - `-i`:每次刪除前詢問一次刪除確認 - `-r`:遞迴,先刪除子目錄的東西,再刪除 >[!Warning] >`rm -rf /` ← 讓你快樂的指令(X ## sudo superuser do,用 root 權限執行 ## chown 轉移檔案權限。 ## chmod 更改檔案權限   | who | user type | description | | -------- | -------- | -------- | | u | user | 檔案所有者 | | g | group | 使用者群組 | | o | others | 所有其他使用者 | | a | all | 所有使用者==ugo | ```shell $ chmod u+x test # 給 user 有 test 的執行權限 ``` ## su 切換成其他使用者 ```shell $ sudo su root ``` ## apt ```shell $ sudo apt update # 更新軟體庫清單 $ sudo apt upgrade # 升級系統軟體 $ sudo apt install <套件名稱> # 安裝軟體 ``` ## vim `esc`:退回 normal 模式 `i`:進入 insert 模式 `:`:進入指令模式 `:w`:儲存 `:q`:退出 `:wq`:儲存並退出 在最後面加 `!` 可以強制執行指令 移動 cursor `h`:左(hjkl的最左邊) `j`:下(像一個向下的鉤子) `k`:上 `l`:右(hjkl的最右邊) 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up