Hadoop Basic HDFS Commands

  • date 21st February, 2019 |
  • by Prwatech |
  • 0 Comments

 

Hadoop Basic HDFS Commands

 

Hadoop HDFS Commands, welcome to the world of Hadoop HDFS Basic commands. Are you the one who is looking forward to knowing the apache Hadoop HDFS commands List which comes under Hadoop technology? Or the one who is very keen to explore the list of all the HDFS commands in Hadoop with examples that are available? Then you’ve landed on the Right path which provides the standard and Basic Hadoop HDFS Commands.

If you are the one who is keen to learn the technology then learn the advanced certification course from the best Hadoop training institute who can help guide you about the course from the 0 Level to Advanced level. So don’t just dream to become the certified Pro Developer Achieve it by choosing the best World classes Hadoop Training institute which consists of World-class Trainers.

 

We, Prwatech listed some of the Top Hadoop HDFS Commands which Every Hadoop Developer should know about. So follow the Below Mentioned Hadoop Basic HDFS Commands and Learn the Advanced Hadoop course from the best Hadoop Trainer like a Pro.

 

Open a terminal window to the current working directory.

==> /home/training

Hadoop HDFS Commands

 

Print the Hadoop version

⇒ Hadoop version

Hadoop HDFS Commands

 

List the contents of the root directory in HDFS

⇒  Hadoop fs -ls /

Hadoop HDFS Commands

 

Count the number of directories, files, and bytes under the paths

⇒  Hadoop fs -count hdfs:/

Hadoop HDFS Commands

 

Run a DFS filesystem checking utility

⇒  Hadoop fsck – /

Hadoop HDFS Commands

 

Run a cluster balancing utility

⇒  Hadoop balancer

Hadoop HDFS Commands

 

Create a new directory named “Hadoop” below the /user/training directory in HDFS.

⇒  Hadoop fs -mkdir /user/training/Hadoop

Hadoop HDFS Commands

Hadoop HDFS Commands

 

Add a sample text file from the local directory named “data” to the new directory you created in HDFS during the previous step

⇒  Hadoop fs -put data/sample.txt/user/training/Hadoop

Hadoop HDFS Commands

Hadoop HDFS Commands

 

List the contents of this new directory in HDFS

⇒  Hadoop fs -ls /user/training/Hadoop

Hadoop HDFS Commands

 

Add the entire local directory called “retail” to the /user/training directory in HDFS

⇒  Hadoop fs -put data/retail /user/training/Hadoop

Hadoop HDFS Commands

Hadoop HDFS Commands

 

Since /user/training is your home directory in HDFS, any command that does not have an absolute path is interpreted as relative to that directory. The next command will, therefore, list your home directory, and should show the items you’ve just added there

⇒  Hadoop fs -ls

Hadoop HDFS Commands

 

Delete a file ‘customers’ from the “retail”   directory

⇒  Hadoop fs -rm Hadoop/retail/customers

Hadoop HDFS Commands

Hadoop HDFS Commands

 

Ensure this file is no longer in HDFS

⇒  Hadoop fs -ls Hadoop/retail/customers

Hadoop HDFS Commands

 

Delete all files from the “retail” directory using a wildcard

⇒  Hadoop fs -rm hadoop/retail/*

Hadoop HDFS Commands

Hadoop HDFS Commands

 

To empty the trash

⇒  Hadoop fs -expunge

Hadoop HDFS Commands

 

Finally, remove the entire retail directory and all
of its contents in HDFS

⇒  Hadoop fs -rm -r Hadoop/retail

Hadoop HDFS Commands

 

List the Hadoop directory again

⇒  Hadoop fs -ls Hadoop

Hadoop HDFS Commands

 

Add the purchases.txt file from the local directory named “/home/training/” to the Hadoop directory you created in HDFS

⇒  Hadoop fs -copyFromLocal /home/training/purchases.txt Hadoop/

Hadoop HDFS Commands

 

To view the contents of your text file purchases.txt which is present in your Hadoop directory

⇒  Hadoop fs -cat hadoop/purchases.txt

Hadoop HDFS Commands

 

Add the purchases.txt file from “Hadoop” directory which is present in HDFS directory to the directory “data” which is present in your local directory

⇒  Hadoop fs -copyToLocal hadoop/purchases.txt /home/training/data

Hadoop HDFS Commands

 

cp is used to copy files between directories present in HDFS

⇒  Hadoop fs -cp /user/training/*.txt /user/training/Hadoop

Hadoop HDFS Commands

 

‘-get’ command can be used alternatively to ‘-copyToLocal’ command

⇒  Hadoop fs -get hadoop/sample.txt /home/training/

Hadoop HDFS Commands

 

Display last kilobyte of the file “purchases.txt” to stdout

⇒  Hadoop fs -tail hadoop/purchases.txt

Hadoop HDFS Commands

 

Default file permissions are 666 in HDFS

 

Use ‘-chmod’ command to change permissions of a file
⇒  Hadoop fs -ls hadoop/purchases.txt

Hadoop HDFS Commands

sudo -u hdfs Hadoop fs -chmod 600 hadoop/purchases.txt

Hadoop HDFS Commands

 

Default names of owner and group are training, training  Use ‘-chown’ to change owner name and group name simultaneously

⇒ hadoop fs -ls hadoop/purchases.txt

Hadoop HDFS Commands

sudo -u hdfs Hadoop fs -chown root: root hadoop/purchases.txt

Hadoop HDFS Commands

 

The default name of group is training Use ‘-chgrp’ command to change the group name

⇒  Hadoop fs -ls hadoop/purchases.txt

Hadoop HDFS Commands

sudo -u hdfs Hadoop fs -chgrp training hadoop/purchases.txt

Hadoop HDFS Commands

 

Move a directory from one location to other

⇒ Hadoop fs -mv Hadoop apache_hadoop

Hadoop HDFS Commands

 

The default replication factor to a file is 3. Use ‘-setrep’ command to change the replication factor of a  file

⇒  Hadoop fs -setrep -w 2 apache_hadoop/sample.txt

Hadoop HDFS Commands

 

Command to make the name node leave safe  mode

⇒  Hadoop fs -expunge sudo -u hdfs hdfs dfsadmin -safemode leave

Hadoop HDFS Commands

 

List all the Hadoop file system shell commands

⇒  Hadoop fs

Hadoop HDFS Commands

hadoop hdfs commands

⇒  Hadoop fs -help

Hadoop HDFS Commands Hadoop HDFS Commands

I hope you like Prwatech Hadoop Basic HDFS Commands, Get the Advanced certification from World-class Trainers of Best Hadoop Training Institute.

 

  • OPEN TERMINAL AND GO TO HBASE SHELL :

cloudera@cloudera-vm:~$ hbase shell

 

  • CHECK WHAT TABLES EXISTS IN THE SYSTEM :

hbase(main):001:0> list
TABLE

hadoop hdfs commands

 

  • CREATE TABLE :

hbase(main):002:0> create ‘batch’, ‘details’

hadoop hdfs commands

 

  • ENTER DATA INTO THE TABLE :

hbase(main):003:0> put ‘batch’, ‘row1’, ‘details:name’, ‘Rhiddhiman’

hbase(main):004:0> put ‘batch’, ‘row2’, ‘details:name’, ‘Rohit’

hbase(main):005:0> put ‘batch’, ‘row3’, ‘details:name’, ‘Dipankar’

hbase(main):006:0> put ‘batch’, ‘row4’, ‘details:name’, ‘Kalyan’

hadoop hdfs commands

 

  • CHECK DATA ENTERED IN THE TABLE :

hbase(main):007:0> scan ‘batch’

hadoop hdfs commands

 

  • CHANGE VALUE OF A PARTICULAR COLUMN IN A ROW :

hbase(main):008:0> put ‘batch’, ‘row2’, ‘details:name’, ‘Jayanta’

 

  • CHECK DATA AFTER MODIFICATION

hbase(main):009:0> scan ‘batch’

hadoop hdfs commands

 

  • CHANGE VALUE OF A PARTICULAR COLUMN IN A ROW :

hbase(main):010:0> put ‘batch’, ‘row3’, ‘details:name’, ‘Dhrubajyoti’

 

  • CHECK DATA AFTER MODIFICATION :

hbase(main):011:0> scan ‘batch’

hadoop hdfs commands

 

  • CHECK VALUE THAT HAS BEEN CHANGED :

hbase(main):012:0> get ‘batch’, ‘row2′, {COLUMN=>’details:name’, VERSIONS=>2}

hadoop hdfs commands

hbase(main):013:0> put ‘batch’, ‘row3’, ‘details:name’, ‘Banajit’

hbase(main):014:0> get ‘batch’, ‘row3′, {COLUMN=>’details:name’, VERSIONS=>3}

hadoop hdfs commands

 

  • ENTER REMAINING DATA :

hbase(main):015:0> put ‘batch’, ‘row1’, ‘details:address’, ‘Marathahalli’

hbase(main):016:0> put ‘batch’, ‘row1’, ‘details:age’, ’27’

hbase(main):017:0> put ‘batch’, ‘row1’, ‘details:course’, ‘Hadoop’

hbase(main):018:0> put ‘batch’, ‘row2’, ‘details:address’, ‘BTM’

hbase(main):019:0> put ‘batch’, ‘row3’, ‘details:address’, ‘Whitefield’

hbase(main):020:0> put ‘batch’, ‘row4’, ‘details:address’, ‘Electronics City’

hadoop hdfs commands

 

  • CHECK DATA :

hbase(main):021:0> scan ‘batch’

hadoop hdfs commands

 

  • DESCRIPTION OF TABLE :

hbase(main):031:0> describe ‘batch’

hadoop hdfs commands

 

0
0

Quick Support

image image