Nobody deletes “./“. It’s far far more likely to be “/ tmp/file”
Also, without the -f it will prompt you. Chances are, the meme is with -f
The other possibility, though I haven’t tested it, is the working directory is / and they did “rm -rf .” Without first checking with pwd. I know that most OS will refuse to remove root without passing in a special flag nowadays. Only a few OS still respect you as sudo.
Though the check isn't very sophisticated, if memory serves. It more or less checks whether / is passed to rm -r.
If you did something like rm -r $VAR/*, but didn't check to make sure that $VAR was set and not empty, it could still fire, since rm wouldn't see that root got passed, only a bunch of directories in root.
I had a coworker preparing a customer database that arrived via sneakernet. He typo'd a variable during an rm -f step and ended up wiping the device because it was his working directory and the variable was undefined.
Last evening, I deleted a file by mistake in my dhcp server. Five minutes later I had recovered the file from the previous night's backup and was going about my merry way as if nothing happened.
If humans can make mistakes with the files, you should consider having backups. Having backups is something you decide to engage in BEFORE you have a loss event, so that you are prepared for when humans make their mistakes.
I am a human, and I know I make mistakes, therefore I prep even my silly infrastructure at home to defend against my sillyness.
I do the opposite. Whenever I delete anything I use rm -rf /full/path/to/file
Just starting to type that triggers a fear response and makes me triple-check what I'm doing.
Honestly, this idea has me pretty mortified as well. Just seeing ”rm -rf /” as part of a string sends chills down my spine.
Granted, any reasons or explanations to cause a string being cut short to this godforsaken form and accidentally run is extremely unlikely, but a valid theoretical possibility: I can easily imagine someone mistyping the first letter after root and, wishing to delete it, pressing Backspace while simultaneously accidentally grazing the Enter key.
Sure, the chances of it happening are about the same as a gun user accidentally dropping their gun, clumsily catching it in the air and accidentally shooting someone right in between the eyes as a result.
..and this is the reason I added this to my root .bashrc: export PS1="\h:\$(realpath .)\$ "
no more following symlinks on a remote mount and forgetting about it.
At a previous job I remember a PR to do essentially
temp=$(mktemp -d)
mv $target $temp
rm -r $temp &
I thought it was pretty clever. Obviously you would need to make sure mktemp is on the same filesystem (there are good flags to just use a dot file in the current directory). mv is atomic on most filesystems and then the & just runs the rm in the background .
24 Comments
db2@lemmy.world · 46 pts · 207d
Everyone asks what is rm but nobody asks how is rm.
a_non_monotonic_function@lemmy.world · 5 pts · 206d
No one ask when rm is.
mushroommunk@lemmy.today · 17 pts · 207d
Those French dictionaries are massive.
lemmy_get_my_coat@lemmy.world · 10 pts · 207d
fr fr
mhzawadi@lemmy.horwood.cloud · 13 pts · 207d
Don't delete the french language pack, it's vital to the OS
JackbyDev@programming.dev · 2 pts · 205d
rm -fr /deegeese@sopuli.xyz · 9 pts · 207d
hddsx@lemmy.ca · 10 pts · 207d
Nobody deletes “./“. It’s far far more likely to be “/ tmp/file”
Also, without the -f it will prompt you. Chances are, the meme is with -f
The other possibility, though I haven’t tested it, is the working directory is / and they did “rm -rf .” Without first checking with pwd. I know that most OS will refuse to remove root without passing in a special flag nowadays. Only a few OS still respect you as sudo.
T156@lemmy.world · 4 pts · 207d
Though the check isn't very sophisticated, if memory serves. It more or less checks whether / is passed to
rm -r.If you did something like
rm -r $VAR/*, but didn't check to make sure that$VARwas set and not empty, it could still fire, since rm wouldn't see that root got passed, only a bunch of directories in root.LunaChocken@programming.dev · 1 pts · 206d
I always add rm flags AFTER the paths. So then I double check the path after adding the flags.
7U5K3N@lemmy.dbzer0.com · 5 pts · 207d
Honestly I was cleaning up some docker stuff today..
So I'm
Hit the refresh button in my gui file browser and it was still there. Lol Took a good 15 seconds for it to vanish.
Crazy. But idk why I expected it to be instant.
sepi@piefed.social · 3 pts · 207d
This is where we sort the younglings from the grizzled veterans that backup and test their backups. Haven't lost a file since 2002.
Peffse@lemmy.world · 4 pts · 207d
I had a coworker preparing a customer database that arrived via sneakernet. He typo'd a variable during an rm -f step and ended up wiping the device because it was his working directory and the variable was undefined.
sepi@piefed.social · 1 pts · 205d
Last evening, I deleted a file by mistake in my dhcp server. Five minutes later I had recovered the file from the previous night's backup and was going about my merry way as if nothing happened.
If humans can make mistakes with the files, you should consider having backups. Having backups is something you decide to engage in BEFORE you have a loss event, so that you are prepared for when humans make their mistakes.
I am a human, and I know I make mistakes, therefore I prep even my silly infrastructure at home to defend against my sillyness.
umbrella@lemmy.ml · 3 pts · 206d
JackbyDev@programming.dev · 3 pts · 205d
rm -i: Am I a joke to you?BoJackHorseman@lemmy.world · 1 pts · 205d
JackbyDev@programming.dev · 3 pts · 205d
alias rm='rm -i': Am I a joke to you?communism@lemmy.ml · 3 pts · 206d
Use trash-put and trash-cli.
mech@feddit.org · 2 pts · 206d
I do the opposite. Whenever I delete anything I use
rm -rf /full/path/to/fileJust starting to type that triggers a fear response and makes me triple-check what I'm doing.
unwarlikeExtortion@lemmy.ml · 4 pts · 205d
Honestly, this idea has me pretty mortified as well. Just seeing ”rm -rf /” as part of a string sends chills down my spine.
Granted, any reasons or explanations to cause a string being cut short to this godforsaken form and accidentally run is extremely unlikely, but a valid theoretical possibility: I can easily imagine someone mistyping the first letter after root and, wishing to delete it, pressing Backspace while simultaneously accidentally grazing the Enter key.
Sure, the chances of it happening are about the same as a gun user accidentally dropping their gun, clumsily catching it in the air and accidentally shooting someone right in between the eyes as a result.
Nemoder@lemmy.ml · 2 pts · 206d
..and this is the reason I added this to my root .bashrc:
export PS1="\h:\$(realpath .)\$ "no more following symlinks on a remote mount and forgetting about it.
bricked@feddit.org · 2 pts · 206d
In that case you should try rmz to speed it up again
ftbd@feddit.org · 1 pts · 203d
Gives you plenty of time to contemplate your backup strategy
janAkali@lemmy.sdf.org · 1 pts · 206d
nemith@programming.dev · 1 pts · 207d
At a previous job I remember a PR to do essentially
temp=$(mktemp -d) mv $target $temp rm -r $temp &
I thought it was pretty clever. Obviously you would need to make sure mktemp is on the same filesystem (there are good flags to just use a dot file in the current directory). mv is atomic on most filesystems and then the & just runs the rm in the background .
bleistift2@sopuli.xyz · 1 pts · 206d
I fail to see the benefit of that script.