hdfs的常用命令
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
Hadoop2 HDFS shell命令
?
1.?hdfs dfs -appendToFile <localsrc> ... <dst>
?
可同時(shí)上傳多個(gè)文件到HDFS里面
?
2.??hdfs dfs -cat URI [URI ...]
?
查看文件內(nèi)容
?
3.?hdfs dfs -chgrp [-R] GROUP URI [URI ...]
?
修改文件所屬組
?
4.??hdfs dfs -chmod [-R] <MODE[,MODE]... | OCTALMODE> URI [URI ...]
?
修改文件權(quán)限
?
5.?hdfs dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]
?
修改文件所有者,文件所屬組,其他用戶的讀、寫、執(zhí)行權(quán)限
?
6.?hdfs dfs -copyFromLocal <localsrc> URI
?
復(fù)制文件到hdfs
?
7.??hdfs dfs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
?
復(fù)制文件到本地
?
8.?hdfs dfs -count [-q] <paths>
?
統(tǒng)計(jì)文件及文件夾數(shù)目
?
9.??hdfs dfs -cp [-f] URI [URI ...] <dest>
?
Hadoop HDFS?文件系統(tǒng)間的文件復(fù)制
?
10.?hdfs dfs -du [-s] [-h] URI [URI ...]
?
統(tǒng)計(jì)目錄下的文件及大小
?
?
?
11.?hdfs dfs -dus <args>
?
匯總目錄下的文件總大小
?
12.??hdfs dfs -expunge
?
清空回收站,文件被刪除時(shí),它首先會(huì)移到臨時(shí)目錄.Trash/中,當(dāng)超過(guò)延遲時(shí)間之后,文件才會(huì)被永久刪除
?
13.?hdfs dfs -get [-ignorecrc] [-crc] <src> <localdst>
?
下載文件到本地
?
14.?hdfs dfs -getfacl [-R] <path>
?
查看ACL?(訪問(wèn)權(quán)限組擁有者)
?
15.?hdfs dfs -getmerge <src> <localdst> [addnl]
?
合并下載文件到本地
?
16.?hdfs dfs -ls <args>
?
查看目錄
?
17.?hdfs dfs -lsr <args>
?
循環(huán)列出目錄、子目錄及文件信息?
?
18.?hdfs dfs -mkdir [-p] <paths>
?
創(chuàng)建空白文件夾
?
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 ...]
?
遞歸刪除??刪除文件及文件夾下的所有文件
?
25.?hdfs dfs -setfacl [-R] [-b|-k?-m|-x <acl_spec>?<path>]|[--set <acl_spec> <path>]
?
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>
?
修改副本數(shù)
?
27.?hdfs dfs -stat URI [URI ...]
?
顯示文件統(tǒng)計(jì)信息
?
28.??hdfs dfs -tail [-f] URI
?
查看文件尾部信息
?
29.?hdfs dfs -test -[ezd] URI
?
對(duì)PATH進(jìn)行如下類型的檢查:?
-e PATH是否存在,如果PATH存在,返回0,否則返回1?
-z?文件是否為空,如果長(zhǎng)度為0,返回0,否則返回1?
-d?是否為目錄,如果PATH為目錄,返回0,否則返回1?
?
30.?hdfs dfs -text <src>
?
查看文件內(nèi)容
?
31.??hdfs dfs -touchz URI [URI ...]
?
創(chuàng)建長(zhǎng)度為0的空文件
轉(zhuǎn)載于:https://my.oschina.net/u/2529303/blog/541061
總結(jié)
- 上一篇: 【迁移2018-05-08 14:14:
- 下一篇: 小白必须懂的MongoDB的十大总结