DEV Community

shubham mishra
shubham mishra

Posted on • Originally published at developerindian.com

Hadoop HDFS Commands

Hadoop HDFS Commands
Most of the commands in FS shell behave like corresponding Unix commands. Differences are described with each of the commands. Error information is sent to stderr and the output is sent to stdout.

We will start with some very basic help commands of hadoop and go into more detail as we go through this lesson.

HDFS Commands
fsck
HDFS Command to check the health of the Hadoop file system.
Command: hdfs fsck /

ls
HDFS Command to display the list of Files and Directories in HDFS.
Command: hdfs dfs –ls /

mkdir
HDFS Command to create the directory in HDFS.
Command: hdfs dfs –mkdir /new_deveoperIndian

touchz
HDFS Command to create a file in HDFS with file size 0 bytes.
command: hdfs dfs –touchz /directory/new_deveoperIndian

du
HDFS Command to check the file size.Command:
hdfs dfs –du –s /new_developerIndian/testfile

cat
HDFS Command that reads a file on HDFS and prints the content of that file to the console as output.
Command: hdfs dfs –cat /new_developerIndian/testfile

text
HDFS Command that takes a source file and outputs the file in text format.
Command: hdfs dfs –text /new_developerIndian/testfile

copyFromLocal
HDFS Command to copy the file from a Local file system to HDFS.
Command: hdfs dfs –copyFromLocal /home/edureka/test /new_developerIndian

copyToLocal
HDFS Command to copy the file from HDFS to Local File System.
Command: hdfs dfs –copyToLocal /new_developerIndian/test /home/developerIndian

put
HDFS Command to copy single source or multiple sources from local file system to the destination file system.
Command: hdfs dfs –put /home/edureka/test /user

get
HDFS Command to copy files from hdfs to the local file system.
Command: hdfs dfs –get /user/test /home/developerIndian

count
HDFS Command to count the number of directories, files, and bytes under the paths that match the specified file pattern.
Command: hdfs dfs –count /user

rm
HDFS Command to remove the file from HDFS.
Command: hdfs dfs –rm /new_developerIndian/test

rm -r
HDFS Command to remove the entire directory and all of its content from HDFS.
Command: hdfs dfs -rm -r /new_developerIndian

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.
Command: hdfs dfs -cp /user/hadoop/file1 /user/hadoop/file2

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.
Command: hdfs dfs -mv /user/hadoop/file1 /user/hadoop/file2

expunge
HDFS Command that makes the trash empty.
Command: hdfs dfs -expunge

rmdir
HDFS Command to remove the directory.
Command: hdfs dfs –rmdir /user/hadoop

usage
HDFS Command that returns the help for an individual command.
Command: hdfs dfs -usage mkdir

help
HDFS Command that displays help for given command or all commands if none is specified.
Command: hdfs dfs -help

Uese of Hadoop HDFS

  • Hdfs is used for Very Large Files
  • HDF work with Streaming Data Access
  • It is support low cost hardware.

Top comments (0)