You might need to install packages using a third-party or PPA (Personal Package Archives) repository when the packages you need are unavailable in the default repository, or if it is, it might not be the version you need.

Once you no longer need packages from the PPA repository, or if the repository does not meet your expectation, you can remove the packages and the PPA repository you've added. On top of just being a simple cleanup exercise, this could prevent issues where the PPA repository might cause unnecessary conflicts with apt or apt-get.

You can remove the repository from apt by deleting the repository configuration file, using a graphical application such as Software Sources, or using the add-apt-repository tool from the terminal. The problem with these methods is that they will only remove the repository but will not remove the packages you installed from the repositories. It's acceptable if you can uninstall all of them manually, but it's better to use dedicated software just for that.

Steps to remove PPA repository on Ubuntu and Debian:

  1. Launch terminal.
  2. Update 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 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. Search for the third party 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 third party 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. Verify the changes and press [ENTER] to confirm and continue.
    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 apt's 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. Update installed packages using latest package repository and lists.
    $ 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.