News for hackers. Stuff that matters.
Re:Don't touch my clipboard by belltaco on Monday February 17, 2020 @10:12PM (#22353131)
Wonder if an author will rename themself sudo rm -rf / with the proper escape codes.
Re:Don't touch my clipboard by dylan604 on Monday February 17, 2020 @10:35PM (#22353241)
You my friend, are an evil, sadistic meglomaniac. I love it. Remind me not to make you mad.
Re:Don't touch my clipboard by sundvor on Monday February 17, 2020 @10:13PM (#22353133)
Bobby wants his tables back!
Re:Don't touch my clipboard by numlock86 on Tuesday February 18, 2020 @04:31AM (#22354649)
Legend has it that all data related to little Bobby Tables has been lost.
Re:Don't touch my clipboard by remotetalks69 on Tuesday February 18, 2020 @01:55AM (#22354024)
:D
Re:Don't touch my clipboard by dan_hawkins on Tuesday February 18, 2020 @10:45AM (#22356816)
`rm -rf ~` is disastrous enough on macOS with a bonus of not having to authentiacate sudo.
Re:Don't touch my clipboard by diegoperini on Wednesday February 19, 2020 @04:01AM (#22364028)
How do people know the result of running this command without running a VM? Is it possible to run OS X in a VM these days?

The command's intention is so obvious I wonder why there is no warning from the os, the shell program or the terminal for such, easily blacklist-able commands. Or is there?

Re:Don't touch my clipboard by dan_hawkins on Wednesday February 19, 2020 @05:47AM (#22364472)
I've learned that personally one night fighting messed up rebase conflicts and for still unknown reason I copied and pasted a path for `rm` and ended up issuing `rm -rf ~ /repo-path /unneeeded-dir` - it took me a couple of seconds to realize that this command takes unexpected long time to execute and then my eye caught a view of Finder window with shrinking list of folders in home directory :) Time Machine helped me quite a lot but unfortunately with a nasty surprise that it doesn't backup dot files :-/ Lessons learned.
Re:Don't touch my clipboard by dan_hawkins on Wednesday February 26, 2020 @08:49AM (#22422826)
PS: it turns out you can restore dot files from the Time Machine backups but it's not enabled by default:

https://apple.stackexchange.com/questions/141321/how-to-rest...

Re:Don't touch my clipboard by mercer on Friday February 21, 2020 @03:36AM (#22381737)
> Time Machine helped me quite a lot but unfortunately with a nasty surprise that it doesn't backup dot files.

Wow, that's good to know!

Re:Don't touch my clipboard by jmnicolas on Tuesday February 18, 2020 @05:15AM (#22354841)
When I learned about this command 10 years ago I tried it on a Debian system that I had no use of anymore.

There's a big warning before it lets you execute the command.

Re:Don't touch my clipboard by trumbitta2 on Tuesday February 18, 2020 @05:30AM (#22354917)
That's true only of distributions that alias rm with rm -i.

Now, almost 20 years ago only RedHat did it. And it felt wrong to me :-/

Re:Don't touch my clipboard by jeroenhd on Tuesday February 18, 2020 @06:54AM (#22355274)
Modern versions of rm require you to pass --no-preserve-root. According to Wikipedia [1] this has been the default (in upstream) since 2006. Of course it took distros some time to actually update to the GNU utils 6.4 (especially long-term support systems like CentOS) but it's been a decade since the change should've been implemented everywhere.

[1]: https://en.wikipedia.org/wiki/Rm_%28Unix%29#Protection_of_th...

Re:Don't touch my clipboard by AdmiralGinge on Tuesday February 18, 2020 @09:11AM (#22356153)
Isn't that only a GNU and FreeBSD thing? I think other Unixes will still let you rm -rf /.

On FreeBSD you can do

    sudo dd if=/dev/random of=/dev/mem
and it will do exactly that, write random crap into your memory without any sort of safeguard, causing a spectacular crash and a console that looks like it's having a seizure. Linux won't let you do that unless it's been compiled with a flag to enable full access to /dev/mem and /dev/kmem.
Re:Don't touch my clipboard by 0xdeadb00f on Thursday February 20, 2020 @07:49AM (#22374690)
I want to try that dd command. For fun. Just to see what happens on OpenBSD.

No lasting effects are there? Besides a crash, afterwards I shouldn't have any memory issues, right?

Re:Don't touch my clipboard by AdmiralGinge on Thursday February 20, 2020 @08:01AM (#22374749)
I tried this in a FreeBSD VM and it booted fine afterwards. OpenBSD wouldn't let me do it at all for some reason.

Obviously no warranty on bare metal/systems that are actually used for anything.

Re:Don't touch my clipboard by Lex-2008 on Tuesday February 18, 2020 @07:12AM (#22355356)
worth noting that it can be trivially workarounded by adding an asterisk at the end: `rm -rf /*` still works.
Re:Don't touch my clipboard by jeroenhd on Tuesday February 18, 2020 @07:20AM (#22355398)
Fair enough, but on the other hand there's nothing preventing you from just putting --no-preserve-root in the command either. I see the feature as something to prevent accidents, not as a way to secure the rm command.
Re:Don't touch my clipboard by tomjakubowski on Wednesday February 19, 2020 @08:50AM (#22365374)
That version will helpfully leave behind any .files lingering in /
Re:Don't touch my clipboard by big_chungus on Tuesday February 18, 2020 @11:22AM (#22357121)
Maybe run `sudo chmod -R 000 /` instead. Can't get charged with destroying any data, but it's a huge pain to get a system working again from that. Only done it twice; hope never to do so again.
Re:Don't touch my clipboard by nodesocket on Tuesday February 18, 2020 @01:20PM (#22358581)
Curious to know how you recover from that? How do you what permissions to assign back to files and directories?
Re:Don't touch my clipboard by hatsubai on Tuesday February 18, 2020 @02:14PM (#22359247)
Depending on how you define "fix," the common way (if the machine has already been rebooted and you're locked out of the session) is to boot via a live distro, mount the filesystem, and change permissions to get a usable system back. There are various other methods depending on the machine state and requirements, too, so it's definitely recoverable from a working machine standpoint. Changing permissions back to what they used to be is a rabbit hole that varies depending on your distro, machine-specific requirements, and any special permissions setup by you and your admins.
Re:Don't touch my clipboard by big_chungus on Tuesday February 18, 2020 @04:34PM (#22360639)
It's a pain-and-a-half. I'm not sure any system ever recovers fully, but you basically run chmod -R's on most of the important directories and then fix the many services that will surely fail once you can get a shell.

More specifically, I used a bunch of these links until I could get a shell, then manually-fixed the rest.

https://askubuntu.com/questions/308939/how-to-reset-default-...

https://askubuntu.com/questions/508359/restore-default-syste...

Re:Don't touch my clipboard by nemosaltat on Wednesday February 19, 2020 @12:33AM (#22363271)
Can confirm. I kept getting permission errors on something I was testing, and in desperation ran `chmod -R 777` thinking I was in my project dir. I was actually at root. After a bunch attempts to recover, I ended up saving the data I cared about and doing a fresh install. 0/10 would not recommend.
Re:Don't touch my clipboard by webXL on Tuesday February 18, 2020 @01:41PM (#22358845)
Curious to know what circumstances led up to someone doing that and if they were charged for other violations.
Re:Don't touch my clipboard by gowld on Tuesday February 18, 2020 @08:16PM (#22362202)
A modern shell should prevent you from directly executing pasted code.