Hadoop_常用命令(hdfs上)
hadoop fs所有文件系统都可以使用
hdfs dfs仅针对于hdfs文件系统
- 1 - 查看所有目录(文件夹)及文件
hdfs dfs -ls /
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093213013-1723437621.png)
- 2 - 在hdfs文件系统中创建目录(文件夹)
hdfs dfs -mkdir /test
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093220452-1268251553.png)
- 3 - 在hdfs文件系统中创建文件
hdfs dfs -touchz /words_1.txt
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093226524-2099512557.png)
- 4 - 在hdfs文件系统中删除文件
hdfs dfs -rm /words_1.txt
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093233021-1095229206.png)
hdfs dfs -rf /words_1.txt
- 5 - 向hdfs上传文件
hdfs dfs -put 文件名 /路径
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093238867-1515318203.png)
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093244878-1361373172.png)
对文件进行词频统计操作:wordcount
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093251821-1459243545.png)
- 6 - 查看hdfs上的文件内容
hdfs dfs -cat /对应路径上的文件名
查看上传路径
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093258906-1005917748.png)
查看打开输出的文件内容
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093305481-878079096.png)
- 7 - 从hdfs下载文件
hdfs dfs -get /文件名 /下载到目标路径
- 8 - 递归删除目录
hdfs dfs -rmr /test
- 9 - 查看节点进程
jps
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093317758-898326793.png)
- 10 - 创建一个文件
vi 文件名
![](https://img2018.cnblogs.com/blog/1568723/201908/1568723-20190810093324064-2037311949.png)