How to uninstall or remove recently-installed packages

9,008

Solution 1

If you installed them today, they’ll all be listed in /var/log/apt/history.log. Look through that, identify the packages you don’t want, and remove them.

Solution 2

sudo apt remove --purge $(ls -tl /var/lib/dpkg/info/*.list | head -n 10 | awk '{print $9}' | xargs -n1 basename | sed -e "s/\.list$//")
sudo apt autoremove --purge

ls -tl /var/lib/dpkg/info/*.list - gives you the list of packages sorted by time

head -n 10 - gives you the first 10 packages

awk '{print $9}' - selects the 9th column which is the file path

xargs -n1 basename - gives the filename

sed -e "s/\.list$//" - gives you the package name

Share:
9,008
user2752471
Author by

user2752471

Updated on September 18, 2022

Comments

  • user2752471
    user2752471 almost 2 years

    I installed the development packages for X11 today and now want to remove them. I do not remember the exact name of the package that I installed. I installed by running apt-get install ... and now want to remove the development package using apt-get purge --auto-remove <name of package>. Any suggestions?

  • orzechow
    orzechow over 2 years
    Thanks! Be aware that the sed replacement gets in conflict with packages containing "list" in their name (like libkf5messagelist5abi1). Anyways, I dumped the intermediate results into files and fixed this manually before passing it on to apt remove.
  • UdaraWanasinghe
    UdaraWanasinghe over 2 years
    I modified the answer to use sed -e "s/.list$//" Hope it will fix your issue.
  • orzechow
    orzechow over 2 years
    Perfect, that fixed it, thanks!