Managing packages on Ubuntu or Debian often involves using third-party PPA (Personal Package Archives) repositories. These repositories provide software packages not available in the official repositories or offer newer versions of existing packages. However, there are times when you need to remove a PPA repository, either because the software is no longer needed or the repository is causing issues.
Removing a PPA repository ensures that your system remains stable and avoids potential conflicts. When a PPA is no longer required, it is important to remove it properly to avoid package conflicts and dependency issues. This process involves not only removing the repository but also handling any packages installed from it.
There are different methods to remove a PPA repository on Ubuntu and Debian. The most thorough method involves using tools like ppa-purge, which not only removes the repository but also downgrades packages to their official versions. Other methods include manually deleting the repository or using graphical tools, but these may not fully address package downgrades.
Steps to remove PPA repository on Ubuntu and Debian:
- Open the terminal on your Ubuntu or Debian system.
- Update the package list to ensure you have the latest information about available packages.
$ 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.
- Install the ppa-purge tool if it is not already installed.
$ 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) ...
- Identify the name of the PPA repository you wish to remove.
$ 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
- Run the ppa-purge command to remove the repository and downgrade any associated packages.
$ 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]
- 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
- Update the package list again after removing the repository.
$ 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.
- Optionally, upgrade the remaining packages to their 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.
- Clean up unnecessary dependencies that were installed with the removed PPA.
$ 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
- Verify that the repository has been removed and that your system is functioning correctly.
$ apt policy | grep ondrej
This guide is tested on Ubuntu:
Version | Code Name |
---|---|
22.04 LTS | Jammy Jellyfish |
23.10 | Mantic Minotaur |
24.04 LTS | Noble Numbat |
Mohd Shakir Zakaria is an experienced cloud architect with a strong development and open-source advocacy background. He boasts multiple certifications in AWS, Red Hat, VMware, ITIL, and Linux, underscoring his expertise in cloud architecture and system administration.
Comment anonymously. Login not required.