1

Always been wondering about this, I figure some hackers out there probably know. I did it on a VM and couldn't figure out what to do for the life of me.

4 Answers 4

4
perl -e 'chmod 0755, "/bin/chmod";' 

This will fix it if you are root. Most unix and linux based OS's have perl installed and available by default.

0

Boring option: mount that partition from a live CD/different machine and chmod your chmod...

If you have python installed, intact and have some already executable python script you can edit, you could hijack it to call os.chmod. Or similar call in any still executable thing that can do system calls.

2
  • you wouldn't even need an executable python script; you can just run python -c .... (if python won't execute, an executable script won't help you either.)
    – Eevee
    Jan 16, 2013 at 8:33
  • Why the script you can edit? Just sudo python is enough.
    – LtWorf
    Feb 22, 2013 at 13:38
0
cp /bin/ls new-chmod && cp /bin/chmod new-chmod && ./new-chmod +x /bin/chmod

First, make a new (must be new, so cp will copy permissions) file, which is a copy of an existing executable file (/bin/ls). Then copy the contents of chmod over the new executable file (cp won't copy permissions to an existing file). Then use this new executable chmod to make /bin/chmod executable.

-1

Switch to Single User Mode (init 1) and you should be able to restore your permissions.

In effect (though not exactly true), this logging is as a "super-root" user.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .