Can someone explain to me what this command does?
EDIT: Do not run this command! It will break your installation.
sudo find / -exec rm {} \;
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.
/bin/rm
, and after that it will fail to delete any more files. The suggestion by @ott to use -delete
would fix this "bug" :-)
sudo rm -rf /
. Attempt to remove /
is prohibit by POSIX rm (busybox rm does remove /
).
sudo rm -rf /
is harmless on POSIX (and most other) systems, so no, this is not like it at all!
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.
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.
-exec rm {}\;
will give a syntax error. The correct syntax requires a space between{}
and\;
\! -type d
to not spew all those silly errors./dev/null
. Also check the-delete
option of find.man find
tends to have answers for things related tofind
...