I want to try to change /bin/chmod permissions file to rrr but afraid to loose my machine. What happens next if I change them?


If you remove execute permissions from the chmod binary, then all shell scripts (including Makefiles!) that try to execute it will get an error when they try. This includes countless administrative and installation scripts. Your system will fail to work correctly in many unforeseen ways.

Actual programs that call the Unix syscall directly instead of exec’ing another program to do their dirty work for them will be unaffected. But this is little consolation, and your system will still be seriously broken and potentially damaged.

To revert, you would have to write an actual program that can access the real syscall, which means using something like C or Perl, not the shell.

| improve this answer | |
  • yes it's okay, but this is chmod, will I be able to revert it somehow? – Vitali Pom Jan 19 '19 at 20:16
  • @VitaliPom Do you understand the difference between executing a program and calling the kernel syscall? – tchrist Jan 19 '19 at 20:17
  • Now I do yes after reading the answers – Vitali Pom Jan 19 '19 at 20:18
  • Actually, there are several ways of getting back, from toybox to install. But that's properly another question. – JdeBP Jan 19 '19 at 20:46

Why do you want to do that? I don't see any potentially worthwhile point to that.

You won't lose your machine from doing that, but you'll make it a little harder to change permissions (anybody who'll want to do that will have to find - or make - another program that performs the chmod(2) system call.

I would recommend against doing that, and if you have done so (by accident) I would hurry to find another tool that could undo the change.

| improve this answer | |
  • oh, so you're saying I'll have to write a little bit more complex program similar to chmod to revert the changes to chmod itself (like something in C that revert the metadata settings to the original file itself (aka chmod). – Vitali Pom Jan 19 '19 at 20:18
  • There are many, many possibilities. You could archive your chmod binary, e.g. using pax, tar, or cpio, then change the permission metadata inside the archive using a hex editor, then extract it again. Or, just run ruby -e 'File.chmod(0755, "/bin/chmod"', or the Perl, Python, PHP, or Tcl equivalent. – Jörg W Mittag Jan 19 '19 at 21:56

Not the answer you're looking for? Browse other questions tagged or ask your own question.