Hadoop 常用shell命令

dfs 是fs 的实现类
hadoop dfs  

        [-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>]
        [-getfacl [-R] <path>]
        [-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> ...]
        [-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
        [-setrep [-R] [-w] <rep> <path> ...]
        [-stat [format] <path> ...]
        [-tail [-f] <file>]
        [-test -[defsz] <path>]
        [-text [-ignoreCrc] <src> ...]
        [-touchz <path> ...]
        [-usage [cmd ...]]

	查看目录 :hadoop dfs   -ls [-R]  / 
    创建目录 :hadoop dfs -mkdir [-p] /user/files
	从本地剪切粘贴到hdfs上:hadoop dfs -moveFromLocal /home/hello.txt   /user/files/
	文件追加到末尾:hadoop dfs -appendToFile /home/word.txt /user/files/hello.txt
	查看文件内容:hadoop dfs -cat /user/files/hello.txt
	修改文件所属组:hadoop dfs -chgrp hadoop /user/files/hello.txt
	修改文件拥有者:hadoop dfs -chown hive:hive /user/files/hello.txt
	修改文件权限:hadoop dfs -chmod 755 hive:hive /user/files/hello.txt
	从本地拷贝到hdfs:hadoop dfs -copyFromLocal /home/hi.txt  /user/files/
	                  hadoop dfs -put /home/hi.txt  /user/files/
	从hdfs下载到本地:hadoop dfs -copyToLocal /user/files/hello.txt /home/text/
	                  hadoop dfs -get /user/files/hi.txt /home/text/
	拷贝文件:hadoop dfs -cp /user/files/hello.txt /user/
	文件移动:hadoop dfs -mv /user/files/hello.txt /user/
	多个文件合并到本地:hadoop dfs -getmerge /user/files/* /home/text/merge.txt
	显示一个文件的末尾:hadoop dfs -tail /user/files/hello.txt
	删除文件或文件夹:hadoop dfs -rm [-r] /user/files/hi.txt
	删除空文件夹:hadoop dfs -rmdir /user/files
	统计文件夹的大小信息:hadoop dfs -du -h /user
	统计文件夹的总大小:hadoop dfs -du -h -s /user 
	设置HDFS文件的副本数为2:hadoop dfs -setrep 2  /user/files/hello.txt

 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值