If my chmod permissions have been reduced to 444 what can I do to rectify this situation?

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

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.

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
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.

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.

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like