Manipulating files on HDFS

Besides commands to copy files from the local directory, HDFS provides commands to operate on files. In this section, we will show you how to operate files, such as downloading files from HDFS, checking the content of files, and removing files from HDFS.

Getting ready

We assume that our Hadoop cluster has been properly configured and all the daemons are running without any issues.

How to do it...

Perform the following steps to check the status of files and the directory on HDFS:

  1. List files of the user's home directory on HDFS using the following command:
    hadoop fs -ls .
    

    For example, this command will give the following output on my machine:

    Found 7 items
    drwx------ - hduser supergroup 0 2013-02-21 22:17 /user/hduser/.staging ...

Get Hadoop Operations and Cluster Management Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.