Take the 2-minute tour ×
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.

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 yesterday
    
The command needs a \! -type d to not spew all those silly errors. –  oals yesterday
1  
@oals Or redirect errors to /dev/null. Also check the -delete option of find. –  ott-- yesterday
4  
I can't tell if this is a joke… or if someone told you to do it as a "joke". –  Shep 21 hours ago
    
On a professionally maintained and secure system it should (probably) not do anything useful. –  roaima 14 hours ago

3 Answers 3

up vote 25 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
11  
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 yesterday
4  
This avoids the built-in protection in GNU rm, which blatantly refuses to remove everything from the root downward. –  Simon Richter 20 hours ago
2  
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 14 hours ago
    
As Cuonglm said, sudo rm -rf / is harmless on POSIX (and most other) systems, so no, this is not like it at all! –  terdon 12 hours ago

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 18 hours ago
    
@jozzas: No, find / list all files and directories under /, all directories left unchange, only files removed. –  cuonglm 17 hours ago
    
@cuonglm I have already mentioned that..please check second paragraph.. –  heemayl 15 hours ago
    
@heemayl: Ah, I see, sorry for my mis-reading. –  cuonglm 14 hours ago

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

Don't run it!

share|improve this answer

protected by Michael Mrozek 7 hours ago

Thank you for your interest in this question. Because it has attracted low-quality answers, 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.