HDFS Commands

command
Description
Usage
fsck
HDFS Command to check the health of the Hadoop file system
hdfs fsck
ls
HDFS Command to display the list of Files and Directories in HDFS
hdfs dfs –ls
mkdir
hdfs dfs –mkdir /directory_name
touchz

HDFS Command to create a file in HDFS with file size 0 bytes

hdfs dfs –touchz /directory/filename
du
HDFS Command to check the file size. 
hdfs dfs –du –s /directory/filename
cat
HDFS Command that reads a file on HDFS and prints the content of that file to the standard output.
hdfs dfs –cat /path/to/file_in_hdfs
text
HDFS Command that takes a source file and outputs the file in text format
hdfs dfs –text /directory/filename
copyFromLocal
HDFS Command to copy the file from Local file system to HDFS.
hdfs dfs -copyFromLocal <localsrc> <hdfs destination> 
copyToLocal
HDFS Command to copy the file from HDFS to Local File System.
hdfs dfs -copyToLocal <hdfs source> <localdst>
put
HDFS Command to copy single source, or multiple sources from local file system to the destination file system.
hdfs dfs -put <localsrc> <destination>
get
HDFS Command to copy files from hdfs to the local file system.
hdfs dfs -get <src> <localdst>
count
HDFS Command to count the number of directories, files and bytes under the paths that match the specified file pattern.

hdfs dfs -count <path>

rm
HDFS Command to remove the file from HDFS.
hdfs dfs –rm <path>
rm -r
HDFS Command to remove the entire directory and all of its content from HDFS.
hdfs dfs -rm -r <path>
cp
HDFS Command to copy files from source to destination. This command allows multiple sources as well, in which case the destination must be a directory.
hdfs dfs -cp <src> <dest>
mv
HDFS Command to move files from source to destination. This command allows multiple sources as well, in which case the destination needs to be a directory.
hdfs dfs -mv <src> <dest>
expunge
HDFS Command that makes the trash empty
hdfs dfs -expunge
rmdir
HDFS Command to remove the directory.
hdfs dfs -rmdir <path>
usage
HDFS Command that returns the help for an individual command.
hdfs dfs -usage <command>