Shell Command Introduce
HDFS Shell
You can use the Hadoop Distributed File System (HDFS) Shell command to perform operations on the HDFS, such as reading and writing files.
To run the HDFS Shell:
Go to the directory of HDFS client and enter the command. An example is shown as follows:
cd /opt/client/HDFS/hadoop/bin
hdfs dfs -mkdir /tmp/input
You can run the following command to seek help about HDFS commands:
hdfs --help
For details about the shell, see
http://hadoop.apache.org/docs/r3.1.1/hadoop-project-dist/hadoop-common/FileSystemShell.html
Scenario |
Operation |
Command |
Description |
---|---|---|---|
hadoop shell command management key |
Create keys. |
hadoop key create <keyname> [-cipher <cipher>] [-size <size>] [-description <description>] [-attr <attribute=value>] [-provider <provider>] [-help] |
The create subcommand creates a key for the name specified by the <keyname> argument within the provider specified by the -provider argument. You may specify a cipher with the -cipher argument. The default cipher is "AES/CTR/NoPadding" currently. The default keysize is 128. You may specify the requested key length using the -size argument. Arbitrary attribute=value style attributes may be specified using the -attr argument. The -attr may be specified for multiple times, once per attribute. |
Rollback |
hadoop key roll <keyname> [-provider <provider>] [-help] |
The roll subcommand creates a new version for the specified key within the provider indicated using the -provider argument. |
|
Delete keys |
hadoop key delete <keyname> [-provider <provider>] [-f] [-help] |
The delete subcommand deletes all versions of the key specified by the <keyname> argument within the provider specified by the -provider argument. The command asks for user confirmation unless -f is specified. |
|
View keys |
hadoop key list [-provider <provider>] [-metadata] [-help] |
The list subcommand displays the keynames contained in a particular provider as configured in core-site.xml or specified with the -provider argument. The -metadata argument displays the metadata. |
Operation |
Command |
Description |
---|---|---|
Group creation |
hdfs colocationadmin -createGroup -groupId <groupID> -locatorIds <comma separated locatorIDs> or -file <path of the file contains all of locatorIDs> |
Used to create a group. In the command, groupID is the group name and locatorID is the locator name. You can enter comma-separated locator IDs using command lines. You can also write locator IDs into a file so that the system can obtain the locator IDs by reading the file. |
Group deletion |
hdfs colocationadmin -deleteGroup <groupID> |
Used to delete the specified group. |
Group query |
hdfs colocationadmin -queryGroup <groupID> |
Used to query details about a specified group, including locators in the group and information about each locator and its corresponding DataNode. |
Viewing all groups |
hdfs colocationadmin -listGroups |
Used to list all groups and their creation time. |
Setting ACL permissions on Colocation directories |
hdfs colocationadmin -setAcl |
Used to set ACL permissions on Colocation directories in ZooKeeper. The default root directory of Colocation in ZooKeeper is /hadoop/colocationDetails. |
SmallFS Shell
The SmallFS provides various command line sfs for users to conduct file system operations. The functions of sfs dfs are proximately the same as that of the hdfs dfs command line operations. For functions of the hdfs dfs command line operations, see http://hadoop.apache.org/docs/r3.1.1/hadoop-project-dist/hadoop-common/FileSystemShell.html.
SmallFS provides fsck command for checking the health status of small files. Run the following command:
sfs fsck <path> ... the "path" here is the directory or file path needs to be checked, and multiple paths can be used when they separated by spaces.
If the small file information is normal, the screen will echo the following information:
Small file path ==> Lost big file path =========================================
If the small file information is missing, the screen will echo the following information:
Small file path ==> Lost big file path ========================================= /sf/10m1/dir_00000000/file_00000077 ==> /sf/10m1/dir_00000000/.sfs/50c9679b-4092-46b1-81a0-1ebb0dae71ae
Table 3 describes the function list of the SmallFS command sfs dfs.
Command |
Function Description |
---|---|
[-cat [-ignoreCrc] <src> ...] |
SmallFS rewrites the interface of HDFS. It supports small files that are merged or unmerged. |
[-copyFromLocal [-f] [-p] [-l] <localsrc> ... <dst>] |
|
[-copyToLocal [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] |
|
[-count [-q] [-h] [-v] [-t [<storage type>]] <path> ...] |
|
[-cp [-f] [-p | -p[topax]] <src> ... <dst>] |
|
[-df [-h] [<path> ...]] |
|
[-du [-s] [-h] <path> ...] |
|
[-find <path> ... <expression> ...] |
|
[-get [-p] [-ignoreCrc] [-crc] <src> ... <localdst>] |
|
[-getmerge [-nl] <src> <localdst>] |
|
[-ls [-d] [-h] [-R] [<path> ...]] |
|
[-mkdir [-p] <path> ...] |
|
[-moveFromLocal <localsrc> ... <dst>] |
|
[-mv <src> ... <dst>] |
|
[-put [-f] [-p] [-l] <localsrc> ... <dst>] |
|
[-rm [-f] [-r|-R] <src> ...] |
|
[-rmdir [--ignore-fail-on-non-empty] <dir> ...] |
|
[-setrep [-R] [-w] <rep> <path> ...] |
|
[-stat [format] <path> ...] |
|
[-tail [-f] <file>] |
|
[-test -[defsz] <path>] |
|
[-touchz <path> ...] |
|
[-appendToFile <localsrc> ... <dst>] |
SmallFS rewrites the interface of HDFS. Supports unmerged small files but not the merged ones. |
[-checksum <src> ...] |
|
[-chgrp [-R] GROUP PATH...] |
|
[-chmod [-R] <MODE[,MODE]... | OCTALMODE> PATH...] |
|
[-truncate [-w] <length> <path> ...] |
|
[-chown [-R] [OWNER][:[GROUP]] PATH...] |
|
[-expunge] |
SmallFS directly uses the interface of HDFS. |
[-help [cmd ...]] |
|
[-text [-ignoreCrc] <src> ...] |
|
[-trace [fs commands]] |
|
[-usage [cmd ...]] |
|
[-createSnapshot <snapshotDir> [<snapshotName>]] |
SmallFS does not support these interfaces. |
[-deleteSnapshot <snapshotDir> <snapshotName>] |
|
[-getfacl [-R] <path>] |
|
[-getfattr [-R] {-n name | -d} [-e en] <path>] |
|
[-moveToLocal <src> <localdst>] |
|
[-renameSnapshot <snapshotDir> <oldName> <newName>] |
|
[-setfacl [-R] [{-b|-k} {-m|-x <acl_spec>} <path>]|[--set <acl_spec> <path>]] |
|
[-setfattr {-n name [-v value] | -x name} <path>] |
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.