Support Questions
Find answers, ask questions, and share your expertise

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

Expert Contributor

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.



Em Jay

Cloudera Employee

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

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