HDFS中dfs 命令

来源:互联网 发布:mysql引擎区别 编辑:程序博客网 时间:2024/06/06 01:49
Usage: hadoop fs [generic options][-appendToFile <localsrc> ... <dst>][-cat [-ignoreCrc] <src> ...][-checksum <src> ...][-chgrp [-R] GROUP PATH...][-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...][-chown [-R] [OWNER][:[GROUP]] PATH...][-copyFromLocal [-f] [-p] <localsrc> ... <dst>][-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>][-count [-q] <path> ...][-cp [-f] [-p] <src> ... <dst>][-createSnapshot <snapshotDir> [<snapshotName>]][-deleteSnapshot <snapshotDir> <snapshotName>][-df [-h] [<path> ...]][-du [-s] [-h] <path> ...][-expunge][-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>][-getmerge [-nl] <src> <localdst>][-help [cmd ...]][-ls [-d] [-h] [-R] [<path> ...]][-mkdir [-p] <path> ...][-moveFromLocal <localsrc> ... <dst>][-moveToLocal <src> <localdst>][-mv <src> ... <dst>][-put [-f] [-p] <localsrc> ... <dst>][-renameSnapshot <snapshotDir> <oldName> <newName>][-rm [-f] [-r|-R] [-skipTrash] <src> ...][-rmdir [--ignore-fail-on-non-empty] <dir> ...][-setrep [-R] [-w] <rep> <path> ...][-stat [format] <path> ...][-tail [-f] <file>][-test -[defsz] <path>][-text [-ignoreCrc] <src> ...][-touchz <path> ...][-usage [cmd ...]]


1.hdfs dfs -hrlp  查看帮助

[root@yufan C000008]# hdfs dfs -help

2.hdfs dfs -mkdir 创建一个文件夹

[root@yufan C000008]# hdfs dfs -mkdir /test

3.hdfs dfs -put 将本地文件上传到hdfs中

[root@yufan C000008]# hdfs dfs -put 10.txt /test/

4.hdfs dfs -ls 列出路径下的所有文件和文件夹

[root@yufan C000008]# hdfs dfs -ls /test/


5.hdfs dfs -cat 查看文件中的内容

[root@yufan C000008]# hdfs dfs -cat /test/10.txt


6.hdfs dfs -text 列出文件中的内容

[root@yufan C000008]#  hdfs dfs -text /test/10.txt


7.hdfs dfs -touchz 创建一个空文件

[root@yufan C000008]#  hdfs dfs -touchz /textFile


8.hdfs dfs -ls -R 递归列出路径下的文件夹和文件

[root@yufan C000008]# hdfs dfs -ls -R /

9.hdfs dfs -mv  A   B  将文件从A 移动到 B

[root@yufan C000008]# hdfs dfs -mv /test/10.txt /test


10.hdfs dfs -cp A  B 将 A 处的文件 复制一份到 B处

[root@yufan C000008]# hdfs dfs -cp /test/10.txt /


11.hdfs dfs -moveFromLocal A B 将文件从本地移动到hdfs 系统中(本地文件会被删除)

[root@yufan C000008]# hdfs dfs -moveFromLocal /home/bigdata/eclipse/testFile/Reduced/C000008/100.txt /test

12.hdfs dfs -rm 删除文件

[root@yufan C000008]# hdfs dfs -rm /test/100.txt

13.hdfs dfs -rmdir 删除文件夹

hdfs dfs -rmdir /test/testDir

14.hdfs dfs -get 将文件从hdfs系统移动到本地

[root@yufan C000008]# hdfs dfs -get /test/testFile /home/









原创粉丝点击