Content:
+ Terminal commands
+ vim
+ Directories
+ 通用的 Linux 系統
+ Android 手機 (2020年時)
+ TEE (Trusted execution environment)
+ 其他
+ 單字表
+ Other references
Terminal commands and tricks
- Rename file/directory
$ mv <old_directory> <new_directory>
$ mv <old_file.xxx> <new_file.xxx>
- grep
快速找尋字串所在位置
grep -w "apple" names.txt // -w 更精準搜索
grep -wi "apple" names.txt // -i 忽略大小寫
grep -win "apple" names.txt // -n 顯示列好
grep -win -B 4 "apple" names.txt // -B 4 外加顯示前四列
grep -win -A 4 "apple" names.txt // -A 4 外加顯示後四列
grep -win -C 4 "apple" names.txt // -C 4 外加顯示前後四列(常用)
grep -win "apple" ./* // current folder
grep -winr "apple" . // -r recusive search
grep -winrl "apple" . // -l only show folder
Download GUN grep
grep
in Mac is so-call BSD grep
, we can download GUN grep
for perl compatible expressions
brew install grep --with-default-names // -with-default-names is optional
- rg
應該是 grep 進階版
快速找尋字串所在位置
- ls
// -l 參數可以顯示檔案與目錄的詳細資訊
// -h 參數可以讓輸出的資訊以比較容易閱讀的格式呈現
// -a 參數可以顯示隱藏的檔案與目錄
- screen (可能需要安裝)
- cutting and pasting text in the command line
ctrl + k // 剪下 cursor 之後的文字
ctrl + y // 回貼剪下的文字
ctrl + u // 刪除整行 (in ohmyzsh)
ctrl + e // move to end of line
ctrl + a // move to start of line
References
- Corey Schafer; Linux/Mac Terminal Tutorial: The Grep Command — Search Files and Directories for Patterns of Text (2018.3)
- tutorialLinux; My 5 Favorite Linux Shell Tricks for SPEEEEEED (and efficiency) (2018.6)
Vim

Commands
i (insert)
:進入insert 模式
,可直接修改文件(esc
退出回到normal 模式
)a (append)
:進入insert 模式
,作用尚不明o
:進入insert 模式
,新增一行並開始輸入:wq
:w
:存檔、q
:跳出:q!
:強迫跳出:set nu
:產生 line numbers (增加易讀性)/
:尋找 (Then use keyn
/shift +n
to move)x
: delete characterdd
:刪除一行d2
:刪除兩行 (????)u
:回到上一步(undo)ctrl + r
:去到下一步(redo)ctrl + y
: Moves screen up one linectrl + e
: Moves screen down one linectrl + u
: Moves cursor & screen up ½ pagectrl + d
: Moves cursor & screen down ½ pagectrl + b
: Moves screen up one page, cursor to last linectrl + f
: Moves screen down one page, cursor to first line$
: Goes to the end of line, remains in command modeA
: Goes to the end of line, switches toinsert
mode^
: Goes to the start of line, remains in command modeI (uppercase i)
: Goes to the start of line, switches toinsert
mode
References
[1] Fireship. Vim in 100 Seconds (2021)
Directories
bin
- Binaries
- Essential executables
- E.g.
gzip
,ls
,curl
…
sbin
- System binaries
- only root user can use
- E.g.
mount
,deluser (delete user)
…
lib
- Libraries (for
bin
,sbin
…)
local
- in
/user
- it contains any binaries that you compile manually
etc
- editable text config
opt
- for add-on software
references
[1] Fireship. Linux Directories Explained in 100 Seconds (2021)
通用的 Linux 系統
Terms
- file system (檔案系統)
- process table (行程表)
- httpd process (httpd 行程,即網頁伺服器行程)
- watchdog process (看門狗行程): 監控 file system 和一系列服務
- ssh daemon (ssh 伺服器)
- cron (執行週期性任務 cron 的背景程式)
- wine process (執行 Wine 的行程):
- pipe (即 UNIX Pipeline)
- terminals and terminal processes (終端機和其行程)
File system
檔案系統是 UNIX 風格的作業系統的基底
httpd
即 web server == HTTP server or HTTP demon
“daemon” 原為「惡魔」之意,在 UNIX 的世界中引申爲常駐程式或背景服務
Wine
有了 Wine,我們即可在 Linux 執行原本針對 Microsoft Windows 的應用程式,該專案背後的推手是 CodeWeavers 公司
GNOME
是大名鼎鼎的 GNOME 桌面環境,推出時間稍晚於 KDE 桌面環境。既然定位是桌面環境,就不會只有一隻程式,因此對應到 Linux 的行程來說,GNOME 桌面環境 啟動後,會建立一系列 Linux 行程且相互溝通。
TTY
tty
=電傳打字機的簡寫
References
- jserv 看漫畫學 Linux (2021.7)
Android 手機 (2020年時)
OS inside
- Linux 核心 (AOSP為基礎)
- Android 系統
- Trusty
Trusty
掌管包含你的指紋和電子支付等需要高度安全處理的資訊
包含以下功能:
a. 提供系統呼叫
b. 允許執行應用程式
c. 具備排程能力
d. 能夠處理中斷和周邊的通訊
Trusty 在 Arm 處理器中,以最高的特權等級 (EL3) 模式執行,可說是凌駕於 Linux 核心之上,重要的功能之一是保護隱私。
倘若沒有這個 Trusty 作業系統, 包含你的指紋在內的隱私資料只是存放在 Linux 系統中,一旦 Linux 遭遇到 rootkit,那麼很可能從你的指紋、電子交易資訊、信用卡卡號、線上影音的 DRM 密鑰甚至是電信商特有的資訊都會被揭露。
TEE (Trusted execution environment)
Arm Cortex-A 系列微處理器
運作機制如下:
- 硬體提供切換機制 (secure moniter exception)
2. 透過指令 (Secure Moniter Call, SMC) 或觸發一些其他 exception,促使 secure moniter 進行受硬體保護的切換
其他
BFloat16
- 2020
- 硬體加速器