Tech Docs

What if chmod’s execution permission is gone.

  • chmod is installed and chowing “chmod: command not found:
  • Accidentally/knowingly typed chmod 644 /bin/chmod

This is kind of “Key board not detected, Enter any key to continue.

Here is the fix

Create a dummy command with functions of chmod

1. Copy a file having execution permission.

To create a dummy command just copy a binary/executable file  to a directory. here I’m taking ‘date’ command. get the location of binary with #which date

cp   -a    /bin/date    /root/dummychmod

-a  is an archieve switch. I’m taking new name as dummychmod in /root, you can choose any directory and name of your choice.

2. Copy the code of chmod to our dummychmod.

To copy the code in the real chmod we can use cat command and redirection. And for this you need to know the location of chmod.

which   chmod

/bin/chmod        Will be the location. Now we can copy the code.

cat    /bin/chmod    >    /root/dummychmod

And now we have got a dummy chmod..!

3. Change permission of chmod using /root/dummychmod.

/root/dummychmod    755    /bin/chmod

Using the dummychmod we have changed the permission of chmod to 755 and so we can start using it.

4.Check chmod to confirm.

chmod    700  /root/dummychmod