I stupidly ran "chmod 400 chmod" and now it appears forever broken

Robert Caldwell picture Robert Caldwell · Oct 24, 2013 · Viewed 10.1k times · Source

I'm "hacking" an ARM-base quadcopter running a stripped down Linux as part of a class assignment, and after getting into it using telnet and getting access to the bash terminal, and then messing around the file system I wanted to see what commands were available and how I could mess with it. I ran "chmod 400 chmod" and now I can't change it back, as when I run "chmod 777 chmod" I get "Permission Denied". Is there a command line fix for this? Or do I need some kind of factory reset to get chmod back? And yes I realized how stupid I am for having done this. Thanks!

Answer

Barmar picture Barmar · Oct 24, 2013

If you have perl, you can do:

perl -e 'chmod(0755, "chmod")'