1 hdfs dfs -ls / 查看根目录下所有文件
2 hdfs dfs -ls -R / 查看根目录下递归查看所有文件和文件夹
3 hdfs dfs -mkdir /mydir1 创建一个名称为mydir1的文件夹
4 hdfs dfs -mkdir -p /mydir2/mydir22/mydir222 递归的创建文件夹
5 hdfs dfs -moveFromLocal 把本地路径下的文件移动到hdfs 上
例如:hdfs dfs -moveFromLocal /root/install.log / 把本地文件 /root/install.log 移动到hdfs下的根目录
6 hdfs dfs -mv hdfs://nn.example.com/file1 hdfs://nn.example.com/file2 把hdfs上一个路径下的文件移动到另外一个路径
例如: hdfs dfs -mv /install.log /mydir1 把hdfs 根目录下的Install.log 移动到 根目录下mydir1这个文件夹中去
7 hdfs dfs -put 把本地文件上传到hdfs 上去 本地是Linux系统中,如果你要上传Windows中的文件 先要上传到Linux中 然后再用这个命令上传到hdfs 中去
例如:hdfs dfs -put install.log.syslog / 把本地文件 install.log.syslog 上传到hdfs 上的根目录上去
8 hdfs dfs -appendToFile … 把本地一个文件或多个文件追加到hdfs中指定的文件中
例如 hdfs dfs appendToFile core-site.xml hdfs-site.xml mapred-site.xml /hello.txt 把 core-site.xml hdfs-site.xml mapred-site.xml 这三个文件追加到hdfs 上的 根目录下hello.txt中(相当于把这三个文件复制后移动到hello.txt当中 )
9 hdfs dfs -cat 查看hdfs 上的文件中的内容
例如 hdfs dfs -cat /wordcount/wordcount.txt 查看/wordcount.txt这个文件中的内容
10 hdfs dfs -cp /hello.txt /hello1.txt 拷贝文件 前面一个是原文件 后面一个是拷贝后的文件
11 hdfs dfs -rm 删除文件
例如 hdfs dfs -rm -r /mydir2 递归的删除了mydir2这个文件
12 hdfs dfs -chmod -R 777 /xxx 改变权限的命令,接一个路径
13 hdfs dfs -chown -R hadoop :hadoop /xxx 递归的用户组