Jump to content
View in the app

A better way to browse. Learn more.

PHP论坛人

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Debian 13更換套件來源 (APT源)

Featured Replies

-----------------------------------
Debian 13 更換套件來源 (APT源)
-----------------------------------

Debian的套件來源 (又稱APT源) 設定檔,在Debian 13預設會使用新的DEB822格式,存放於 /etc/apt/sources.list.d/debian.sources

當然,系統也向下相容舊的單行格式,該格式的檔案位於 /etc/apt/sources.list


-----------------------
確認目前來源設定
-----------------------

列出所有APT來源檔
ls -la /etc/apt/sources.list /etc/apt/sources.list.d/


查看DEB822設定
cat /etc/apt/sources.list.d/debian.sources


查看舊格式
cat /etc/apt/sources.list





-----------------
編輯來源設定檔
-----------------

Debian 13推薦使用新的DEB822格式,這種格式更清晰易讀

根據你的需求選擇以下方法之一。所有操作需要root權限


----------------------------------------
方法 A:編輯新的DEB822格式 (推薦)
----------------------------------------

vi /etc/apt/sources.list.d/debian.sources

將內容替換為以下設定 (Debian 官方來源)

Types: deb
URIs: https://deb.debian.org/debian
Suites: trixie trixie-updates
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg

Types: deb
URIs: https://security.debian.org/debian-security
Suites: trixie-security
Components: main contrib non-free non-free-firmware
Signed-By: /usr/share/keyrings/debian-archive-keyring.gpg



儲存檔案並離開vi編輯器
按 Esc,輸入 :wq,按 Enter




DEB822欄位說明
欄位	用途
Types	來源類型 (通常為 deb)
URIs	伺服器網址
Suites	發行版本
Components	套件分類
Signed-By	GPG金鑰





-------------------------------
方法 B:編輯傳統的單行格式
-------------------------------

若你習慣舊有的設定方式,系統仍完全相容 

vi /etc/apt/sources.list

設定內容 (Debian 官方來源)

# Debian 主要套件庫
deb https://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware
# deb-src https://deb.debian.org/debian/ trixie main contrib non-free non-free-firmware

# Debian 安全更新
deb https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware
# deb-src https://security.debian.org/debian-security trixie-security main contrib non-free non-free-firmware

# Debian 一般更新
deb https://deb.debian.org/debian/ trixie-updates main contrib non-free non-free-firmware
# deb-src https://deb.debian.org/debian/ trixie-updates main contrib non-free non-free-firmware




儲存檔案並離開vi編輯器
按 Esc,輸入 :wq,按 Enter




註:
以 # 開頭的行為註解,不會被執行

deb-src 為原始碼來源,一般使用者可保持註解以加快更新速度

若要改用其他鏡像站,只需將 https://deb.debian.org/debian/ 部分替換為對應的網址即可 


套件分類說明
分類	說明
main 符合自由軟體指導方針的官方支援軟體
contrib 依賴非自由軟體的自由軟體
non-free 非自由軟體
non-free-firmware 硬體驅動程式 (如Wi-Fi、顯示卡) 必備的非自由韌體




----------------------
更新與驗證
----------------------

修改完成後,請執行以下指令更新套件清單並升級已安裝套件:

更新套件清單
apt update


升級已安裝的套件
apt upgrade -y


清理舊檔,移除不需要的套件
apt clean

apt autoclean

apt autoremove -y


驗證來源是否正常,此指令會顯示目前使用的套件來源優先順序
apt-cache policy


若有核心更新或重大變更,建議重新啟動
reboot





----------
疑難排解
----------

apt update 出現GPG簽署錯誤

解決方法
apt-get install debian-archive-keyring

apt update



sources.list 與 sources.d 衝突

若兩者都存在相同來源,可能造成:重複套件列表、優先權混亂

建議:只保留一種格式

Edited by Jack

Create an account or sign in to comment

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.