# How to change default (installation) user "pi"

**URL:** <https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962>\
**Category:** General\
**Created:** [8 October 2020 20:20 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962 "2020-10-08T20:20:49Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [8 October 2020 20:20 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/1 "2020-10-08T20:20:49Z")

</div>

Dear all,

when installing Node-RED, i did it on an raspberryPi and used the default user "pi"- Now, I disabled the login of this user and use a different user name to login for security reasons. Node-red still works fine, but:

When I use the exec node to run a shell script and write "whoami" in the script, it says "pi". How can I change this to my current user - so change the user Node-RED uses?

---

<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:** [8 October 2020 20:31 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/2 "2020-10-08T20:31:36Z")

</div>

You will have a systemd script to run node-red. In it, there is a definition of the user that node-red runs under. You can change the user there.

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [8 October 2020 20:39 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/3 "2020-10-08T20:39:48Z")

</div>

Hmm.. I found /etc/systemd/system folder and there zigbee2mqtt.service, with this user in it (see below) - but nothing about Node-RED.. ?

```auto
[Unit]
Description=zigbee2mqtt
After=network.target

[Service]
ExecStart=/usr/bin/npm start
WorkingDirectory=/opt/zigbee2mqtt
StandardOutput=inherit
StandardError=inherit
Restart=always
User=pi

[Install]
WantedBy=multi-user.target

```

---

<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:** [8 October 2020 20:49 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/4 "2020-10-08T20:49:57Z")

</div>

There will be other service files, have a look around.

> [@loeten](#):
>
> `User=pi`

That's what you will need to change.

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [8 October 2020 20:52 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/5 "2020-10-08T20:52:58Z")

</div>

Ok thanks, I found it; just not under /etc/systemd but /lib/systemd  
Now I see what you mean / will try.

---

<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:** [8 October 2020 20:54 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/6 "2020-10-08T20:54:17Z")

</div>

If you run  
`sudo systemctl status nodered`  
it will tell you where the service file is. Note there is no dash in nodered.

An alternative to changing it manually is to login as the new user and then run the node red install/upgrade script again. That will replace the service file with one for the correct user. It will also upgrade node red to the latest of course.

How are you making it pick up the correct .node-red folder? That is also defined in that service file via the user name.

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [8 October 2020 21:06 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/7 "2020-10-08T21:06:44Z")

</div>

> [@Colin](#):
>
> How are you making it pick up the correct .node-red folder?

I just copied the folder. Works fine so far.

---

<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:** [9 October 2020 08:10 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/8 "2020-10-09T08:10:37Z")

</div>

> [@loeten](#):
>
> I just copied the folder. Works fine so far.

If node red is still running as the user pi then it should be picking up the folder from /home/pi, not the new user. What I meant was how are you telling node red to use the new user's .node-red folder?

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [9 October 2020 11:26 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/9 "2020-10-09T11:26:47Z")

</div>

> [@Colin](#):
>
> If node red is still running as the user pi then it should be picking up the folder from /home/pi, not the new user. What I meant was how are you telling node red to use the new user's .node-red folder?

The "whoami" in the script tells now it used the new user, that I set in the nodered.service file. Which folder it uses - I didn't care as long as it works. 🙂

---

<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:** [9 October 2020 12:41 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/10 "2020-10-09T12:41:36Z")

</div>

How do you know which files to backup so you don't lose everything in case of a problem, if you don't know where they are?

If you run  
`node-red-stop`  
`node-red-start`  
It will tell you where it is.

---

<div class="post-metadata">

**Author:** ![loeten](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@loeten](https://discourse.nodered.org/u/loeten)\
**Post date:** [9 October 2020 12:59 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/11 "2020-10-09T12:59:20Z")

</div>

> [@Colin](#):
>
> How do you know which files to backup so you don't lose everything in case of a problem, if you don't know where they are?

I just make an image of the raspi's SD card. But you are right, always good to know what's going on! 🙂

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 December 2020 12:59 UTC](https://discourse.nodered.org/t/how-to-change-default-installation-user-pi/33962/12 "2020-12-08T12:59:24Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
