注意事項
請注意
建議搭配其他篇使用,前一篇是 Part 1
基礎安裝
各項基礎工具安裝
Ubuntu 流程
sudo apt install git curl wget vim btop unzip zip p7zip-full unrar tar xz-utils build-essential
#如果是KDE可以不用裝
sudo apt install ark
Fedora 流程
sudo dnf install git curl wget vim btop unzip unrar zip p7zip p7zip-plugins tar xz
# 編譯相關
sudo dnf group install c-development
# 虛擬化相關
sudo dnf install @virtualization
# 如果是KDE可以不用裝
sudo dnf install ark
git:版控工具(Git)。
curl:用 URL 傳輸資料(支援 HTTP(S)、FTP…)。
wget:另一個常用下載器(續傳方便)
vim:經典終端文字編輯器。
btop:漂亮的互動式系統監控(CPU/RAM/磁碟/網路/程序)。
unzip / zip:解壓/壓縮 ZIP。
p7zip / p7zip-plugins:7-Zip 的 CLI 版本。
unrar:專門處理 RAR(尤其加密或新 RAR 版本更相容)。
tar:打包工具,常搭配壓縮。
xz:xz/txz 壓縮工具與庫。
c-development:C 編譯相關套件與開發工具
@virtualization:虛擬化套件
Flatpak
Ubuntu
在 Ubuntu 中輸入以下指令來安裝 flatpak
sudo apt install flatpak
# 使用 GNOME 不用下面這一條
#sudo apt install gnome-software-plugin-flatpak
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
reboot
Fedora
Fedora 已自帶
小麥注音輸入法
- Repo: https://github.com/openvanilla/fcitx5-mcbopomofo
- Wiki: https://github.com/openvanilla/fcitx5-mcbopomofo/wiki
Flatpak Ver. ( Recommend )
Ubuntu 與 Fedora 皆適用
並且為全域安裝
#可選:ubuntu可用以下指令移除ibus
sudo apt purge ibus
#logout is a good idea
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo
# 可能需要輸入密碼驗證
flatpak install flathub org.fcitx.Fcitx5
flatpak install flathub org.fcitx.Fcitx5.Addon.McBopomofo
flatpak run org.fcitx.Fcitx5
使用以下指令設定
fcitx5-config-qt
會提示要安裝 fcitx5-configtool,允許安裝即可
Ubuntu 流程
全域 global
安裝在全域,所有使用者皆可使用
按照以下步驟操作即可
sudo apt install fcitx5 fcitx5-chinese-addons
# from 24.04 install instrction
# might breal in 20.04
sudo apt install pkg-config fcitx5 libfcitx5core-dev libfcitx5config-dev libfcitx5utils-dev fcitx5-modules-dev cmake extra-cmake-modules gettext libfmt-dev libicu-dev libjson-c-dev
im-config -n fcitx5
sudo apt purge ibus
mkdir ~/Tools && cd ~/Tools
git clone https://github.com/openvanilla/fcitx5-mcbopomofo.git
cd fcitx5-mcbopomofo
-
Ubuntu 20.04
mkdir -p build cd build cmake ../ -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Debug -DUSE_LEGACY_FCITX5_API=1 make -
Ubuntu 22.04/24.04
cmake -B build -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_BUILD_TYPE=Release cmake --build build sudo cmake --install build # 初次安裝後,執行以下指令,小麥注音 icon 就會出現在 fcitx5 選單中 sudo update-icon-caches /usr/share/icons/*
使用以下指令設定
fcitx5-config-qt
會提示要安裝 fcitx5-configtool,允許安裝即可
Fedora 流程
一樣為全域安裝,使用 copr 來完成安裝,安裝完成後所有使用者皆可使用
按照以下步驟操作即可
# 還沒安裝 fcitx5 的話,先安裝 fcitx5
sudo dnf install fcitx5
sudo dnf copr enable apicalshark/fcitx5-mcbopomofo
sudo dnf install fcitx5-mcbopomofo
Gnome 的自動啟動已由 fcitx5-autostart 設定
KDE 需由 Keyboard(鍵盤)> Virtual Keyboard (虛擬鍵盤)
使用以下指令設定
fcitx5-config-qt
會提示要安裝 fcitx5-configtool,允許安裝即可
設定為 KDE 預設輸入法
fcitx 在 KDE 中預設啟動方式為設定預設虛擬鍵盤
~/.config/kwinrc-
[Wayland] InputMethod[$e]=/usr/share/applications/fcitx5-wayland-launcher.desktop VirtualKeyboardEnabled=true
設完之後請登出再登入
Oh-My-Zsh and powerlevel10k
Ubuntu
首先安裝 Zsh
sudo apt install zsh
若進入 zsh 設定頁面,按 q 離開即可
Fedora
sudo dnf install zsh
若進入 zsh 設定頁面,按 q 離開即可
以下兩者皆適用
為單獨使用者安裝
輸入完成後使用以下指令套用 zsh
使用 chsh -s $(which zsh) 並且重開機
重新登入後繼續後續步驟
若進入 zsh 設定頁面,按 q 離開即可
接著在當前使用者安裝 oh my zsh
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
安裝完成 zsh 後安裝 powerlevel10k
首先下載所需字體
sudo mkdir -p /usr/local/share/fonts/m/
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf"
接著執行以下指令套用
fc-cache -fv /usr/local/share/fonts
並且重開終端機重開完後
在 Open Settings → Edit Current Profile → Appearance, click Select Font and select MesloLGS NF Regular
(不一定需要,通常可以吃到)
接著安裝及下載 powerlevel10k
git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
這會將 powerlevel10k 放在 oh my zsh 中的 theme 資料夾中
之後在 .zshrc 中更改這一行以便套用到 oh my zsh
ZSH_THEME="powerlevel10k/powerlevel10k"
接著按照指示設定即可
為所有使用者進行安裝(全域安裝)
在前面安裝完 zsh 後
使用以下指令套用 zsh
輸入 chsh -s $(which zsh) 並且重開機
重新登入後繼續後續步驟
若進入 zsh 設定頁面,按 q 離開即可
首先,若是全新設定,使用者僅有一人的情況,請按照以下步驟操作
首先將未來新建立使用者預設為使用 zsh
sudo useradd -D -s /bin/zsh
接下來進行全域安裝
首先將 oh my zsh 下載到 /usr/share/ohmyzsh
sudo git clone https://github.com/ohmyzsh/ohmyzsh.git /usr/share/ohmyzsh
設定各項權限
# 把擁有權只給 root
sudo chown -R root:root /usr/share/ohmyzsh
# 將目錄權限設定為 755
sudo find /usr/share/ohmyzsh -type d -exec chmod 755 {} +
# 將檔案權限設定為 755
sudo find /usr/share/ohmyzsh -type f -exec chmod 755 {} +
安裝完成 zsh 後安裝 powerlevel10k
首先下載所需字體
sudo mkdir -p /usr/local/share/fonts/m/
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Regular.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Italic.ttf"
sudo wget -P /usr/local/share/fonts/m/ "https://github.com/romkatv/powerlevel10k-media/raw/master/MesloLGS%20NF%20Bold%20Italic.ttf"
接著執行以下指令套用
fc-cache -fv /usr/local/share/fonts
並且重開終端機重開完後
在 Open Settings → Edit Current Profile → Appearance, click Select Font and select MesloLGS NF Regular
(不一定需要,通常可以吃到)
下載 powerlevel10k ( 這與上面安裝 powerlevel10k 的指令不一樣,請注意 )
sudo git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "/usr/share/ohmyzsh/custom/themes/powerlevel10k"
接著在現在的使用者上面執行以下操作
nano ~/.zshrc
並輸入
export ZSH="/usr/share/ohmyzsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
source "$ZSH/oh-my-zsh.sh"
下載完成後
接著要設定新建使用者的參考檔案,使用以下指令
sudo nano /etc/skel/.zshrc
裡面寫
export ZSH="/usr/share/ohmyzsh"
ZSH_THEME="powerlevel10k/powerlevel10k"
source "$ZSH/oh-my-zsh.sh"
完成
之後新建的所有使用者會有 zsh + oh my zsh + powerlevel10k
SSH Server 與 Client 設定教學(Linux Server + Windows Client)
在 Linux 上設定 SSH 伺服器(Server)
1. 安裝 SSH 服務
在 Fedora(或其他使用 dnf 的系統)使用 SSH
若是要使用 Client,通常有預裝,
但 server 可能沒有,若是沒有裝的話
使用以下指令安裝
# 安裝 ssh server
sudo dnf install openssh-server
2. 啟用防火牆並開放 SSH
確認防火牆已開啟
sudo systemctl status firewalld
如果沒有開啟,使用以下指令開啟並檢查並檢查狀態
sudo systemctl enable --now firewalld
sudo systemctl status firewalld
之後
使用以下指令讓防火牆允許 ssh 的流量通過
sudo firewall-cmd --add-service=ssh --permanent
sudo firewall-cmd --reload
3. 啟動並自動啟用 SSH 伺服器
使用以下指令啟動並設定開機自動啟用
sudo systemctl enable --now sshd
sudo systemctl status sshd
4. 取得 SSH Server 公鑰指紋(fingerprint)
指紋是連線時用來確認伺服器真偽的「安全碼」。
假設使用的演算法是 ed25519
使用以下指令檢查指紋
ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
若系統沒有這組檔案,可自行改用其他公鑰的檔案代替此檔
把顯示的指紋記下來,稍後 Windows 連線時要比對。
到此,Server 的 SSH 基本設定完成。
接下來可從 Windows 登入測試。
在 Windows(Client)使用密碼登入
-
開啟 PowerShell 或 CMD
-
輸入:
ssh <使用者名稱>@<伺服器IP>範例如下:
ssh testuser@192.168.1.10 -
第一次連線會顯示伺服器指紋。
與剛剛在 Linux 那邊查到的指紋比對,若正確,輸入yes。 -
系統會要求輸入密碼 → 登入成功即完成。
至此,一般的 SSH 登入與設定完成
使用金鑰登入(Key Pair Authentication)
除了密碼登入 SSH 以外,我們也可以使用金鑰登入
金鑰登入比密碼更安全。流程為「Windows 產生金鑰 > 上傳公鑰到 Server > 登入」。
1. 在 Server 啟用金鑰登入功能
sudo nano /etc/ssh/sshd_config
找到並確認這行已啟用(取消註解):
PubkeyAuthentication yes
存檔後離開。
然後,在要登入的使用者帳號下建立 SSH 資料夾:
cd ~
mkdir .ssh
2. 在 Windows 產生金鑰
ssh-keygen -t ed25519 -C "my key"
-C 為註解
建議使用
ed25519(速度快、強度高)。
預設儲存在C:\Users\<你的帳號>\.ssh\。
可選擇設定 passphrase(建議設定,增加安全性)。
完成後會生成兩個檔案:
id_ed25519 私鑰(保存在本機)
id_ed25519.pub 公鑰(要傳給伺服器)
3. 將公鑰上傳至 Server
在 PowerShell 輸入以下指令
將公鑰複製到指定使用者的家目錄
cd C:\Users\<你的帳號>\.ssh
scp id_ed25519.pub user@<server_ip>:~
4. 在 Server 佈署公鑰
登入 Linux 後執行:
cat ~/id_ed25519.pub
# 打完上面這句後,將公鑰複製起來
nano ~/.ssh/authorized_keys
# 打完上面這句後,貼上剛複製的公鑰
chmod 600 ~/.ssh/authorized_keys
sudo systemctl restart sshd
rm -rf ~/id_ed25519.pub
這樣 Server 就會信任你這個金鑰。
5. 測試免密碼登入
在 Windows:
ssh user@<server_ip>
若成功登入而不需輸入密碼(或只要求輸入 passphrase),代表金鑰設定成功。
停用密碼登入(可選)
為安全起見,若確認金鑰登入可用,可關閉密碼登入:
sudo nano /etc/ssh/sshd_config
找到:
PasswordAuthentication yes
將其改成或取消註解後改成:
PasswordAuthentication no
存檔後重新啟動服務:
sudo systemctl restart sshd
結束設定