put

Copies a single file or multiple files from the local file system to the destination file system. It also reads input from STDIN and writes to the destination file system if the source is set to -. Copying fails if the file already exists, unless the -f flag is given.

Returns 0 on success and -1 on error.

The usage is as follows:

$ hadoop fs -put [-f] [-p] [-l] [-d] [-t <thread count>] [ - | <localsrc1> .. ]. <dst>
Arguments

-p

Preserves access and modification time, ownership, and the permissions (assuming the permissions can be propagated across filesystems)

-f

Overwrites the destination if it already exists

-l

Allows DataNode to lazily persist a file to disk; forces the replication factor of 1. This flag results in reduced durability. Be cautious when using this argument

-d

Skips the creation of the temporary file with the suffix .COPYING

If the name of a local file contains spaces, substitute them with %20 when filling in the <localsrc1> argument.

For example, to copy a file named local file.txt, run:

$ hadoop fs -put local%20file.txt /user/hadoop/hadoopfile

To copy multiple files, specify their paths as follows:

$ hadoop fs -put -f localfile1 localfile2 /user/hadoop/hadoopdir

To copy data to HDFS, specify an HDFS directory as the destination path:

$ hadoop fs -put -d localfile hdfs://nn.example.com/hadoop/hadoopfile

An example command for copying data from STDIN to HDFS:

$ cat test\ data.txt | hadoop fs -put - /user/test\ data2.txt
Found a mistake? Seleсt text and press Ctrl+Enter to report it