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
Usersis 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.txtis the local file location
/Users/chikkiis 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