# Permission denied to var folder on Raspberry

**URL:** <https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581>\
**Category:** General\
**Created:** [15 April 2025 09:54 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581 "2025-04-15T09:54:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![balintpietro](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@balintpietro](https://discourse.nodered.org/u/balintpietro)\
**Post date:** [15 April 2025 09:54 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/1 "2025-04-15T09:54:39Z")

</div>

Hi Everyone,

I would like to use "write file" and "file copy" commands in /var/opt/codesys/PlcLogic/visu/ folder but I got permisson denied error measage.

How could I add permisson to Node-RED to edit files in var folder?

---

<div class="post-metadata">

**Author:** ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)\
**Post date:** [15 April 2025 09:58 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/2 "2025-04-15T09:58:23Z")

</div>

You need to set write access to the folder in the `settings` file, and the path is kind of fixed to the `node-red/public/....` folder.

But I could be wrong on the last point.

---

<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:** [15 April 2025 10:32 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/3 "2025-04-15T10:32:32Z")

</div>

What does this command show?  
`ls -al /var/opt/codesys/PlcLogic/visu`  
That will show you the owner, group and permissions for the folder.

---

<div class="post-metadata">

**Author:** ![balintpietro](https://avatars.discourse-cdn.com/v4/letter/b/c37758/32.png) [@balintpietro](https://discourse.nodered.org/u/balintpietro)\
**Post date:** [15 April 2025 12:14 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/4 "2025-04-15T12:14:28Z")

</div>

I use the following command to give permisson for pi user to /var/opt/codesys folder.  
Now it seems to me it works.  
But is it the correct way to solve this problem?

sudo chown -R raspberry /var/opt/codesys

---

<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:** [15 April 2025 12:27 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/5 "2025-04-15T12:27:45Z")

</div>

> [@balintpietro](#):
>
> But is it the correct way to solve this problem?
> 
> sudo chown -R raspberry /var/opt/codesys

It's not generally a good idea to change the ownership or permissions of Linux system files & directories.  
It's not generally a good idea to write to system directories either.  
Why do you want to do this?

However, if you must, probably a better way is to write files somewhere else and then use the exec node with sudo to move them.

```auto
sudo mv i_really_know_what_i_am_doing.txt /var/opt/codesys/PlcLogic/visu

```

---

<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:** [14 July 2025 12:28 UTC](https://discourse.nodered.org/t/permission-denied-to-var-folder-on-raspberry/96581/6 "2025-07-14T12:28:49Z")

</div>

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