Home  >  Blog  >   Hadoop  > 

CLI Commands In Hadoop With Syntaxes

Rating: 5
  1. Share:

Hadoop CLI Commands

1) Hadoop fs –: Even hadoop CLI Command should start this command only.
Syntax:- root @local host # hadoop fs – command
2) Hadoop fs –ls/ To see all the directories and files in the hadoop file system.
Syntax:- root @local host # hadoop fs – ls/
3) Hadoop Fs –ls/ user: To see all the directories and files of user in the hadoop file system.
Syntax:- root @local host # hadoop fs – ls/users
4) Hadoop fs –ls/ user/root: To see  the list of directories and files of /user/root  directory  in hadoop file system
Syntax:- root @local host # hadoop fs – ls/user/root 
5) Hadoop fs –mkdir: To create a new directory  in the hadoop file system
a) Syntax:- root @local host # hadoop fs – mkdir test.
The directory fest  will be created in default directory of hadoop file system i.e/user/root
 To check, the command is
root @local host # hadoop fs – ls/user/root 
Output will be:
Drwar-xr-x –root supergroup 0 2011-07-29 12:25
b) Syntax:- root @local host # hadoop fs – mkdir/user/root/test1/user/root/fest
The new directory will be crested in the specified pash.

Inclined to build a profession as Hadoop Developer? Then here is the blog post on HADOOP TRAINING Online.

6) Hadoop Fs –ls/user/root /grcp di name: Used to return the lines which has the name specified after grcp
Example:- root @local host # hadoop fs –ls/user/root / frcp test
Output: drwxr-xr-x-root super group 2011-07-09 12:25 /user/root / test
drwxr-xr-x-root super group 2011-07-09 12:32 /user/root / test
7) Hadoop fs –put: To more the file from local system to Hadoop file system.

 MindMajix YouTube Channel

8) Hadoop fs –move ToLocal: Is not possible, because there are many replicas of the file is present on HDFS. so moving is not possible.
9) Hadoop Fs –rm: To remove the files from directory i.e same as in local
Ex: a.  #hadobp fs –rm hdfs test/*-*
                  Remove all files from the directory
       b.  #hadobp fs –rm hdfs test/file1.txt
                  Remove the files 1.true from the directory.
10) Hadoop fs –rmv: To remove the dir.
Ex: #hadobp fs –rmv hdfs test
                                         Directory name
11) Hadoop fs –mv: Used to move files from one directory to other directory in hdfs. i.e files not available in source directory.
12) Hadoop fs –cp: To copy the files from one directory to another directory.
Ex: #hadobp fs –cp hdfs test1/* hdfstest
All files
13) Hadoop fs –touch z: It will create the dummy file with
Ex: #hadobp fs –touch z hdfs test/file1.txt
                               File1 is created

Frequently asked Hadoop Interview Questions

List of Big Data Courses:

 Hadoop Adminstartion  MapReduce
 Big Data On AWS  Informatica Big Data Integration
 Bigdata Greenplum DBA  Informatica Big Data Edition
 Hadoop Hive  Impala
 Hadoop Testing  Apache Mahout
Join our newsletter

Stay updated with our newsletter, packed with Tutorials, Interview Questions, How-to's, Tips & Tricks, Latest Trends & Updates, and more ➤ Straight to your inbox!

Course Schedule
Hadoop TrainingApr 01 to Apr 16
Hadoop TrainingApr 04 to Apr 19
Hadoop TrainingApr 08 to Apr 23
Hadoop TrainingApr 11 to Apr 26
Last updated: 30 March 2023
About Author
Remy Sharp
Ravindra Savaram

Ravindra Savaram is a Content Lead at Mindmajix.com. His passion lies in writing articles on the most popular IT platforms including Machine learning, DevOps, Data Science, Artificial Intelligence, RPA, Deep Learning, and so on. You can stay up to date on all these technologies by following him on LinkedIn and Twitter.

Recommended Courses

1 /15