Sure
pi@homeautomatic:~ $ which node
/usr/sbin/node
pi@homeautomatic:~ $ /usr/sbin/node -v
v16.3.0
pi@homeautomatic:~ $ ls -l /usr/sbin/node
lrwxrwxrwx 1 root root 20 Oct 30 19:38 /usr/sbin/node -> /opt/nodejs/bin/node
pi@homeautomatic:~ $
Sure
pi@homeautomatic:~ $ which node
/usr/sbin/node
pi@homeautomatic:~ $ /usr/sbin/node -v
v16.3.0
pi@homeautomatic:~ $ ls -l /usr/sbin/node
lrwxrwxrwx 1 root root 20 Oct 30 19:38 /usr/sbin/node -> /opt/nodejs/bin/node
pi@homeautomatic:~ $
Delete /usr/sbin/node and rerun the install script.
OK I deleted the /usr/sbin/node and ran the script again
pi@homeautomatic:~ $ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16
Now the install script woun't work
Running Node-RED install for user pi at /home/pi on raspbian
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
This can take 20-30 minutes on the slower Pi versions - please wait.
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Stop Node-RED ✘
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Remove old version of Node-RED ✔
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Remove old version of Node.js ✔ v16.18.0
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Install Node.js for Armv6 ✘sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
v16.18.0 Npm 8.19.2
Clean npm cache ✘
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Install Node-RED core ✘
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Move global nodes to local -
Leave existing nodes -
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Install extra Pi nodes ✘
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Add shortcut commands ✘
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
md5sum: /lib/systemd/system/nodered.service.temp: No such file or directory
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Update systemd script - Skipped - existing script is customized.
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
All done.
You can now start Node-RED with the command node-red-start
or using the icon under Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
Just FYI : Your settings.js file is different from the latest defaults.
You may wish to run
diff -y --suppress-common-lines /usr/lib/node_modules/node-red/settings.js /home/pi/.node-red/settings.js
to compare them and see what the latest options are.
**********************************************************************************
### WARNING ###
DO NOT EXPOSE NODE-RED TO THE OPEN INTERNET WITHOUT SECURING IT FIRST
Follow the guide at https://nodered.org/docs/user-guide/runtime/securing-node-red
to setup security.
### ADDITIONAL RECOMMENDATIONS ###
- Remove the /etc/sudoers.d/010_pi-nopasswd file to require entering your password
when performing any sudo/root commands:
sudo rm -f /etc/sudoers.d/010_pi-nopasswd
- Change the ownership of its settings file to 'root' to prevent unauthorised changes:
sudo chown root:root ~/.node-red/settings.js
**********************************************************************************
Now it seems I do not have the rights to install? How has that changed?
I then ran ls -la /usr/bin/sudo
and got
pi@homeautomatic:~ $ ls -la /usr/bin/sudo
-rwsr-xr-x 1 pi pi 147560 Jan 20 2021 /usr/bin/sudo
From what I can read on the net, the rights for sudo should be owned my root. How can that change?
That is really bad news. Do you know how you got to that condition? Did you run sudo chown
something? If so then I wonder whether you have accidentally set large sections of the file system to be owned by pi instead of root. I think possibly the only way of recovering is to take the SD card out and plug it into a PC and change the ownership of sudo back to root:root. I don't know how to do that on a Windows PC. Even that may not be enough. Have a look at the ownership of / and /usr and /usr/bin. If they all show as owned by pi then you might have further issues. In fact the easiest thing might be to start again on a new SSD card. Don't overwrite your existing card in case you need to get stuff off it, unless you are sure you have everything backed up.
Something is odd about your install on your Pi. I would export your flow and then get a new SD card,
sudo apt update && sudo apt full-upgrade
If it works, you could then import your flow and the nodes it needs and test it out.
The sort of thing that can cause this issue is to run something like
sudo chown -R pi:pi /home/pi
but accidentally add a space after the first slash, which runs it recursively on the whole system. Another regular thing that can destroy a system is to run
sudo rm -rf /home/pi/something
but again accidentally add a space after the first slash. This has the effect of deleting everything in the whole file system, which is embarrassing to say the least. For this reason I never run sudo commands with a full path as the parameter. Instead, for the chown command I would do
cd /home/pi
then check carefully that I am in the right folder, then
sudo chown -R pi:pi .
That is a dot at the end, which means the current directory.
If you backup the whole of the .node-red folder except node_modules, and copy that to the new system then go into your .node-red folder and run
npm install
and it will automatically install all your contrib nodes and also the credentials and anything configured in settings.js should still work.
I still have a Raspberry Pi running Buster and I see
-rwsr-xr-x 1 root root 147560 Jan 20 2021 /usr/bin/sudo
Interesting to see the modification date is the same as yours because if I chown a file it changes the modification date.
Anyway, I don't think the situation is recoverable, you should certainly follow the advice to rebuild it.
A useful one-line command to achieve this is
tar cf noderedbackup --exclude="node_modules" .node-red
Save this file to a USB stick and once you have installed Node-red recover from the backup with
tar xf noderedbackup
For me it does not change the date.
Ah. Maybe my expectations overruled what my eyes saw via ls -l Confirmation bias.
And the other thing I said - recover from backup after installing node-red - might be wrong too, at least if you are going to a new version of NR.
I'm clearly not having a good day.
I expected the date to change too, so was surprised when I saw it didn't.
For the restore, it would be necessary to run npm install
in order to rebuild node_modules.
Thank you all for you time and inputs. I will backup the node-red files do a fresh install on my Raspberry Pi on a fresh SD card (Thank you @Colin, @zenofmud and jbudd). This will have to wait until the weekend, and I will let you know how it went.
Henrik
Out of interest, do you know what it might have been that you did that messed up the file ownership?
Hmm, on basis of what you have suggested could have done the change of ownership, my best guess is when I deleted /usr/sbin/node
I used the rm
command but had not the rights to delete it, so I used sudo rm
. After that I reran the installation script for Node Red and I began seeing the sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
.
I admit it. I am mostly a Windows guy since the beginning of the 1990's, but have tried several times since about 1999 to learn/use Linux with mixed results... I just don't have the overview of all the commands Linux offers and which ones should be handled with care...
The NR installation script does execute sudo chown pi:pi blahblah but I can't see any circumstances where blahblah equates to /usr/bin/sudo.
On the other hand nor can I see any circumstances where you could mistype sudo rm /usr/sbin/node and end up with sudo chown pi:pi /usr/bin/sudo.
You have to remember that Linux commands do not come with an Undo option, they generally don't say "are you sure?" and often they don't even report that they did anything.
So all should be handled with some care.
If a command includes sudo, never, never press return without checking that you have the command, it's options and especially any pathnames exactly right.
I agree, I can't see any way the script could have done it, or the rm command. The chown would not have to have been done directly on /usr/bin/sudo, it could have been on that whole directory or one of the parent directories (up to /) if recursive were specified). It is most odd.
@henrik1 are you sure you did not run chown
manually?
Also could you have a look at the card and see if it is just /usr/bin/sudo that is owned by pi, or is it the whole of that directory, or possibly even the whole file system. You can check by running
ls -al /
ls -al /usr
ls -al /usr/bin
You don't need to post all that, just look to see if the files are owned by root or pi.
We would really like to know how it happened in case it is the script, or something related to node-red that caused it. We don't want other users to have to re-install their OS.
[Edit] Also could you do
ls -n /usr/bin/sudo
ls -n $HOME
In my mind, this means the OP upgraded node.js by a means other than the NR script.
I would think that is likely to be the source of why things went wrong from then on rather than an issue with the script
Yes, that may well be where the extra nodejs install came from. It doesn't explain the problem with sudo though.
All says root root
pi@homeautomatic:~ $ ls -al /usr
total 896
drwxr-xr-x 10 root root 4096 Feb 6 2021 .
drwxr-xr-x 18 root root 4096 Jan 11 2021 ..
-rw-r--r-- 1 pi pi 692851 Nov 2 20:58 CHANGELOG.md
-rw-r--r-- 1 pi pi 88740 Nov 2 20:58 LICENSE
-rw-r--r-- 1 pi pi 35345 Nov 2 20:58 README.md
drwxr-xr-x 2 pi pi 36864 Nov 2 21:06 bin
drwxr-xr-x 2 root root 4096 Dec 9 2020 games
drwxr-xr-x 36 pi pi 16384 Oct 30 11:13 include
drwxr-xr-x 59 pi pi 4096 Nov 1 16:28 lib
drwxr-xr-x 10 root root 4096 Jan 11 2021 local
drwxr-xr-x 2 root root 12288 Nov 2 20:55 sbin
drwxr-xr-x 95 pi pi 4096 Apr 16 2022 share
drwxr-xr-x 2 root root 4096 Dec 9 2020 src
ALL says pi pi
pi@homeautomatic:~ $ ls -n /usr/bin/sudo
-rwsr-xr-x 1 1000 1000 147560 Jan 20 2021 /usr/bin/sudo
pi@homeautomatic:~ $ ls -n $HOME
total 308
-rw-r--r-- 1 1000 1000 307200 Nov 3 17:09 noderedbackup
-rw-r--r-- 1 1000 1000 81 Oct 30 21:06 package-lock.json
drwxr-xr-x 2 1000 1000 4096 Oct 30 19:38 temp
I am absolutely sure I don't know the chown
command, so I have not typed it in my self. That said I did search the net for advice what to do when I got the sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
running the Node-Red install script . I have been through my web browsers history and found this site I have visited https://unix.stackexchange.com/questions/419122/sudo-must-be-owned-by-uid-0-and-have-the-setuid-bit-set and in there the following commands are used:
# return ownership
chown root:root /usr/bin/sudo
# fix permissions
chmod 4755 /usr/bin/sudo
reboot
I am pretty sure I ran this to try to fix the error I got, but that was AFTER a got the sudo: /usr/bin/sudo must be owned by uid 0 and have the setuid bit set
running the Node-Red install script .
I think it likely that is when it happened. Do you know what you were doing then? Can you show us the start of that file please.
Thanks for helping with this, we would very much like to know how it happened.
Also the start of the readme there please.