Recovery Steps from chmod -R 000 /bin/chmod?

Everyone knows /bin is the binary location for all the general commands we use in Linux. Let see how can we recover if the permission for chmod binary changed to 000.

There is a way to recover it by reinstalling coreutils.

Lets go with test case

[root@instance-1 ~]# ls -al /bin/chmod
-rwxr-xr-x. 1 root root 52472 Jun 19 2018 /bin/chmod

[root@instance-1 ~]# chmod 000 /bin/chmod

[root@instance-1 ~]# ls -al /bin/chmod
———-. 1 root root 52472 Jun 19 2018 /bin/chmod

root@instance-1 ~]# chmod 644 test
-bash: /bin/chmod: Permission denied
[root@instance-1 ~]#

Now we are in trouble, we cannot change permission of any of the files.

We can start our troubleshooting and fix it soon.

Check what version of OS we are using

root@instance-1 ~]# uname -a
Linux instance-1 2.6.32-754.9.1.el6.x86_64 #1 SMP Thu Dec 6 08:02:15 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux
[root@instance-1 ~]# rpm –query centos-release
centos-release-6-10.el6.centos.12.3.x86_64
[root@instance-1 ~]#

Download the core utils for the respective version from CentOS website and upgrage the coreutils forcefully

[root@instance-1 ~]# wget http://mirror.centos.org/centos-6/6.10/os/x86_64/Packages/coreutils-8.4-47.el6.x86_64.rpm

[root@instance-1 ~]# rpm -Uvh –force coreutils-8.4-47.el6.x86_64.rpm
Preparing… ########################################### [100%]
1:coreutils ########################################### [100%]

[root@instance-1 ~]# ls -al /bin/chmod
-rwxr-xr-x. 1 root root 48712 Jun 19 2018 /bin/chmod
[root@instance-1 ~]#

Yes we did it… 🙂


Leave a comment