You might need to use a third-party apt repository when the packages you need are not available in the default repository, or if it is, it might not be the version you need.

You will need to delete the third-party or PPA (Personal Package Archives) repository once you no longer need them, or the one you've just added is not as what you initially expected them to be.

PPA repository can be removed using add-apt-repository tool from the terminal.

Steps to remove PPA repository on Ubuntu and Debian:

  1. Launch terminal.
  2. Search for the repository name from the list of installed apt repositories.

    $ apt-cache policy | grep ondrej  500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main i386 Packages      release v=20.04,o=LP-PPA-ondrej-php,a=focal,n=focal,l=***** The main PPA for supported PHP versions with many PECL extensions *****,c=main,b=i386  500 http://ppa.launchpad.net/ondrej/php/ubuntu focal/main amd64 Packages      release v=20.04,o=LP-PPA-ondrej-php,a=focal,n=focal,l=***** The main PPA for supported PHP versions with many PECL extensions *****,c=main,b=amd64

  3. Remove PPA repository using add-apt-repository.

    $ sudo add-apt-repository --remove ppa:ondrej/php  Co-installable PHP versions: PHP 5.6, PHP 7.x and most requested extensions are included. Only Supported Versions of PHP (http://php.net/supported-versions.php) for Supported Ubuntu Releases (https://wiki.ubuntu.com/Releases) are provided. Don't ask for end-of-life PHP versions or Ubuntu release, they won't be provided.  Debian oldstable and stable packages are provided as well: https://deb.sury.org/#debian-dpa  You can get more information about the packages at https://deb.sury.org  BUGS&FEATURES: This PPA now has a issue tracker: https://deb.sury.org/#bug-reporting  CAVEATS: 1. If you are using php-gearman, you need to add ppa:ondrej/pkg-gearman 2. If you are using apache2, you are advised to add ppa:ondrej/apache2 3. If you are using nginx, you are advised to add ppa:ondrej/nginx-mainline    or ppa:ondrej/nginx  PLEASE READ: If you like my work and want to give me a little motivation, please consider donating regularly: https://donate.sury.org/  WARNING: add-apt-repository is broken with non-UTF-8 locales, see https://github.com/oerdnj/deb.sury.org/issues/56 for workaround:  # LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php  More info: https://launchpad.net/~ondrej/+archive/ubuntu/php Press [ENTER] to continue or Ctrl-c to cancel removing it.

  4. Update apt's package list.

    $ sudo apt update Hit:1 http://jp.archive.ubuntu.com/ubuntu focal InRelease Get:2 http://jp.archive.ubuntu.com/ubuntu focal-updates InRelease [111 kB] Hit:3 http://security.ubuntu.com/ubuntu focal-security InRelease Get:4 http://jp.archive.ubuntu.com/ubuntu focal-backports InRelease [98.3 kB] Fetched 210 kB in 1s (258 kB/s)      Reading package lists... Done Building dependency tree        Reading state information... Done All packages are up to date.

  5. Update installed packages using latest package repository and lists.

    $ sudo apt dist-upgrade --assume-yes Reading package lists... Done Building dependency tree        Reading state information... Done Calculating upgrade... Done 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

  6. Remove unnecessary packages from PPA.

    $ sudo apt remove --assume-yes php5.6 Reading package lists... Done Building dependency tree        Reading state information... Done The following packages were automatically installed and are no longer required:   apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1 libaprutil1   libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php-common php5.6-cli php5.6-common php5.6-json   php5.6-opcache php5.6-readline Use 'sudo apt autoremove' to remove them. The following packages will be REMOVED:   php5.6 0 upgraded, 0 newly installed, 1 to remove and 0 not upgraded. After this operation, 291 kB disk space will be freed. (Reading database ... 186098 files and directories currently installed.) Removing php5.6 (5.6.40-30+ubuntu20.04.1+deb.sury.org+1) ...

  7. Remove unnecessary dependencies from previously installed packages.

    $ sudo apt autoremove --assume-yes Reading package lists... Done Building dependency tree        Reading state information... Done The following packages will be REMOVED:   apache2 apache2-bin apache2-data apache2-utils libapache2-mod-php5.6 libapr1 libaprutil1   libaprutil1-dbd-sqlite3 libaprutil1-ldap liblua5.2-0 php-common php5.6-cli php5.6-common php5.6-json   php5.6-opcache php5.6-readline 0 upgraded, 0 newly installed, 16 to remove and 0 not upgraded. After this operation, 24.0 MB disk space will be freed. (Reading database ... 186091 files and directories currently installed.) ##### snipped

Guide compatibility:

Operating System
Ubuntu 16.04 LTS (Xenial Xerus)
Ubuntu 16.10 (Yakkety Yak)
Ubuntu 17.04 (Zesty Zapus)
Ubuntu 17.10 (Artful Aardvark)
Ubuntu 18.04 LTS (Bionic Beaver)
Ubuntu 18.10 (Cosmic Cuttlefish)
Ubuntu 19.04 (Disco Dingo)