1.查看所有命令 查看hdfs dfs下的所有可用命令: 2查看某目录下文件列表 hdfs dfs -ls / 3.查看某文本文件的内容 hdfs dfs -cat /tmp/input.txt 4.创建目录 在hdfs中创建/tmp/tianliangedu目录: hdfs dfs -mkdir /tmp/tianliangedu 5.删除目录 hdfs dfs -rm -r /tmp/tianliangedu 6.从hdfs下载文件 将hdfs中的/tmp/index.html文件下载到本地文件的当前路径下: hdfs dfs -copyToLocal /tmp/index.html 7.从本地上传文件到hdfs 从本地当前目录下,上传之前的index.html文件到hdfs的/tmp/tianliangedu目录中: hdfs dfs -copyFromLocal index.html /tmp/tianliangedu
8.查看压缩的文件内容 查看压缩文本文件的格式: hdfs dfs -text /tmp/tianliangedu/index.html.gz | more 9.查看文件大小 查看hdfs中目录/tmp/tianliangedu中文件占用磁盘大小: hdfs dfs -du -h /tmp/tianliangedu 10.创建文件 在/tmp/tianliangedu目录中创建空文件HelloWorld.txt: hdfs dfs -touchz /tmp/tianliangedu/HelloWorld.txt 11.查看命令帮助信息 查看hdfs dfs中某个命令的用法,比如:cp: hdfs dfs -usage cp