When managing packages on Ubuntu or Debian, you might need to use third-party PPA (Personal Package Archives) repositories. These repositories often contain packages that are not available in the default repositories or newer versions of existing packages, providing access to the latest features or specific software not yet included in the main repository.

However, you may need to remove a PPA repository if the packages it provides are no longer needed, or if the repository is causing conflicts or issues with your system's package management. Removing a PPA repository involves deleting the repository from your system and ensuring that any packages installed from it are properly removed or downgraded to versions from the official repositories.

To remove a PPA repository on Ubuntu or Debian, you can use several methods. The ppa-purge tool is a reliable option that not only removes the repository but also downgrades any installed packages to their versions in the official repositories. Other methods include using graphical tools like Software Sources or manually deleting the repository configuration file, though these might not handle the packages installed from the PPA as thoroughly as ppa-purge.

Steps to remove PPA repository on Ubuntu and Debian:

  1. Launch the terminal.
  2. Update the apt package list.
    $ sudo apt update
    [sudo] password for user: 
    Hit:1 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease                   
    Hit:2 http://ports.ubuntu.com/ubuntu-ports jammy-proposed InRelease                   
    Hit:3 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy InRelease              
    Hit:4 http://us.ports.ubuntu.com/ubuntu-ports jammy InRelease
    Hit:5 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
    Hit:6 http://us.ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
  3. Install the ppa-purge package using apt.
    $ sudo apt install --assume-yes ppa-purge
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Suggested packages:
      aptitude
    The following NEW packages will be installed:
      ppa-purge
    0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
    Need to get 6,566 B of archives.
    After this operation, 24.6 kB of additional disk space will be used.
    Get:1 http://us.ports.ubuntu.com/ubuntu-ports jammy/universe arm64 ppa-purge all 0.2.8+bzr63-0ubuntu1 [6,566 B]
    Fetched 6,566 B in 1s (9,146 B/s)
    Selecting previously unselected package ppa-purge.
    (Reading database ... 207407 files and directories currently installed.)
    Preparing to unpack .../ppa-purge_0.2.8+bzr63-0ubuntu1_all.deb ...
    Unpacking ppa-purge (0.2.8+bzr63-0ubuntu1) ...
    Setting up ppa-purge (0.2.8+bzr63-0ubuntu1) ...
    Processing triggers for man-db (2.10.2-1) ...
  4. Identify the PPA repository name from the list of installed apt repositories.
    $ apt-cache policy | grep ondrej
     500 https://ppa.launchpadcontent.net/ondrej/php/ubuntu jammy/main arm64 Packages
         release v=22.04,o=LP-PPA-ondrej-php,a=jammy,n=jammy,l=***** The main PPA for supported PHP versions with many PECL extensions *****,c=main,b=arm64
  5. Remove the PPA repository using ppa-purge.
    $ sudo ppa-purge ondrej/php
    Updating packages lists
    PPA to be removed: ondrej php
    Package revert list generated:
     libapache2-mod-php8.2- libgd3:arm64/jammy libpcre2-32-0:arm64/jammy 
    libpcre2-8-0:arm64/jammy libxml2:arm64/jammy php-common/jammy php8.2- php8.2-cli- 
    php8.2-common- php8.2-opcache- php8.2-readline-
    
    Disabling ondrej PPA from /etc/apt/sources.list.d/ondrej-ubuntu-php-jammy.list
    Updating packages lists
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Selected version '2.3.0-2ubuntu2' (Ubuntu:22.04/jammy [arm64]) for 'libgd3'
    Selected version '10.39-3ubuntu0.1' (Ubuntu:22.04/jammy-updates, Ubuntu:22.04/jammy-security [arm64]) for 'libpcre2-32-0'
    Selected version '10.39-3ubuntu0.1' (Ubuntu:22.04/jammy-updates, Ubuntu:22.04/jammy-security [arm64]) for 'libpcre2-8-0'
    Selected version '2.9.13+dfsg-1ubuntu0.1' (Ubuntu:22.04/jammy-updates, Ubuntu:22.04/jammy-security [arm64]) for 'libxml2'
    Selected version '2:92ubuntu1' (Ubuntu:22.04/jammy [all]) for 'php-common'
    The following packages were automatically installed and are no longer required:
      apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
      libaprutil1-dbd-sqlite3 libaprutil1-ldap
    Use 'sudo apt autoremove' to remove them.
    Suggested packages:
      libgd-tools
    The following packages will be REMOVED:
      libapache2-mod-php8.2 php8.2 php8.2-cli php8.2-common php8.2-opcache
      php8.2-readline
    The following packages will be DOWNGRADED:
      libgd3 libpcre2-32-0 libpcre2-8-0 libxml2 php-common
    0 upgraded, 0 newly installed, 5 downgraded, 6 to remove and 0 not upgraded.
    Need to get 1,245 kB of archives.
    After this operation, 21.7 MB disk space will be freed.
    Do you want to continue? [Y/n]
  6. Confirm and apply the changes by pressing [ENTER].
    Get:1 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 libpcre2-8-0 arm64 10.39-3ubuntu0.1 [202 kB]
    Get:2 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 libxml2 arm64 2.9.13+dfsg-1ubuntu0.1 [728 kB]
    Get:3 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 libgd3 arm64 2.3.0-2ubuntu2 [126 kB]
    Get:4 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates/main arm64 libpcre2-32-0 arm64 10.39-3ubuntu0.1 [177 kB]
    Get:5 http://us.ports.ubuntu.com/ubuntu-ports jammy/main arm64 php-common all 2:92ubuntu1 [12.4 kB]
    Fetched 1,245 kB in 3s (488 kB/s)  
    (Reading database ... 207413 files and directories currently installed.)
    Removing php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Removing libapache2-mod-php8.2 (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Module php8.2 disabled.
    apache2_invoke prerm: Disable module php8.2
    Removing php8.2-cli (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Removing php8.2-readline (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Removing php8.2-opcache (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    Removing php8.2-common (8.2.0~rc1-2+ubuntu22.04.1+deb.sury.org+1) ...
    dpkg: warning: downgrading libpcre2-8-0:arm64 from 10.40-1+ubuntu22.04.1+deb.sury.org+1 to 10.39-3ubuntu0.1
    (Reading database ... 207310 files and directories currently installed.)
    Preparing to unpack .../libpcre2-8-0_10.39-3ubuntu0.1_arm64.deb ...
    Unpacking libpcre2-8-0:arm64 (10.39-3ubuntu0.1) over (10.40-1+ubuntu22.04.1+deb.sury.org+1) ...
    Setting up libpcre2-8-0:arm64 (10.39-3ubuntu0.1) ...
    dpkg: warning: downgrading libxml2:arm64 from 2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org+1 to 2.9.13+dfsg-1ubuntu0.1
    (Reading database ... 207310 files and directories currently installed.)
    Preparing to unpack .../libxml2_2.9.13+dfsg-1ubuntu0.1_arm64.deb ...
    Unpacking libxml2:arm64 (2.9.13+dfsg-1ubuntu0.1) over (2.9.14+dfsg-0+ubuntu22.04.1+deb.sury.org+1) ...
    dpkg: warning: downgrading libgd3:arm64 from 2.3.3-5+ubuntu22.04.1+deb.sury.org+1 to 2.3.0-2ubuntu2
    Preparing to unpack .../libgd3_2.3.0-2ubuntu2_arm64.deb ...
    Unpacking libgd3:arm64 (2.3.0-2ubuntu2) over (2.3.3-5+ubuntu22.04.1+deb.sury.org+1) ...
    dpkg: warning: downgrading libpcre2-32-0:arm64 from 10.40-1+ubuntu22.04.1+deb.sury.org+1 to 10.39-3ubuntu0.1
    Preparing to unpack .../libpcre2-32-0_10.39-3ubuntu0.1_arm64.deb ...
    Unpacking libpcre2-32-0:arm64 (10.39-3ubuntu0.1) over (10.40-1+ubuntu22.04.1+deb.sury.org+1) ...
    dpkg: warning: downgrading php-common from 2:92+ubuntu22.04.1+deb.sury.org+1 to 2:92ubuntu1
    Preparing to unpack .../php-common_2%3a92ubuntu1_all.deb ...
    Unpacking php-common (2:92ubuntu1) over (2:92+ubuntu22.04.1+deb.sury.org+1) ...
    Setting up php-common (2:92ubuntu1) ...
    Setting up libpcre2-32-0:arm64 (10.39-3ubuntu0.1) ...
    Setting up libgd3:arm64 (2.3.0-2ubuntu2) ...
    Setting up libxml2:arm64 (2.9.13+dfsg-1ubuntu0.1) ...
    Processing triggers for man-db (2.10.2-1) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    PPA purged successfully
  7. Update the apt package list.
    $ sudo apt update
    Hit:1 http://ports.ubuntu.com/ubuntu-ports jammy-security InRelease
    Hit:2 http://us.ports.ubuntu.com/ubuntu-ports jammy InRelease
    Hit:3 http://ports.ubuntu.com/ubuntu-ports jammy-proposed InRelease
    Hit:4 http://us.ports.ubuntu.com/ubuntu-ports jammy-updates InRelease
    Hit:5 http://us.ports.ubuntu.com/ubuntu-ports jammy-backports InRelease
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    All packages are up to date.
  8. Upgrade installed packages to the latest versions from the official repositories.
    $ sudo apt dist-upgrade --assume-yes
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    Calculating upgrade... Done
    The following packages were automatically installed and are no longer required:
      apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
      libaprutil1-dbd-sqlite3 libaprutil1-ldap
    Use 'sudo apt autoremove' to remove them.
    Receive additional future security updates with Ubuntu Pro.
    Learn more about Ubuntu Pro at https://ubuntu.com/pro
    0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
  9. Remove unnecessary dependencies from previously installed packages.
    $ sudo apt autoremove --assume-yes
    Reading package lists... Done
    Building dependency tree... Done
    Reading state information... Done
    The following packages will be REMOVED:
      apache2 apache2-bin apache2-data apache2-utils libapr1 libaprutil1
      libaprutil1-dbd-sqlite3 libaprutil1-ldap
    0 upgraded, 0 newly installed, 8 to remove and 0 not upgraded.
    After this operation, 7,012 kB disk space will be freed.
    (Reading database ... 207308 files and directories currently installed.)
    Removing apache2 (2.4.52-1ubuntu4.1) ...
    Removing apache2-bin (2.4.52-1ubuntu4.1) ...
    dpkg: warning: while removing apache2-bin, directory '/var/lib/apache2' not empty so no
    t removed
    Removing apache2-data (2.4.52-1ubuntu4.1) ...
    Removing apache2-utils (2.4.52-1ubuntu4.1) ...
    Removing libaprutil1-dbd-sqlite3:arm64 (1.6.1-5ubuntu4) ...
    Removing libaprutil1-ldap:arm64 (1.6.1-5ubuntu4) ...
    Removing libaprutil1:arm64 (1.6.1-5ubuntu4) ...
    Removing libapr1:arm64 (1.7.0-8build1) ...
    Processing triggers for ufw (0.36.1-4build1) ...
    Processing triggers for man-db (2.10.2-1) ...
    Processing triggers for libc-bin (2.35-0ubuntu3.1) ...
    ##### snipped

This guide is tested on Ubuntu:

Version Code Name
22.04 LTS Jammy Jellyfish
23.10 Mantic Minotaur
24.04 LTS Noble Numbat
Discuss the article:

Comment anonymously. Login not required.