Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question

migrated from stackoverflow.com Jan 16 '13 at 1:48

This question came from our site for professional and enthusiast programmers.

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.

share|improve this answer

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.

share|improve this answer
    
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 '13 at 8:33
    
Why the script you can edit? Just sudo python is enough. – LtWorf Feb 22 '13 at 13:38
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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.