0% found this document useful (0 votes)
15 views4 pages

PRACTICAL NO-3 Word Count

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

PRACTICAL NO-3 Word Count

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

PRACTICAL NO.

3
AIM: Write a word count program using MapReduce in Hadoop

HDFS Commands Descriptions


1. -ls: Lists directory contents in HDFS, showing details like
permissions, size, and modification date.
2. -mkdir: Creates a directory in HDFS.
3. -put: Uploads files from the local file system to HDFS.
4. -get: Downloads files from HDFS to the local file system.
5. -copyFromLocal: Copies files from the local file system to HDFS,
similar to -put.

Steps for WordCount in Hadoop:

Create a Directory in HDFS:

Use the -mkdir command to create a directory in HDFS.

[hdfs dfs -mkdir /user/hadoop/mydir]

Create a Text File Locally:

Create a text file in your local file system using a text editor like nano, vi, or echo

[echo "Hello Hadoop" > myfile.txt].

Put the Text File into HDFS:

Use the -put command to upload the text file from your local file system to the
directory you created in HDFS.

[hdfs dfs -put myfile.txt /user/hadoop/mydir/]

Get the Text File from HDFS:

Use the -get command to download the text file from HDFS back to your local file
system.

[hdfs dfs -get /user/hadoop/mydir/myfile.txt /localdir/]


Copy the Text File from Local to HDFS:

Use the -copyFromLocal command to copy a file from your local file system to
HDFS.

[hdfs fs -copyFromLocal myfile.txt /user/hadoop/mydir/]

View the Contents of the Text File in HDFS:

Use the cat command to display the contents of the text file stored in HDFS.

[hadoop fs -cat /user/hadoop/mydir/myfile.txt]

You might also like