10

I noticed that

sudo apt-get update

takes longer and longer, because i used several

sudo apt-add-repository xxx

it seems like non ubuntu repositories are not as fast or dont have as much bandwith as the default ones.

How can i reset the repositories to the default ones, removing all the ones added by me? (not to worry, if ever need any of them i can add them later)

Pilot6
  • 90,100
  • 91
  • 213
  • 324
Then Enok
  • 815

4 Answers4

29

To delete and purge all PPAs:

The ppa-purge removes the PPA and tries to replace the installed packages with the version of the Officially Ubuntu Repositories

  1. Install ppa-purge

    sudo apt-get install ppa-purge
    
  2. List the commands to be used with the command below. This command does nothing than print the commands to be used in the next step

    find /etc/apt/sources.list.d -type f -name "*.list" -print0 | \
        while read -d $'\0' file; do awk -F/ '/deb / && /ppa\.launchpad\.net/ {print "sudo ppa-purge ppa:"$4"/"$5}' "$file"; done
    
  3. Check the previous output and if all is ok, fire the purge-commands by the command below

    find /etc/apt/sources.list.d -type f -name "*.list" -print0 | \
        while read -d $'\0' file; do awk -F/ '/deb / && /ppa\.launchpad\.net/ {system("sudo ppa-purge ppa:"$4"/"$5)}' "$file"; done
    

Sample output

% find /etc/apt/sources.list.d -type f -name "*.list" -print0 | while read -d $'\0' file; do awk -F/ '/deb / && /launchpad/ {print "sudo ppa-purge ppa:"$4"/"$5}' "$file"; done
sudo ppa-purge ppa:yannubuntu/boot-repair
sudo ppa-purge ppa:bugs-launchpad-net-falkensweb/cool-retro-term
sudo ppa-purge ppa:andreas-boettger/gmusicbrowser-art
sudo ppa-purge ppa:yorba/ppa
sudo ppa-purge ppa:libreoffice/libreoffice-prereleases
sudo ppa-purge ppa:ricotz/testing
sudo ppa-purge ppa:nilarimogard/webupd8
sudo ppa-purge ppa:andreas-boettger/private
sudo ppa-purge ppa:snappy-dev/beta
sudo ppa-purge ppa:diesch/testing
sudo ppa-purge ppa:webupd8team/tor-browser
sudo ppa-purge ppa:musicbrainz-developers/stable
sudo ppa-purge ppa:latexila/ppa
sudo ppa-purge ppa:gencfsm/ppa
sudo ppa-purge ppa:webupd8team/java
sudo ppa-purge ppa:minecraft-installer-peeps/minecraft-installer
sudo ppa-purge ppa:gnome3-team/gnome3-staging
sudo ppa-purge ppa:git-core/ppa
sudo ppa-purge ppa:stackapplet-dev/stackapplet
sudo ppa-purge ppa:linuxgndu/sqlitebrowser
sudo ppa-purge ppa:webupd8team/atom
sudo ppa-purge ppa:webupd8team/unstable
sudo ppa-purge ppa:gnome3-team/gnome3
sudo ppa-purge ppa:webupd8team/y-ppa-manager
sudo ppa-purge ppa:team-xbmc/ppa
sudo ppa-purge ppa:peterlevi/ppa
sudo ppa-purge ppa:stebbins/handbrake-snapshots
sudo ppa-purge ppa:noobslab/apps
sudo ppa-purge ppa:numix/ppa
sudo ppa-purge ppa:dreibh/ppa
sudo ppa-purge ppa:saiarcot895/flightgear
sudo ppa-purge ppa:andreas-boettger/gmusicbrowser-daily
sudo ppa-purge ppa:xorg-edgers/ppa
A.B.
  • 90,397
  • There is no need to add a PPA itself for ppa-purge, it's already on Official Repos. – xangua Jul 10 '15 at 18:31
  • 3
    Dear downvoter, some constructive critic would be great. – A.B. Jul 10 '15 at 18:31
  • 1
    This is really useful before 'sudo apt dist-upgrade'!!! I saved all in a file and replaced ppa-purge with add-apt-repository to make a script to use after dist-upgrade! – Cirelli94 Nov 03 '16 at 18:35
  • 2
    Minor improvement: in step 3., the -y option should be passed to ppa-purge to ensure that previously installed PPA packages are properly downgraded. Failing to pass this option commonly results in errors resembling Warning: Something went wrong, packages may not have been reverted. (Your mileage may vary.) – Cecil Curry Feb 07 '19 at 21:02
  • for me it didn't work until i removed them from /etc/apt/sources.list.d with this script find /etc/apt/sources.list.d -type f -name "*.list" -print0 | while read -d $'\0' file; do awk -F/ '/deb / && /ppa\.launchpad\.net/ {system("sudo rm /etc/apt/sources.list.d/"$4"-ubuntu-"$5"-focal.list")}' "$file"; done – med benzekri Sep 04 '22 at 05:57
1

You can use same command with key --remove like this:

sudo apt-add-repository --remove ppa:<user_name>/<ppa_name>

And clean them one by one. It's the safe way. Or clean their files under /etc/apt/sources.list.d/, this way not recommended but working as well.

You can also use package ppa-purge. As mentioned there.

-2

You could try this:

  sudo add-apt-repository remove (ppa)

and it might work fine this way.

Michael
  • 2,499
  • 5
  • 19
  • 24
-4

You can do it by running in terminal

sudo rm /etc/apt/sources.list.d/*

This will remove all ppa. But this will NOT remove packages installed from ppa.

Pilot6
  • 90,100
  • 91
  • 213
  • 324
  • something is broken thenok@thenok-MS-7693 ~ $ sudo apt-get update Error: No information about packages! (Maybe no deb entries?) E: Problem executing scripts APT::Update::Post-Invoke-Success 'test -x /usr/bin/apt-show-versions || exit 0 ; apt-show-versions -i' E: Sub-process returned an error code – Then Enok Jul 10 '15 at 17:38
  • @ThenEnok What do you mean "broken"? What did you do? – Pilot6 Jul 10 '15 at 17:39
  • This will not remove the packages installed by all PPA's – xangua Jul 10 '15 at 17:46
  • ran the above command and afterwards ran sudo apt-get update – Then Enok Jul 10 '15 at 17:46
  • Did you type the command by hand or copied it from here? You could have made an error. – Pilot6 Jul 10 '15 at 17:48
  • I tested it on my computer and it works OK. You could mistype and spoil someting. Please post output of history 20. – Pilot6 Jul 10 '15 at 17:51
  • @xangua And? That was not the question. – A.B. Jul 10 '15 at 18:02
  • 1
    @A.B. It's important to focus on what the real problem is, not just the question. This is not internet points, is people helping people. – xangua Jul 10 '15 at 18:05
  • 1
    @xangua The real problem is slow running of apt-get update. And this answer addresses exactly what OP asked. – Pilot6 Jul 10 '15 at 18:06
  • @xangua - there is no goal to remove all packages installed by PPA. And there is already answer on askubuntu or even set of same answers. – user3417815 Jul 10 '15 at 18:16
  • You could try this: sudo -i and then gedit /etc/atp/sources.list and delete them you don't need. – Michael Jul 10 '15 at 21:37