[R] create a folder with mode '0777'

Patrick Breheny patrick.breheny at uky.edu
Wed May 4 16:38:14 CEST 2011


Linux systems have a user mask that limits the file mode creation 
possibilities of any processes launched from that shell.  If you check 
your /etc/profile file, you will see the line

umask 022

This prevents you by default from creating files with write access for 
everyone except the user.  In other words, this is a linux issue, not an 
R issue -- the same thing happens when you use mkdir.  This can be 
overridden, however.  For example,

system("chmod -R 0777 test")

which recursively changes the mode of test and all its subdirectories 
from within R.

_______________________
Patrick Breheny
Assistant Professor
Department of Biostatistics
Department of Statistics
University of Kentucky

On 05/04/2011 09:55 AM, Xian Zhang wrote:
> Dear list,
>
> I am trying to create a folder structure, say 'test/sub', and set the
> folder and sub folder to be writable to everyone.
>
> By default
>
> dir.create('test/sub', recursive=TRUE, mode='0777')
>
> creates folders with mode: drwxr-xr-x
>
> After
>
> Sys.chmod('test/sub',mode='0777')
>
> The folder 'test' is: drwxr-xr-x
> and the sub folder 'sub' is: drwxrwxrwx
>
> The question is how to generate a folder and sub folders, with every
> folder being drwxrwxrwx ?
>
> I am using a linux/redhat system.
>
> Thank you for your help.
> Xian
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list