Posts Commands for manipulating files and directories on HDFS
Post
Cancel

Commands for manipulating files and directories on HDFS

The commands on HDFS are generally quite similar to the commands on Linux, both in terms of their functions and names, if you are familiar with Linux/Ubuntu then you probably don’t need to learn much, so apply. just use it.

help

Ask about common line in HDFS :

1
2
hdfs dfs -help
hdfs dfs -usege <utility_name>

Ask about a specific command:

1
2
hdfs dfs -help <statement>
VD: hdfs dfs -help ls

mkdir

Make folder in HDFS:

1
hdfs dfs -mkdir /newfolder

Make folder if this already exists, add parameter:

1
hdfs dfs -mkdir -p /newfolder

ls

Display folder and file in directory:

1
hdfs dfs -ls /

Display folder and file in directory and all subfolder in this:

1
hdfs dfs -ls -R /

put

Copy file from local folder to HDFS folder:

1
2
hdfs dfs -put ~/test.txt /newfolder/
hdfs dfs -copyFromLocal ~/test.txt /newfolder/

get

Copy file from HDFS folder to local folder:

1
2
hdfs dfs -get /newfolder/test.txt /copyfromhdfs/
hdfs dfs -copyToLocal /newfolder/test.txt /copyfromhdfs/

cat

Check content in file:

1
hdfs dfs -cat /newfolder/test.txt

mv

Move file or folder from folder to folder:

1
hdfs dfs -mv /newfolder /DR

cp

Copy file or folder from folder to folder:

1
hdfs dfs -cp /DR/newfolder/test.txt /DR

rm

Delete file in HDFS:

1
hdfs dfs -rm /DR/test.txt

getmerge

Merge file in HDFS and download to local:

1
hdfs dfs -getmerge /usr/trannguyenhan /home/trannguyenhan01092000/output.dat
This post is licensed under CC BY 4.0 by the author.