HDFS Command

HDFS command path

|- bin
|- sbin

There are 2 commands

  • bin/hdfs dfs
  • bin/hadoop fs

Basically same

This command is similar to the “hadoop fs”

command except that this only deals with the HDFS filesystem

Command DescriptionFormatExample
Show Help hadoop fs -help hadoop fs -help
Create new directory at the root level hadoop fs -mkdir <dirname>

hdfs dfs -mkdir -p <dirname>
hadoop fs -mkdir /test
Check files under specific directory like (ls) hadoop fs -ls <dirname>hadoop fs -ls /test
Copy file from local to HDFShadoop fs -copyFromLocal <localfile> <dst>

hadoop fs -put <localfile> <dst>
hadoop fs -copyFromLocal ./etc/hadoop/core-site.xml /test
Copy file from HDFS to localhadoop fs -copyToLocal <HDFS file> <dst>

hadoop fs -get <HDFS file> <dst>
hadoop fs -copyToLocal /test/* ./fromhdfs
Delete file from HDFShadoop fs -rm -r <filename>hadoop fs -rm -r ./test/test.txt
Data Hadoop
Professional Programmer2