• 博客园logo
  • 会员
  • 周边
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
漂亮少年
博客园    首页    新随笔    联系   管理    订阅  订阅
Hadoop 命令大全
转载于https://blog.csdn.net/baidu_30851231/article/details/81664420

Hadoop 命令大全

appendToFile [localsrc] [dst]

将本地文件localsrc追加到hdfs的dst文件中,如果dst文件不存在,则创建。

hdfs dfs -appendToFile /home/t2.txt /user/hdfs/gpl/t2.txt

-cat [dst]

显示文件内容

hdfs dfs -cat /user/hdfs/gpl/t2.txt

-checksum [dst]

为匹配文件模式dst到stdou的文件转储校验和信息

hdfs dfs -checksum /user/hdfs/gpl/t2.txt

-chgrp [-R] GROUP PATH

相当与-chown

hdfs dfs -chgrp hdfs /user/hdfs/gpl/t2.txt

-chmod

更改文件的权限,与shell的chmod命令类似

hdfs dfs -chmod 777 /user/hdfs/gpl/t2.txt

-chown

更改文件所属者

hdfs dfs -chown hdfs /user/hdfs/gpl/tx.txt

-copyFromLocal [localsrc] [dst]

将本地文件上传到hdfs目录

hdfs dfs -copyFromLocal /home/t2.txt /user/hdfs/gpl/

-copyToLocal [dst] [localsrc]

将hdfs文件下载到本地

hadoop fs -copyToLocal /user/hdfs/data2/ip=10.69.2.3/logfile_localhost.lo
caldomain_1531106559.txt /home/

-count

查看目录下,子目录数[-q]、文件数[-h]、文件大小[-v]、文件名/目录名[dst]

 hdfs dfs -count /user/hdfs/gpl

-cp SRC [SRC …] DST

将文件从SRC复制到DST,如果指定了多个SRC,则DST必须为一个目录

hdfs dfs -cp /user/hdfs/data2/ip=10.69.2.3/logfile_localhost.loc
aldomain_1531106600.txt /user/hdfs/gpl/

-createSnapshot [snapshotDir] [snapshotName]

在目录上创建快照

hdfs dfs -createSnapshot /user/hdfs/gpl/ kz

-deleteSnapshot [snapshotDir][snapshotName]

在目录上删除快照

hdfs dfs -deleteSnapshot /user/hdfs/gpl/kz

-df

显示文件系统的容量、空闲空间和使用空间

hdfs dfs -df /user/hdfs/gpl

-du

显示该目录中每个文件或目录的大小

 hdfs dfs -du -s -h /user/hdfs

-expunge

清空回收站,文件被删除时,它首先会移到临时目录.Trash/中,当超过延迟时间之后,文件才会被永久删除

 hdfs dfs -expunge

-find

查找与指定表达式匹配的所有文件

hdfs dfs -find /user/hdfs -name t2.txt

-get

将hdfs文件下载到本地与-copyToLocal 类似

hadoop fs -get /user/hdfs/data2/ip=10.69.2.3/logfile_localhost.lo
caldomain_1531106559.txt /home/

-getfacl [-R] [path]

显示文件和目录的访问控制列表(acl)。如果一个目录有一个默认的ACL,然后getfacl也显示默认的ACL。

hdfs dfs -getfacl /user/hdfs

-getfattr

显示文件或的扩展属性名和值(如果有的话)
-getmerge [src] [localdst]

将hdfs的多个文件合并后下载到本地

hsfs dfs -getmerge /user/hdfs/data2/ip=10.69.2.3/ /home/ip.txt

help

帮助命令,列出可操作命令
-ls

列出指定目录下的文件或目录

hdfs dfs -ls /user/hdfs

-mkdir

创建目录

hdfs dfs -mkdir /user/hdfs/test

-moveFromLocal [localsrc] … [dst]

本地文件系统复制文件到HDFS文件系统后删除本地文件

hdfs dfs -moveFromLocal /home/md.txt /user/hdfs/gpl

-mv [src] [dst]

将匹配指定文件模式src的文件移动到目标dst,在移动多个文件时,目标必须是一个目录。

hdfs dfs -mv /user/hdfs/gpl/mft5.txt /user/hdfs/gpl/mft.txt

-put [localsrc] [dst]

本地文件系统复制文件到HDFS文件系统与,与-copyFromLocal类似
-renameSnapshot [snapshotDir][oldName] [newName]

快照重命名
-rm

删除 ,与shell的rm命令类似

 hdfs dfs -rm -r /user/hdfs/gpl/mtf.txt

-rmdir [dir]

删除指定的dir目录项

hdfs dfs -rmdir /user/hdfs/test

-setfacl

设置文件和目录的访问控制列表(acl)。
-setfattr

设置文件或目录的扩展属性名和值。
-setrep

设置文件的复制级别
-stat [format] path

以指定格式打印文件/目录的统计信息,其中,%b-块、%g-所属组 、%n-文件名、%o块大小、%u用户名

hdfs dfs -stat [%b-%g-%n-%o-%r-%u-%y:%Y] /user/hdfs/gpl

-tail [-f] path

Show the last 1KB of the file

hdfs dfs -tail /user/hdfs/gpl/t2.txt

-test -[defsz] path

回答关于path的各种问题,结果通过退出状态。

-text

获取源文件并以文本格式输出该文件。允许的格式是zip和TextRecordInputStream和Avro。
-touchz path

在path处创建一个0长度的文件,当前时间作为时间戳 <路径>如果文件的长度不为零,则返回错误

-usage

hdfs dfs -touchz /user/hdfs/gpl/1.txt

-usage

显示给定命令或所有命令的用法(如果没有指定任何命令)。与-help类似

hdfs dfs -usage
posted on 2020-03-18 17:07  漂亮少年  阅读(1001)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3