Linux命令操作HDFS文件系统

HDFS命令操作

# 格式化操作
$ bin/hdfs namenode -format
# 展示文件和文件夹列表
$ bin/hdfs dfs -ls /
# 创建文件夹
	# 在用户目录下创建
	$ bin/hdfs dfs -mkdir AAA/
	# 在根目录下创建
	$ bin/hdfs dfs -mkdir /AAA/
	# 递归层级创建多个文件夹
	$ bin/hdfs dfs -mkdir -p /BBB/CCC
	# 上传本地文件到HDFS,如果上传成功,则删除本地文件(就是剪切操作)
	$ bin/hdfs dfs -moveFromLocal hello_world.txt /
	# 末尾追加数据到HDFS中已经存在的文件里面
	$ bin/hdfs dfs -appendToFile hello_world2.txt /hello_world.txt
	# 查看文件内容
	$ bin/hdfs dfs -cat /hello_world.txt 
	# 查看文件末尾信息
	$ bin/hdfs dfs -tail /hello_world.txt
	# 拷贝本地文件到HDFS,-copyFromLocal可以替换为-put
	$ bin/hdfs dfs -copyFromLocal words.txt /AAA
	# 拷贝HDFS文件到HDFS另一个目录
	$ bin/hdfs dfs -cp /AAA/words.txt /BBB
	# 或剪切
	$ bin/hdfs dfs -mv /AAA/words.txt /BBB
	# 下载HDFS中的文件到本地文件系统
	$ bin/hdfs -get /hello_world.txt ./
	# 下载多个文件,并合并为一个文件到本地文件系统
	$ bin/hdfs dfs -getmerge /*.txt ./demo.txt
	# 删除文件或文件夹
	$ bin/hdfs dfs -rmr /AAA
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值