I've faced times when I accidentally ran dangerous commands and lost all my data. How do I set Linux to ask for current user password or root user password when running potentially dangerous commands like
rm -rf . or
rm -rf / and many other?
There isn't really anything you can do beyond making use of
The other tip you'll often make use of, is wrapping destructive commands such as
Be warned though, this typically gets extremely annoying and you'll likely revert to running with it disabled.
The main problem might be to reliably identify a "dangerous command". But let's assume you have a list of dangerous commands.
You can "overwrite" each binary with a function (similar to a shell alias but more powerful):