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?

3 Answers 3

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

  • 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.
    – orzechow
    Dec 30, 2021 at 21:19
  • 1
    I modified the answer to use sed -e "s/.list$//" Hope it will fix your issue. Dec 31, 2021 at 2:11
  • Perfect, that fixed it, thanks!
    – orzechow
    Jan 2, 2022 at 17:03

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.


Alternative: look at bash command history: history.

Future: use equivs-control to create a .deb, it makes it easier to un-install.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .