-1

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?

Vitali Pom
  • 99
  • 5

2 Answers2

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.

tchrist
  • 433
1

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 '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