4 ms·
Is there a rm variant that bundles an undo command?
by medstrom 5y ago
Is there a rm variant that bundles an undo command?
- hnlmorg 5y agoThere's a few ways to solve this: + a command that doesn't actually delete but rather moves the file to a trash folder that gets emptied periodically (this is exactly how a desktop environments work) + a command that removes the inode but leaves the data intact. This could get pretty messy pretty quickly on SSDs. + `rm` behaves as normal but you restore the file using forensic tools / file recovery tools. Similar problem with SSDs as above. + `rm` behaves as normal but you run a snapshotting file system such as ZFS (maybe even have a wrapper function around `rm` to take a snapshot before running `/bin/rm`). Any "undo" would be recovering from snapshot. + `rm` behaves as normal but you restore from backup. Which isn't really a solution but still worth presenting here given the range of options I've presented. Personally I went with ZFS where possible. If recovery is tricky and I'm throwing wildcards at the problem then I'll do an `ls` first just to double check I'm not doing anything stupid.
- medstrom 5y agoThere are a number of commands named "trash". But I don't want to keep in mind to execute "trash-empty" occasionally, especially when rm'ing the same large file several times (say, ones made by "dd if=/dev/zero ..."). So either a cron job for emptying the trash, or I think more elegantly, have "trash" just empty the trash before trashing the next file (i.e. there is only ever one thing in the trash).