Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 296
Robert Caldwell Avatar asked Oct 24 '13 00:10

Robert Caldwell


2 Answers

If you have perl, you can do:

perl -e 'chmod(0755, "chmod")'
like image 115
Barmar Avatar answered Sep 21 '22 22:09

Barmar


As suggested here: https://unix.stackexchange.com/questions/77852/how-to-recover-from-a-chmod-r-000-bin you could try using sudo perl -e 'chmod 0755, "/bin/chmod"' to fix the permissions on the file.

I tried this myself just now by copying /bin/chmod to ~/chmod, running ~/chmod 400 ~/chmod then attempting to use ~/chmod again. I received a permission denied error as expected. I then used the perl trick such that perl -e 'chmod 0755, "~/chmod"' and was able to once again use ~/chmod.

I hope this helps.

like image 20
Brandon Haston Avatar answered Sep 20 '22 22:09

Brandon Haston