table of Contents
HDFS commonly used commands
View all commands help
[172.23.7.9:hadoop]$ hadoop fs help
View the path to the file
[172.23.7.9:hadoop]$ hadoop fs -ls /
Create a folder
[172.23.7.9:hadoop]$ hadoop fs -mkdir /test
Create a multi-level folder
[172.23.7.9:hadoop]$ hadoop fs -mkdir -p /test/test1/test2
Check under the specified directory and subdirectories of all files
[172.23.7.9:hadoop]$ hadoop fs -ls -R /test
upload files
[172.23.7.9:hadoop]$ hadoop fs -put part.txt /test
or
[172.23.7.9:hadoop]$ hadoop fs -copyFromLocal part.txt /test
download file
[172.23.7.9:hadoop]$ hadoop fs -get /test/part.txt ~/test
or
[172.23.7.9:hadoop]$ hadoop fs -copyToLocal /test/part.txt ~/test
Merge download
[172.23.7.9:hadoop]$ hadoop fs -getmerge /test/part0.txt /test/part1.txt ./temp.txt
copy
[172.23.7.9:hadoop]$ hadoop fs -cp /test/part.txt /output
mobile
[172.23.7.9:hadoop]$ hadoop fs -mv /test/part.txt /output
delete
[172.23.7.9:hadoop]$ hadoop fs -rm /test/part.txt
Forced to delete
[172.23.7.9:hadoop]$ hadoop fs -rm -r /test/part.txt
View the file contents
[172.23.7.9:hadoop]$ hadoop fs -cat /test/part.txt
Show file size
[172.23.7.9:hadoop]$ hadoop fs -du -h /test/part.txt
test
[172.23.7.9:hadoop]$ hadoop fs -test -[ezd] /test/part.txt
Options:
-e to check whether a file exists. If there is 0 is returned.
-z check whether a file is 0 bytes. If it returns 0.
-d If the path is a directory, returns 1, otherwise it returns 0.
web interface
http://xx.xx.xx.xx:9870/explorer.html#/