"Permission denied" when try to copy file to usb

I'am working on raspberry device and i have to copy a file to my usb connected.
Sometimes, it works but sometimes, i get error on copy node and i get "permission denied".
I wonder what causes this problem to appear suddenly then it despears ?
And how can i avoid this type of error ? Do i need each time to use "chmod" to change permission on files ??

So this is one possible scenario that may be happening. Happened to me.
So lets say your allowed to read or write to USB-Drive.
You write a file with node-red to the USB-Drive
then you take that USB-Drive and plug it in another computer and read and write to that file.
When you plug it back into the node-red computer and try to read and write to it you get "permission denied"

I had the above happen. Started setting my user:group permission for the file every time I did something to it on another computer. especially if i created a new file.

open the folder in terminal where the file is located.

$ chown nodered:nodered ./name_of_your_file.txt
$ chmod 755 ./name_of_your_file.txt

755 I can change and run it, everyone else can run it.
644 I can change it, everyone else can read it.

good luck!

1 Like

Are you possibly sometimes using sudo when running something that writes to the file? Either running a command or starting node-red for example. If you do that then afterwards you won't be able to write to the file without using sudo or changing the permissions.

1 Like

How is the usb drive mounted to the raspberry pi, and with what permissions? That might be related too