FetchDebian可通過APT包管理器(推薦,簡單快捷)或手動編譯(適用于無APT環境的場景)安裝。
打開終端,依次執行以下命令更新APT源列表并安裝FetchDebian:
sudo apt update
sudo apt install fetchdebian
安裝完成后,通過fetchdebian --version驗證是否成功安裝。
若APT源中無FetchDebian,可從GitHub克隆倉庫手動編譯:
git clone https://github.com/fetchdebian/fetchdebian.git
cd fetchdebian
sudo apt install build-essential git python3-pip # 安裝依賴
./autogen.sh && ./configure && make
sudo make install
安裝完成后,同樣用fetchdebian --version驗證。
FetchDebian的核心功能包括下載鏡像和管理軟件包,以下是常見操作:
使用list命令查看所有支持的Debian版本(如buster、bullseye)及對應架構(amd64、arm64):
fetchdebian list
通過search命令查找指定版本的鏡像(如“buster”代表Debian 11):
fetchdebian search buster
download命令,格式為<版本> <架構>:fetchdebian download buster amd64
latest命令,指定架構即可:fetchdebian latest amd64
iso命令,格式同“download”:fetchdebian iso buster amd64
FetchDebian也可用于下載Debian軟件包(二進制文件或源代碼):
fetchdebian vim
-s或--source選項:fetchdebian -s vim
-v或--version指定版本:fetchdebian -v vim=2:8.2-1
-o或--output設置保存路徑:fetchdebian -o ~/downloads vim
-m或--mirror指定鏡像URL(如國內清華鏡像):fetchdebian -m https://mirrors.tuna.tsinghua.edu.cn/debian/ vim
通過配置文件可定制FetchDebian的默認行為,避免每次輸入重復參數。
~/.fetchdebianrc(僅當前用戶生效)/etc/fetchdebian.conf(所有用戶生效)編輯配置文件(如sudo nano /etc/fetchdebian.conf),添加以下內容:
[mirror]
url = https://deb.debian.org/debian/ # 默認鏡像源
[distribution]
name = Debian
codename = bullseye # 默認下載版本
[components]
main = true
contrib = true
non-free = true # 是否包含contrib/non-free組件
[download]
output = /var/cache/fetchdebian # 默認下載目錄
threads = 4 # 下載線程數(提升速度)
保存后,FetchDebian會自動應用這些配置。
sha256sum命令驗證校驗和(FetchDebian會生成.sha256文件):sha256sum /path/to/debian.iso
將輸出與官方提供的校驗和對比,確保文件未被篡改。export http_proxy=http://proxy.example.com:8080設置代理(臨時生效),或修改配置文件中的mirror選項為可訪問的鏡像源。sudo apt install -f自動解決依賴關系。