# Settings.js moved to root

**URL:** <https://discourse.nodered.org/t/settings-js-moved-to-root/21250>\
**Category:** General\
**Created:** [4 February 2020 10:31 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250 "2020-02-04T10:31:04Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [4 February 2020 10:31 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/1 "2020-02-04T10:31:04Z")

</div>

Can anyone help please  
I have been backing up my node-red flows regularly, but something strange has changed and my backup files are now being ignored. I deleted settings.js and it is not being re-created.  
Does this mean it has moved to root? I don't know how to recover.

4 Feb 10:20:14 - [info] Node-RED version: v1.0.3  
4 Feb 10:20:14 - [info] Node.js version: v12.14.1  
4 Feb 10:20:14 - [info] Linux 4.19.93-v7+ arm LE  
4 Feb 10:20:16 - [info] Loading palette nodes  
4 Feb 10:20:20 - [info] Settings file : /root/.node-red/settings.js  
4 Feb 10:20:20 - [info] Context store : 'default' [module=memory]  
4 Feb 10:20:20 - [info] User directory : /root/.node-red  
4 Feb 10:20:20 - [warn] Projects disabled : editorTheme.projects.enabled=false  
4 Feb 10:20:20 - [info] Flows file : /root/.node-red/flows\_atticPI.json

---

<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:** [4 February 2020 10:36 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/2 "2020-02-04T10:36:09Z")

</div>

Looks like you are executing as root which is strongly discouraged. That's why it is picking up root's settings file as shown in your listing.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [4 February 2020 11:21 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/3 "2020-02-04T11:21:26Z")

</div>

Thanks but as a Linux noob I don't know how that has happened. I followed the installation instructions carefully.

---

<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:** [4 February 2020 11:23 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/4 "2020-02-04T11:23:48Z")

</div>

Which install instructions did you follow (provide link please) and how are you starting node-red?

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [4 February 2020 11:45 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/5 "2020-02-04T11:45:57Z")

</div>

I think it was  
[https://nodered.org/docs/getting-started/raspberrypi](https://nodered.org/docs/getting-started/raspberrypi)  
and I start node red automatically as a service.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [4 February 2020 11:54 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/6 "2020-02-04T11:54:45Z")

</div>

Apologies... I think I am being stupid. I was stop/starting node red with  
sudo node-red-stop/sudo node-red-start  
Would that explain why settings.js was regenerating in a different place after I had deleted from its usual folder?  
Sorry linux and root etc confuses me.

---

<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:** [4 February 2020 13:41 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/7 "2020-02-04T13:41:16Z")

</div>

> [@muggins](#):
>
> Would that explain why settings.js was regenerating in a different place

Yes, when you start node red it looks for a .node-red folder in the current users home directory. When you use sudo the current user effectively becomes the root user so it looks there instead of in your own directory.

**[Edit]** Don't worry about the confusion, once you get the hang of it you will find it a lot less confusing than Windows.

---

<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:** [4 February 2020 16:39 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/8 "2020-02-04T16:39:26Z")

</div>

> [@muggins](#):
>
> sudo node-red-stop/sudo node-red-start

Yes, you've confused the normal manual startup with the setup for running Node-RED as a service.

Take the sudo off and you should get back to your normal settings.js and flows. Though you might also want to delete the root `.node-red` folder so that you don't have confusion in the future.

In case it isn't clear (apologies if I'm over explaining), you need sudo when setting up the service because that is a change to the system and so you need administrative rights and `sudo` makes you temporarily the root user of course. But you don't want that for a normal startup as it is a risk to the system if something goes wrong (a Node-RED flow could delete parts of your system for example).

Confusion over these things is far from uncommon, we've all been there so as Colin say's it isn't a problem.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [5 February 2020 08:41 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/9 "2020-02-05T08:41:00Z")

</div>

Thank you for your help. I think I am up and running again.

I assume that I now have some stuff in the root folder. I can’t seem to find it to delete.

---

<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:** [5 February 2020 09:15 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/10 "2020-02-05T09:15:38Z")

</div>

The root folder is not accessible to normal uses. This should do it  
`sudo rm -rf /root/.node-red`  
Make **absolutely certain** that there are not any spaces in `/root/.node-red`. If, for example, you did (and I am not even going to write it in full here in case someone copies it) the rm -rf command followed by `/ .node-red` then that would first remove (without warning) the `/` directory and all directories under it, which it could do since it is running using sudo. That would leave you with an empty SD card or disc, which is not helpful.  
Normally when removing folders using `rm -rf` , with or without sudo. I would recommend switching to the parent directory first, then using rm without the path, so in this case

```auto
cd /root
sudo rm -rf .node-red

```

obviously checking that the cd has worked before running the rm command. In this case you (probably) can't do that as /root is not normally accessible at all to normal users, so the cd would fail. If you did not notice that the cd had failed then it would remove your own .node-red directory which equally is not a good thing. The moral is always be extremely careful when using `rm -rf` that you are removing the right directory.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [5 February 2020 10:36 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/11 "2020-02-05T10:36:46Z")

</div>

> [@Colin](#):
>
> The root folder is not accessible to normal uses. This should do it  
> `sudo rm -rf /root/.node-red`

Alternatively, you could assume root privileges and delete it...

```auto
sudo su 
cd
ls -la
rm -rf .node-red
exit

```

![root](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/a/9/a919259325f4178bfd50874218f05c1c0f2b97a0.jpeg)

---

<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:** [5 February 2020 11:05 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/12 "2020-02-05T11:05:24Z")

</div>

> [@Paul-Reed](#):
>
> sudo su

I tend not to recommend the use of `sudo su`. It is even more dangerous for the uninitiated as it is easy to forget to exit from the su session and carry on regardless, with even more risk of damaging something accidentally.

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [5 February 2020 11:31 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/13 "2020-02-05T11:31:28Z")

</div>

> [@Colin](#):
>
> I tend not to recommend the use of `sudo su`

Same here, but for something as trivial and quick as this, I'd like to think that the OP would remember 😉

---

<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:** [19 February 2020 11:31 UTC](https://discourse.nodered.org/t/settings-js-moved-to-root/21250/14 "2020-02-19T11:31:31Z")

</div>

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