Reply
Highlighted
Expert Contributor
Posts: 126
Registered: ‎11-01-2013

How to preserve permissions while putting data from local to HDFS ?

I am trying to copy the data existing in local machine over to hdfs...But the problem is, I need to preserve the permissions like the file permissions and ownership should not change after copying data to HDFS...Permissions in HDFS should look same as in local machine..

 

How can I achieve this without manually changing permissions in hadoop using hadoop fs -chmod/-chown.

 

Thanks

Em Jay
Cloudera Employee
Posts: 9
Registered: ‎08-01-2013

Re: How to preserve permissions while putting data from local to HDFS ?

You would use the -p when doing a put.  From the docs:

-put [-f] [-p] <localsrc> ... <dst>: Copy files from the local file system into fs. Copying fails if the file already exists, unless the -f flag is given. Passing -p preserves access and modification times, ownership and the mode. Passing -f overwrites the destination if it already exists.

Expert Contributor
Posts: 126
Registered: ‎11-01-2013

Re: How to preserve permissions while putting data from local to HDFS ?

I tried using -p while doing put but really didn't worked out.

 

hadoop fs -put -p test.txt
-put: Illegal option -p
Usage: hadoop fs [generic options] -put <localsrc> ... <dst>

 

I tried couple ways with different arguments but no luck.....It keep saying illegal option....

Em Jay