Hadoop HDFS Commands
Contents
Running Hadoop HDFS Commands
hadoop fs Commands
Help Command
Hadoop file system commands are ran using hadoop fs
with all commands falling under that prefix. e.g. to get help we do hadoop fs -help
hadoop fs -put
Put allows uploading a file from your local file system to the hadoop file system.
hadoop fs -put <local-src> <hdfs-destination>
hadoop fs -ls
Once the file is uploaded we can check that it exists using the hadoop ls command, that lists the contents of a directory.
hadoop fs -ls <path>
hdfs Copy File to New Directory
For copying a file to a new directory we will use two commands, mkdir and cp.
hadoop fs -mkdir <foldername>
- Creates a new directory.
hadoop fs -cp <src> <destintation>
- Copies a file from a src path to a destination.
hadoop fs -get
To download a file from the hadoop file system to our local file system we can use the get command.
hadoop fs -get <hdfs-src> <local-destination>
hadoop fsck Commands
Another useful command in hadoop is the fsck command. We can for instance use it to get details on blocks and files:
Delete Files and Directories
To delete a file or directory from the hadoop file system we use the rm command.
hadoop fs -rm <file>
hadoop fs -rm -r <folder>