Permission denied to var folder on Raspberry

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?

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.

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

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

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.

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