How to Remove an APT Repository from Debian

To remove an APT repository from Debian, first find the source entry, then either disable it or delete it, and finish with sudo apt update. On current Debian systems, repositories are commonly stored as deb822-style .sources files under /etc/apt/sources.list.d/. Older .list entries and /etc/apt/sources.list are still supported, but the one-line format is deprecated. Debian documents both formats in the APT sources.list manual.

If sudo is not configured on your Debian installation, run the same commands from a root shell instead.

1. Find which file contains the repository

Start by searching for a distinctive part of the repository URL. Replace packages.example.invalid with the real domain you want to remove:

grep -RHi --include='*.list' --include='*.sources' 'packages.example.invalid' \
  /etc/apt/sources.list /etc/apt/sources.list.d 2>/dev/null

The output tells you exactly which file contains the matching entry. This matters because a third-party repository may be in its own .sources or .list file, or it may share /etc/apt/sources.list with other repositories.

Debian terminal locating an APT repository entry under /etc/apt/sources.list.d
Search for the repository domain before editing or deleting any APT source file.

2. Disable the repository without deleting it

Disabling is the safest choice if you may need the repository again.

For a modern .sources file

Open the matching file, for example:

sudo nano /etc/apt/sources.list.d/vendor.sources

In the repository stanza you want to disable, add:

Enabled: no

That is the preferred deb822-style switch documented by APT. If a .sources file contains more than one stanza, change only the stanza for the repository you intend to disable.

Debian source file with Enabled no in a deb822 APT repository stanza
For a deb822 .sources entry, adding Enabled: no disables that repository without deleting its configuration.

For a legacy .list entry

Open the file and place # at the start of the matching deb or deb-src line. APT treats the rest of a line after # as a comment. Do not comment out unrelated Debian mirrors.

3. Permanently remove the repository

If the repository has its own dedicated file, delete that file after confirming its contents. For example:

sudo rm /etc/apt/sources.list.d/vendor.sources

For an older source, the filename may end in .list instead. If the repository is stored inside /etc/apt/sources.list, edit that file and remove only the relevant line or lines. If a .sources file contains several unrelated repository stanzas, delete only the matching stanza rather than the whole file.

Debian terminal removing a dedicated third-party APT .sources file
Delete a dedicated repository file only after confirming it contains the source you no longer want.

4. Refresh APT and verify the repository is gone

After disabling or removing the source, refresh APT:

sudo apt update

The removed repository should no longer appear in the update output. You can also repeat the earlier grep command with the repository domain. If it still returns a match, another source file is still referencing the same server.

Debian terminal running sudo apt update after an APT repository was removed
Run apt update so APT refreshes package metadata without the removed repository.

Should you remove the repository signing key too?

Removing a repository does not automatically remove its signing key. For third-party deb822 entries, check the Signed-By: field before deleting any key file. The APT manual recommends /etc/apt/keyrings for keys managed by the system administrator and /usr/share/keyrings for package-managed keyrings.

Only delete a key from /etc/apt/keyrings when you are sure no remaining repository uses it. Do not remove Debian archive keyrings or package-owned keyrings just to clean up a source entry.

What removing a repository does not do

Removing the source stops APT from fetching package metadata and future versions from that repository. It does not uninstall packages you previously installed from it. If you also want to remove one of those packages, use the normal package command, such as sudo apt remove package-name, after reviewing what APT proposes to remove.

If APT still contacts the old repository

  • Search the repository domain across both /etc/apt/sources.list and /etc/apt/sources.list.d/ again.
  • Check both .sources and .list files; the same repository can be defined more than once.
  • If you see a Signed-By conflict, look for duplicate definitions that point to the same repository with different key settings.
  • Do not delete official Debian entries unless you intentionally want to stop receiving packages or security updates from that archive.

Debian 13 documentation recommends the newer deb822 .sources layout, and the Debian Reference package-management chapter describes /etc/apt/sources.list.d/*.sources as the modern source-list format.

Leave a Comment

How to Record Speaker Output on Linux with Audacity

How to Record Speaker Output on Linux with Audacity

Capture Linux desktop audio in Audacity by routing its recording stream to your output device’s monitor source. Follow PulseAudio and PipeWire steps, export tips, and fixes for silent tracks.

How to Use Dropbox on Linux: Install and Sync Your Files

How to Use Dropbox on Linux: Install and Sync Your Files

Install Dropbox on Linux from the official package, sign in, sync a local folder, manage selective sync, and check status from the command line.

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

How to Install Inkscape on Linux: Ubuntu, Fedora, Arch, and More

Install Inkscape from your Linux distribution’s repositories, the Ubuntu stable PPA, Snap, or Flathub, with current commands and notes for choosing a package source.

How to Find and Remove Duplicate Files on Linux With FSlint

How to Find and Remove Duplicate Files on Linux With FSlint

Use FSlint to scan selected Linux folders, review duplicate groups, and safely delete redundant files or learn when hard-link merging is appropriate.

How to Install SABnzbd on Linux and Configure It

How to Install SABnzbd on Linux and Configure It

Install SABnzbd on Ubuntu or Debian, or run it in Docker on another Linux host. Then open the web interface and configure your provider and download folders.

How to Install the Paper GTK Theme on Linux

How to Install the Paper GTK Theme on Linux

Install the Paper GTK theme from supported Linux repositories, enable it for GTK apps in GNOME Tweaks, and see what the legacy theme can and cannot change.

How to Install and Set Up Plex on OpenMediaVault with Compose

How to Install and Set Up Plex on OpenMediaVault with Compose

The old OpenMediaVault Plex plugin is archived. Set up Plex on OMV 8 with OMV-Extras, the Compose plugin, persistent storage, and Plex’s official container.

How to Clean and Speed Up Ubuntu Safely

How to Clean and Speed Up Ubuntu Safely

Clean and speed up Ubuntu with safe APT cleanup, storage checks, and startup controls that help free space and troubleshoot a sluggish desktop.

How to Install the Hiri Email Client on Linux

How to Install the Hiri Email Client on Linux

Install Hiri on Linux with its Snap package or official tarball, add a desktop launcher, and check supported accounts plus a warning about Hiri’s old Snap release.

How to Get System Specifications for a Linux PC

How to Get System Specifications for a Linux PC

Use Fastfetch and built-in Linux commands to check your distro, kernel, CPU, memory, graphics, storage, and connected devices, then save a clear report.