How to add files to HDFS using Command Prompt in Hadoop 2.7.0

After successful installation of Hadoop, adding files to HDFS is very simple.
In this article I will show you tin simple steps how to add Directories/Files to HDFS using HDFS commands.
To add a directory to HDFS use:
$HADOOP_DIR/bin/hadoop fs -mkdir /Users
where Users is the directory name.
You can see the directory name while browsing the HDFS in browser at location http://localhost:50070
To add a file to the directory use command:
bin/hadoop fs -put /Users/chikki/Documents/hadoop/hadoop-2.7.0/README.txt /Users/chikki
/Users/chikki/Documents/hadoop/hadoop-2.7.0/README.txt is the local file location



/Users/chikki is the HDFS file location.
There are other useful command just like linux commands in HDFS
To list all the files in a HDFS directory use:
$HADOOP_HOME/bin/hadoop fs -ls /Users

Leave a Reply

Your email address will not be published. Required fields are marked *