I want to make an alias for rm -rf /
. I know how to make an alias; the problem is that I don't know how to use a succession of commands to make an alias with all of them. I want something like rm -rf / = echo 'something'
, but only when "/" is used.
How can I achieve this?
This would be much better done by applying the appropriate permissions to prevent people from deleting stuff.
This aliasing ‘security’ approach would be easily overridden by disabling the alias, symlinking to
rm
and running it that way, copying therm
binary, or possibly even running it directly.You should secure your desktop by pressing Ctrl+Alt+L to lock it when leaving it unattended.
A simple
bash
function would do (but this can obviously be overwritten by an user):Note that, even if some user do
rm -rf /
, the operation would not go on as one needs to input--no-preserve-root
option withrm
to remove the root directory recursively. (But nothing is preventing one from doingrm -rf /*
orcd /; rm -rf *
by the way)But you should look at implementing a good security policy instead of monkey-patching sensitive stuffs.
The real problem here is your system's security. The "ppl" that you work with shouldn't be able to
rm -rf /
since that requires root access - implementing a better security model would avoid incompetent people from breaking the system, plus yourrm
command should (if it's a recent version) implement--no-preserve-root
.