1、目录操作
hdfs dfs [命令] [命令] 等价于 hadoop fs [] []
1 ./bin/hdfs dfs -mkdir -p /user/hadoop 基本操作在hadoop目录bin中hdfs 后跟dfs
-mkdir 创建目录 -p代表创建多级目录
2 hadoop fs -ls . "."表示当前用户目录
3 hadoop fs -mkdir /input 创建input目录
4 hadoop fs -rm -r /input 删除input目录 -r 表示删除目录和目录下的所有文件
2. 文件操作
hadoop fs -put test.text / 将本地文件上传到hadoop根目录
hadoop fs -cat /test.text 查看文件内容
- ./bin/hdfs dfs -cat /dbtaobao/dataset/user_log/small_user_log.csv | head -10 查看前十行
hadoop fs -get /test.text ~/date/ //将hdfs文件下载到本地
hadoop fs -cp /test.text /hello //复制一份
其他命令 Hadoop fs 回车看注解
[-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] [-l] <localsrc> ... <dst>] //从本地复制
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] //复制到本地
[-count [-q] [-h] [-v] <path> ...]
[-cp [-f] [-p | -p[topax]] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] //拿到
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] <src> <localdst>]
[-help [cmd ...]]
[-ls [-d] [-h] [-R] [<path> ...]] //查看目录 需要有目录 hadoop fs -ls /
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] <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>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-usage [cmd ...]]