So I did a
chmod -x chmod. How I can fix this problem? How do I give execute rights back to chmod?
/lib/ld-linux.so.2 /bin/chmod +x /bin/chmod
# python Python> import os Python> os.chmod("/bin/chmod",0755)
This relies on the fact that permissions of a destination file are preserved rather than the source file when it is being copied over. We're "borrowing" the permissions of
cp /bin/ls /tmp/chmod.tmp cp /bin/chmod /tmp/chmod.tmp mv /tmp/chmod.tmp /bin/chmod
% perl -e 'chmod 0755, qw[/bin/chmod]'
setfacl -m u::rx /bin/chmod
... will grant the owner execute permissions.
/lib/ld-linux.so.2 trick is neat. :)
This is weird... I saw something like this a few days ago via someone's tweet...
Should you be on a system where
/bin/chmod can't be loaded by the dynamic linker:
# /bin/mv /bin/chmod /bin/chmod.tmp # install -p -m 755 /bin/chmod.tmp /bin/chmod
This works on my MacOS X system.
/rescue/chmod 555 /bin/chmod
I think you could also use mtree.
I suspect this is not a real question: http://www.slideshare.net/cog/chmod-x-chmod
- Reinstall chown: sudo apt-get install --reinstall coreutils
- perl -e 'chmod 0755, "chmod"'
- more examples in the slides
create a new chmod and use that for the original
umask 000 cat chmod > ~/my-chmod ~/my-chmod a+x chmod