Recently I tried installing Zigbee2Mqtt next to my openhab2.5
I followed the instructions found here:
But after executing ```
sudo chown -R ${USER}: /opt/zigbee2mqtt
(literally)
I keep getting following error when trying any sudo command:
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Solutions I find online are either telling me I need to reinstall my OS, which I definitely want to avoid since I also have other custom code running next to openhab, communicating with my openhab over mqtt. This runs for more than a year now but I remember having a hard time getting it to work. Since I donât take notes on everything I do, I will also not remember how to get it to work again so I will have to figure everything out once again on a fresh installation. I also canât backup my openhab since I need to do this with a sudo commandâŠ
An alternative solution I find is to login as root but that doesnât seem to be possible in openhabianâŠ
Does anyone has any idea on how to fix this?
that would be /etc/passwd but anyway, when it puts the uid numerical that tells you the OS canât find a user entry with that uid itself.
On my system it get this:
$ ls -la /usr/bin/sudo
-rwsr-xr-x 1 root root 147560 Jan 20 2021 /usr/bin/sudo
note the s in -rws above, guess it signifys said setuid bit. Google it.
1001 probably existed once, was referenced in an unfortunate chown command, and later deleted.
Did you keep notes of the root passwd on that box? You could try su to become root, then chown root: /usr/bin/sudo
If you donât know the root password you will need another linux box, for example a virtualbox with a minimum debian install. You would mount the sd-card on that system and fix the permissions as root from there.
Good luck and yes, keeping a journal of your installs and modifications can be really useful. Take a look at ~/.bash_history
And if you want to research your install history on that system, try this:
I can only recommend in the strongest possible terms to use some kind of tool to manage deployments instead of manually messing around with machines directly. It doesnât scale, it isnât reproducible and getting things back to a âknown goodâ configuration is close to impossible.
Iâve had that very same issue with openHABian before as well, so that is not a precaution.
Happened during a Homebridge initiated update, so also not really that much of manual messing.
My only option was to reinstall the system, admittedly with openHABian made easier. I also then set up a root password, disable root login for general use, but enable it before installations where this might possibly appear again so I can easily correct sudo again just in case.
I broke sudo in this way recently, and I was able to recover from it without reinstalling. I had to boot my system into rescue mode using grub, then change the ownership of sudo (and half the rest of the drive) back to root. Since my debian install had disabled the root account, I had to set a password for that too.
Once sudo worked again I used apt to reinstall all packages so they fixed their ownerships too.