# How to install node red and recognizer

**URL:** <https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249>\
**Category:** General\
**Created:** [22 October 2023 07:50 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249 "2023-10-22T07:50:51Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [22 October 2023 16:30 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/21 "2023-10-22T16:30:17Z")

</div>

Yes. I didn't want to write out the user, but whatever. There is one user, I use it, everything was installed with it. (not as root as I recall) But you're right, you have to reinstall everything from scratch, I just didn't know that you have to install things as user or root. (node ​​red, recognizer, portaudio, audio device, etc.) so i try  
thanks  
(sorry for my poor english) 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 October 2023 16:43 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/22 "2023-10-22T16:43:51Z")

</div>

If you aren't sure, install as a user unless that doesn't work.

Instructions will usually say if you need to use sudo. But be slightly wary if instructions tell you to use sudo to get access to server hardware - that is nearly always wrong - you should add your user to the appropriate security group rather than compromise security by making everything root.

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [22 October 2023 17:06 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/23 "2023-10-22T17:06:39Z")

</div>

I was able to do quite good things in node red, but I was always in trouble with these permissions, because, as you wrote, there are things that "require" the use of sudo, but then you can't access them properly from another application. I know how to add a user to a security group, but I don't always know where to add it. Thank you very much for the clarification, I understand much better now! (Uninstall sounddevice, reinstall sounddevice in global, but it didn't help)

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [22 October 2023 19:20 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/24 "2023-10-22T19:20:36Z")

</div>

Yes, permissions, especially hardware permissions in Linux can get complex. And you can see from the very many rubbish tutorials on the interweb that many people don't bother to even attempt to get this right.

But Linux permissions are fine-grained and not so hard to understand with a little effort.

> [@azxo1](#):
>
> there are things that "require" the use of sudo

Yes, but really not that many.

Here is an example from my home server's `/dev` folder:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/2/f2d87711fb9eed7279c09cc8b36360985b3fcc92.png)

You can see that some devices have a group setting of `tty` or `dialout`. So easy enough to connect a user to those. But some, like v4l for example are root/root - so should you give users root access to use that device? Well, no, that would be bad. Instead, that device needs changing to maybe give it group permissions of `video`. Because if you give your user root access, they can write to everything (change anything) and so if someone broke into your server (see another recent thread), they could do all sorts of damage or at least maybe access video streams they shouldn't be able to.

So often, a simple `ls -l` in a folder is enough to help you understand what needs doing.

> [@azxo1](#):
>
> Uninstall sounddevice, reinstall sounddevice in global, but it didn't help

Yes, that is a bad choice anyway since you would have to give Python apps root access.

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [27 October 2023 14:30 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/25 "2023-10-27T14:30:23Z")

</div>

Well, it's like:

if `sudo systemctl enable nodered.service`, then node red starts automatically with the raspberry, but the script does not run.

if `systemctl enable nodered.service`, then node red must be started from putty (node-red), the script runs, but if I exit putty, node red also stops

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 October 2023 14:50 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/26 "2023-10-27T14:50:32Z")

</div>

If there is a difference when you run with systemd rather than running `node-red` then it is a difference in the environment between those two.  
Show us the systemd service script and tell us which user you are logged in as when you run `node-red`.

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [27 October 2023 14:56 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/27 "2023-10-27T14:56:10Z")

</div>

I wrote the system service script above.  
(but by default : `sudo systemctl enable nodered.service` ) There is one user. Node red needs to start automatically with raspberry. Now I'm looking for (perhaps a solution) to start node red automatically, but as a user.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 October 2023 15:05 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/28 "2023-10-27T15:05:20Z")

</div>

> [@azxo1](#):
>
> if `sudo systemctl enable nodered.service`, then node red starts automatically with the raspberry, but the script does not run.
> 
> if `systemctl enable nodered.service`, then node red must be started from putty (node-red), the script runs, but if I exit putty, node red also stops

I believe that you need to use sudo to run systemd commands, except for` systemctl status nodered`.

If you run `sudo systemctl enable nodered` (the .service suffix is not necessary), then Node-red should start up automatically **the next time you reboot**.

The command to start or stop is `sudo systemctl restart nodered` or `sudo systemctl stop nodered`

> [@azxo1](#):
>
> but the script does not run.

How are you trying to start the script now?  
Please show us the output of `ls -l /full/pathname/file.py` and `head -1 /full/pathname/file.py` for the script file  
By all means falsify the actual username and script name in the output.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 October 2023 15:13 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/29 "2023-10-27T15:13:31Z")

</div>

> [@azxo1](#):
>
> I wrote the system service script above.

I can't see it. Please post it again.

> [@azxo1](#):
>
> Now I'm looking for (perhaps a solution) to start node red automatically, but as a user.

You do that in the systemd service script.

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [27 October 2023 15:40 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/30 "2023-10-27T15:40:41Z")

</div>

I'm not running my script back and forth, I just described how I've tried it so far. My own script starts from putty with the same user that I specified in the raspberry imager during the raspberry installation. I tried in putty as a user and with sudo, but it doesn't run with sudo. I tried bigexec, exec, pythonsell nodes in node red, but the script did not run. But the last time I managed to run my script from node red was that in putty as a  
user: `sudo systemctl disable nodered.service`,  
then `systemctl enable nodered.service`,  
then I started it with user: `node-red`,  
and then in node red from bigexec I run my own script. If I speak into the microphone, my speech is displayed as text in the payload. This method is not good only because node red does not start automatically with raspberry because it is not sudo systemctl. I'm sorry for my poor English. I think we just misunderstand each other.

I am very grateful that you are trying to understand and help me 🙂

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 October 2023 15:48 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/31 "2023-10-27T15:48:10Z")

</div>

> [@jbudd](#):
>
> I believe that you need to use sudo to run systemd commands, except for` systemctl status nodered`.
> 
> If you run `sudo systemctl enable nodered` (the .service suffix is not necessary), then Node-red should start up automatically **the next time you reboot**.

That is correct. However, note that the sudo refers to systemctl and not to Node-RED. The script that systemd runs can contain a user and group definition that would be used for actually running Node-RED. See [this](https://github.com/TotallyInformation/alternate-node-red-installer/blob/master/templates/master/system/node-red.service) for reference.

Also, `enable` only enables node-red to systemd, you also need to start it with:

```auto
sudo systemctl start nodered.service

```

Unless you want to reboot the device.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 October 2023 15:52 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/32 "2023-10-27T15:52:34Z")

</div>

> [@azxo1](#):
>
> This method is not good only because node red does not start automatically with raspberry because it is not sudo systemctl.

My understanding is that `systemctl enable nodered` will do nothing.  
It certainly will not start node-red.

As @Colin says, the user which node-red runs as is specified in the systemd script.

You need to get control of

- The username that runs node-red at startup.
- The method of starting the python script from node-red
- How the operating system know which language the script should be interpreted as.

You seem strangely reluctant to share any of these details.

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [27 October 2023 16:03 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/33 "2023-10-27T16:03:13Z")

</div>

Then this would be the correct start? :

```auto
sudo systemctl enable nodered
sudo systemctl start nodered GalZoli:GalZoli

```

to automatically start as user when booting?

But that's the way it is:  
/lib/systemd/system/nodered.service :

```auto
[Service]
Type=simple
# Run as normal pi user - change to the user name you wish to run Node-RED as
User=GalZoli
Group=GalZoli
WorkingDirectory=/home/GalZoli

```

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [27 October 2023 16:17 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/35 "2023-10-27T16:17:23Z")

</div>

> [@azxo1](#):
>
> `sudo systemctl start nodered GalZoli:GalZoli`

You really want to put the user/group into the startup script - the example I gave shows how.

I think you can use `sudo systemctrl edit --full nodered` to use your command line editor to change the script.

* * *

Questions about installs and running seem to be cropping up again repeatedly with seemingly a new generation of Node-RED users. So I've created an FAQ:

> [@Should I install and/or run Node-RED with an admin account? (SUDO)](https://discourse.nodered.org/t/should-i-install-and-or-run-node-red-with-an-admin-account-sudo/82402):
>
> You MAY install Node-RED using elevated privileges (e.g. using sudo on a Linux system) - this is generally required if installing as a "global" node-red install -g ..... Which many people do. You should NOT run Node-RED using a privileged account (e.g root on Linux systems). Since this is very insecure and will also almost certainly cause you many issues later on. For a low security installation, you might install globally using elevated privileges and run using the same account as you usuall…

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 October 2023 16:19 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/36 "2023-10-27T16:19:35Z")

</div>

> [@azxo1](#):
>
> Then this would be the correct start? :
> 
> `sudo systemctl enable nodered`

Once you have enabled nodered it will start up automatically when you reboot.  
There is normally no need to use sudo system start nodered.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 October 2023 16:21 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/37 "2023-10-27T16:21:52Z")

</div>

> [@azxo1](#):
>
> to automatically start as user when booting?

The systemctl enable command tells it to start node red on boot.  
The systemctl start command tells it to start node red now.

> [@azxo1](#):
>
> ```auto
> [Service]
> Type=simple
> # Run as normal pi user - change to the user name you wish to run Node-RED as
> User=GalZoli
> Group=GalZoli
> WorkingDirectory=/home/GalZoli
> 
> ```

That tells it the user and group so you don't need to specify that in the systemctl start command. Just use  
`sudo systemctl start nodered`

---

<div class="post-metadata">

**Author:** ![azxo1](https://avatars.discourse-cdn.com/v4/letter/a/b487fb/32.png) [@azxo1](https://discourse.nodered.org/u/azxo1)\
**Post date:** [27 October 2023 16:33 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/38 "2023-10-27T16:33:31Z")

</div>

> The systemctl enable command tells it to start node red on boot.  
> Yeah I know

> The systemctl start command tells it to start node red now.  
> Yeah I know

> sudo systemctl start nodered  
> Yeah I know

But this way my script doesn't run in node red.  
Just like this:

```auto
GalZoli@raspberrypi:~ $ sudo systemctl disable nodered.service
[spoiler]GalZoli@raspberrypi:~ $ systemctl enable nodered.service[/spoiler]
GalZoli@raspberrypi:~ $ node-red

```

But this way node red does not start automatically

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [27 October 2023 16:37 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/40 "2023-10-27T16:37:36Z")

</div>

> [@azxo1](#):
>
> `systemctl enable nodered.service`

I will say it one more time and then I'm out.

The command `systemctl enable nodered.service` **neither enables nor starts node-red**

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 October 2023 16:39 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/41 "2023-10-27T16:39:15Z")

</div>

> [@azxo1](#):
>
> But this way my script doesn't run in node red.

Since you are running it as the same user then it is something else in the environment that makes the difference. When you run it using just `node-red` then it uses the environment of the command window you are running in (PATH etc). When running via systemd script the environment is determined by what is in the systemd script.  
If you add an exec node running the command  
`printenv`  
triggered by an inject node, then start node red with systemd and with node-red command you will see what the differences are. Something there is probably what is causing the problem.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [27 October 2023 16:44 UTC](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249/42 "2023-10-27T16:44:39Z")

</div>

> [@azxo1](#):
>
> `GalZoli@raspberrypi:~ $ systemctl enable nodered.service`

If you try to run systemctl without sudo I would expect something like

```auto
$ systemctl enable nodered
==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-unit-files ===
Authentication is required to manage system service or unit files.
Authenticating as: root
Password: 

```

Though if you have the pi configured to not need passwords when you use sudo I am not sure what would happen. Configuring the pi like that is not a good idea.

[Previous page](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249.md?page=1)

[Next page](https://discourse.nodered.org/t/how-to-install-node-red-and-recognizer/82249.md?page=3)
