# "Permission denied" when try to copy file to usb

**URL:** <https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828>\
**Category:** General\
**Created:** [23 September 2019 22:07 UTC](https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828 "2019-09-23T22:07:06Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hathemi](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hathemi/32/3792_2.png) [@hathemi](https://discourse.nodered.org/u/hathemi)\
**Post date:** [23 September 2019 22:07 UTC](https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828/1 "2019-09-23T22:07:06Z")

</div>

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 ??

---

<div class="post-metadata">

**Author:** ![meeki007](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/meeki007/32/12499_2.png) [@meeki007](https://discourse.nodered.org/u/meeki007)\
**Post date:** [23 September 2019 23:51 UTC](https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828/2 "2019-09-23T23:51:04Z")

</div>

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.

```auto
$ 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!

---

<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:** [24 September 2019 09:01 UTC](https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828/3 "2019-09-24T09:01:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![afelix](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/afelix/32/9743_2.png) [@afelix](https://discourse.nodered.org/u/afelix)\
**Post date:** [25 September 2019 19:03 UTC](https://discourse.nodered.org/t/permission-denied-when-try-to-copy-file-to-usb/15828/4 "2019-09-25T19:03:31Z")

</div>

> [@hathemi](#):
>
> And how can i avoid this type of error ? Do i need each time to use "chmod" to change permission on files ??

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