Big Data Architect’s Handbook
上QQ阅读APP看书,第一时间看更新

Copying files from a local file system to HDFS

We have created a file called test.txt in our home directory. To copy this file from the home directory, that is, the local file system storage, to HDFS inside the folder hadooptest, we need to execute the following command. The operator required for this purpose is -put:

$ hdfs dfs -put test.txt /hadooptest/

To test whether the file has been copied successfully, execute the ls command, as we have done previously. The output should be similar to the following screenshot:

Figure-3.2.2

If you don't specify the destination folder when putting a file in HDFS, it will copy the file to a similar directory structure as the local file system if the same directory structure is present in HDFS.