This guide explains how to configure and manage APT repositories on Debian-based systems. It covers the syntax of repository entries, editing the sources.list file, handling GPG keys, and setting up an offline repository using a Debian ISO.
General format:
deb [URL] [distribution] [components]
- deb → Binary package repository (used for installing software)
- deb-src → Source package repository (used for downloading source code)
- [URL] → Server hosting the packages (e.g., http://deb.debian.org/debian/)
- [distribution] → Debian release name (e.g., bookworm for Debian 12)
- [components] → Software categories like main, contrib, non-free, etc.
The /etc/apt/sources.list file contains a list of software repositories from which APT fetches packages. You can edit this file to add or modify repositories.
- SimplyLinux Debian Generator: https://repogen.simplylinux.ch/
- Debian Sources Generator (GitHub): https://debgen.github.io/ or https://debgen.xyz/
- Debian Wiki on Sources List: https://wiki.debian.org/SourcesList
To edit the sources file:
vim /etc/apt/sources.list
Example (Default Debian 12 Bookworm):
deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware
deb http://security.debian.org/debian-security bookworm-security main contrib non-free non-free-firmware
deb http://deb.debian.org/debian bookworm-updates main contrib non-free non-free-firmware
- Verify the correct Debian version in /etc/os-release:
cat /etc/os-release - Replace bookworm with your version (e.g., bullseye, buster) in sources.list if needed.
If GPG signature errors appear, add the missing keys:
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_ID
(Refer to Debian 12 official site or mirrors)
mount -o loop /path/to/debian.iso /mnt
mkdir /ubuntudvd
cp -r /mnt/* /ubuntudvd
umount /mnt
- Mounts the ISO to /mnt.
- Copies all files from the ISO into /ubuntudvd.
- Unmounts the ISO after copying.
vim /etc/apt/sources.list
Inside sources.list, comment other entries and add:
deb [trusted=yes] file:/ubuntudvd bookworm main contrib non-free-firmware
- deb [trusted=yes] marks the repo as trusted (no signature checks).
- file:/ubuntudvd points to the local repo directory.
- bookworm main contrib non-free-firmware specifies package categories.
apt update
Refreshes the package list from the offline repository.
apt install vim
Installs vim from the local repository.
apt-cache policy vim
Displays the priority and source of the package. If file:/ubuntudvd appears, the offline repo is working.
Your Debian offline repository is now fully set up!