Hadoop(三)命令行操作hdfs
hdfs dfs -ls /
hdfs dfs -du [-s] /kb08/data 统计文件夹信息
hdfs dfs -mkdir /kb08
hdfs dfs -mkdir -p /kb08/data 创建多级目录
hdfs dfs -rmdir /kb08/data 删除目录
hdfs dfs -rm -R /user 递归删除目录
hdfs dfs -put ~/kb08/hadoop/story.csv /kb08/data 上传文件
hdfs dfs -get /kb08/data/story.csv ~ 下载文件
hdfs dfs -getmerge /kb08/data/* ~/merge.txt 合并下载
hdfs dfs -rm /kb08/data/story.csv
hdfs dfs -cat /kb08/data/story.csv
# 查看前3行:hdfs dfs -cat /kb08/data/story.csv | head -n 3
touch append.txt
vi append.txt
hello guys, I am so hornored to see you agin
let us enjoy this moment
hdfs dfs -appendToFile append.txt /kb08/data/story.csv 追加文件内容
hdfs dfs -chmod 777 /kb08/data/story.csv
hdfs dfs -chown henry:root /kb08/hadoop/story.csv
hdfs dfs -cp /kb08/hadoop/story.csv /kbcom/data
hdfs dfs -mv /kb08/hadoop/story.csv /kbcom/data
hdfs dfs -setrep 3 /kb08/data/story.csv 设置文件备份数量(不能超过节点数量)
hdfs dfsadmin -safemode get 查看安全模式
hdfs dfsadmin -safemode enter 进入安全模式
hdfs dfsadmin -safemode enter 离开安全模式