4 ms·
One time I was flipping back and forth between directories, compiling some code, then checking it, then rm -rf'ing it. I accidentally hit up an cd ..'d one too
by gleenn 2y ago
One time I was flipping back and forth between directories, compiling some code, then checking it, then rm -rf'ing it. I accidentally hit up an cd ..'d one too many times. Suddenly the rm command hung and I was confused because it should be nearly instant as it was a few files. I stared in horror as I was accidentally deleting everything in mybhome directory. Luckily back then I had a .pr0n directory with a significant amount of content. A few things were lost but that .pr0n folder was luckily early enough in the list and big enough to slow down the deletion of my photos and documents. That's why I always recommend having a big "buffer" of video content for such situations, ya know, for data integrity ;)
- hinkley 2y agoUnless you were using tcsh you had to rewrite your shell configuration though.
- OKRainbowKid 2y agoGreat idea, I shall see to it right away.
- winwang 2y agoThat's wild and inspirational. Like the scene in Rush Hour when a stack of bills saves Tucker from a bullet. Though I'm moreso tempted to just create a `.1111aaaa-antidumb` directory and store my caches and backups there. This has also un-inspired me from creating a fast `rm`-esque utility.
- woleium 2y agoYou could of course alias rm -rf to rm -rf -i
- marc_abonce 2y agoI always use trash-cli and alias rm to 'echo NO! #'. Only if the file is too big to fit into the garbage bin, I can unalias rm, rm the thing and then reset the alias immediately after.
- bardan 2y agoThere is also safe-rm https://adamheins.com/blog/a-safer-rm https://adamheins.com/blog/a-safer-rm
- immibis 2y agoI thought -f cancels out -i, and when you alias "rm=rm -i", and then run "rm -rf" you get "rm -i -rf" and -f is last so it still wins.
- contingencies 2y agoUserpace pronfs provides high latency unlinking?
- satiric 2y agoTurns out that pronfs uses fsck in the background to provide the delay
- mekster 2y agoSeriously, start using trash-cli. Even Windows from 30 years ago had a recycle bin. I can’t grasp how “power users” like Linux users are stuck working in primitive environments.
- Ferret7446 2y agoIf you delete things from a file manager in Linux, they all generally go into the Trash too. And if you rm/del/Remove-Item on Windows, it will also delete without sending to the recycle bin.
- 3836293648 2y agoYou're way too trusting of trash-cli here. I switched to it a while back and the only time I actually needed to recover something half the files in the folder weren't in the rubbsih bin, they were just gone
- LoganDark 2y agoFuck recycle bins. Make proper backups. When I delete something I want it deleted. If I make a mistake I grab it from a backup or just re-obtain it.
- accelbred 2y agoNah, recycle bin is the wrong model. Automatic filesystem snapshoting is the way to go. Snapshots are cheap and let you recover full state from your history. Just use btrfs, and set up btrbk to snapshot your home directory every 5 minutes, and have its gc keep every snapshot from past few hours, an hourly snapshot for past few days, and weekly for past few months.
- wruza 2y agoRecycle bin is just a different model. I have full disk weekly and homedir daily backups and could use live snapshots too, but it’s just easier to dig into the bin sorted by deletion date.
- miki123211 2y agoI wish filesystems had a first-in, first-out "garbage heap" model. The problem with snapshots is that they take up space. The trash has the same issue, with the added drawback that you have to think about emptying it, and if you empty it before realizing you made a mistake, it won't help you. With a "garbage heap" model, all deleted files would automatically end up on the "heap" when deleted. The heap would be exactly as large as the amount of free space you have left, and shrink when necessary by deleting the oldest files, perhaps with a minimum size (expressed in days) that would require manual action to shrink beyond.
- jamesy0ung 2y agoThis is the best comment I've read on Hacker News in a long time
- LinuxBender 2y agoThat's why I always recommend having a big "buffer" of video content for such situations, ya know, for data integrity Good idea, for safety of course. Just for completeness sake I would add one should not rely on that especially if they are using XFS and especially if using a hardware raid controller. The recursive rm may complete faster than the inodes are removed due to the nature how XFS among a few other filesystems operate in the background. I doubt many are using hardware raid controllers on their workstations but if one is on a server there is a chance there may be one and those will also perform some transactions in the background and one may get their prompt back sooner than the inodes have actually been removed. This is all edge case off course. People should have a massive .pr0n folder regardless.
- JoshTriplett 2y agorm has a --preserve-root option that's enabled by default, which prevents you from removing / . I wish it had a --preserve-home option too.