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.
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 the Permissions 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:
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.
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.
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:
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-put 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:
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
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.