[hadoop fs -]=[hdfs dfs -]
(1)启动集群
全启动:
start-all.sh
start-dfs.sh 单独
start-yarn.sh 单独
单独启动节点:
hadoop-daemon.sh start namenode
关闭:
hadoop-daemon.sh stop namenode
关闭所有:
stop-all.sh
stop-dfs.sh 单独
stop-yarn.sh 单独
(2)帮助信息
hadoop fs -help appendToFile
介绍 语法 + 解释
hdfs dfs -lsr / 查看详细文件信息(常用)
(3)上传文件到hdfs①
hdfs dfs -put body.txt /centos/file/body.txt
(4) 上传文件到hdfs②
hdfs dfs -copyFromLocal body.txt /centos/file/body.txt
(5) 下载文件到本地①
hdfs dfs -get /centos/file/body.txt .
(6)下载文件到本地②
hdfs dfs -copyToLocal /centos/file/body.txt .
(7)hdfs文件内容不能随意修改但可以追加内容 appendToFile
hdfs dfs -appendToFile body.txt /centos/file/hello.txt
(xx)echo use hdfs ! >body.txt 内容重定向到文件中
(8)查看目录信息
hadoop fs -lsr / 查看详细文件信息
(9)创建目录
hadoop fs -mkdir -p /uer/atiguigu/
递归创建文件夹
不加p只能创建一层
(10)从本地剪切到hdfs
hdfs dfs -moveFromLocal body.txt /centos/file
(11) cat 显示文件内容
hdfs dfs -cat /centos/file/body.txt
(12) tail 显示文件末尾内容
hdfs dfs -tail /centos/file/body.txt
(13)权限问题
hdfs dfs -chmod xxx /centos/file/body.txt
u g o
hdfs dfs -chown root:root /centos/file/body.txt
chown:可以同时修改用户和用户组
chgrp 只能修改用户组
(14)删除问题
hdfs dfs -rm /centos/file/body.txt 只能删除文件
hdfs dfs -rmr /centos/file/ 可以递归删除文件夹/删除文件 (常用)
hdfs dfs -rmr /centos/file/ 可以删除空目录
(15)hdfs 内部复制和移动文件
hdfs dfs -cp /centos/file/body.txt /usr/antiguigu/
hdfs dfs -mv /centos/file/body.txt /usr/antiguigu/
(16)文件系统可用空间信息
hdfs dfs -df -h /
(17) 特定文件夹可用空间信息
hdfs dfs -du -s -h /centos/