# Files being written as 'root' instead of 'user'

**URL:** <https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804>\
**Category:** General\
**Created:** [9 July 2020 18:03 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804 "2020-07-09T18:03:06Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![khakira](https://avatars.discourse-cdn.com/v4/letter/k/87869e/32.png) [@khakira](https://discourse.nodered.org/u/khakira)\
**Post date:** [9 July 2020 18:03 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804/1 "2020-07-09T18:03:07Z")

</div>

Hi

Ubuntu 18.04

Brand new to node-js. I have hooked into an S7 (Siemens PLC system) device and I am writing to a file.  
If I have node-red set up as a service via systemd the files are written with root ownership. To get around this I am starting node-red locally - after which the files are written to the 'user'.

Is there any way to change the systemd setup to write the files as 'user'?

Thanks  
Dave

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [9 July 2020 18:07 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804/2 "2020-07-09T18:07:28Z")

</div>

Did you install via the official installer script? If not, you might want to reinstall.

---

<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 July 2020 20:28 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804/3 "2020-07-09T20:28:33Z")

</div>

and if you did use [the script](https://nodered.org/docs/getting-started/raspberrypi) then do it again, but this time not logged in as root and not using sudo. Login as the user you want to run node-red.

---

<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:** [9 July 2020 21:52 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804/4 "2020-07-09T21:52:36Z")

</div>

> [@khakira](#):
>
> If I have node-red set up as a service via systemd the files are written with root ownership

OK, so if you created the startup file yourself, you are lacking the config that sets the appropriate user.

This may give you some inspiration:

> <https://github.com/TotallyInformation/alternate-node-red-installer/blob/master/templates/master/system/node-red.service>

And as Colin says, make sure you didn't install Node-RED as root.

---

<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:** [7 September 2020 21:52 UTC](https://discourse.nodered.org/t/files-being-written-as-root-instead-of-user/29804/5 "2020-09-07T21:52:40Z")

</div>

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