操作hdfs的基本命令
在hdfs中,路径需要用绝对路径
1. 查看根目录
hadoop fs -ls /
2. 递归查看所有文件和文件夹 -lsr等同于-ls -R
hadoop fs -lsr /
3. 创建文件夹
hadoop fs -mkidr /hello
4. 创建多级文件夹
hadoop fs -mkdir -p /good/good
5. 创建文件
hadoop fs -touchz /hello/test.txt
6. 移动文件或重命名,当hello1不存在是为重命名,否则为移动 hello-->hello1
hadoop fs -mv /hello /hello1
7. 复制 将hello1复制到wo文件夹中
hadoop fs -cp /hello1 /wo
8. 统计wo目录下各文件的大小
hadoop fs -du /wo
9. 统计wo目录下个文件[夹]数量
hadoop fs -count /wo
10. 查看文件内容
hadoop fs -cat /hello/test.txt
hadoop fs -text /hello/test.txt
11. 上传文件,将当前文件中的文件上传到根目录下 -copyFromLocal与-put相同
hadoop fs -put hadoop-2.7.7.tar.gz /
12. 下载
hadoop fs -get /hadoop-2.7.7.tar.gz /opt/test
13. 删除, -rmr 等同于 -rm -r
hadoop fs -rm /hadoop-2.7.7.tar.gz #删除文件
hadoop fs -rmr /wo/hello2 #删除文件或文件夹
hadoop fs -rm -r -f /other #强制删除
14. 查看空间
hadoop fs -df /