Week 1 Assignment Solution
Week 1 Assignment Solution
Assignment Solution
Week1: Getting Started with Big Data and Understanding
HDFS Concept along with Linux Commands
TRENDYTECH 9108179578
1 2
Note:
Total Marks : 50
Each Subpart carries 2 Marks
1. Create two directories ‘dir1’ and ‘dir2’ using a single hdfs command
inside
home directory of hdfs in cloudera VM.dir2 should be subdirectory of
dir1.
2. Verify that the two folders have been created in the above path.
3. Inside dir 2 Create an empty file, file1.txt
4. Create a file file2.txt in local filesystem with some text inside it
5. Copy file2.txt from local to hdfs inside dir2.
6. List the subdirectories and files inside dir1 recursively
7. List the files inside dir2 ,sorted by size but size should be displayed in
KBs/MBs and not bytes
8. Rename the file, file2.txt to file3.txt
9. Remove the directory dir1 using a single command.
Solution:
4) gedit ./Desktop/file2.txt
TRENDYTECH 9108179578
1 3
Question 2) (2 Marks)
Suppose there is file of size 514 MB stored in HDFS (Hadoop 2.x) using
default block size configuration and default replication factor.Then, how
many blocks will be created in total and what will be the size of each
block?
Solution:
There will be 5 blocks created. 4 blocks of size 128MB each and 1 Block
of size 2MB. Default replication factor is 3. Considering RF ,Totally 5*3
= 15 blocks are created.
Question 3) (8 Marks)
Solution:
i) mkdir test
ii) touch test/a.pdf test/b.html test/c.xml
iii) ls -lr test
iv) ls -ltr test | grep html OR ls -l | grep .html
TRENDYTECH 9108179578
1 4
Question 4) (8 Marks)
1. Create two new text files, file1 and file2 , with following content using
cat command in your linux home directory.
file1 : This is from file1
file2: This is from file2
2. Display the contents of the file 1 and file2 using cat command
3. Concatenate the contents of the two files and put them into a new file
file3 and display the results.
4. Count the number of lines and number of words in the file3.
Solution:
Or
Or
iv) wc -l file3
wc -w file3
Or
wc-l-w file3
TRENDYTECH 9108179578
1 5
Question 5) (4 Marks)
Solution:
Or
tail -3 myfile.txt
Solution:
2) cd Desktop
TRENDYTECH 9108179578
1 6
gedit file1.txt
gedit file2.txt
5) cat ./Desktop/filenew.txt
***********************************************************
TRENDYTECH 9108179578