Skip to content

Latest commit

 

History

History
109 lines (90 loc) · 3.63 KB

File metadata and controls

109 lines (90 loc) · 3.63 KB

Managing APT Repositories in Debian

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.


Syntax of an APT Repository Entry

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.

Managing APT Repositories Online (/etc/apt/sources.list)

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.

Useful Sources List Generators

Editing the sources.list File

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

Fixing Issues with sources.list

  1. Verify the correct Debian version in /etc/os-release:
    cat /etc/os-release
    
  2. Replace bookworm with your version (e.g., bullseye, buster) in sources.list if needed.

GPG Signature Errors

If GPG signature errors appear, add the missing keys:

apt-key adv --keyserver keyserver.ubuntu.com --recv-keys KEY_ID

Setting Up an Offline Repository in APT

Download a Debian 12 DVD ISO

(Refer to Debian 12 official site or mirrors)

A. Using Debian DVD/ISO as a Repository

Step 1: Mount the ISO and Copy Files

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.

Step 2: Add the Local Repository to APT

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.

Step 3: Update APT Cache

apt update

Refreshes the package list from the offline repository.

Step 4: Install Packages from Offline Repo

apt install vim

Installs vim from the local repository.

Step 5: Verify APT is Using 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!