Hadoop HDFS命令

创建HDFS目录

hadoop fs -mkdir
[root@localhost bin]# hadoop fs -mkdir /home

列出HDFS目录

hadoop dfs -ls / 列出HDFS目录

[root@localhost bin]# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 3 items
drwxr-xr-x   - root supergroup          0 2019-08-01 19:13 /home
drwx-wx-wx   - root supergroup          0 2019-08-01 16:28 /tmp
drwxr-xr-x   - root supergroup          0 2019-08-01 17:29 /user

复制本地文件(local)到HDFS

hadoop fs -copyFromLocal
使用-copyFromLocal复制本地文件(local)到HDFS

[root@localhost bin]# hadoop fs -copyFromLocal app_h5_start.jar /home/
[root@localhost bin]# hadoop dfs -ls /home/
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 1 items
-rw-r--r--   1 root supergroup       6890 2019-08-01 19:16 /home/app_h5_start.jar

put复制本地(local)文件到HDFS

hadoop fs -put 使用-put复制本地(local)文件到HDFS

[root@localhost bin]# hadoop fs -put app_h5_start.java /home/
[root@localhost bin]# hadoop dfs -ls /home/
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 2 items
-rw-r--r--   1 root supergroup       6890 2019-08-01 19:16 /home/app_h5_start.jar
-rw-r--r--   1 root supergroup      16075 2019-08-01 19:17 /home/app_h5_start.java

将HDFS上的文件复制到本地

hadoop fs -copyToLocal 将HDFS上的文件复制到本地(local)

[root@localhost bin]# hadoop fs -copyToLocal /home/app_h5_start.jar /data/

get将HDFS上的文件复制到本地

hadoop fs -get 将HDFS上的文件复制到本地(local)

[root@localhost data]# hadoop fs -copyToLocal /home/app_h5_start.java /data/

复制HDFS文件

hadoop fs -cp 复制HDFS文件

[root@localhost data]# hadoop fs -cp /home/app_h5_start.jar /home/test01.jar
[root@localhost data]# hadoop dfs -ls /home/
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 3 items
-rw-r--r--   1 root supergroup       6890 2019-08-01 19:16 /home/app_h5_start.jar
-rw-r--r--   1 root supergroup      16075 2019-08-01 19:17 /home/app_h5_start.java
-rw-r--r--   1 root supergroup       6890 2019-08-01 19:19 /home/test01.jar

删除HDFS文件

hadoop fs -rm 删除HDFS文件

[root@localhost data]# hadoop fs -rm /home/test01.jar
Deleted /home/test01.jar
[root@localhost data]# hadoop dfs -ls /home/
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 2 items
-rw-r--r--   1 root supergroup       6890 2019-08-01 19:16 /home/app_h5_start.jar
-rw-r--r--   1 root supergroup      16075 2019-08-01 19:17 /home/app_h5_start.java

列出HDFS目录下的文件的内容

hadoop fs -cat 列出HDFS目录下的文件的内容

[root@localhost data]# hadoop fs -cat /home/app_h5_start.java
// ORM class for table 'app_h5_start'
// WARNING: This class is AUTO-GENERATED. Modify at your own risk.
//
// Debug information:
// Generated date: Thu Aug 01 18:23:47 CST 2019
// For connector: org.apache.sqoop.manager.MySQLManager

删除HDFS目录

hadoop fs -rm -r -skipTrash <目录名称> 删除HDFS目录

[root@localhost data]# hadoop fs -rm -r -skipTrash /home/
Deleted /home
[root@localhost data]# hadoop dfs -ls /
DEPRECATED: Use of this script to execute hdfs command is deprecated.
Instead use the hdfs command for it.

Found 2 items
drwx-wx-wx   - root supergroup          0 2019-08-01 16:28 /tmp
drwxr-xr-x   - root supergroup          0 2019-08-01 17:29 /user

你可能感兴趣的:(Hadoop)