HDFS文件系统的基本操作,hadoop基本命令的使用
hdfs命令行客户端的常用操作命令
1 查看hdfs中的目录信息
2 上传文件到hdfs中
1 2 3
| hadoop fs -put /本地文件 /aaa hadoop fs -copyFromLocal /本地文件 /hdfs路径 ## copyFromLocal等价于 put hadoop fs -moveFromLocal /本地文件 /hdfs路径 ## 跟copyFromLocal的区别是:从本地移动到hdfs中
|
3 下载文件到客户端本地磁盘
1 2 3
| hadoop fs -get /hdfs中的路径 /本地磁盘目录 hadoop fs -copyToLocal /hdfs中的路径 /本地磁盘路径 ## 跟get等价 hadoop fs -moveToLocal /hdfs路径 /本地路径 ## 从hdfs中移动到本地
|
4 在hdfs中创建文件夹
1
| hadoop fs -mkdir -p /aaa/xxx
|
5 移动hdfs中的文件(更名)
1
| hadoop fs -mv /hdfs的路径 /hdfs的另一个路径
|
6 删除hdfs中的文件或文件夹
7 修改文件的权限
1 2
| hadoop fs -chown user:group /aaa hadoop fs -chmod 700 /aaa
|
追加内容到已存在的文件
1
| hadoop fs -appendToFile /本地文件 /hdfs中的文件
|
8 显示文本文件的内容
1 2
| hadoop fs -cat /hdfs中的文件 hadoop fs -tail /hdfs中的文件
|
9 其他命令
hdfs命令行客户端的所有命令列表
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
| Usage: hadoop fs [generic options] [-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] [-d] <localsrc> ... <dst>] [-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] [-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...] [-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>] [-createSnapshot <snapshotDir> [<snapshotName>]] [-deleteSnapshot <snapshotDir> <snapshotName>] [-df [-h] [<path> ...]] [-du [-s] [-h] [-x] <path> ...] [-expunge] [-find <path> ... <expression> ...] [-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] [-getfacl [-R] <path>] [-getfattr [-R] {-n name | -d} [-e en] <path>] [-getmerge [-nl] [-skip-empty-file] <src> <localdst>] [-help [cmd ...]] [-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]] [-mkdir [-p] <path> ...] [-moveFromLocal <localsrc> ... <dst>] [-moveToLocal <src> <localdst>] [-mv <src> ... <dst>] [-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>] [-renameSnapshot <snapshotDir> <oldName> <newName>] [-rm [-f] [-r|-R] [-skipTrash] [-safely] <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> ...] [-truncate [-w] <length> <path> ...] [-usage [cmd ...]]
|