Personal Package Archives (PPAs) can be great. You get newer software or programs that are missing in your distribution’s default repositories. But from time to time, you will want to remove a PPA for various reasons. How you do this depends on what you want to achieve. Normally, you would find yourself in one of these two scenarios:
- You want to remove the PPA from your software sources list and remove the packages installed.
- You want to remove the PPA from your software sources list and revert to the default packages provided by your distribution.
Let’s explore the first scenario.
Remove PPA and its Packages
Make sure you have the “add-apt-repository” utility installed. It should be available, by default, on most Ubuntu-based distributions, but just to make sure, run the following command.
sudo apt install software-properties-common
Next, you need the exact name of the PPA you want to remove. If you forgot it, you can Google it, open up the Launchpad page where it’s hosted and look for the install instructions. There you will find its exact name (e.g. “ppa:libreoffice/ppa”).
Alternatively, instead of searching the Web, you can search your software sources lists to see what PPAs you currently have active.
grep -r -i ppa /etc/apt/
Next, you can open any link starting with “http://ppa.launchpad.net” and find the exact PPA name you need.
Replace “NAME_OF_PPA” in the next command with the actual name you found earlier. For example, the final command might look like this: sudo add-apt-repository --remove ppa:libreoffice/ppa
.
sudo add-apt-repository --remove NAME_OF_PPA
Refresh the package manager’s information.
sudo apt update
Finally, remove the package and its dependencies with
sudo apt autoremove NAME_OF_PACKAGE
After you enter this command, pay close attention to the list of packages that will be removed. If you see something you need in that list, then use the remove
option of apt (instead of autoremove
):
sudo apt remove NAME_OF_PACKAGE
Find All Packages Installed from PPAs
If the autoremove option doesn’t seem to uninstall all packages that come from that PPA, you might have to remove them manually.
Install the following utility.
sudo apt install apt-forktracer
Now, you can find all packages installed on your system that come from a PPA.
apt-forktracer | grep -i ppa | awk '{print $1}'
Next, you can remove them with sudo apt remove
or sudo apt autoremove
. autoremove
will try to automatically uninstall the package(s) you specify, plus all the dependencies. remove
will just uninstall the package(s) you specify.
If you’re sure you can remove all packages previously displayed by apt-forktracer, you can use a command such as
sudo apt remove $(apt-forktracer | grep -i ppa | awk '{print $1}')
Be sure to double-check what would get removed so that you don’t accidentally uninstall something you need.
Remove PPA and Revert Packages to Distribution’s Versions
Like in the previous section, you first need to know the exact name of the PPA. If you don’t know it, try the methods above.
Install ppa-purge.
sudo apt install ppa-purge
Run the ppa-purge script, which will remove PPAs from your software repositories and replace the installed PPA packages with your distribution’s packages. Of course, this requires that your Linux distribution has these packages available. In most cases this means that newer software will get downgraded to older versions.
sudo ppa-purge NAME_OF_PPA
Example command: sudo ppa-purge ppa:libreoffice/ppa
.
Conclusion
On “clean” systems the above commands should run without a hitch. On other systems, though, you might run into some conflicts generated by packages that are incompatible with each other. There’s no general solution, unfortunately, as it depends on your exact situation. Most of the time it can be solved by removing/downgrading/upgrading some of those packages. To avoid such an experience in the future, you can read Don’t Break Debian to know how to keep your operating system in a “clean” state.
Our latest tutorials delivered straight to your inbox