Common Hadoop commands and their usage

Apache Hadoop as per their official definition is a Java based framework that is used for distributed processing of large data sets across a cluster of computers using simple programming models.


While working with Hadoop, you may need to use many file automation commands to work with files in the Hadoop file system. Here is the list of commonly used Hadoop commands along with their usage examples for your reference.




1. mkdir: 

This command is used to create a new folder or directory

Example: hadoop fs -mkdir new_folder

The above example command will create a new directory with the name "new_folder"



2. ls: 

This command is used to view the list of files and directories present in the current location. In addition to the list, it also displays some attributes such as file size, permissions, owner, modified date etc.

Example: hadoop fs -ls



3. cp: 

This command is used to copy files and folders from a source to a destination path.

Example: hadoop fs -cp <source path> <destination path>



4. mv:  

This command is used to move files and folders from a source to a destination path

Example: hadoop fs -mv <source path> <destination path>



5. copyFromLocal: 

This command is used to copy files from local system to HDFS

Example: hadoop fs -copyFromLocal <source local file path> <destination path in HDFS>



6. copyToLocal: 

This command is used to copy files from HDFS to local file system

Example: hadoop fs -copyToLocal <source HDFS path> <destination local file path>



7. moveFromLocal: 

This command is used to move files from local system to HDFS

Example: hadoop fs -moveFromLocal <source local file path> <destination path in HDFS>



8. moveToLocal: 

This command is used to move files from HDFS to local file system

Example: hadoop fs -moveToLocal <source HDFS path> <destination local file path>



9. rm: 

This command is used to remove/delete the file from HDFS

Example: hadoop fs -rm <file path>



10. chmod: 

This command is used to change the file permission associated with the file or directory.

Example: hadoop fs -chmod -r <file name>



I hope these commands are helpful to you. Do let me know your thoughts in the comments.

Post a Comment

0 Comments