Raspberry Pi 4 running Openhab 3.3.0
I have playing all evening trying to get Node-Red to work and now suddenly found, that I can’t use any more “sudo” command in console…
It gives me “/usr/bin/sudo must be owned by uid 0 and have the setuid bit set”
I don’t know, what I did to have this problem…
Openhab itself runs nicely, everyting is working.
In console command " sudo openhabian-config" gives me the answer: “sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set”
Command “ls-l /usr/bin/sudo” gives me “-rwxr-xr-x 1 frontail frontail 135376 Jan 23 2021 /usr/bin/sudo”
Yes but you’re not going to like it. And the permissions on the sodoers file is not something that just randomly happens which makes me question whether there isn’t something much more fundamental going on (SD care is wearing out) like you ran one of the nuclear destruction commands on Linux/Unix machines like recursively changing the ownership of all files under / or even just under /etc which is going to take way more than just fixing that one file to get the machine back up and running.
To fix sudo you’ll need to stop that machine, mount the SD card on another machine that can read ext4 file systems (Windows cannot without special software, many will use a VM running Linux to mount the file system). Then navigate to that folder and fix the ownership of the file to root:root (i.e. 0:0) and make sure the file permissions are -rwsr-xr-x.
Given that output from ls I’m going to guess you (or something) ran a chmod -r and chown -r from \ to set the permissions for frontail and now everything is owned by frontail with those permissions. If only that one file is owned by frontail, your SD card is wearing out or at the very least your file system is corrupted.
In either case the fastest solution will be to start up a new SD card and restore from a backup or mount the SD card to another machine and pull off it what you can. But you will have to pay attention to the ownership and permissions that those file need to be on the new machine. They can’t stay owned by frontail.
Thank you for pointing that.
My Openhab has run on this setup at least for 5 years, and those times all told, that heavy log writing will destroy SD card soone or later - and it did! Added SSD, openhabian-config had “move file system to…” and everything run perfectly.
…untill I messed up with npm and node-red install and accidentally changed owner from root to frontail…
I’m not a linux egineer, my daywork is not computers and programming, Openhab is my hobby project at my house, and I’m dealing with it in the evenings and nights.
Yesterday evening also spent 5 hours to find solution from google, BEFORE to write here and ask for help!
It’s a catch 22. You need root to change the ownership to root. And you don’t have root any more because of the ownership and permissions.
But once again, if this impacted all the files in /usr/bin, which is highly likely, sudo is not the only thing that’s broken. In fact most of your commands and programs will be broken. I’d be surprised if you tried to reboot whether the machine would come back online.
It’s my understanding that openhabian-config has the option to install Node-Red. Why didn’t you use that?
I’ll say it once again, this machine is toast. It’s going to take far longer to fix what’s broken than it will be to start over from scratch. The good news is if you don’t have backups the files on this machine are likely intact. But their ownership and permissions are likely not correct so be careful when you restore them on the new machine that they get restored with proper ownership and permissions (you can see the default files that are there and match those ownership and permission settings.
If you insist on trying to fix this by hand, it’s going to take many hours of tedious work and you will not get much help here because:
it’s a Linux problem, not an openHAB or even an openHABian problem
we’ve already told you the easiest way to fix this, it’s not really required of us to support you doing it the hard way