Search code examples
rrstudio-server

Access denied when writing to file in RStudio Server


In RStudio Server I want to write to the directory /var/www/r_diagnostics:

f <- "/var/www/r_diagnostics/test.txt"
writeLines("test", con = f)

The name of my user is randomuser.

> system("whoami")
randomuser

The directory permissions for r_diagnostics are set as:

drwxrwxrwx  2 randomuser randomuser   4096  6. Jan 18:15 r_diagnostics

What can I do about it?


Solution

  • To write a file, you have to find the directory. This requires execute permission for each element in the path. Execute permission allows you to find a directory's contents.

    Plus, you also need write permission to the final leaf directory in order to modify a file (you had that already).