Tuesday, June 12, 2012

sudo: unable to execute /bin/rm: Success

I found a weird error message when I tried to delete some files in my linux box today. The command I used was

sudo rm -rf *.js
to delete some .js files, and I got an error message:
sudo: unable to execute /bin/rm: Success
After googling around, I found this wonderful site, and the solution is to use find coupled with -exec flag rather than rm:
sudo find . -iname '*.js' -exec rm {} \;
The problem is, according to the site, was caused by buffer overflow when expanding the *. 
The single quote that we used in the find command will prevent it from expanding and causing overflow.

So, that's all folks. 

1 comment:

Anonymous said...

Thanks for the help on a weird error. But use a "-maxdepth 1" or appropriate flag, as 'find' recurses by default, where "rm" does not. This:
% cd / ; sudo rm l* # might be benign
% cd / ; sudo find . -name="l*" -exec rm {} \; # would remove, /bin/ls, for example.