Command Line in HDFS and HDFS command line

Source: Internet
Author: User
Tags hadoop fs

Command Line in HDFS and HDFS command line

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.







Related Article

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.