Hadoop shell命令

官方文档

appendToFile

Usage: hadoop fs -appendToFile <localsrc> ... <dst>

将一个或多个文件从本地文件系统追加到目标文件系统中的文件末尾,也可以从stdin读取文件追加到目标文件系统的文件末尾。
Example:

  • hadoop fs -appendToFile localFile /user/hadoop/hadoopFile
  • hadoop fs -appendToFile localFile1 localFile2 /user/hadoop/hadoopFile
  • hadoop fs -appendToFile - /user/hadoop/hadoopFile
[hadoop@jms-master-01 test]$ hadoop fs -appendToFile appendToFileTest /user/hadoop/shell-command-test/appendToFile/appendFile
19/03/28 09:50:35 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-01 test]$
[hadoop@jms-master-01 test]$ hadoop fs -appendToFile test1 test2 /user/hadoop/shell-command-test/appendToFile/appendFile
19/03/28 09:54:13 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-01 test]$

cat

Usage: hadoop fs -cat URI [URI ...]

将路径资源复制到stdout中。
Example:

  • hadoop fs -cat /user/hadoop/hadoopFile
[hadoop@jms-master-02 test]$ hadoop fs -cat /user/hadoop/shell-command-test/appendToFile/appendFile
19/03/28 15:09:14 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
我是appendToFile命令联系文件,我是第一行。
# hadoop fs -appendToFile appendToFileTest /user/hadoop/tmp/test1
我是一个测试,用来测试appendToFile命令
aaa bbb ccc ddd
eee fff ggg hhh
aaa bbb ccc ddd 111
eee fff ggg hhh 111
[hadoop@jms-master-02 test]$

checksum

Usage: hadoop fs -checksum URI

返回一个文件的checksum信息
Example:

  • hadoop fs -checksum /user/hadoop/hadoopFile
[hadoop@jms-master-01 ~]$ hadoop fs -checksum /user/hadoop/input/spark-test.txt
19/03/29 11:26:47 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
/user/hadoop/input/spark-test.txt   MD5-of-0MD5-of-512CRC32C    000002000000000000000000a883055136469e1ac85af27b6f0bc040

chgrp

Usage: hadoop fs -chagrp [-R] GROUP URI [URI ...]

改变文件属组,可以通过-R 参数递归修改。
Example:

  • hadoop fs -chgrp newGroup /user/hadoop/hadoopFile
  • hadoop fs -chgrp new Group /user/hadoop/hadoopDir
[hadoop@jms-master-01 test]$ hadoop fs -chgrp stefan /user/stefan/test1
19/03/29 11:58:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-01 test]$
[hadoop@jms-master-01 test]$
[hadoop@jms-master-01 test]$ hadoop fs -ls /user/stefan
19/03/29 11:58:58 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 2 items
-rw-r--r--   3 hadoop stefan         32 2019-03-29 11:32 /user/stefan/test1
-rw-r--r--   3 hadoop supergroup         40 2019-03-29 11:32 /user/stefan/test2

chmod

Usage: hadoop fs -chmod [-R] <MODE[,MODE]... | OCTALMODE> URI [URI ...]

修改文件权限。

[hadoop@jms-master-01 test]$ hadoop fs -ls /user/stefan
19/03/29 11:59:30 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 2 items
-rw-r--r--   3 hadoop stefan         32 2019-03-29 11:32 /user/stefan/test1
-rw-r--r--   3 hadoop     supergroup         40 2019-03-29 11:32 /user/stefan/test2
[hadoop@jms-master-01 test]$ hadoop fs -chmod 777 /user/stefan/test1
19/03/29 12:02:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-01 test]$ hadoop fs -ls /user/stefan
19/03/29 12:02:52 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 2 items
-rwxrwxrwx   3 hadoop stefan         32 2019-03-29 11:32 /user/stefan/test1
-rw-r--r--   3 hadoop     supergroup         40 2019-03-29 11:32 /user/stefan/test2

chown

Usage: hadoop fs -chown [-R] [OWNER][:[GROUP]] URI [URI]

改变文件的属主。用户必须是超级用户。-R选项递归目录执行。

[hadoop@jms-master-02 test]$ hadoop fs -ls /user/hadoop/shell-command-test/appendToFile
19/04/01 09:29:18 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 3 items
-rw-r--r--   3 hadoop supergroup        248 2019-03-28 09:54 /user/hadoop/shell-command-test/appendToFile/appendFile
-rw-r--r--   3 hadoop supergroup        195 2019-03-28 14:02 /user/hadoop/shell-command-test/appendToFile/appendToFile
-rw-r--r--   3 hadoop supergroup        351 2019-03-28 15:09 /user/hadoop/shell-command-test/appendToFile/stdinFile
[hadoop@jms-master-02 test]$ hadoop fs -chown stefan:stefan /user/hadoop/shell-command-test/appendToFile/stdinFile
19/04/01 09:30:12 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls /user/hadoop/shell-command-test/appendToFile
19/04/01 09:30:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 3 items
-rw-r--r--   3 hadoop     supergroup        248 2019-03-28 09:54 /user/hadoop/shell-command-test/appendToFile/appendFile
-rw-r--r--   3 hadoop     supergroup        195 2019-03-28 14:02 /user/hadoop/shell-command-test/appendToFile/appendToFile
-rw-r--r--   3 stefan     stefan            351 2019-03-28 15:09 /user/hadoop/shell-command-test/appendToFile/stdinFile
[hadoop@jms-master-02 test]$

copyFromLocal

Usage: hadoop fs -copyFromLocal <localsrc> URI
从本地复制文件到hdfs。

[hadoop@jms-master-02 test]$ hadoop fs -copyFromLocal localFile /user/hadoop/shell-command-test/
19/04/01 09:51:25 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -cat /user/hadoop/shell-command-test/localFile
19/04/01 09:51:55 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
我是本地文件

copyToLocal

Usage: hadoop fs -copyToLocal [-ignoresrc] [-crc] URI <localdst>

类似于get命令,区别是只限于本地文件系统

[hadoop@jms-master-02 test]$ hadoop fs -copyToLocal /user/hadoop/shell-command-test/localFile /home/hadoop/stefan/test/localFile1
19/04/01 10:00:57 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ ls
appendFile  localFile  localFile1

count

Usage:hadoop fs -count [-q] [-h] <paths>

统计和指定文件模式匹配路径下的目录,文件,字节数。
-count参数的输出列:DIR_COUNT, FILE_COUNT, CONTENT_SIZE, PATHNAME
-count -q输出列:QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA, DIR_COUNT, FILE_COUNT, CONTENT_SIZE, PATHNAME
-h:将单位转换为可读大小
官网中-v参数已不可用。

[hadoop@jms-master-02 test]$ hadoop fs -count /user/hadoop/shell-command-test/
19/04/01 10:06:07 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
           2            4                813 /user/hadoop/shell-command-test
[hadoop@jms-master-02 test]$ hadoop fs -count -q /user/hadoop/shell-command-test/
19/04/01 10:06:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
        none             inf            none             inf            2            4                813 /user/hadoop/shell-command-test
[hadoop@jms-master-02 test]$ hadoop fs -count -h /user/hadoop/shell-command-test/
19/04/01 10:06:41 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
           2            4                813 /user/hadoop/shell-command-test

cp

Usage:hadoop fs -cp [-f] [-p] -p[topax] URI [URI ... ] <dest>

复制文件从源到目的地。该命令复制多个源时,目的地必须是目录。
Options:

  • -f:目标文件如果存在则会覆盖。
    *-p:保留文件属性[topx](时间戳,所有权,权限,ACL,XAttr)。-p没有指定参数,则保留时间戳,属主和权限。
[hadoop@jms-master-02 test]$ hadoop fs -cp /user/hadoop/shell-command-test/localFile /user/hadoop/shell-command-test/localFile2
19/04/01 10:25:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls /user/hadoop/shell-command-test/
19/04/01 10:25:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 3 items
drwxr-xr-x   - hadoop supergroup          0 2019-03-28 10:11 /user/hadoop/shell-command-test/appendToFile
-rw-r--r--   3 hadoop supergroup         19 2019-04-01 09:51 /user/hadoop/shell-command-test/localFile
-rw-r--r--   3 hadoop supergroup         19 2019-04-01 10:25 /user/hadoop/shell-command-test/localFile2

df

Usage: hadoop fs -df [-h] URI [URI ...]

查看可用空间。
-h:可读模式显示。

[hadoop@jms-master-02 test]$ hadoop fs -df /user/hadoop/
19/04/01 10:32:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Filesystem                         Size     Used     Available  Use%
hdfs://jms-master-01:9000  321944301568  1941774  297705459712    0%
[hadoop@jms-master-02 test]$ hadoop fs -df -h /user/hadoop/
19/04/01 10:32:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Filesystem                    Size   Used  Available  Use%
hdfs://jms-master-01:9000  299.8 G  1.9 M    277.3 G    0%

du

Usage: hadoop fs -du [-s] [-h] URI [URI ...]

显示给定目录中包含的文件和目录的大小,当仅仅是文件时,显示文件的长度。
*-s:汇总显示
*-h:可读模式显示

[hadoop@jms-master-02 test]$ hadoop fs -du /user/hadoop/
19/04/01 10:37:27 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
1506  /user/hadoop/input
54    /user/hadoop/output
870   /user/hadoop/shell-command-test
0     /user/hadoop/我是stdin的输入文字
[hadoop@jms-master-02 test]$ hadoop fs -du -s /user/hadoop/
19/04/01 10:39:18 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2430  /user/hadoop
[hadoop@jms-master-02 test]$ hadoop fs -du -s -h /user/hadoop/
19/04/01 10:40:07 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
2.4 K  /user/hadoop

dus(弃用)

Usage: hadoop fs -dus <args>
显示文件大小。
当前已经被hadoop fs -du -s命令替换。

find

Usage: hadoop fs -find <path> ... <expression> ...

查找与指定表达式匹配的所有文件,并将选定的操作应用于他们。如果未指定路径,则默认未当前工作目录。如果未指定表达式,则默认未-print。
表达式:
*-name
*-iname(文件名不区分大小写)
*-print
*-print0
*expression -a expression
*expression -and expression
*expression expression

[hadoop@jms-master-02 test]$ hadoop fs -find /user/hadoop -name test*
19/04/01 11:21:41 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
/user/hadoop/input/test1
/user/hadoop/input/test2

get

Usage: hadoop fs -get [-ignorecrc] [-crc] <src> <localdst>
复制文件到本地文件系统。使用-ignorecrc忽略CRC校验失败复制,使用-crc指定通过CRC校验复制。

[hadoop@jms-master-02 test]$ hadoop fs -get -crc /user/hadoop/input/test1 .
19/04/01 11:41:11 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ ll
总用量 16
-rw-r--r-- 1 hadoop     hadoop     32 4月   1 11:41 test1

getfacl

Usage: hadoop fs -getfacl [-R] <path>

显示文件和目录的访问控制列表(ACL)。如果目录具有默认ACL,则getfacl会显示默认的ACL。
*-R选项可以递归列出所有文件和目录的ACL。

hadoop@jms-master-02 test]$ hadoop fs -getfacl /user/hadoop
19/04/01 11:45:10 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
# file: /user/hadoop
# owner: hadoop
# group: supergroup
getfacl: The ACL operation has been rejected.  Support for ACLs has been disabled by setting dfs.namenode.acls.enabled to false.
[hadoop@jms-master-02 test]$ hadoop fs -getfacl -R /user/hadoop
19/04/01 11:45:22 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
# file: /user/hadoop
# owner: hadoop
# group: supergroup
getfacl: The ACL operation has been rejected.  Support for ACLs has been disabled by setting dfs.namenode.acls.enabled to false.

getfattr

Usage: hadoop fs -getfattr [-R] -n name | -d [-e en] <path>

显示文件或目录的扩展属性名称和值(如果有)。

[hadoop@jms-master-02 test]$ hadoop fs -getfattr -R -n user.myAttr /user/hadoop/shell-command-test/localFile
19/04/01 12:07:42 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
# file: /user/hadoop/shell-command-test/localFile

getmerge

Usage: hadoop fs -getmerge [-nl] <src> <localdst>
将源文件内容写入到本地文件,支持多个源文件合并到本地文件。如果本地文件存在,则会被覆盖。
将test1和test2合并到本地。

[hadoop@jms-master-02 test]$ hadoop fs -cat /user/hadoop/input/test1
19/04/01 14:28:32 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
aaa bbb ccc ddd
eee fff ggg hhh
[hadoop@jms-master-02 test]$ hadoop fs -cat /user/hadoop/input/test2
19/04/01 14:28:36 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
aaa bbb ccc ddd 111
eee fff ggg hhh 111
[hadoop@jms-master-02 test]$ hadoop fs -getmerge -nl /user/hadoop/input/test1 /user/hadoop/input/test2 testmerge
19/04/01 14:26:53 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ cat testmerge
aaa bbb ccc ddd
eee fff ggg hhh

aaa bbb ccc ddd 111
eee fff ggg hhh 111

ls

Usage: hadoop fs -ls [-d] [-h] [-R] <args>
Options:
*-d:目录列为纯文件
*-h:可读方式格式化文件大小
*-R:递归列出遇到的子目录

[hadoop@jms-master-02 test]$ hadoop fs -ls -R /user/hadoop
19/04/01 14:33:14 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
drwxr-xr-x   - hadoop supergroup          0 2019-03-19 16:43 /user/hadoop/input
-rw-r--r--   3 hadoop supergroup       1434 2019-03-19 16:43 /user/hadoop/input/spark-test.txt
-rw-r--r--   3 hadoop supergroup         32 2019-03-15 20:14 /user/hadoop/input/test1
-rw-r--r--   3 hadoop supergroup         40 2019-03-15 20:14 /user/hadoop/input/test2
drwxr-xr-x   - hadoop supergroup          0 2019-03-15 20:15 /user/hadoop/output
-rw-r--r--   3 hadoop supergroup          0 2019-03-15 20:15 /user/hadoop/output/_SUCCESS
-rw-r--r--   3 hadoop supergroup         54 2019-03-15 20:15 /user/hadoop/output/part-r-00000
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 10:27 /user/hadoop/shell-command-test
drwxr-xr-x   - hadoop supergroup          0 2019-03-28 10:11 /user/hadoop/shell-command-test/appendToFile
-rw-r--r--   3 hadoop     supergroup        248 2019-03-28 09:54 /user/hadoop/shell-command-test/appendToFile/appendFile
-rw-r--r--   3 hadoop     supergroup        195 2019-03-28 14:02 /user/hadoop/shell-command-test/appendToFile/stdinFile
-rw-r--r--   3 hadoop     supergroup         19 2019-04-01 09:51 /user/hadoop/shell-command-test/localFile
-rw-r--r--   3 hadoop     supergroup         19 2019-04-01 10:25 /user/hadoop/shell-command-test/localFile2
-rw-r--r--   3 hadoop     supergroup         19 2019-04-01 09:51 /user/hadoop/shell-command-test/localFile3
-rw-r--r--   3 hadoop     supergroup         19 2019-04-01 10:27 /user/hadoop/shell-command-test/localFile4
-rw-r--r--   3 hadoop     supergroup          0 2019-03-28 14:04 /user/hadoop/我是stdin的输入文字

mkdir

Usage: hadoop fs -mkdir [-p] <paths>
创建目录。-p:遇到不存在的父目录时,自动创建。

[hadoop@jms-master-02 test]$ hadoop fs -mkdir -p /user/hadoop/mkdir/test/
19/04/01 14:37:25 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls -R /user/hadoop
drwxr-xr-x   - hadoop supergroup          0 2019-03-19 16:43 /user/hadoop/input
-rw-r--r--   3 hadoop supergroup       1434 2019-03-19 16:43 /user/hadoop/input/spark-test.txt
-rw-r--r--   3 hadoop supergroup         32 2019-03-15 20:14 /user/hadoop/input/test1
-rw-r--r--   3 hadoop supergroup         40 2019-03-15 20:14 /user/hadoop/input/test2
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 14:37 /user/hadoop/mkdir
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 14:37 /user/hadoop/mkdir/test

moveFromLocal

Usage: hadoop fs -moveFromLocal <localsrc> <dst>
和put命令类似,只是在复制后会删除源文件localsrc

[hadoop@jms-master-02 test]$ ls
appendFile  localFile  localFile1  localFile2  localFile3  test1  testmerge
[hadoop@jms-master-02 test]$ hadoop fs -moveFromLocal testmerge /user/hadoop/mkdir/test
19/04/01 14:41:20 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls /user/hadoop/mkdir/test
19/04/01 14:41:33 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 1 items
-rw-r--r--   3 hadoop supergroup         74 2019-04-01 14:41 /user/hadoop/mkdir/test/testmerge
[hadoop@jms-master-02 test]$ ls
appendFile  localFile  localFile1  localFile2  localFile3  test1

moveToLocal

Usage: hadoop fs -moveToLocal [-crc] <src> <dst>
还未实现的命令(可能以后会实现吧)。

[hadoop@jms-master-02 test]$ hadoop fs -moveToLocal /user/hadoop/mkdir/test/testmerge /home/hadoop/xiepengjie/test
moveToLocal: Option '-moveToLocal' is not implemented yet.

mv

Usage: hadoop fs -mv URI [URI ...] <dest>
移动文件从源到目标。

[hadoop@jms-master-02 test]$ hadoop fs -ls -R /user/hadoop/mkdir
19/04/01 15:10:14 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 14:41 /user/hadoop/mkdir/test
-rw-r--r--   3 hadoop supergroup         74 2019-04-01 14:41 /user/hadoop/mkdir/test/testmerge
[hadoop@jms-master-02 test]$ hadoop fs -mv /user/hadoop/mkdir/test/testmerge /user/hadoop/mkdir
19/04/01 15:10:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls -R /user/hadoop/mkdir
19/04/01 15:10:42 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 15:10 /user/hadoop/mkdir/test
-rw-r--r--   3 hadoop supergroup         74 2019-04-01 14:41 /user/hadoop/mkdir/testmerge

put

Usage: hadoop fs -put <localsrc> .. <dst>
上传文件到hdfs系统

[hadoop@jms-master-02 test]$ ls
appendFile  localFile  localFile1  localFile2  localFile3  test1
[hadoop@jms-master-02 test]$ hadoop fs -put test1 /user/hadoop/mkdir/test
19/04/01 15:12:34 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls -R /user/hadoop/mkdir
19/04/01 15:12:48 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
drwxr-xr-x   - hadoop supergroup          0 2019-04-01 15:12 /user/hadoop/mkdir/test
-rw-r--r--   3 hadoop supergroup         32 2019-04-01 15:12 /user/hadoop/mkdir/test/test1
-rw-r--r--   3 hadoop supergroup         74 2019-04-01 14:41 /user/hadoop/mkdir/testmerge

rm

Usage: hadoop fs -rm [-f] [-r | -R ] [-skipTrash] URI [URI ...]
删除文件。
Options:
*-f:如果文件不存在,-f参数将不显示诊断消息或修改退出状态以反映错误。
*-R:递归删除
-r:和-R等效
*-skipTrash:跳过垃圾桶并立即删除文件。当需要从超配额目录中删除文件时,可以使用。

[hadoop@jms-master-02 test]$ hadoop fs -rm -r /user/hadoop/mkdir
19/04/01 15:19:58 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
19/04/01 15:20:00 INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = 0 minutes, Emptier interval = 0 minutes.
Deleted /user/hadoop/mkdir

rmdir

Usage: hadoop fs -rmdir [--ignore-fail-on-non-empty] URI [URI ...]
删除目录。默认情况下目录不为空时删除失败,当指定参数--ignore-fail-on-non-empty时,跳过不为空校验。

[hadoop@jms-master-02 test]$ hadoop fs -rmdir /user/hadoop/input
19/04/01 15:21:39 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
rmdir: `/user/hadoop/input': Directory is not empty
[hadoop@jms-master-02 test]$ hadoop fs -rmdir --ignore-fail-on-non-empty /user/hadoop/input
19/04/01 15:26:26 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable

stat

Usage: hadoop fs -stat [ format] <path> ...

[hadoop@jms-master-02 test]$ hadoop fs -stat "%F %u:%g %b %y %n" /user/hadoop/input/test2
19/04/01 15:46:46 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
regular file hadoop:supergroup 40 2019-03-15 12:14:44 test2

tail

Usage: hadoop fs -tail [-f] URI

显示文件的最后一千字节到stdout。-f选项可以将增量输出持续输出到stdout。

test

Usage: hadoop fs -test -[defsz] URI
Options:
*-d:如果是目录,返回0
*-e:如果路径存在,返回0
*-f:如果路径是文件,返回0
*-s:如果路径不为空,返回0
*-z:如果文件长度为0,返回0

touchz

Usage: hadoop fs -touchz URI [URI ...]
创建一个空文件。

[hadoop@jms-master-02 test]$ hadoop fs -touchz /user/hadoop/input/_SUCCESS
19/04/01 16:10:38 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
[hadoop@jms-master-02 test]$ hadoop fs -ls /user/hadoop/input
19/04/01 16:10:49 WARN util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
Found 4 items
-rw-r--r--   3 hadoop supergroup          0 2019-04-01 16:10 /user/hadoop/input/_SUCCESS

©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 203,772评论 6 477
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 85,458评论 2 381
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 150,610评论 0 337
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 54,640评论 1 276
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 63,657评论 5 365
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 48,590评论 1 281
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 37,962评论 3 395
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,631评论 0 258
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 40,870评论 1 297
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,611评论 2 321
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 37,704评论 1 329
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,386评论 4 319
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 38,969评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 29,944评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,179评论 1 260
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 44,742评论 2 349
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,440评论 2 342

推荐阅读更多精彩内容