本篇作為書籤用途,記錄網路上的 Linux 參考資料
Linux 系統目錄用途

REF: https://www.tecmint.com/linux-directory-structure-and-important-files-paths-explained/
檢查系統資訊
1 2 3 4 5 6
| hostnamectl
lsb_release -a
lshw
|
更新系統
1 2 3 4 5 6 7 8
| sudo apt dist-upgrade
sudo do-release-upgrade -c
sudo reboot
sudo do-release-upgrade
|
更新套件
請不時執行以下指令進行系統及套件更新:
1 2 3 4 5 6 7 8
| sudo apt update
sudo apt update && sudo apt upgrade -y
sudo apt clean
sudo apt autoremove
|
若不定時移除舊核心檔案,容易造成 /boot 空間不足,嚴重時將無法開機
空間使用量
1 2 3 4 5
| df -h
sudo du -h --max-depth=1 / | sort -h
|
清空
設定 alias
在 bash 環境,會透過 .bash_profile 或 .bashrc 設定檔來存放 alias 設定。兩個設定檔的差異簡單來說,假設是透過帳號密碼或 ssh 登入系統,登入時會去自動讀取 .bash_profile,而 .bashrc 則是讓非登入的操作命令使用。如果不想兩個檔案都做重複設定,可以在 .bash_profile 中引用 .bashrc 中的設定,如下:
1 2 3
| if [ -f ~/.bashrc ]; then source ~/.bashrc fi
|
查看 port 被程式佔用的方法
使用 lsof 指令如下:
1 2
| lsof -i -P -n | grep LISTEN lsof -i -P -n | grep :80
|
使用 netstat 指令如下:
1 2 3 4
| apt install net-tools
netstat -tulpn | grep LISTEN netstat -tulpn | grep :80
|
使用 Zsh
Zsh 會讀取 .zprofile 來當設定檔,像是 .zsh_profile 或 .bash_profile 那樣。
安裝請參考下列步驟:
1 2 3 4 5 6 7 8
| sudo apt install zsh
sudo chsh -s $(which zsh) $(whoami)
sudi chsh -s /bin/bash
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
|
使用 powerlevel9k 主題
powerlevel9k
1 2 3 4 5 6 7 8 9 10
| git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
ZSH_THEME="powerlevel9k/powerlevel9k"
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context dir vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
|
好用套件
1 2 3 4 5 6
| git clone https://github.com/zsh-users/zsh-autosuggestions ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
plugins=(zsh-autosuggestions)
|
1 2 3 4 5 6
| git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting
plugins=(git zsh-autosuggestions zsh-syntax-highlighting)
|
nano editor
WSL
安裝及檢查 Windows Subsystem for Linux,根據這篇官方部落格可以使用一個簡單的命令就可以安裝 WSL,或者參考下列指令:
1 2 3 4 5 6 7 8 9 10 11 12
| wsl.exe --install
wsl --list --online
wsl --install -d <DistroName>
wsl --update
wsl --update rollback
wsl --set-default-version 2
|
1 2 3 4 5
| wsl --list --verbose wsl -l -v
wsl --status
|
參考資料: