HDFS Command

HDFS Command:

Linux———- HDFS(store/process)

Run this command we can see all hadoop commands.

[hadoop-1.0.3] bin/hadoop fs

  1. Bin/hadoop fs –ls -command

Description: list out all files

  1. Bin/hadoop fs – lsr

Desc: display files and directories

  1. Bin/hadoop fs –du

Desc: display disk usage

  1. Bin/hadoop fs -dus

o/p : display disk usage of files and directories

  1. Bin/hadoop fs -count/user/sajith

o/p: display list of file

  1. Bin/hadoop rm [-skipTrash]<path>

o/p: remove file from hadoop

  1. Bin/hadoop rm [-skipTrash]<path>

o/p: perment delete without going recycle bin

  1. Bin/ hadoop -expunge

o/p: remove/delete from recycle bin

  1. Put <local> <destination>

o/p: H — L

  1. Get merge <src> <localhost> <addr/>

o/p: -getmerge s1+s2+s3 >s4





  1. – cat filename

Bin/hadoop fs -cat filename – display content of file

  1. Bin/hadoop fs -text filename

o/p: display text format

  1. Bin/hadoop fs -mkdir dir name

o/p: make directories

Interview Question and Answers:

  1. File system status?

Ans: How to see file system status

o/p: bin.hadoop fsck /user/sajith

o/p: file system under path “/user/sajith” is healthy. It shows the status of file.

  1. File level Reflication factor:

Ans: the file system replication (hdfs-site.xml)

Default – 3, maximum-8

If tou want to take more than 8

Cmd: $ bin/hadoop fs -set rep [-R] [-U] <rep> filename

  1. Create empty file in hadoop or obytes!

Ans: bin/hadoop fs – touchz sample

  1. How to find statices of file?

Ans: bin/hadoop fs –start /user/sajith

o/p: 2014-8-03 16:59:00

  1. How to give a permission in hadoop?

Ans: chmod

Bin/hadoop fs -g + w sample

  1. Help command,if you want help any particular command.

Eg : bin/hadoop fs -help chown

How to copy files lineex to hadoop


[hadoop]$bin /hadoop fs –cp sampel 5 sample 6

[hadoop]$bin/hadoop fs—mv sample 5sample 6

Local to local (L to L)

Hadoop to hadoop (H to H)

L to H

[hadoop]$bin/ hadoop fs copy from local/home/sajith/sample sample 1

H to L

[hadoop]$bin/hadoop fs –copy to local sample /home/sajith/sample.

[L to H]

[hadoop]$bin/hadoop fs- move from local /home/sajith/sample sample

[H to L]

[hadoop]$bin/hadoop fs –move to local sample /home /sajith/sample

Not yet implemented

[hadoop]$bin/hadoop fs –put /home /sajith/sample L to H

[hadoop]$bin/hadoop fs –set sample /home /sajith/sample H to L

[hadoop]$bin/hadoop fs –cat sampl

o/p: display the data

safe mode-off: (How to switch off/leave –safemode)


bin/hadoop dfsadminm -safemode leave

bin/hadoop dfsadmin -safemode leave

Difference B/W set/put and copyFromLocal and Copy ToLocal:

Put and set are linex commands

CopyFromLocal, copyToLocal are Hadoop commands

Since set/put are linex command they may be chance wrong file will be copy/moved to


Fls -ltr

/us/ -sampe

s/u/s -sample


Bin/hadoop fs –ls hadoop

$ fs -put sample1 sample 2


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s