Blog

CLI Commands In Hadoop With Syntaxes

 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.
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.
   
16) Hadoop fs –move ToLocal: Is not possible, because there are many replicas of the file is present on HDFS. so moving is not possible.
17) 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.
18) Hadoop fs –rmv: To remove the dir.
Ex: #hadobp fs –rmv hdfs test
                                         Directory name
19) Hadoop fs –mv: Used to move files from one directory to other directory in hdfs. i.e files not available in source directory.
20) Hadoop fs –cp: To copy the files from one directory to another directory.
Ex: #hadobp fs –cp hdfs test1/* hdfstest
All files
21) Hadoop fs –touch z: It will create the dummy file with
Ex: #hadobp fs –touch z hdfs test/file1.txt
                               File1 is created by
                             Enroll for Live Instructor Led Hadoop Training


RELATED COURSES

Get Updates on Tech posts, Interview & Certification questions and training schedules