Well, I'm going to say some things that are basic philosophy type things.
The primary protections against this sort of thing are:
1. Don't run as root. Now, you don't say you were using root as your user account, but if you were, don't. Precisely what you describe (limiting a specific user's abilities) is why there are non-root accounts. If you weren't running as root, you wouldn't have been able to delete the directory at all. If you were using root to do some administrative things, then don't do those things when you are half-asleep. I know it's hard to pull yourself away--wanting to get that last task done before sleeping, but you shouldn't because being half-asleep will lead to problems like this.
2. Have a backup. That's their purpose: to recover from mistakes and/or hardware failures.
The second is just /, it would be at least nice to be asked, first, if you want to rm -rf /, I doubt there are many instance where you would want to do that. Is there any protection available for these issues?
1. Alias your rm command (especially root's rm command) to 'rm -i'. In fact, most distros do this by default. This will ask you if you want to remove the file(s). This cannot protect you if you use "rm -f" which means "remove this without asking." So what you're asking for is a command that can read your mind. I'm not trying to be flippant about it by saying it that way. Though, that is basically what you're asking for. Get in the habit of using rm without the -f unless you are absolutely sure you want to delete the files
--which is exactly what you told the system: that you were absolutely sure.
2. Mount filesystems that should be left alone as read only. Bear in mind that this won't protect filesystems that are mounted read-write. So, rm -rf * from / will kill everything not mounted as read-only.
Lastly, the chattr
command might have something useful for you. Though again, I strongly suggest that you not resort to this but rather change your habits to be more in-line with the approaches listed above.