It should be unsage execution but with an easy undo like git or zfs.
It should be unsage execution but with an easy undo like git or zfs.
$ man mr
MR(1)
NAME
mr, relink - restore directory entries
$ mr -fr / # restore a filesystem root after deleting it (recursively, forced restore)Edit: lies!
import timetravel from timetravel import Delorean
d = Delorean(color="SILVER")
if d.power_gw >= 1.21:
d.flux_compensator.charge()
print("Great Scott!")Spinning up a VM for testing is another Very Good Practice.
It should be non recoverable. Everybody need to learn their lesson right.
ps. they had backups
The worst situation I've been in was running the classic 'rm -rf' from the root filesystem, several decades ago.
I was running a bootable distro, had mounted all filesystems but the one I was actually attempting to reformat and repurpose read-only, and the upshot was that I enjoyed the experience of seeing just what a system which has shell internals (not sure it was even full bash) and little else functions like. (I found that "echo *" is a good poor-man's 'ls'.) Then, having removed the filesystem I'd intended to remove in the first place (and a few more ... memory-only ... filesystems), I rebooted and continued.
What saved me was safeing all parts of the system save that which I was specifically acting on. Where I've had to perform similarly destructive commands elsewhere and since, I've made a habit of doing similarly, ensuring I'd had backups where necessary, triple-checking that what I wanted to annihilate was in fact what I was going to annihilate.
Among those practices:
I'll often move files or directories to a specific "DELETE_ME" directory, which 1) gives a few non-destructive checkpoints to destructive actions, 2) takes no system time or space (file / directory moves on the same filesystem don't involve copying or writing data other than the filesystem metadata), then review and finally delete those files.
I'll set all filesystems other than those I'm specifically performing surgery on to "read-only". This suffices for almost any file-oriented actions, though of course not filesystem or partition operations. ('dd' is the exception to file-oriented commands, though you'd have to be writing to a partition to cause problems.)
Rather than using dynamically-generated file lists (e.g., using shell globs, 'find | xargs', $(shell expansions), or similar techniques, I'll generate a one-off shell script to perform complex operations. This makes explicit all expansions and permits reviewing of operations before committing them.
I'll often log complex output so that I can review the operation and see if it ran as intended.
These have avoided numerous unpleasant surprises.
How do I "undo", say, `rm ./temp/*.txt`
/s but I sincerely hope it isn’t necessary