Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can someone explain to me what this command does?

EDIT: Do not run this command! It will break your installation.

sudo find / -exec rm {} \;
share|improve this question
As you (originally) presented it,-exec rm {}\; will give a syntax error. The correct syntax requires a space between {} and \; – Peter.O Sep 3 '15 at 19:34
The command needs a \! -type d to not spew all those silly errors. – oals Sep 3 '15 at 19:46
@oals Or redirect errors to /dev/null. Also check the -delete option of find. – ott-- Sep 3 '15 at 19:56
I can't tell if this is a joke… or if someone told you to do it as a "joke". – Shep Sep 4 '15 at 1:58
On a professionally maintained and secure system it should (probably) not do anything useful. – roaima Sep 4 '15 at 9:03
up vote 26 down vote accepted

Bad Things ® ™. It's (almost) the equivalent of sudo rm -rf / - it will, as root, find all files or directories starting from / and recursively descending from there, and then execute the rm command against each file/directory it finds. It won't actually delete directory entries as there's no -f or -r options passed to rm, but it will remove all the file entries.

Hint: don't run this unless you feel like reinstalling your operating system.

share|improve this answer
Strictly speaking, at some point it will delete /bin/rm, and after that it will fail to delete any more files. The suggestion by @ott to use -delete would fix this "bug" :-) – Nate Eldredge Sep 3 '15 at 20:33
This avoids the built-in protection in GNU rm, which blatantly refuses to remove everything from the root downward. – Simon Richter Sep 4 '15 at 2:43
Note that this command won't be equivalent to sudo rm -rf /. Attempt to remove / is prohibit by POSIX rm (busybox rm does remove /). – cuonglm Sep 4 '15 at 8:55
As Cuonglm said, sudo rm -rf / is harmless on POSIX (and most other) systems, so no, this is not like it at all! – terdon Sep 4 '15 at 11:02

Don't run it.

This will find everything (all files, directories, links, sockets etc) under / i.e. everything in the system and then it will try to remove those one at a time with rm.

Note that as there is no -r option with rm, only the directory entries will not be removed, everything else will be gone.

share|improve this answer
@cuonglm find / will list all files, and -exec executes the command on each result of find. So it's the find command doing the recursion, and rm is only called for each individual file. – jozzas Sep 4 '15 at 5:10
@jozzas: No, find / list all files and directories under /, all directories left unchange, only files removed. – cuonglm Sep 4 '15 at 6:41
@cuonglm I have already mentioned that..please check second paragraph.. – heemayl Sep 4 '15 at 8:41
@heemayl: Ah, I see, sorry for my mis-reading. – cuonglm Sep 4 '15 at 8:42

Simple! This command will remove all files in your server.

Don't run it!

share|improve this answer

protected by Michael Mrozek Sep 4 '15 at 16:10

Thank you for your interest in this question. Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.