Debian 堅持自由軟件原則,默認倉庫僅含開源軟件。安裝專有驅動、編解碼器、字體等閉源軟件需啟用 contrib 和 non-free 倉庫。本文詳述配置流程與最佳實踐。
| 組件 | 許可證 | 內容示例 | 是否 DFSG 合規 |
|---|---|---|---|
main | 自由軟件 | Linux 內核、GCC、systemd、大多數應用 | ✅ 是 |
contrib | 自由但依賴非自由 | 需專有固件的驅動、依賴非自由庫的構建工具 | ✅ 是(但依賴非自由) |
non-free | 非自由/專有 | NVIDIA 驅動、微軟字體、商業編解碼器、固件二進制 | ❌ 否 |
non-free-firmware | 非自由固件 | 硬件固件二進制(Debian 12+ 新增) | ❌ 否 |
sudo vim /etc/apt/sources.list
Debian 11 (Bullseye) 示例:
deb https://deb.debian.org/debian bullseye main contrib non-free
deb-src https://deb.debian.org/debian bullseye main contrib non-free
deb https://security.debian.org/debian-security bullseye-security main contrib non-free
deb-src https://security.debian.org/debian-security bullseye-security main contrib non-free
deb https://deb.debian.org/debian bullseye-updates main contrib non-free
deb-src https://deb.debian.org/debian bullseye-updates main contrib non-free
Debian 12 (Bookworm) 新增 non-free-firmware:
deb https://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb https://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb https://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
sudo apt update
# 或 aptitude 用戶
sudo aptitude update
# 搜索閉源包
apt search nvidia-driver
apt search firmware-linux
# 查看包屬於哪個組件
apt policy nvidia-driver
# 輸出含:500 https://deb.debian.org/debian bullseye/non-free amd64 Packages
| 需求 | 安裝命令 | 所需倉庫 |
|---|---|---|
| NVIDIA 專有驅動 | sudo apt install nvidia-driver | non-free |
| 微軟核心字體 | sudo apt install ttf-mscorefonts-installer | contrib |
| 無線網卡固件 | sudo apt install firmware-linux-nonfree | non-free / non-free-firmware |
| 商業編解碼器 | sudo apt install gstreamer1.0-libav | non-free |
| VirtualBox 官方版 | sudo apt install virtualbox-6.1 | contrib (需添加官方源) |
# 添加官方 VirtualBox 倉庫
echo "deb [arch=amd64] https://download.virtualbox.org/virtualbox/debian $(lsb_release -sc) contrib" | sudo tee /etc/apt/sources.list.d/virtualbox.list
wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc -O- | sudo apt-key add -
sudo apt update && sudo apt install virtualbox-6.1
non-free 軟件可能含專有許可限制,商業環境需審查合規性vrms (Virtual Richard M. Stallman) 檢測系統安裝的非自由軟件合理配置軟件源,在自由原則與實用需求間找到平衡點。