Putting a file on HDFS

Putting a file on HDFS is relatively easy. There are a few steps to take. Let us assume the file is on a linux system. The first step is to copy the file to an area where it can be stored with the hdfs user as its owner. On my system, I have /tmp that has 777 privs: here files with every owner can be stored. So I copy my file to that area:

cp /root/uit /tmp

Now, I have got the file in an area where the user as I use in my HDFS platform can be set as owner to the file.
The user I have on my HDFS plaform is “hdfs”. I set the file with “hdfs” as owner with:

chown hdfs:hdfs /tmp/uit

Now the file uit has hdfs as owner. I can now put it on HDFS with:

sudo -u hdfs hadoop fs -put /tmp/uit /Chapter5/uit

Door tom