6

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!

Robert Caldwell
  • 89
  • 1
  • 1
  • 5

3 Answers3

5

If you have perl, you can do:

perl -e 'chmod(0755, "chmod")'
Barmar
  • 741,623
  • 53
  • 500
  • 612
4

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.

Community
  • 1
  • 1
Brandon Haston
  • 434
  • 3
  • 5
3

Maybe it's possible to copy another chmod binary (with executable rights) to the messed Linux and with that chmod the messed up chmod binary. eg

/path/to/the/copied/chmod 777 /path/to/the/old/chmod.
Yu Hao
  • 119,891
  • 44
  • 235
  • 294
Biluxx
  • 41
  • 1