Command Line in HDFS
This article describes the functions and usage of several common command lines when running HDFS with command lines ~
1. fs
Fs is the command line action to start. It is used to provide a series of sub-commands.
Format: Hadoop fs-cmd <args>
Cmd is a sub-command, and args is a specific command operation.
For example, hadoop fs-help
Or fs is the father of other sub-commands, and the rest are in the "-cmd" mode!
2.-cat output
Hadoop fs-cat URI
Output the file specified by the path to the screen
3.-copyFromLocal: copy the local file to HDFS.
Hadoop fs-copyFromLocal <localsrc> URI
Hadoop fs-copyFromLocal/usr/localFile.txt sample.txt
Local files can be uploaded to HDFS, and the target path is simplified.
4.-cp Replication
Hadoop fs-cp/usr/file1/usr/files/user/dir
Copy the files in the Source Path to the target path. There can be multiple source paths, but only one target path can exist.
5.-du: displays the size of all files in the directory, or the size of a file.
Hadoop fs-du/usr/dir1
6.-dus: displays the file size.
7.-expunge clear the recycle bin
Hadoop fs-expunge
8.-get copy the local file to the local system
Usage: hadoop fs-get <locaodst>
Hadoop fs-get/usr/file localfile
9.-put copy the local file to the target file system
Usage: hadoop fs-put <localsrc> <dst>
Hadoop fs-put localfile hadfs: // host: port/usr/file
10.-ls browse local files
Usage: hadoop fs-ls <arg>
Returned information:
File name <Number of replicas> file size modification date permission user ID/group ID
11.-The lsr recursively queries the File Content
12.-create the corresponding file directory in mkdir
Hadoop fs-mkdir/usr/dir1/dir2/dir3/file
13.-mv mobile
Move the source file to the target path. The target path can contain multiple
Hadoop fs-mv/usr/file1/usr/file2
14.-rm Deletion
Hadoop fs-rm URI
15.-rmr recursive Deletion
16.-Setrep: change the number of copies
Hadoop fs-setrep-w 3-R/usr/file
17.-Test check the file
Use ezd to check the file
-E: Check whether the file exists. If yes, 0 is returned;
-Z: Check whether the file is 0 bytes. If yes, 0 is returned;
-D: Check whether the path is a directory. If yes, 1 is returned;
18.-text: output the source file to the text format
The format of hadoop fs-text <src> is zip and Text.
-------------------------------------- Split line --------------------------------------
Copy local files to HDFS
Download files from HDFS to local
Upload local files to HDFS
Common commands for HDFS basic files
Introduction to HDFS and MapReduce nodes in Hadoop
Hadoop practice Chinese version + English version + Source Code [PDF]
Hadoop: The Definitive Guide (PDF]
-------------------------------------- Split line --------------------------------------