HDFS commands
Print the Hadoop version
hadoop version
List the contents of the root directory in HDFS
hadoop fs -ls /
Run a DFS filesystem checking utility
hadoop fsck – /
Create a new directory named “hadoop” below the
hadoop fs -mkdir /user/training/hadoop
Add a sample text file from the local directory
hadoop fs -put data/sample.txt /user/training/hadoop
List the contents of this new directory in HDFS.
hadoop fs -ls /user/training/hadoop
Add the entire local directory called “retail” to the
hadoop fs -put data/retail /user/training/hadoop
Delete a file ‘customers’ from the “retail” directory.
hadoop fs -rm hadoop/retail/customers
List the contents that match the specified path, if path not specified it displays the contents of current user.
-ls <path>
Similar to ls command, but recursively list the contents
-lsr <path>
Moves files from <src> to <dst>. If <src> is a pattern that may return multiple files then <dst> should be a directory
- mv <src> <dst>
Similar to “mv” command, but it source won’t be removed after the file(s) copied
-cp <src> <dst>
Copies files from Local system to HDFS
-copyFromLocal <localsrc> <HDFSdst>
Same as copyFromLocal, but the source deleted once the file copied
-moveFromLocal <localsrc> <HDFSdst>
Similar to copyFromLocal
-put <localsrc> <HDFSdst>
Displays the amount of space, in bytes, for files
-du <path>
Displays the amount of space, in bytes, for a specified directory
-dus <path>
Delete all file(s) that match the <src> pattern
-rm <src>
Delete all directory(s) that match the <src> pattern
-rmr <src>
Enables you to specify the File/directory permissions on <src>
-chmod (0-7) (0-7) (0-7) <src>
Count the number of directories, files and bytes under <path>
-count <path>
Displays statistics about file/directory at <path>
-stat <path>
Write a timestamp in yyyy-MM-dd HH:mm:ss format in an empty file at <path>
-touchz <path>
Set the replication level of a file
-setrep <path>
Show the last 1KB of the file.
-tail <file>
Outputs the file in text format only for zip file or TextRecordInputStream.
-text <src>
Displays help for a command specified
-help [cmd]
No comments:
Post a Comment