HDFS命令行客户端的常用操作命令

HDFS文件系统的基本操作,hadoop基本命令的使用

hdfs命令行客户端的常用操作命令

1 查看hdfs中的目录信息

hadoop fs -ls /hdfs路径

2 上传文件到hdfs中

hadoop fs -put /本地文件  /aaa
hadoop fs -copyFromLocal /本地文件  /hdfs路径   ##  copyFromLocal等价于 put
hadoop fs -moveFromLocal /本地文件  /hdfs路径  ## 跟copyFromLocal的区别是:从本地移动到hdfs中

3 下载文件到客户端本地磁盘

hadoop fs -get /hdfs中的路径   /本地磁盘目录
hadoop fs -copyToLocal /hdfs中的路径 /本地磁盘路径   ## 跟get等价
hadoop fs -moveToLocal /hdfs路径  /本地路径  ## 从hdfs中移动到本地

4 在hdfs中创建文件夹

hadoop fs -mkdir  -p /aaa/xxx

5 移动hdfs中的文件(更名)

hadoop fs -mv /hdfs的路径  /hdfs的另一个路径

6 删除hdfs中的文件或文件夹

hadoop fs -rm -r /aaa

7 修改文件的权限

hadoop fs -chown user:group /aaa
hadoop fs -chmod 700 /aaa

追加内容到已存在的文件

hadoop fs -appendToFile /本地文件   /hdfs中的文件

8 显示文本文件的内容

hadoop fs -cat /hdfs中的文件
hadoop fs -tail /hdfs中的文件

9 其他命令

hdfs命令行客户端的所有命令列表

Usage: hadoop fs [generic options]
        [-appendToFile  ... ]
        [-cat [-ignoreCrc]  ...]
        [-checksum  ...]
        [-chgrp [-R] GROUP PATH...]
        [-chmod [-R]  PATH...]
        [-chown [-R] [OWNER][:[GROUP]] PATH...]
        [-copyFromLocal [-f] [-p] [-l] [-d]  ... ]
        [-copyToLocal [-f] [-p] [-ignoreCrc] [-crc]  ... ]
        [-count [-q] [-h] [-v] [-t []] [-u] [-x]  ...]
        [-cp [-f] [-p | -p[topax]] [-d]  ... ]
        [-createSnapshot  []]
        [-deleteSnapshot  ]
        [-df [-h] [ ...]]
        [-du [-s] [-h] [-x]  ...]
        [-expunge]
        [-find  ...  ...]
        [-get [-f] [-p] [-ignoreCrc] [-crc]  ... ]
        [-getfacl [-R] ]
        [-getfattr [-R] {-n name | -d} [-e en] ]
        [-getmerge [-nl] [-skip-empty-file]  ]
        [-help [cmd ...]]
        [-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [ ...]]
        [-mkdir [-p]  ...]
        [-moveFromLocal  ... ]
        [-moveToLocal  ]
        [-mv  ... ]
        [-put [-f] [-p] [-l] [-d]  ... ]
        [-renameSnapshot   ]
        [-rm [-f] [-r|-R] [-skipTrash] [-safely]  ...]
        [-rmdir [--ignore-fail-on-non-empty]  ...]
        [-setfacl [-R] [{-b|-k} {-m|-x } ]|[--set  ]]
        [-setfattr {-n name [-v value] | -x name} ]
        [-setrep [-R] [-w]   ...]
        [-stat [format]  ...]
        [-tail [-f] ]
        [-test -[defsz] ]
        [-text [-ignoreCrc]  ...]
        [-touchz  ...]
        [-truncate [-w]   ...]
        [-usage [cmd ...]]

本文作者:foochane
本文链接:https://foochane.cn/article/2019051902.html
版权声明:本文采用 知识共享署名 4.0 国际许可协议 ,转载请注明出处!
  目录