Long story short, while learning bash scripting etc, I erroneously ran chmod -R 770 /bin (please don't ask why, this is already quite embarrassing as is).

The issue that made me realize the horrible mistake was a denied permission running /bin/bash when logging in as user (resulting in a closed SSH connection), and after trying many other solutions found googling, I checked .bash_history to find out the comic mistake.

Anyways, is there any way at all to get permissions back to defaults for folder and files? (other than reinstalling the os)

I have a backup of the whole SD (I'm on a headless RasPi running Minibian) not older than 3 days, but I'm not quite sure rolling back the previous version would actually change any permission. Are these details stored in the folder itself, or in some sort of a registry?

Also. Why is it that, despite being the permissions rwx on the user as well as the root, the scripts aren't executed?

  • 1
    How did you make the backup? – muru Dec 11 '15 at 19:20
  • dd from /sd to .img – nxet Dec 11 '15 at 19:21
  • It would be simpler if you can boot to a live USB and mount the Pi and the backup image. Can you do that? Which distro are you using? Please edit your question to add clarifications. – muru Dec 11 '15 at 19:24
  • (added above) I'm running Minibian. And what do you mean by mounting the Pi? In any case, in this very moment the Pi is the only Linux machine I can use, therefore it would be best for me to find a solution working directly on the Pi logged in as root. – nxet Dec 11 '15 at 19:29
  • just to be clear, did you mean to guide me through a procedure like the following? superuser.com/questions/132891/… – nxet Dec 11 '15 at 19:33

For a starter, chmod -R 555 /bin will get you up and running.

Then chmod 4755 /bin/ping6 /bin/su /bin/mount /bin/ping /bin/umount will get your setuid scripts working.

If you didn't mess up /usr/bin, your sudo should be okay but if not run chmod 4111 /usr/bin/sudo.

There is more that should be fixed but this would be the start of a recovery procedure if overwriting that whole directory is not an option.

  • simple overwriting can be an option then? – nxet Dec 11 '15 at 20:19
  • Should be, if you have a backup. Just be sure you copy from the backup (a) as root, and (b) with a "preserve permissions and owner" flag set. (I often use rsync rather than cp because it is considerably faster for many cases and it is more versatile.) – Wildcard Dec 12 '15 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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