萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 作業系統 >  >> Linux 教學

Debian 啟用非自由軟體倉庫安裝閉源套件:修改 sources.list 加入 contrib non-free

Debian 嚴格遵循 DFSG (Debian Free Software Guidelines),將軟體分為 main (自由)、contrib (自由但依賴非自由)、non-free (非自由) 三類倉庫。預設僅啟用 main,安裝專有驅動、編碼器、字型等閉源套件需手動啟用 contrib non-free。

倉庫分類說明

修改 /etc/apt/sources.list (以 Debian 7 Wheezy 為例)

# 備份原檔
cp /etc/apt/sources.list /etc/apt/sources.list.bak

# 編輯
vi /etc/apt/sources.list

# 每行 deb/deb-src 後加入 "contrib non-free"
deb https://ftp.us.debian.org/debian/ wheezy main contrib non-free
deb-src https://ftp.us.debian.org/debian/ wheezy main contrib non-free

deb https://security.debian.org/ wheezy/updates main contrib non-free
deb-src https://security.debian.org/ wheezy/updates main contrib non-free

# wheezy-updates (原 volatile)
deb https://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free
deb-src https://ftp.us.debian.org/debian/ wheezy-updates main contrib non-free

更新套件索引並搜尋安裝

# 更新索引
sudo apt-get update
# 或 aptitude
sudo aptitude update

# 搜尋非自由套件
apt-cache search nvidia | grep non-free
aptitude search '~s non-free'

# 安裝範例:NVIDIA 專有驅動
sudo apt-get install nvidia-driver

# 安裝範例:微軟核心字型
sudo apt-get install ttf-mscorefonts-installer

現代 Debian (8 Jessie 以降) 建議寫法

# /etc/apt/sources.list
deb https://deb.debian.org/debian/ stable main contrib non-free
deb-src https://deb.debian.org/debian/ stable main contrib non-free

deb https://security.debian.org/debian-security stable/updates main contrib non-free
deb-src https://security.debian.org/debian-security stable/updates main contrib non-free

deb https://deb.debian.org/debian/ stable-updates main contrib non-free
deb-src https://deb.debian.org/debian/ stable-updates main contrib non-free

使用 stable、testing、unstable 代號比具體版本號 (wheezy/jessie/stretch/buster/bullseye/bookworm) 更易維護。

Debian 12 Bookworm 非自由韌體獨立元件

Debian 12 起將非自由韌體分離為 non-free-firmware:

deb https://deb.debian.org/debian/ bookworm main contrib non-free non-free-firmware

單次安裝不修改 sources.list

# 臨時啟用非自由倉庫安裝單一套件
sudo apt-get -o Dir::Etc::SourceList=/etc/apt/sources.list.nonfree update
sudo apt-get -o Dir::Etc::SourceList=/etc/apt/sources.list.nonfree install pkg-name

哲理提醒

Debian 社群堅持自由軟體原則,contrib 與 non-free 僅為用戶便利而維護,**不屬於 Debian 專案正式一部分**。「自由」不僅指價格,更指使用、研究、修改、分發的自由。選用閉源軟體前請評估授權限制與供應商鎖定風險。

copyright © 萬盛學電腦網 all rights reserved
元件授權說明範例
mainDFSG 相容核心專案一部分Linux 核心、GCC、GNOME、Apache
contribDFSG 相容建構/執行依賴 non-free需專有固件的驅動、某些遊戲引擎
non-free非 DFSG可重新分發但非自由NVIDIA 驅動、Flash、微軟字型、解碼器