6 ways to recover from chmod a-x chmod

Someone did:

chmod a-x /bin/chmod

marking the chmod programm not executable, how can we repair this, when we can’t execute chmod?

  • copy/cat
  • cp /bin/echo /root/echo
    cat /bin/chmod > /root/echo
    /root/echo a+x /bin/chmod

  • rsync
  • rsync --chmod=a+x /bin/chmod /root/chmod
    /root/chmod a+x /bin/chmod

  • busybox
  • busybox chmod a+x /bin/chmod

  • gcc
  • cat > chmod.c
    int main() {
    char path[] = "/bin/chmod";
    chmod(path,00555);
    }
    ^D
    gcc chmod.c
    ./a.out

  • ld.so
  • /lib64/ld-linux-x86-64.so.2 /bin/chmod a+x /bin/chmod

  • setfacl
  • setfacl -m user::rwx /bin/chmod

    Found another solution? Let me know in the comments.

    Leave a Reply

    Your email address will not be published. Required fields are marked *