Hadoop learning notes (3) Common commands

Source: Internet
Author: User
Tags hadoop fs
Hadoop learning notes (3) Common commands
  • Go to the hadoop_home directory.
  • Execute sh bin/start-all.sh

  • Go to the hadoop_home directory.
  • Execute sh bin/stop-all.sh

 

Usage: Java fsshell
[-Ls <path>]
[-LSR <path>]
[-Du <path>]
[-DUS <path>]
[-Count [-q] <path>]
[-MV <SRC> <DST>]
[-CP <SRC> <DST>]
[-RM [-skiptrash] <path>]
[-RMR [-skiptrash] <path>]
[-Expunge]
[-Put <localsrc>... <DST>]
[-Copyfromlocal <localsrc>... <DST>]
[-Movefromlocal <localsrc>... <DST>]
[-Get [-ignorecrc] [-CRC] <SRC> <localdst>]
[-Getmerge <SRC> <localdst> [addnl]
[-Cat <SRC>]
[-Text <SRC>]
[-Copytolocal [-ignorecrc] [-CRC] <SRC> <localdst>]
[-Movetolocal [-CRC] <SRC> <localdst>]
[-Mkdir <path>]
[-Setrep [-R] [-W] <rep> <path/File>]
[-Touchz <path>]
[-Test-[ezd] <path>]
[-Stat [format] <path>]
[-Tail [-F] <File>]
[-Chmod [-R] <mode [, mode]... | octalmode> path...]
[-Chown [-R] [owner] [: [group] path...]
[-Chgrp [-R] group path...]
[-Help [cmd]

1. view the content in the specified directory

Hadoop DFS-ls [file directory]

Eg: hadoop DFS-ls/user/wangkai.pt

2. Open an existing file

Hadoop DFS-cat [file_path]

Eg: hadoop DFS-CAT/user/wangkai.pt/data.txt

3. Store Local files to hadoop

Hadoop FS-put [local address] [hadoop Directory]

Hadoop FS-Put/home/T/file.txt/user/T

(File.txt is the file name)

4. Store Local folders to hadoop

Hadoop FS-put [local directory] [hadoop Directory]
Hadoop FS-Put/home/T/dir_name/user/T

(Dir_name is the folder name)

5. Down a file on hadoop to a local directory

Hadoop FS-Get [file directory] [local directory]

Hadoop FS-Get/user/T/OK .txt/home/T

6. delete a specified file on hadoop

Hadoop FS-RM [file address]

Hadoop FS-RM/user/T/OK .txt

7. Delete specified folders (including subdirectories) on hadoop)

Hadoop FS-RM [directory address]

Hadoop FS-RMR/user/T

8. Create a new directory in the specified directory of hadoop

Hadoop FS-mkdir/user/T

9. Create an empty file under the specified directory of hadoop

Run the touchz command:

Hadoop FS-touchz/user/new.txt

10. rename a file on hadoop

Use the MV command:

Hadoop FS-mV/user/test.txt/user/OK .txt (rename test.txt as OK .txt)

11. Save all content in the specified hadoop directory as a file and go down to the local directory.

Hadoop DFS-getmerge/user/home/T

12. Kill a running hadoop job.

Hadoop job-kill [job-I

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.