A common command __hadoop under Hadoop

Source: Internet
Author: User
Tags chmod mkdir hadoop fs

Today in Bluemix easy to build a Hadoop cluster, Candide is the Hadoop command to forget to find out, today's supplement restudying


FS Shell

Calling the file system (FS) shell command should use the form of Bin/hadoop FS <args>. All of the FS shell commands use the URI path as a parameter. The URI format is Scheme://authority/path. For the HDFs file system, Scheme is HDFS, for the local file system, scheme is file. The scheme and authority parameters are optional, and if not specified, the default scheme specified in the configuration is used. A HDFs file or directory such as/parent/child can be expressed as hdfs://namenode:namenodeport/parent/child, or simpler/parent/ Child (assuming that the default value in your configuration file is Namenode:namenodeport). The behavior of most FS shell commands is similar to that of the corresponding Unix shell commands, and the differences are indicated below when the commands are used for details. The error message is output to stderr, and other information is exported to stdout. cat

How to use: Hadoop fs-cat uri [uri ...]

The path specifies the contents of the file to be exported to stdout.

Example: Hadoop fs-cat hdfs://host1:port1/file1 hdfs://host2:port2/file2 Hadoop fs-cat file:///file3/user/hadoop/file4

return value:
Successfully returns 0, failure returns-1.
chgrp

How to use: Hadoop fs-chgrp [-R] GROUP uri [uri ...] Change Group Association of files. With-r, make the change recursively through the directory structure. The user must be the owner of files, or else a super-user. Additional information is in thepermissions User guide.-->

change the group to which the file belongs. Using-R causes changes to be recursively performed under the directory structure. The user of the command must be the owner of the file or the superuser. For more information, see the HDFs Permissions User's Guide. chmod

How to use: Hadoop fs-chmod [-r] <mode[,mode] ... | octalmode> uri [uri ...]

change the permissions on the file. Using-R causes changes to be recursively performed under the directory structure. The user of the command must be the owner of the file or the superuser. For more information, see the HDFs Permissions User's Guide. chown

How to use: Hadoop Fs-chown [-R] [Owner][:[group]] uri [URI]

change the owner of the file. Using-R causes changes to be recursively performed under the directory structure. The user of the command must be a superuser. For more information, see the HDFs Permissions User's Guide. copyfromlocal

How to use: Hadoop fs-copyfromlocal <localsrc> URI

In addition to qualifying the source path is a local file , it is similar to the put command. copytolocal

How to use: Hadoop fs-copytolocal [-IGNORECRC] [-CRC] URI <localdst>

In addition to qualifying the target path is a local file , it is similar to the Get command. CP

How to use: Hadoop fs-cp uri [uri ...] <dest>

Copies the file from the source path to the target path. This command allows multiple source paths, at which point the destination path must be a directory.
Example: Hadoop fs-cp/user/hadoop/file1/user/hadoop/file2 Hadoop fs-cp/user/hadoop/file1/user/hadoop/file2/user/hadoop/ Dir

return value:

successfully returns 0, failure returns-1. du

How to use: Hadoop fs-du uri [uri ...]

Displays the size of all files in the directory, or the size of the file when only one file is specified.
Example:
Hadoop fs-du/user/hadoop/dir1/user/hadoop/file1 Hdfs://host:port/user/hadoop/dir1
return value:
Successfully returns 0, failure returns-1.
dus

How to use: Hadoop fs-dus <args>

displays the size of the file. expunge

How to use: Hadoop fs-expunge

Empty the Recycle Bin. Refer to the HDFs design documentation for more information about the Recycle Bin features. get

How to use: Hadoop fs-get [-IGNORECRC] [-CRC] <src> <localdst>

Copy files to the local file system. You can copy a CRC failed file with the-IGNORECRC option. Use the-CRC option to copy files and CRC information.

Example: Hadoop fs-get/user/hadoop/file localfile Hadoop fs-get hdfs://host:port/user/hadoop/file localfile

return value:

successfully returns 0, failure returns-1. getmerge

How to use: Hadoop fs-getmerge <src> <localdst> [ADDNL]

accepts a source directory and a target file as input, and connects all files in the source directory to the local destination file. ADDNL is optional and is used to specify that a newline character be added at the end of each file. ls

How to use: Hadoop fs-ls <args>

If it is a file, the file information is returned in the following format:
File name < number of copies > file size modification Date Modify time rights User ID group ID
If it is a directory, it returns a list of its immediate subfolders, as in Unix. The information for the catalog return list is as follows:
Directory name <dir> Modify date Modify time rights User ID group ID
Example:
Hadoop fs-ls/user/hadoop/file1/user/hadoop/file2 Hdfs://host:port/user/hadoop/dir1/nonexistentfile
return value:
Successfully returns 0, failure returns-1.
LSR

How to use: Hadoop FS-LSR <args>
Recursive version of the LS command. Similar to the Ls-r in Unix.
mkdir

How to use: Hadoop fs-mkdir <paths>

Takes the URI specified by the path as a parameter and creates the directories. Its behavior is similar to that of Unix mkdir-p, which creates levels of parent directories in the path.

Example: Hadoop fs-mkdir/user/hadoop/dir1/user/hadoop/dir2 hadoop fs-mkdir hdfs://host1:port1/user/hadoop/dir hdfs:// Host2:port2/user/hadoop/dir

return value:

successfully returns 0, failure returns-1. movefromlocal

How to use: Dfs-movefromlocal <src> <dst>

output A "not implemented" message. mv

How to use: Hadoop fs-mv uri [uri ...] <dest>

Moves the file from the source path to the target path. This command allows multiple source paths, at which point the destination path must be a directory. Moving files between different file systems is not allowed.
Example: Hadoop fs-mv/user/hadoop/file1/user/hadoop/file2 hadoop fs-mv hdfs://host:port/file1 hdfs://host:port/file2 HDFs: Host:port/file3 Hdfs://host:port/dir1

return value:

successfully returns 0, failure returns-1. put

How to use: Hadoop fs-put <localsrc> ... <dst>

Copies single or multiple source paths to the destination file system from the local file system. Read input from standard input is also supported to write to the target file system.
Hadoop fs-put localfile/user/hadoop/hadoopfile Hadoop fs-put localfile1 localfile2/user/hadoop/hadoopdir Hadoop fs-pu T LocalFile hdfs://host:port/hadoop/hadoopfile Hadoop fs-put-hdfs://host:port/hadoop/hadoopfile
Reads the input from the standard input.

return value:

successfully returns 0, failure returns-1. rm

How to use: Hadoop fs-rm uri [uri ...]

Deletes the specified file. Delete only non-empty directories and files. Refer to the RMR command for recursive deletion.
Example: Hadoop fs-rm Hdfs://host:port/file/user/hadoop/emptydir

return value:

successfully returns 0, failure returns-1. RMR

How to use: Hadoop fs-rmr uri [uri ...]

The recursive version of Delete.
Example: Hadoop fs-rmr/user/hadoop/dir Hadoop FS-RMR hdfs://host:port/user/hadoop/dir

return value:

successfully returns 0, failure returns-1. setrep

How to use: Hadoop Fs-setrep [-R] <path>

Change the copy factor of a file. The-r option is used to recursively change the copy coefficients of all files in the directory.

Example: Hadoop fs-setrep-w 3-r/user/hadoop/dir1

return value:

successfully returns 0, failure returns-1. stat

How to use: Hadoop fs-stat uri [uri ...]

Returns statistics for the specified path.

Example: Hadoop fs-stat path

return value:
Successfully returns 0, failure returns-1.
tail

How to use: Hadoop Fs-tail [-f] URI

Outputs 1K bytes of file tail to stdout. The-f option is supported, and the behavior is consistent with UNIX.

Example: Hadoop fs-tail pathname

return value:
Successfully returns 0, failure returns-1.
test

How to use: Hadoop fs-test-[ezd] URI

Options:
-e Checks if the file exists. Returns 0 if present.
-Z checks to see if the file is 0 bytes. If yes, return 0.
-D If the path is a directory, return 1 or 0.

Example: Hadoop fs-test-e filename text

How to use: Hadoop fs-text <src>

output the source file as text format. The allowed formats are zip and Textrecordinputstream. touchz

How to use: Hadoop fs-touchz uri [uri ...]

Creates a 0-byte empty file.

Example: Hadoop-touchz pathname

return value:
Successfully returns 0, failure returns-1.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.