概述
上一篇文章我们搭建好hadoop 之后,我们可以来尝试一些hadoop 的shell 命令。其实 hadoop 的shell跟linux 的shell 有很多相似的,只要是熟悉linux 的shell,学起来会很轻松。
hadoop shell
ls 查看:hadoop fs -ls {hdfs_path}
ex:输入hadoop fs -ls /
查看根目录:mkdir 创建文件夹:hadoop fs -mkdir {hdfs_path}
ex: 输入hadoop fs -mkdir /test1
创建test1 目录rm 删除文件和文件夹: hadoop fs -rm {-arg} {hdfs_file_path}
ex: 输入hadoop fs -rm -r /test1
put 将本地文件上传到hdfs 中: hadoop fs -put {local_file} {hdfs_path}
ex : 在当前目录创建test.txt 并输入hadoop fs -put ./test.txt /test
上传到test目录中。get 将hdfs 的文件下载到本地: hadoop fs -get {hdfs_file_path} {local_file_path}
ex :输入hadoop fs -get /test/test.txt ./text2.txt
将text.txt 下载并保持到本地为test2.txt<img style=’float:left’src=”7.png”/>cat 展示hdfs 文件内容: hadoop fs -cat {hdfs_file_path}
ex : 输入hadoop fs cat /test/test.txt
查看test.txt 内容