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
Author by
user2752471
Updated on September 18, 2022Comments
-
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 usingapt-get purge --auto-remove <name of package>
. Any suggestions? -
orzechow over 2 yearsThanks! 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 toapt remove
. -
UdaraWanasinghe over 2 yearsI modified the answer to use
sed -e "s/.list$//"
Hope it will fix your issue. -
orzechow over 2 yearsPerfect, that fixed it, thanks!