📜  Hadoop-命令参考

📅  最后修改于: 2020-12-01 06:41:23             🧑  作者: Mango


“ $ HADOOP_HOME / bin / hadoop fs”中的命令比此处演示的要多,尽管这些基本操作可以帮助您入门。在不使用其他参数的情况下运行./bin/hadoop dfs将列出可以在FsShell系统上运行的所有命令。此外,如果您遇到问题, $ HADOOP_HOME / bin / hadoop fs -help commandName将显示有关操作的简短用法摘要。

所有操作的表格如下所示。以下约定用于参数-

"" means any file or directory name. 
"..." means one or more file or directory names. 
"" means any filename. 
"" and "" are path names in a directed operation. 
"" and "" are paths as above, but on the local file system. 

所有其他文件和路径名均引用HDFS中的对象。

Sr.No Command & Description
1

-ls

Lists the contents of the directory specified by path, showing the names, permissions, owner, size and modification date for each entry.

2

-lsr

Behaves like -ls, but recursively displays entries in all subdirectories of path.

3

-du

Shows disk usage, in bytes, for all the files which match path; filenames are reported with the full HDFS protocol prefix.

4

-dus

Like -du, but prints a summary of disk usage of all files/directories in the path.

5

-mv

Moves the file or directory indicated by src to dest, within HDFS.

6

-cp

Copies the file or directory identified by src to dest, within HDFS.

7

-rm

Removes the file or empty directory identified by path.

8

-rmr

Removes the file or directory identified by path. Recursively deletes any child entries (i.e., files or subdirectories of path).

9

-put

Copies the file or directory from the local file system identified by localSrc to dest within the DFS.

10

-copyFromLocal

Identical to -put

11

-moveFromLocal

Copies the file or directory from the local file system identified by localSrc to dest within HDFS, and then deletes the local copy on success.

12

-get [-crc]

Copies the file or directory in HDFS identified by src to the local file system path identified by localDest.

13

-getmerge

Retrieves all files that match the path src in HDFS, and copies them to a single, merged file in the local file system identified by localDest.

14

-cat

Displays the contents of filename on stdout.

15

-copyToLocal

Identical to -get

16

-moveToLocal

Works like -get, but deletes the HDFS copy on success.

17

-mkdir

Creates a directory named path in HDFS.

Creates any parent directories in path that are missing (e.g., mkdir -p in Linux).

18

-setrep [-R] [-w] rep

Sets the target replication factor for files identified by path to rep. (The actual replication factor will move toward the target over time)

19

-touchz

Creates a file at path containing the current time as a timestamp. Fails if a file already exists at path, unless the file is already size 0.

20

-test -[ezd]

Returns 1 if path exists; has zero length; or is a directory or 0 otherwise.

21

-stat [format]

Prints information about path. Format is a string which accepts file size in blocks (%b), filename (%n), block size (%o), replication (%r), and modification date (%y, %Y).

22

-tail [-f]

Shows the last 1KB of file on stdout.

23

-chmod [-R] mode,mode,…

Changes the file permissions associated with one or more objects identified by path…. Performs changes recursively with R. mode is a 3-digit octal mode, or {augo}+/-{rwxX}. Assumes if no scope is specified and does not apply an umask.

24

-chown [-R] [owner][:[group]]

Sets the owning user and/or group for files or directories identified by path…. Sets owner recursively if -R is specified.

25

-chgrp [-R] group

Sets the owning group for files or directories identified by path…. Sets group recursively if -R is specified.

26

-help

Returns usage information for one of the commands listed above. You must omit the leading ‘-‘ character in cmd.