TOP HADOOP HDFS COMMANDS

1. To check all the services are running use 

jps 

2. Two types of prefix in hadoop command 

hdfs dfs (specially with hdfs file system) 

hadoop fs (to interact with  other file system)

3. To display the list of files/directory present in HDFS filesystem

hadoop fs –ls  

hadoop fs –ls <directory>

5. To create directory on HDFS


hadoop fs –mkdir <directory-name>


6. To create a empty  file in HDFS 


hadoop fs –touchz <file-name>


7. To copy file from LOCAL to HDFS


hadoop fs –copyFromLocal f1.txt <hdfs-path> 


hadoop fs –put f1.txt <hdfs-path> 


8. To check file content


hadoop fs –cat <hdfs-path>/f1.txt 


9. To copy file from HDFS to Local


hadoop fs –copyToLocal <hdfs-path>/f1.txt <local-path>


hadoop fs –get <hdfs-path>/f1.txt <local-path>


10. To copy  file from directory to other directory in hdfs


hadoop fs –cp <source> <destination> 


11. To move/rename to file within hdfs directory :


hadoop fs –mv <source> <destination> 


12. To check disk usage for each file in directory :


hadoop fs –du <source> 


13. To test given destination is directory or not: 


hadoop fs –test –d <destination> 


14. To check is this directory or not – echo$? If answer is 0 then it means it is directory else not 


15. To check if destination exist or not in hdfs – hadoop fs –test –e destination 


16. To check if destination is file or not – hadoop fs –test –f destination 


17. To check given is empty or not – hadoop fs –test –z destination/xyz.txt 18. To move file from local to hdfs – hadoop fs –moveFromLocal a2.txt destination/ 


19. Merge file in hdfs and copy it into local – hadoop fs –getmerge –nl filename filename  ~/Desktop/ 


20. Append to file in hdfs -- hadoop fs –appendToFile source source destination 21. To check status of hdfs – hadoop fsck - / 


22. To check the directory,no. of file in that directory and size – hadoop fs –count  directoryname 


23. To remove some file – hadoop fs –rm directory/filename


24. Size of file -- Hadoop fs –stat %b directory/filename %r for replication %g for group %u for  username %y for last modification 


25. Hadoop fs – help any command work like man command in linux 


26. Hadoop fs –head directory/filename give first kb of lines 


27. Hadoop fs –expunge – to delete the file in trash 


28. To change permission to a file – hadoop fs –chmod 777 filename 


29. Hadoop fs –setrep –w 3 pathoffile -- to change the replication  


30. Hadoop fs –truncate –w 100 filepathname – to reduce the size of lengthy long file 


31. To add extra comment to the file – hadoop fs –setfattr –n ‘user.ap’ –v this is dummyfile  filepath 


32. hadoop fs –getfattr –d filepath – to get attribute


Post a Comment

0 Comments