一、基本语法
bin/hadoop fs 具体命令
#或者
bin/hdfs dfs 具体命令
注意:其中dfs
是fs
的实现类
二、命令大全
[hadoop@SZMaster01 hadoop-2.8.3]$ bin/hadoop fs
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] [-l] [-d] <localsrc> ... <dst>]
[-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...]
[-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] [-x] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] [-skip-empty-file] <src> <localdst>]
[-help [cmd ...]]
[-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-truncate [-w] <length> <path> ...]
[-usage [cmd ...]]
三、常用命令
-
-help
:输出这个命令参数[hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -help rm
-
-ls
: 显示目录信息[hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -ls /
-
-mkdir
:在HDFS
上创建目录[hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -mkdir /test202001
-
-moveFromLocal
:从本地剪切粘贴到HDFS
[hadoop@SZMaster01 hadoop-2.8.3]$ touch test.txt [hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -moveFromLocal ./test.txt /test202001/test.txt
-
-appendToFile
:追加一个文件到已经存在的文件末尾[hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -appendToFile ./zhuijia.txt /test01.txt
-
-cat
:显示文件内容[hadoop@SZMaster01 hadoop-2.8.3]$ hadoop fs -cat /test01.txt
-
-chgrp
、-chmod
、-chown
:Linux
文件系统中的用法一样,修改文件所属权限chgrp
:改变文件所属群组chown
:改变文件拥有者chmod
:改变文件的权限
-
-copyFromLocal
:从本地文件系统中拷贝文件到HDFS
路径去 -
-copyToLocal
:从HDFS
拷贝到本地 -
-cp
:从HDFS
的一个路径拷贝到HDFS
的另一个路径 -
-mv
:在HDFS
目录中移动文件 -
-get
:等同于copyToLocal
,就是从HDFS
下载文件到本地 -
-getmerge
:合并下载多个文件 -
-put
:等同于copyFromLocal
-
-tail
:显示一个文件的末尾 -
-rm
:删除文件或文件夹 -
-rmdir
:删除空目录 -
-du
统计文件夹的大小信息 -
-setrep
:设置HDFS
中文件的副本数量
来源:CSDN
作者:easy_sir
链接:https://blog.csdn.net/qq_40947493/article/details/104134656