Is there a way to purge
all packages installed via apt-get
from the very moment you installed the Ubuntu OS, up till this very point?
One could call it a a "mega apt-get purge".
The purpose of this operation to clear the system of everything I've installed so far (from apt
) on top of the Ubuntu OS itself. This would bring me the closer to a fresh install of a Ubuntu OS, without any added software (of course, the only thing I'll have left is to clear all non-apt
software and individual files I've added, but that is of course another issue).
The reason for this operation is because this is done on a VPS machine in which I can't install and uninstall operating systems in the traditional way; I can indeed use the "rebuild" functionality of my hosting provider but I find it a bit annoying to use from personal reasons so I just want to go closest I can to a fresh install without that.
How will you do the desired "mega apt-get purge"? Thanks.
You can use
apt
with some scripting:Please remember - you are trying to perform very dangerous operation.
If unsure please do not remove
--simulate
.On system with 555 manually installed packages
apt-get
writes the following:then it stops.
So it is completely bad idea (I have no
cat
,sudo
commands afterwards).System boots with kernel panic.
I have snapshot, I'll restore it in 5 seconds.
Conclusion: you should use clever manual method - for example determine which services were installed manually (with
apt list --manual-installed
) and running (withhtop
,netstat
,systemctl
, whatever) and then purge only their packages.If you still have all the logfiles from apt in /var/log/apt , you can do: $grep install /var/log/apt/history.log; zgrep install /var/log/apt/history.log.*.gz , this will show all packages that have been installed on the system through apt.
Removing them in one commandline would take some bash scripting.
Hope this helps.