7

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?

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
user2752471
  • 237
  • 1
  • 2
  • 11

3 Answers3

9
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

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

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.

Stephen Kitt
  • 411,918
  • 54
  • 1,065
  • 1,164
0

Alternative: look at bash command history: history.

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

ctrl-alt-delor
  • 27,473
  • 9
  • 58
  • 102