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