1、-mkdir 在HDFS文件系统上创建目录。
首先进入你的hadoop目录下
之后在命令行行中输入:
当你创建多个文件夹是 使用-p即可
[root@hadoop101 hadoop-2.7.2]# hadoop fs -mkdir -p /user/hadoop/testdect
2、-ls 显示目录文件信息
[root@hadoop101 hadoop-2.7.2]# hadoop fs -ls /user/hadoop/
3、-put 上传本地文件到HDFS指定目录。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -put /home/hadoop/test.txt /user/hadoop/testdect
测试:
4、-get 从hdfs下载文件到本地。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -get /user/hadoop/testdect/test.txt /home
5、-rm 从HDFS删除文件。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -rm /user/hadoop/testdect/test.txt
-rmr 是递归删除文件夹及其文件夹下所有的东西!
6、 -moveFromLocal 剪切本地文件到HDFS
[root@hadoop101 hadoop-2.7.2]# hadoop fs -moveFromLocal /home/test.txt /user/hadoop/testdect
7、-cat 显示文件内容。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -cat /user/hadoop/testdect/test.txt
8、-appendToFile 在文件末尾追加数据。
第一个路径是加的内容,第二个路径是加到哪里的目录
[root@hadoop101 hadoop-2.7.2]# hadoop fs -appendToFile /home/hadoop/test.txt /user/hadoop/testdect/test.txt
9、-chmod 更改文件所属权限。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -ls /user/hadoop/testdect/
Found 1 items
-rw-r--r-- 2 root supergroup 182 2020-05-10 15:38 /user/hadoop/testdect/test.txt
[root@hadoop101 hadoop-2.7.2]# hadoop fs -chmod 777 /user/hadoop/testdect/test.txt
[root@hadoop101 hadoop-2.7.2]# hadoop fs -ls /user/hadoop/testdect/
Found 1 items
-rwxrwxrwx 2 root supergroup 182 2020-05-10 15:38 /user/hadoop/testdect/test.txt
[root@hadoop101 hadoop-2.7.2]#
用户权限所有者分别是:
文件所属用户u
文件所属用户组g
其他人o
权限:可读 可写 可执行 ;分别为:4 2 1
10、-cp 实现文件的拷贝。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -cp /user/hadoop/testdect/test.txt /user/
[root@hadoop101 hadoop-2.7.2]# hadoop fs -ls /user/
11、 -mv 移动文件。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -mv /user/test.txt /user/hadoop/testdect
12、-df 统计文件系统的可用空间信息。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -df -h /user/hadoop/testdect/
13、-du 统计文件夹的大小信息。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -du /user/hadoop
14、-count 统计一个指定目录下的文件数量。
[root@hadoop101 hadoop-2.7.2]# hadoop fs -count /user/hadoop
3 2 273 /user/hadoop
3 表示/user/hadoop下的文件夹数
2 表示/user/hadoop下的文件数
273 表示占用磁盘用量