Since HDFS is a distributed file system for data access, operations on HDFS are basic operations on the file system, such as file creation, modification, deletion, and modification permissions, folder creation, deletion, and renaming. Pair
HDFS operation commands are similar to Linux Shell operations on files, but in HDFS, hadoop FS is the main command, and other commands such as LS, MV, and CP are used as the option of this command.
The following table lists some common HDFS Shell Command Options.
Option name |
Format |
Description |
-Ls |
-Ls <path> |
View the current directory structure of the specified path |
-LSR |
-LSR <path> |
Recursively view the directory structure of a specified path |
-Du |
-Du <path> |
Measure the file size in the directory. |
-DUS |
-DUS <path> |
Summarize the file (folder) size in the statistics directory |
-Count |
-Count [-q] <path> |
Count the number of files (CLIPS) |
-MV |
-MV <Source Path> <Destination path> |
Mobile |
-CP |
-CP <Source Path> <Destination path> |
Copy |
-Rm |
-RM [-skiptrash] <path> |
Delete files/empty folders |
-RMR |
-RMR [-skiptrash] <path> |
-RMR [-skiptrash] <path> |
-Put |
-Put <files on multiple Linux instances> <HDFS path> |
Upload files |
-Copyfromlocal |
-Copyfromlocal <files on multiple Linux instances> <HDFS path> |
Copy from local |
-Movefromlocal |
-Movefromlocal <files on multiple Linux instances> <HDFS path> |
Move from local |
-Getmerge |
-Getmerge <Source Path> <Linux path> |
Merge to local |
-Cat |
-Cat <HDFS path> |
View File Content |
-Text |
-Text <HDFS path> |
View File Content |
-Copytolocal |
-Copytolocal [-ignorecrc] [-CRC] [HDFS Source Path Path] [Linux Destination path] |
Copy from local |
-Movetolocal |
-Movetolocal [-CRC] <HDFS Source Path> <Linux Target path> |
Move from local |
-Mkdir |
-Mkdir <HDFS path> |
Create a blank folder |
-Setrep |
Setrep [-R] [-W] <Number of replicas> <path> |
Modify the number of copies |
-Touchz |
-Touchz <file path> |
Create a blank File |
-Stat |
-Stat [format] <path> |
Display file statistics |
-Tail |
-Tail [-F] <File> |
View File tail Information |
-Chmod |
-Chmod [-R] <permission mode> [path] |
Modify permissions |
-Chown |
-Chown [-R] [owner] [: [group] path |
Modify owner |
-Chgrp |
-Chgrp [-R] group name path |
Modify Group |
-Help |
-Help [Command Options] |
Help |
Note: For paths in the preceding table, including paths in HDFS and those in Linux. The "Linux path" or "HDFS path" will be pointed out when ambiguity is easily caused ". If not explicitly stated, it means HDFS path