HDFS常用的shell命令

命令:

[-appendToFile <localsrc> ... <dst>]
[-cat [-ignoreCrc] <src> ...]
[-checksum <src> ...]
[-chgrp [-R] GROUP PATH...]
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...]
[-chown [-R] [OWNER][:[GROUP]] PATH...]
[-copyFromLocal [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
[-copyToLocal [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-count [-q] [-h] [-v] [-t [<storage type>]] [-u] [-x] <path> ...]
[-cp [-f] [-p | -p[topax]] [-d] <src> ... <dst>]
[-createSnapshot <snapshotDir> [<snapshotName>]]
[-deleteSnapshot <snapshotDir> <snapshotName>]
[-df [-h] [<path> ...]]
[-du [-s] [-h] [-x] <path> ...]
[-expunge]
[-find <path> ... <expression> ...]
[-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
[-getfacl [-R] <path>]
[-getfattr [-R] {-n name | -d} [-e en] <path>]
[-getmerge [-nl] [-skip-empty-file] <src> <localdst>]
[-help [cmd ...]]
[-ls [-C] [-d] [-h] [-q] [-R] [-t] [-S] [-r] [-u] [<path> ...]]
[-mkdir [-p] <path> ...]
[-moveFromLocal <localsrc> ... <dst>]
[-moveToLocal <src> <localdst>]
[-mv <src> ... <dst>]
[-put [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
[-renameSnapshot <snapshotDir> <oldName> <newName>]
[-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...]
[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]]
[-setfattr {-n name [-v value] | -x name} <path>]
[-setrep [-R] [-w] <rep> <path> ...]
[-stat [format] <path> ...]
[-tail [-f] <file>]
[-test -[defsz] <path>]
[-text [-ignoreCrc] <src> ...]
[-touchz <path> ...]
[-truncate [-w] <length> <path> ...]
[-usage [cmd ...]]

 解释:

1.[-touchz <path> ...]
Creates a file of zero length at <path> with current time as the timestamp of that <path>. An error is returned if the file exists with non-zero length
在<path>创建一个大小为0的文件,并将当前时间作为该<path>的时间戳。 如果已经存在大小不为0的文件,则返回错误。

2.[-appendToFile <localsrc> ... <dst>]
Appends the contents of all the given local files to the given dst file. The dst file will be created if it does not exist. If <localSrc> is -, then the input is read from stdin.
将指定的本地文件的内容添加到指定的文件中,如果指定的文件不存在就将其创建。如果本地文件是-,则从stdin中读取输入。

3.[-cat [-ignoreCrc] <src> ...]
Fetch all files that match the file pattern <src> and display their content on stdout.
提取与文件模式<src>匹配的所有文件,并在stdout上显示其内容。

4.[-checksum <src> ...]
Dump checksum information for files that match the file pattern <src> to stdout. Note that this requires a round-trip to a datanode storing each block of the file, and thus is not efficient to run on a large number of files. The checksum of a file depends on its content, block size and the checksum algorithm and parameters used for creating the file.
输出与src匹配的文件的校验和信息。注意,这需要往返在储存这个文件的数据节点,所以挡在大量的文件上运行时并不高效。文件的校验和和文件的内容,块的大小,校验和算法和创建文件的参数有关。

5.[-mkdir [-p] <path> ...]
Create a directory in specified location.
-p Do not fail if the directory already exists

6.[-rmdir [--ignore-fail-on-non-empty] <dir> ...]
Removes the directory entry specified by each directory argument, provided it is empty.
删除空目录

7.[-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ...]
-rm [-f] [-r|-R] [-skipTrash] [-safely] <src> ... :
Delete all files that match the specified file pattern. Equivalent to the Unix
command "rm <src>"

-f If the file does not exist, do not display a diagnostic message or
modify the exit status to reflect an error.
-[rR] Recursively deletes directories.
-skipTrash option bypasses trash, if enabled, and immediately deletes <src>.
-safely option requires safety confirmation, if enabled, requires
confirmation before deleting large directory with more than
<hadoop.shell.delete.limit.num.files> files. Delay is expected when
walking over large directory recursively to count the number of
files to be deleted before the confirmation.
删除所有与指定文件模式匹配的文件。
-f :如果该文件不存在,则不显示诊断消息或修改退出状态以反映错误。
-[rR]:递归删除目录
-skipTrash:如果启用该选项,则绕过垃圾桶,并立即删除<src>。
-safely:当要删除的目录中含有超过<hadoop.shell.delete.limit.num.files>个文件时,需要确认后才能删除。

8.[-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst>]
-get [-f] [-p] [-ignoreCrc] [-crc] <src> ... <localdst> :
Copy files that match the file pattern <src> to the local name. <src> is kept.
When copying multiple files, the destination must be a directory. Passing -f
overwrites the destination if it already exists and -p preserves access and
modification times, ownership and the mode.

将与文件模式<src>匹配的文件复制到本地名称。 <src>被保留。 复制多个文件时,目标位置必须是目录。
-f:如果目标已经存在,则将其写入
-p:保留访问和修改时间,所有权和模式。


9.[-copyFromLocal [-f] [-p] [-l] [-d] <localsrc> ... <dst>]
参考get

10.[-mv <src> ... <dst>]
-mv <src> ... <dst> :
Move files that match the specified file pattern <src> to a destination <dst>.
When moving multiple files, the destination must be a directory.
移动文件,当移动多个文件的时候,目的地必须是一个目录。

Nodes: 后续用到其余的命令继续添加...

猜你喜欢

转载自www.cnblogs.com/sykline/p/12445307.html