0

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?

closed as unclear what you're asking by Romeo Ninov, Rui F Ribeiro, Jeff Schaller, Christopher, RalfFriedl Jan 22 at 20:48

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • The permissions of which files, exactly? – Jeff Schaller Jan 19 at 20:08
  • Fixed it in edit. The permission of which chmod itslef – Vitali Pom Jan 19 at 20:10
2

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.

  • 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 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 at 21:56
2

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.

  • yes it's okay, but this is chmod, will I be able to revert it somehow? – Vitali Pom Jan 19 at 20:16
  • @VitaliPom Do you understand the difference between executing a program and calling the kernel syscall? – tchrist Jan 19 at 20:17
  • Now I do yes after reading the answers – Vitali Pom Jan 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 at 20:46

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