2

I have been using a Raspberry Pi for a few weeks and put a lot of hours into configuring everything for my university project.

I wanted to install Samba and have everything as a network folder. I used sudo chown -R pi:pi /.

Now my sudo is broken and prints sudo: effective uid is not 0, is sudo installed setuid root? every time I run it (for instance, sudo nano).

Can this be repaired? Please help me so I do not have to reinstall EVERYTHING. I cannot even remember what I did in the past weeks... so much work.

3
  • 2
    I always pause for a moment and consider the effects whenever I have a lone / in a command, and for any command with with root privileges (sudo) . How did you get the idea to do that?
    – RobertL
    Nov 4, 2015 at 22:19
  • you have broken your system. you can't fix it unless you have a complete list of files and what their owner/group and permissions should be. You may be able to extract this information (for system files at least) from the original tarballs or packages for your raspberry pi. it will be tedious and a complete PITA. probably easier to backup your personal files and /etc and reinstall from scratch. be more careful with chown (and other commands/options that work recursively from the / directory) in future.
    – cas
    Nov 5, 2015 at 1:13
  • To avoid this problem, use a configuration management tool. I simple one is to write scripts to make every change on you system, and put these scripts into revision control. Only make system changes by running the scripts, this way you can restore the system, by re-running the scripts. (not fool proof, but will help.) Jun 29, 2016 at 21:16

3 Answers 3

2

Running sudo chown -R pi:pi / basically broke the ownership of every file on your system.

Unfortunately, reinstalling is probably the easiest option in your case. It would be very tedious and error-prone to try to restore the proper ownerships by hand (using a different computer, presumably). I recommend imaging your Raspberry Pi's storage before you reinstall, so that, after reinstalling, you can restore the some of the changes you made.

0

The setuid bit in an executable file means that the file in question may change its effective UID to be that of the owning user instead of that of the calling/executing user.

By running sudo chwon -R pi:pi / you made sudo to be owned by user pi (non-zero UID) and therefore, when sudo checks if it can change its effective UID to 0 (root), it sees that it cannot, because it is not owned by root anymore.

You may try to repair it by executing chown root:root over sudo, but it might say that you do not have enough permission to do that, so reinstalling might be the only possibility there.

0

The easiest approach is to find and save all files that have been modified in "the last few weeks", then reinstall and reapply the changes.

  1. Boot a rescue disk.
  2. Find and save "recently" changed files - cd /mnt/root && tar czvf /mnt/usb/tarball.tgz --newer-mtime='2015-10-01 00:00:00' . Make sure that /mnt/root is the root of your Pi system and not the root of the rescue disk, and that /mnt/usb is somewhere safe, such as a USB stick
  3. Reinstall
  4. Restore the files you carefully saved - cd / && tar xzvf /root/tarball.tgz
  5. Reboot
0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .