COMMAND Line Interface
COMMAND Line Interface
INTERFACE
• The File System (FS) shell includes various shell-like commands that directly interact
with the Hadoop Distributed File System (HDFS) as well as other file systems that
Hadoop supports, such as Local FS, HFTP FS, S3 FS, and others.
• Below are the commands supported
• AppendToFile
• hadoop fs -appendToFile /home/testuser/test/test.txt /user/haas_queue/test/test.txt
• append the content of the /home/testuser/test/test.txt to the
/user/haas_queue/test/test.txt in the hdfs.
• cat
• Copies source paths to stdout.
• hadoop fs -cat hdfs://nameservice1/user/haas_queue/test/test.txt
• checksum
• Returns the checksum information of a file.
• hadoop fs -checksum hdfs://nameservice1/user/haas_queue/test/test.txt
• chgrp
• Usage: hadoop fs -chgrp [-R] GROUP URI [URI …]
• Change group association of files. The user must be the owner of files, or else a
super-user.
• The -R option will make the change recursively through the directory structure.
• chmod
• hadoop fs -chmod [-R] <MODE[,MODE]… |
• Change the permissions of files. With -R, make the change recursively through
the directory structure. The user must be the owner of the file, or else a super-
user.
• Options
• The -R option will make the change recursively through the directory structure
• chown
• Usage: hadoop fs -chown [-R] [OWNER][:[GROUP]] URI [URI ]
• Change the owner of files. The user must be a super-user.
• Options
• The -R option will make the change recursively through the directory structure.
• copyFromLocal
• hadoop fs -copyFromLocal /home/sa081876/test/* /user/haas_queue/test
• This command copies all the files inside test folder in the edge node to test folder in the hdfs
• Similar to put command, except that the source is restricted to a local file reference.
• Options:
• The -f option will overwrite the destination if it already exists.
• copyToLocal
• hadoop fs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
• hadoop fs -copyFromLocal /user/haas_queue/test/* /home/sa081876/test
• This command copies all the files inside test folder in the hdfs to test folder in the edge
node.
• Similar to get command, except that the destination is restricted to a local file
reference.
• count
• hadoop fs -count [-q] [-h] [-v] <paths>
• Count the number of directories, files and bytes under the paths that match the specified file pattern. The output columns with
-count are: DIR_COUNT, FILE_COUNT, CONTENT_SIZE, PATHNAME
• The output columns with -count -q are: QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA,
DIR_COUNT, FILE_COUNT, CONTENT_SIZE, PATHNAME
• The -h option shows sizes in human readable format.
• The -v option displays a header line.
• Example:
• hadoop fs -count hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
hadoop fs -count -q hdfs://nn1.example.com/file1
hadoop fs -count -q -h hdfs://nn1.example.com/file1
hdfs dfs -count -q -h -v hdfs://nn1.example.com/file1
• cp
• Usage: hadoop fs -cp [-f] [-p | -p[topax]] URI [URI …] <dest>
• Copy files from source to destination. This command allows multiple sources as well in which case the destination
must be a directory.
• Options: