0% found this document useful (0 votes)
14 views

BDC Output 2

Uploaded by

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

BDC Output 2

Uploaded by

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

Big Data Practical

Computing No. 2
File Management Task in Hadoop:
1. Create a directory in HDFS at given path(s).
Usage :
Hadoop fs -mkdir
<paths> Example :
Hadoop fs -mkdir/user/saurzcode

2. List the contents of directory.


Usage :
hadoop fs -ls
<args> Example :
hadoop fs - mkdir/user/saurzcode/dir1/user/caurzcode/dir2

3. Upload and download a file in HDFS.


Usage :
hadoop fs -
put Example
:
hadoop fs – put /home /saurzcode /samplefile.txt /user/saurzcode
/dir3

Download:
hadoop fs -get:
Copies/Downloads files to the local file
system Usage:
hadoop fs -get <hdfs_src>
<localdst> Example:
hadoop fs -get /user/saurzcode/dir3/Samplefile.txt /home/

4. See contents of a file


Same as unix cat command:
Usage:
hadoop fs -cat
<path[filename]> Example:
hadoop fs -cat /user/saurzcode/dir1/abc.txt

5. Copy a file from source to destination


This command allows multiple sources as well in which
case the destination must be a directory.
Usage:
hadoop fs -cp <source>
<dest> Example:
hadoop fs -cp /user/saurzcode/dir1/abc.txt /user/saurzcode/ dir2
6. Copy a file from/To Local file system to HDFS
Big Data Practical
Computing No. 2
copyFromLoc
al Usage:
hadoop fs -copyFromLocal
<localsrc> URI Example:
hadoop fs -copyFromLocal /home/saurzcode/abc.txt
/user/ saurzcode/abc.txt
Similar to put command, except that the source is restricted to
a local file reference.
copyToLoc
al Usage:
hadoop fs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
Similar to get command, except that the destination is restricted
to a local file reference.

7. Move file from source to destination.


Note:- Moving files across filesystem is not
permitted. Usage :
hadoop fs -mv <src>
<dest> Example:
hadoop fs -mv /user/saurzcode/dir1/abc.txt /user/saurzcode/ dir2

8. Remove a file or directory in HDFS.


Remove files specified as argument.
Deletes directory only when it is empty
Usage :
hadoop fs -rm
<arg> Example:
hadoop fs -rm /user/saurzcode/dir1/abc.txt Recursive version
of delete. Usage :
hadoop fs -rmr
<arg> Example:
hadoop fs -rmr /user/saurzcode/

9. Display last few lines of a file.

Similar to tail command in


Unix. Usage :
hadoop fs -tail
<path[filename]> Example:
hadoop fs -tail /user/saurzcode/dir1/abc.txt
10. Display the aggregate length of a file.
Big Data Practical
Computing No. 2
Big Data Practical
Computing No. 2

You might also like