So I did a chmod -x chmod. How I can fix this problem? How do I give execute rights back to chmod?
Asked
Active
Viewed 1.4k times
10 Answers
18
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 ls:
cp /bin/ls /tmp/chmod.tmp
cp /bin/chmod /tmp/chmod.tmp
mv /tmp/chmod.tmp /bin/chmod
Dennis Williamson
- 64,083
7
setfacl -m u::rx /bin/chmod
... will grant the owner execute permissions.
But, the /lib/ld-linux.so.2 trick is neat. :)
Kyle Brantley
- 1,391
5
This is weird... I saw something like this a few days ago via someone's tweet...
ThatGraemeGuy
- 15,788
5
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.
Alnitak
- 21,641
2
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
Julien
- 1,048
1
create a new chmod and use that for the original
umask 000
cat chmod > ~/my-chmod
~/my-chmod a+x chmod
Kevin M
- 2,322