hdfs的 shell命令

hdfs的 shell命令:

hdfs dfs -put
hdaoop dfs -
hadoop fs -
hdfs dfs -ls hdfs://hadoopnet:8020/test

查看hdfs的shell命令用法 hdfs dfs -help
[-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 …]]

从本地上传一个文件到hdfs文件系统
hdfs fs -put
从hdfs文件系统下载一个文件到本地
hdfs dfs -get
查看hdfs文件系统上的一个文件的内容
hdfs dfs -cat
查看一个路径下的文件列表
hdfs dfs -ls /
在hdfs的文件系统创建一个文件
hdfs dfs -mkdir

1.查看
查看文件列表
hdfs dfs -ls /路径
hdfs dfs -ls -R /路径
查看文件内容
hdfs dfs -cat /文件路径
hdfs dfs -tail /文件路径
2.创建文件夹
hdfs dfs -mkdir /路径
hdfs dfs -mkdir -p /一个多级空目录
创建一个空文件
hdfs dfs -touchz /一个文件路径
拼接上传(把本地文件dream.txt里面的内容上传到hdfs文件f2.txt中)
hdfs dfs -appendToFile dream.txt /test/f2.txt
3.上传
hdfs dfs -put /本地文件路径 /hdfs的文件路径
copyFromLocal(复制上传)
hdfs dfs -copyFromLocal f.txt /
moveFromLocal(剪切上传)
hdfs dfs -moveFromLocal f.txt /
4.下载
hdfs dfs -get /hdfs的文件路径 /本地路径
copyToLocal
hdfs dfs -copyToLocal /test/f2.txt /home/data
moveToLocal(moveToLocal: Option ‘-moveToLocal’ is not implemented yet)

5.删除
hdfs dfs -rm /一个文件的目录
hdfs dfs -rmdir /一个空目录
hdfs dfs -rm -R /删除一个非空的目录
6.更改文件权限
hdfs dfs -chmod 777 /test/f.txt
hdfs dfs -chmod u-x /test/f.txt
7.checksum查看文件的校验和
hdfs dfs -checksum /test/f2.txt
8.-count 查看一个路径的目录数量 文件大小 占用的大小
hdfs dfs -count /test
9.cp hdfs文件系统内部文件的拷贝
hdfs dfs -cp /test/f.txt /demo/
10.mv hdfs文件系统内部文件的剪切/重命名
hdfs dfs -mv /test/f2.txt /demo/ 直接剪切 不改名字
hdfs dfs -mv /test/f2.txt /demo/ff.txt 把f2.txt进行剪切 并把名字改为ff.txt
11.getmerge 合并下载(把hdfs文件系统中的demo路径下的所有txt结尾的文件 下载本地的file.txt文件中。
注意file.txt文件中原来的内容会被覆盖)
hdfs dfs -getmerge /demo/*.txt /home/data/file.txt

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值