Search This Blog

HDFS Commands examples

This article cover simple and useful HDFS commands examples. Apache Hadoop is data processing tool at web scale. Hadoop contains three modules :

HDFS                          ---   Data storage system

MAPREDUCE           ---    Data processing framework

YARN                         ---    Resource management system for Hadoop

We will discuss some commands to learn how to interact with Hadoop distributed File System (HDFS). All hdfs file system commands start with hdfs dfs.  Most of the hadoop distributions  (CDH, HDP) come with standard hdfs user.


Change the current user  root to HDFS user. Mostly hdfs user will be password less user.


Create a file on the local file system using cat command.


Create a directory in HDFS using mkdir command.


Upload local file helloworld to HDFS directory helloworld using put command.


Check file is loaded into hdfs directory helloworld using ls command.


Read hdfs file content using cat command.


Rename HDFS file helloworld to helloworldfile using mv command.


Copy helloworldfile to another hdfs directory using cp command.


Check the size of a file in HDFS using du command.


Check replication factor of a file in HDFS using ls command. Rounded number is the replication factor of the file.


Change the replication factor of a file in HDFS using setrep command.The example below changes replication factor from 3 to 2.

No comments:

Post a Comment