Hadoop2 HDFS shell指令
1. hdfs dfs -appendToFile <localsrc> ... <dst>
可同時上傳多個檔案到HDFS裡面
2. hdfs dfs -cat URI [URI ...]
檢視檔案内容
3. hdfs dfs -chgrp [-R] GROUP URI [URI ...]
修改檔案所屬組
4. hdfs dfs -chmod [-R] <MODE[,MODE]... | OCTALMODE> URI [URI ...]
修改檔案權限
5. hdfs dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]
修改檔案所有者,檔案所屬組,其他使用者的讀、寫、執行權限
6. hdfs dfs -copyFromLocal <localsrc> URI
複制檔案到hdfs
7. hdfs dfs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
複制檔案到本地
8. hdfs dfs -count [-q] <paths>
統計檔案及檔案夾數目
9. hdfs dfs -cp [-f] URI [URI ...] <dest>
Hadoop HDFS 檔案系統間的檔案複制
10. hdfs dfs -du [-s] [-h] URI [URI ...]
統計目錄下的檔案及大小
11. hdfs dfs -dus <args>
彙總目錄下的檔案總大小
12. hdfs dfs -expunge
清空資源回收筒,檔案被删除時,它首先會移到臨時目錄.Trash/中,當超過延遲時間之後,檔案才會被永久删除
13. hdfs dfs -get [-ignorecrc] [-crc] <src> <localdst>
下載下傳檔案到本地
14. hdfs dfs -getfacl [-R] <path>
檢視ACL (通路權限組擁有者)
15. hdfs dfs -getmerge <src> <localdst> [addnl]
合并下載下傳檔案到本地
16. hdfs dfs -ls <args>
檢視目錄
17. hdfs dfs -lsr <args>
循環列出目錄、子目錄及檔案資訊
18. hdfs dfs -mkdir [-p] <paths>
建立空白檔案夾
19. dfs -moveFromLocal <localsrc> <dst>
剪切檔案到hdfs
20. hdfs dfs -moveToLocal [-crc] <src> <dst>
剪切檔案到本地
21. hdfs dfs -mv URI [URI ...] <dest>
剪切hdfs檔案
22. hdfs dfs -put <localsrc> ... <dst>
上傳檔案
23. hdfs dfs -rm [-skipTrash] URI [URI ...]
删除檔案/空白檔案夾
24. hdfs dfs -rmr [-skipTrash] URI [URI ...]
遞歸删除 删除檔案及檔案夾下的所有檔案
Sets Access Control Lists (ACLs) of files and directories.
Options:
-b: Remove all but the base ACL entries. The entries for user, group and others are retained for compatibility with permission bits.
-k: Remove the default ACL.
-R: Apply operations to all files and directories recursively.
-m: Modify ACL. New entries are added to the ACL, and existing entries are retained.
-x: Remove specified ACL entries. Other ACL entries are retained.
--set: Fully replace the ACL, discarding all existing entries. The acl_spec must include entries for user, group, and others for compatibility with permission bits.
acl_spec: Comma separated list of ACL entries.
path: File or directory to modify.
Examples:
hdfs dfs -setfacl -m user:hadoop:rw- /file
hdfs dfs -setfacl -x user:hadoop /file
hdfs dfs -setfacl -b /file
hdfs dfs -setfacl -k /dir
hdfs dfs -setfacl --set user::rw-,user:hadoop:rw-,group::r--,other::r-- /file
hdfs dfs -setfacl -R -m user:hadoop:r-x /dir
hdfs dfs -setfacl -m default:user:hadoop:r-x /dir
Exit Code:
Returns 0 on success and non-zero on error.
26. hdfs dfs -setrep [-R] [-w] <numReplicas> <path>
修改副本數
27. hdfs dfs -stat URI [URI ...]
顯示檔案統計資訊
28. hdfs dfs -tail [-f] URI
檢視檔案尾部資訊
29. hdfs dfs -test -[ezd] URI
對PATH進行如下類型的檢查:
-e PATH是否存在,如果PATH存在,傳回0,否則傳回1
-z 檔案是否為空,如果長度為0,傳回0,否則傳回1
-d 是否為目錄,如果PATH為目錄,傳回0,否則傳回1
30. hdfs dfs -text <src>
31. hdfs dfs -touchz URI [URI ...]
建立長度為0的空檔案
本文轉自 yntmdr 51CTO部落格,原文連結:http://blog.51cto.com/yntmdr/1733811,如需轉載請自行聯系原作者