Ubuntu – Prevent a package from being uninstalled in Ubuntu

aptdebianUbuntuuninstall

So, after an accidential fat finger with aptitude today, it wanted to uninstall mysql-server, this was on our database server. Since it was a pile of text, I just pressed Y, blindly trusting apt to not do anything insane. And it went ahead and uninstalled our mysql on our database server.

So, to prevent this happening again, is there anyway I can set up apt/dpkg/aptitude/etc. to not remove a certain package, ever?

The ideal solution would be a file somewhere listing packages, and none of those packages would be able to be uninstalled using the standard tools. You'd have to edit that file in order to allow that package to be uninstalled. Sort of "extra step to prevent stupid sysadmins"?

I tried aptitude hold mysql-server, and then aptitude remove mysql-server, but aptitude happily removed mysql

Best Answer

The answer to this is to pay attention to what you're doing. See also my answer to the question What are the recommended ways of defending a remote *nix install from a hamfisted admin?

As I said there nothing can protect you from your own stupidity. You, being the systems administrator, are the only thing standing between your stupidity and utter disaster. It is your job to avoid that.

Any technological measure you try to put into place will eventually fail because someday you'll be working at a level underneath whatever you put in place. You, in particular, can't even rely on the computer double checking every action with you, since you blatantly ignored the warning.

When the system tells you something read it. Then think about it. Then act.