0% found this document useful (0 votes)
186 views

Hadoop Commands

The document lists various commands used to interact with HDFS in Hadoop. Some key commands include: - hadoop fs -ls to list files/directories in HDFS - hadoop fs -mkdir and -touchz to create directories and empty files in HDFS - hadoop fs -copyFromLocal and -copyToLocal to copy files between local file system and HDFS - hadoop fs -cat to view file contents - hadoop fs -rm to delete files from HDFS

Uploaded by

Kajendiran .S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
186 views

Hadoop Commands

The document lists various commands used to interact with HDFS in Hadoop. Some key commands include: - hadoop fs -ls to list files/directories in HDFS - hadoop fs -mkdir and -touchz to create directories and empty files in HDFS - hadoop fs -copyFromLocal and -copyToLocal to copy files between local file system and HDFS - hadoop fs -cat to view file contents - hadoop fs -rm to delete files from HDFS

Uploaded by

Kajendiran .S
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

TOP HADOOP HDFS COMMAND

1. To check all the services are running use --- jps


2. Two types of prefix hdfs dfs (specially with hdfs file system) and hadoop fs (to interact with
other file system) in hadoop command
3. hadoop fs –ls
4. To display the content of a directory which is present in hdfs filesystem
hadoop fs –ls g

5. To create directory in hdfs -- hadoop fs –mkdir Prerna

6. To create a file empty in hdfs -- hadoop fs –touchz ap.txt

7. To copy file from local to hdfs – hadoop fs –copyFromLocal f1.txt Prerna

8. To check file content – hadoop fs –cat Prerna/f1.txt

9. To copy file from hdfs to Local – hadoop fs –copyToLocal Prerna/f1.txt ~/Desktop/

10. To send file from directory to other directory in hdfs – hadoop fs –cp source destination

11. To move 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

You might also like