Command line in HDFs

Source: Internet
Author: User
Tags hadoop fs

Command line in HDFs

This article describes the role of several common command lines and how to use them when HDFs runs at the command line ~



1. FS

FS is the start command-line action that is used to provide a series of subcommands.

Used in the form of Hadoop fs–cmd <args>

Where Cmd is a subcommand, args is the specific command operation.

such as Hadoop fs–help

Or FS is the father of the rest of the subcommands, 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 copying local files into HDFs

Hadoop fs-copyfromlocal <localsrc> URIs

Hadoop Fs–copyfromlocal/usr/localfile.txt Sample.txt

Can implement local file upload to HDFs, and the target path is simplified


4.-CP Replication

Hadoop Fs–cp/usr/file1/usr/files/user/dir

The source path of the file is copied to the destination path, the source path can have multiple, but the destination path only has one


5.–DU Displays the size of all files in the directory, or the size of a file

Hadoop Fs–du/usr/dir1


6.–dus Display File size
7.–expunge emptying the recycle bin

Hadoop Fs–expunge


8.–get Copy this piece to the local system

How to use: Hadoop fs–get <locaodst>

Hadoop fs–get/usr/file LocalFile


9.–put Local files to the target file system

How to use: Hadoop fs–put <localsrc> <dst>

Hadoop fs–put LocalFile Hadfs://host:port/usr/file


10.–ls browsing Local files

How to use: Hadoop fs–ls <arg>

Return information:

File name < number of copies > size modified date permissions User ID/group ID


11.–LSR recursively check the contents of a file
12.–mkdir Creating the corresponding file directory

Hadoop fs–mkdir/usr/dir1/dir2/dir3/file


13.–MV Mobile

To move the source file to the destination path, the destination path can have multiple

Hadoop fs–mv/usr/file1/usr/file2


14.–RM Delete

Hadoop fs–rm URI


15.–rmr Recursive deletion
16.–setrep Change the number of copies of a copy

Hadoop fs–setrep–w 3–r/usr/file


17.–test Checking Files

Using Ezd to check a file

-E: Check if the file exists and returns 0 if present;

-Z: Check whether the file is 0 bytes, if it is returned 0;

-D: Check if the path is a directory, if it returns 1;


18.–text exporting source files to text format

Hadoop Fs–text <src> runs in the form of zip and text class







Command line in HDFs

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.