2-2.1.Hadoop2.0x HDFS shell命令(Hadoop系列day02)

本文提供了一份详细的Hadoop2 HDFS shell命令列表,包括文件上传、下载、权限设置等功能,帮助用户高效管理和操作HDFS中的文件。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Hadoop2 HDFS shell命令
 
1. hdfs dfs -appendToFile <localsrc> ... <dst>
 
可同时上传多个文件到HDFS里面
 
2.  hdfs dfs -cat URI [URI ...]
 
查看文件内容
 
3. hdfs dfs -chgrp [-R] GROUP URI [URI ...]
 
修改文件所属组
 
4.  hdfs dfs -chmod [-R] <MODE[,MODE]... | OCTALMODE> URI [URI ...]
 
修改文件权限
 
5. hdfs dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]
 
修改文件所有者,文件所属组,其他用户的读、写、执行权限
 
6. hdfs dfs -copyFromLocal <localsrc> URI
 
复制文件到hdfs
 
7.  hdfs dfs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
 
复制文件到本地
 
8. hdfs dfs -count [-q] <paths>
 
统计文件及文件夹数目
 
9.  hdfs dfs -cp [-f] URI [URI ...] <dest>
 
Hadoop HDFS 文件系统间的文件复制
 
10. hdfs dfs -du [-s] [-h] URI [URI ...]
 
统计目录下的文件及大小
 
 
 
11. hdfs dfs -dus <args>
 
汇总目录下的文件总大小
 
12.  hdfs dfs -expunge
 
清空回收站,文件被删除时,它首先会移到临时目录.Trash/中,当超过延迟时间之后,文件才会被永久删除
 
13. hdfs dfs -get [-ignorecrc] [-crc] <src> <localdst>
 
下载文件到本地
 
14. hdfs dfs -getfacl [-R] <path>
 
查看ACL (访问权限组拥有者)
 
15. hdfs dfs -getmerge <src> <localdst> [addnl]
 
合并下载文件到本地
 
16. hdfs dfs -ls <args>
 
查看目录
 
17. hdfs dfs -lsr <args>
 
循环列出目录、子目录及文件信息 
 
18. hdfs dfs -mkdir [-p] <paths>
 
创建空白文件夹
 
19.  dfs -moveFromLocal <localsrc> <dst>
 
剪切文件到hdfs
 
20.  hdfs dfs -moveToLocal [-crc] <src> <dst>
 
剪切文件到本地
 
21. hdfs dfs -mv URI [URI ...] <dest>
 
剪切hdfs文件
 
22. hdfs dfs -put <localsrc> ... <dst>
 
上传文件
 
23. hdfs dfs -rm [-skipTrash] URI [URI ...]
 
删除文件/空白文件夹
 
24.  hdfs dfs -rmr [-skipTrash] URI [URI ...]
 
递归删除  删除文件及文件夹下的所有文件
 
25. hdfs dfs -setfacl [-R] [-b|-k -m|-x <acl_spec> <path>]|[--set <acl_spec> <path>]
 
Sets Access Control Lists (ACLs) of files and directories.
Options:
-b: Remove all but the base ACL entries. The entries for user, group and others are retained for compatibility with permission bits.
-k: Remove the default ACL.
-R: Apply operations to all files and directories recursively.
-m: Modify ACL. New entries are added to the ACL, and existing entries are retained.
-x: Remove specified ACL entries. Other ACL entries are retained.
--set: Fully replace the ACL, discarding all existing entries. The acl_spec must include entries for user, group, and others for compatibility with permission bits.
acl_spec: Comma separated list of ACL entries.
path: File or directory to modify.
Examples:
hdfs dfs -setfacl -m user:hadoop:rw- /file
hdfs dfs -setfacl -x user:hadoop /file
hdfs dfs -setfacl -b /file
hdfs dfs -setfacl -k /dir
hdfs dfs -setfacl --set user::rw-,user:hadoop:rw-,group::r--,other::r-- /file
hdfs dfs -setfacl -R -m user:hadoop:r-x /dir
hdfs dfs -setfacl -m default:user:hadoop:r-x /dir
Exit Code:
Returns 0 on success and non-zero on error.
 
 
26.  hdfs dfs -setrep [-R] [-w] <numReplicas> <path>
 
修改副本数
 
27. hdfs dfs -stat URI [URI ...]
 
显示文件统计信息
 
28.  hdfs dfs -tail [-f] URI
 
查看文件尾部信息
 
29. hdfs dfs -test -[ezd] URI
 
对PATH进行如下类型的检查: 
-e PATH是否存在,如果PATH存在,返回0,否则返回1 
-z 文件是否为空,如果长度为0,返回0,否则返回1 
-d 是否为目录,如果PATH为目录,返回0,否则返回1 
 
30. hdfs dfs -text <src>
 
查看文件内容
 
31.  hdfs dfs -touchz URI [URI ...]
 

创建长度为0的空文件




hive (test_db)> LOAD DATA LOCAL INPATH'/root/name.txt' INFO TABLE t1; MismatchedTokenException(26!=143) at org.antlr.runtime.BaseRecognizer.recoverFromMismatchedToken(BaseRecognizer.java:617) at org.antlr.runtime.BaseRecognizer.match(BaseRecognizer.java:115) at org.apache.hadoop.hive.ql.parse.HiveParser.loadStatement(HiveParser.java:1835) at org.apache.hadoop.hive.ql.parse.HiveParser.execStatement(HiveParser.java:1608) at org.apache.hadoop.hive.ql.parse.HiveParser.statement(HiveParser.java:1112) at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:202) at org.apache.hadoop.hive.ql.parse.ParseDriver.parse(ParseDriver.java:166) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:397) at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:309) at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1145) at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1193) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1082) at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1072) at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213) at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165) at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376) at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:736) at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681) at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.apache.hadoop.util.RunJar.run(RunJar.java:221) at org.apache.hadoop.util.RunJar.main(RunJar.java:136) FAILED: ParseException line 1:39 mismatched input 'INFO' expecting INTO near ''/root/name.txt'' in load statement
最新发布
06-24
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值