HDFS命令

hdfs dfs -ls /


hdfs dfs -put a.txt / #将文件复制到hdfs

hdfs dfs -put /root/a.txt /root/

hdfs dfs -mkdir /dir1
hdfs dfs -mkdir -p /dir1/dir11 #递归创建文件夹
hdfs dfs -moveFromLocal a.txt /dir1/dir11 #将文件移动到hdfs

hdfs dfs -get /a.txt ./ #将文件下载到当前目录

hdfs dfs -mv /dir1/a.txt /dir2 #将hdfs的文件移动到hdfs的另外一个路径
hdfs dfs -rm /a.txt #删除一个文件(删除文件之后移动到hdfs的垃圾桶,七天之后自动删除)
hdfs dfs -rm -r /dir1 #递归删除一个文件夹(删除文件之后移动到hdfs的垃圾桶)

 


hdfs dfs -cp -p /dir1/a.txt /dir2/b.txt #将hdfs的某个文件拷贝到hdfs的另外一个路径(深度拷贝)

 


hdfs dfs -cat /a.txt #查看hdfs文件的内容
hdfs dfs -chmod -R 777 / #修改hdfs文件或者文件夹(加-R参数)权限


hdfs dfs -appendToFile a.xml b.xml /big.xml #将linux本地的文件合并之后上传到hdfs

hdfs dfs -appendToFile /export/servers/hadoop-2.7.5/etc/hadoop/*.xml /big.xml

posted on 2021-09-08 15:55  季昂  阅读(142)  评论(0编辑  收藏  举报