Do It in 5 Minutes: Quick Start with ppa-purge
If you’ve added a PPA to Ubuntu and want to remove it along with all associated packages, here’s the fastest way:
# Step 1: Install ppa-purge
sudo apt install ppa-purge
# Step 2: Remove the PPA and downgrade packages to the official Ubuntu versions
sudo ppa-purge ppa:author-name/ppa-name
# Real example: remove ondrej's Nginx mainline PPA
sudo ppa-purge ppa:ondrej/nginx
That’s all. ppa-purge will automatically remove the PPA from your sources.list and downgrade every package installed from that PPA to the official Ubuntu version — no manual intervention needed.
Why Do You Need ppa-purge? What’s Wrong with Removing Manually?
I’ve installed Ubuntu Server 22.04 on over 20 VPS instances, and this process is always my first move when cleaning up PPAs — instead of removing them manually with add-apt-repository --remove.
The problem is that add-apt-repository --remove only does half the job:
- Removing a PPA from sources.list does not mean installed packages will automatically downgrade
- PPA packages often have higher versions that remain on your system even after the PPA is removed
- When upgrading Ubuntu later, dependency conflicts arise because the versions don’t match the official repositories
- It’s hard to remember which packages you installed from which PPA, especially after a few months
A Concrete Example
Say you added the ondrej/php PPA to install PHP 8.2, and now you want to go back to Ubuntu 22.04’s default PHP (8.1). If you only remove the PPA without using ppa-purge, PHP 8.2 stays right where it is. Ubuntu won’t downgrade it automatically, and a future apt upgrade may throw broken package errors.
Inside ppa-purge: 3 Steps It Does for You
ppa-purge isn’t complicated — it does 3 things in sequence:
- Disable the PPA: Comments out the PPA entries in sources.list.d (without deleting the file, making it easy to restore)
- Identify PPA packages: Compares the currently installed versions against what’s available in the official Ubuntu repo
- Automatic downgrade: Runs
apt installwith the Ubuntu repository version for each affected package
After it runs, check the .list file in sources.list.d and you’ll see the entries have been commented out:
# Check the result after ppa-purge
cat /etc/apt/sources.list.d/ondrej-ubuntu-nginx-jammy.list
# Output:
# deb https://ppa.launchpadcontent.net/ondrej/nginx/ubuntu/ jammy main
# deb-src https://ppa.launchpadcontent.net/ondrej/nginx/ubuntu/ jammy main
Common Real-World Scenarios
Scenario 1: Removing a PHP PPA
# Check existing PPAs first
ls /etc/apt/sources.list.d/
# Remove the ondrej/php PPA and downgrade PHP to the Ubuntu version
sudo ppa-purge ppa:ondrej/php
Scenario 2: Can’t Remember the Exact PPA Name
If you can’t remember the PPA name, look it up with these commands:
# List all PPAs currently on the system
grep -r "^deb " /etc/apt/sources.list.d/ | grep ppa.launchpad
# Or check which source a package comes from
apt-cache policy nginx | grep -i ppa
Scenario 3: ppa-purge Reports a “no alternative” Error
When the official Ubuntu repo has no version of a particular package, ppa-purge will ask whether you want to remove it entirely. Two ways to handle this:
# Option 1: Remove the package if you no longer need it — agree when prompted
sudo ppa-purge ppa:name/ppa
# Option 2: Keep the package at its current version using apt-mark hold
sudo apt-mark hold package-name
sudo ppa-purge ppa:name/ppa
# Held packages won't be downgraded or removed
# Remove the hold afterward if needed
sudo apt-mark unhold package-name
Advanced: Full PPA Control on Your Server
Identify Which Packages Come from a PPA
# Install apt-show-versions to check package origins
sudo apt install apt-show-versions
# List packages that are not from Ubuntu's official repo
apt-show-versions | grep -v "Ubuntu"
# Check the version of a specific package
apt-show-versions nginx
Simulate Before Actually Running
ppa-purge supports the -s flag to preview which packages will be affected without actually downgrading them:
# Preview which packages will be downgraded
sudo ppa-purge -s ppa:name/ppa
Full Cleanup After Purging
By default, ppa-purge only comments out the PPA file — it doesn’t delete it. For a complete cleanup:
# After ppa-purge, remove the remaining PPA file
sudo rm /etc/apt/sources.list.d/ondrej-ubuntu-nginx-jammy.list
sudo rm -f /etc/apt/sources.list.d/ondrej-ubuntu-nginx-jammy.list.save
sudo apt update
Practical Tips from Experience
I once removed a MariaDB PPA on a production server without taking a backup — downgrading from 10.11 to 10.6 left some data files incompatible and I had to restore. The whole afternoon was gone. The lesson: if a PPA is providing something critical like a database engine or web server, snapshot the VM before running any commands.
Once ppa-purge finishes, don’t stop there — clean up the rest:
sudo apt update
sudo apt upgrade
sudo apt autoremove
sudo apt autoclean
Are your services still running after the downgrade? Don’t guess — check immediately:
# Verify versions after downgrading
dpkg -l | grep -E "nginx|php|mariadb"
# Check if services are still running
sudo systemctl status nginx
sudo systemctl status php8.1-fpm
Desktop apps and dev tools are fine to test directly. Server software is a different story — one wrong downgrade on production can cost you hours of recovery time. Always test on staging first, no exceptions.
One small habit that saves hours of debugging: before adding a new PPA, jot down why you’re adding it and which packages depend on it. A simple /root/notes/ppa-list.txt file is enough — I guarantee you’ll thank yourself three months later.
ppa-purge does exactly one thing: return packages to the correct distro version after removing a PPA, instead of leaving a pile of dangling versions like add-apt-repository --remove does. Use it freely on dev and staging — just back up before running it on production.

