操作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 /