Results 1 to 7 of 7

Thread: Possible to Undo Most-Recent apt-get install?

  1. #1
    Join Date
    Feb 2012
    Beans
    134

    Possible to Undo Most-Recent apt-get install?

    I have made a major gaff, and I wonder if there is an easy way out.

    I am using Bodhi Linux, based on Ubuntu. For this particular machine, I chose Bodhi to keep the install light on disk space, and because I like the menu setup in e17. In any case, I made a big booboo today, and wonder if there is a way out.

    I was looking for a way to tweak the appearance of my GTK apps, especially the fonts. I read a bit about the gnome-tweak-tool (but obviously did not read far enough) and it sounded like it might help. So did an apt-get-install. Bad idea. In addition to the tweak tool, I got the gnome shell, nautilus, pulseaudio, and hundreds of other things. Most of this stuff I don't need. Although I have now somewhat "learned my lesson" about doing a test install first, I'm wondering if there is any way to essentially "undo" this hundreds-of-items download/install.

    I have not installed anything further since that goof, so it was the last install done.

    Any possible solution? I looked in the log, and there's no way I can remove all those packages one by one.

  2. #2
    Join Date
    Nov 2008
    Location
    S.H.I.E.L.D. 6-1-6
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: Possible to Undo Most-Recent apt-get install?

    Run
    Code:
    awk '!/^Start|^Commandl|^End|^Upgrade:|^Error:/ { gsub( /\([^()]*\)/ ,"" );gsub(/ ,/," ");sub(/^Install:/,""); print}' /var/log/apt/history.log
    copy the last line of output (it may wrap)
    Code:
    sudo apt-get remove [packageshere]
    replace [packageshere] with the last line
    Don't waste your energy trying to change opinions ... Do your thing, and don't care if they like it.

  3. #3
    ibjsb4 is offline Ubuntu addict and loving it
    Join Date
    Sep 2012
    Beans
    4,987

    Re: Possible to Undo Most-Recent apt-get install?

    Wow, its a keeper

    Thanks sandyd

  4. #4
    Join Date
    Feb 2012
    Beans
    134

    Re: Possible to Undo Most-Recent apt-get install?

    Wow! That sure is very clever. And VERY much appreciated.

    Before I "pull the trigger," let me ask you this:

    Should I be adding any purge or autoremove to your command. I don't know if there are any config files or whatever to remove. Sorry to be such a noob; but this is a great education.

  5. #5
    Join Date
    Apr 2008
    Location
    LOCATION=/dev/random
    Beans
    5,767
    Distro
    Ubuntu Development Release

    Re: Possible to Undo Most-Recent apt-get install?

    Quote Originally Posted by ibjsb4 View Post
    Wow, its a keeper

    Thanks sandyd
    Isn't it just.

    I've needed something that does exactly this several times recently
    Last edited by Cheesemill; April 8th, 2013 at 01:31 AM.
    Cheesemill

  6. #6
    Join Date
    Aug 2011
    Location
    52.5° N 6.4° E
    Beans
    6,824
    Distro
    Xubuntu 22.04 Jammy Jellyfish

    Re: Possible to Undo Most-Recent apt-get install?

    I'd say using
    Code:
    sudo apt-get remove the-package-you-installed
    sudo apt-get autoremove
    should work too. The first command will remove the package you mistakenly installed, the second will remove all its dependencies you no longer need. It's not exactly an undo, but it would solve your problem.

  7. #7
    Join Date
    Feb 2012
    Beans
    134

    Re: Possible to Undo Most-Recent apt-get install? [Solved]

    Thanks to all who made suggestions.

    I believe that the

    sudo apt-get remove [pkgname]
    sudo apt-get autoremove

    approach would be helpful, but not a complete solution. In the present case, the package brought along a lot of recommends, in addition to the dependencies. I believe the autoremove will take out the dependencies that are not needed elsewhere; but I don't think it will take out recommended programs like Nautilus, PulseAudio, Gnome Shell, and so on. Of course, I am a rank beginner, and am not certain at all about this. Nevertheless, I am grateful for the suggestion.

    I went ahead with the solution written by sandyd, which appears to address very specifically all of the packages that were installed alongside the gnome-tweak-tool. (There were 158 packages!) It appears to have worked like a charm. The only remaining question I had was whether I should have added a purge to the command. I subsequently looked into Synaptic and saw all the residual config files that were left behind. But it is easy enough to simply remove them all in Synaptic.

    Hopefully, I've learned my lesson about installing packages without thoroughly researching them, and without running a trial install. That said, I have copied the elegant solution written by sandyd to my special folder of Linux tricks, just in case.

    Again, many thanks to sandyd for bailing me out, and to the others who took time to help.
    Last edited by Iggy64; April 8th, 2013 at 12:18 PM. Reason: Problem Solved

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •