hadoop shell 命令总结

hadoop shell 命令总结

Usage: hadoop fs [generic options]
[-appendToFile … ]
[-cat [-ignoreCrc] …]
[-checksum …]
[-chgrp [-R] GROUP PATH…]
[-chmod [-R] <MODE[,MODE]… | OCTALMODE> PATH…]
[-chown [-R] [OWNER][:[GROUP]] PATH…]
[-copyFromLocal [-f] [-p] [-l] … ]
[-copyToLocal [-p] [-ignoreCrc] [-crc] … ]
[-count [-q] [-h] …]
[-cp [-f] [-p | -p[topax]] … ]
[-createSnapshot []]
[-deleteSnapshot ]
[-df [-h] [ …]]
[-du [-s] [-h] …]
[-expunge]
[-find … …]
[-get [-p] [-ignoreCrc] [-crc] … ]
[-getfacl [-R] ]
[-getfattr [-R] {-n name | -d} [-e en] ]
[-getmerge [-nl] ]
[-help [cmd …]]
[-ls [-d] [-h] [-R] [ …]]
[-mkdir [-p] …]
[-moveFromLocal … ]
[-moveToLocal ]
[-mv … ]
[-put [-f] [-p] [-l] … ]
[-renameSnapshot ]
[-rm [-f] [-r|-R] [-skipTrash] …]
[-rmdir [–ignore-fail-on-non-empty]

…]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} ]|[–set <acl_spec> ]]
[-setfattr {-n name [-v value] | -x name} ]
[-setrep [-R] [-w] …]
[-stat [format] …]
[-tail [-f] ]
[-test -[defsz] ]
[-text [-ignoreCrc] …]
[-touchz …]
[-truncate [-w] …]
[-usage [cmd …]]

ls

-ls [-d] [-h] [-R] [ …]

说明:

列出与指定文件模式匹配的内容

示例:

hadoop fs -ls /

参数:

参数原文说明
-dDirectories are listed as plain files.目录作为普通文件列出。
-hFormats the sizes of files in a human-readable fashion rather than a number of bytes.将文件大小格式化为人类可读的方式,而不是字节数。
-rRecursively list the contents of directories.递归地列出目录的内容。

mkdir

-mkdir [-p]

说明:

在指定位置创建目录

示例:

hadoop fs -mkdir /test

参数:

参数原文说明
-pDo not fail if the directory already exists如果目录已经存在,则不会失败

moveFromLocal

-moveFromLocal … :

说明:

从本地剪切粘贴到HDFS。与-put相同,不同之处在于源文件在复制后会被删除。  

示例:

hadoop fs -moveFromLocal <本地路径文件> <hdfs上传路径>

appendToFile

-appendToFile …

说明:

追加一个文件到已经存在的文件末尾

示例:

hadoop fs -appendToFile <本地路径> <hdfs追加文件的路径>

cat

-cat [-ignoreCrc] …

说明:

显示文件内容

示例:

hadoop fs -cat /test/a.txt

copyFromLocal

-copyFromLocal [-f] [-p] [-l] … :

说明:

从本地文件系统中拷贝文件到HDFS路径去。与-put命令相同

示例:

hadoop fs -copyFromLocal <本地文件> <hdfs路径地址>

参数:

参数原文说明
-fOverwrites the destination if it already exists.如果目标已经存在,则覆盖该目标。
-pPreserves access and modification times, ownership and the mode.保留访问和修改时间、所有权和模式。
-lAllow DataNode to lazily persist the file to disk. Forces replication factor of 1. This flag will result in reduced durability. Use with care.允许DataNode将文件延迟保存到磁盘。强制复制因子为1。此标志将导致耐久性降低。小心使用。

copyToLocal

-copyToLocal [-p] [-ignoreCrc] [-crc] … :

说明:

从HDFS拷贝到本地

示例:

hadoop fs -copyToLocal /sanguo/shuguo/kongming.txt ./

cp

-cp [-f] [-p | -p[topax]] … :

说明:

从HDFS的一个路径拷贝到HDFS的另一个路径

示例:

hadoop fs -cp /sanguo/shuguo/kongming.txt /zhuge.txt

mv

-mv … :

说明:

在HDFS目录中移动文件

示例:

hadoop fs -mv /zhuge.txt /sanguo/shuguo/

get

-get [-p] [-ignoreCrc] [-crc] … :

说明:

从HDFS下载文件到本地。等同于copyToLocal

示例:

hadoop fs -get /sanguo/shuguo/kongming.txt ./

getmerge

-getmerge [-nl] :

说明:

合并下载多个文件,比如HDFS的目录 /test下有多个文件:log.1, log.2,log.3,...

示例:

hadoop fs -getmerge /test/* ./zaiyiqi.txt

参数:

参数原文说明
-nlAdd a newline character at the end of each file.在每个文件的末尾添加换行符。

put

-put [-f] [-p] [-l] … :

说明:

从本地文件系统中拷贝文件到HDFS路径去。与-copyFromLocal命令相同

示例:

hadoop fs -put ./zaiyiqi.txt /test/

参数:

参数原文说明
-fOverwrites the destination if it already exists.如果目标已经存在,则覆盖该目标。
-pPreserves access and modification times, ownership and the mode.保留访问和修改时间、所有权和模式。
-lAllow DataNode to lazily persist the file to disk. Forces replication factor of 1. This flag will result in reduced durability. Use with care.允许DataNode将文件延迟保存到磁盘。强制复制因子为1。此标志将导致耐久性降低。小心使用。

tail

-tail [-f] :

说明:

显示一个文件的末尾     显示文件的最后1KB。

示例:

hadoop fs -tail /test/a.txt

参数:

参数原文说明
-fShows appended data as the file grows.随着文件的增长显示追加的数据。

rm

-rm [-f] [-r|-R] [-skipTrash] … :

说明:

删除所有符合指定文件模式的文件

示例:

hadoop fs -rm /test/jinlian2.txt

参数:

参数原文说明
-skipTrashoption bypasses trash, if enabled, and immediately deletes选项绕过垃圾处理,如果启用,并立即删除
-fIf the file does not exist, do not display a diagnostic message or modify the exit status to reflect an error.如果该文件不存在,则不显示诊断消息或修改退出状态以反映错误。
- rRecursively deletes directories递归删除目录

rmdir

-rmdir [–ignore-fail-on-non-empty]

… :

说明:

删除空目录

示例:

hadoop fs -mkdir /test

du

-du [-s] [-h] … :

说明:

统计文件夹的大小信息

示例:

hadoop fs -du -s -h /test

参数:

参数原文说明
-sRather than showing the size of each individual file that matches the pattern, shows the total (summary) size.它不是显示与模式匹配的每个文件的大小,而是显示总的(摘要)大小。
-hFormats the sizes of files in a human-readable fashion rather than a number of bytes.将文件大小格式化为人类可读的方式,而不是字节数。

setrep

-setrep [-R] [-w] … :

说明:

设置HDFS中文件的副本数量

示例:

hadoop fs -setrep 10 /test/kongming.txt

参数:

参数原文说明
-WIt requests that the command waits for the replication to complete. This can potentially take a very long time.它请求命令等待复制完成。这可能需要很长时间。
-RIt is accepted for backwards compatibility. It has no effect向后兼容是可以接受的。没有效果
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值