Linux: What If chmod loses it’s execution

Introduction

“chmod” is one of the frequently used command for file permission bits manipulation. Due to it’s simple nature and wide variety, it is definitely used at-least once by any Linux System admin. Still if you are new to it, internet is full of numerous articles on it, please let us know in comment section if you want more details on that.

The Tragedy

Imagine a situation where some accidentally removed its execution bit. You can compare it with someone in mid of war without any weapons.

Enough of theory, let’s understand the scenario with live demo. Use below commands to check the absolute path of chmod command and the permission bits.    

pic1

Well these are the permission bits only [the 9 ones after -] which are mainly managed by “chmod”.

pic2

Accident happened, and someone removed the execute bit (knowingly or accidentally)

pic3

Capturepic7

Our hero command lost it’s power, even root is not able to fix it’s execution rights.

pic4

Now what ? will admin loses it’s job for running one silly command. Thankfully NO as we can rescue it by several methods 🙂 , i am going to discuss one with you below.

Before moving to next section, we would suggest you to personally read the scenario again, and guess the probable rescue strategies.

The rescue

Access Control list (ACL’s) as name suggest for controlling the access rights of an user/group on file/directory can be used here as a savior. (Personally glad to see it in action apart from it’s boring traditional use). Congratulations, if you guessed same, still if you have anything else to use, please share it in comments section below.

Please use below command to set the access rights of read write and execute to current user (root user in our case) on “chmod” binary file.

pic5

Bingo! You successfully restored the weapons to our hero in war. 

pic6

Well all this from our end, we believe that this blog will be your mate someday in need of hour. Practice and share your feedback. Happy learning !

2 thoughts on “Linux: What If chmod loses it’s execution

Leave a comment