In our last post we saw how we can install Hadoop on single machine, we managed to start and stop the Hadoop components. See the post here
In this post we will dive into using the hadoop command line and try to understand the way hadoop stores the file into hdfs. This post will be done at the command line and no GUI will be involved.
The basic syntax of a hadoop command is:
Available commands:
You can get all this information and more by running the following command:
In general the hadoop commands are very similar to Linux os commands e.g.:cp, ls , mkdir etc..
So let us Start with some simple and basic commands
List he content of the hadoop root directory:
Create new directory in hadoop hdfs:
List the content of a directory in hadoop hdfs:
Remove/drop a directory from hadoop hdfs:
Note: this will work if the directory is empty.
Remove/drop a directory from hadoop hdfs that contains file or other folders:
this is remove the folder and the content recursively.
Load a file into hadoop hdfs:
Load more file into hadoop hdfs using a wildcard:
Check to see the content of the folder:
Multiple files have been loaded.
Read the content of a file that is stored in hadoop:
for this we will need to use the cat option
Read the content of multiple files that is stored in hadoop:
is the same command but we will use the wildcard for the file name.
Append to a file the content of other file/files:
this can be done using a external hadoop source or internal hadoop source.
Count the numbers of directories, files and bytes under the paths that match the specified file pattern.
See the space capacity:
Fine or locate a file inside the hadoop hdfs:
List the ACL(Access Control Lists) of files and directories.
And finally the most waited command, the help command:
you can use the -help command with any other command option to see the preferred syntax and the used options.
Note: for the command you are looking to get help for you should not set the hyphen sign.
Wanna see the Video tutorial as well covering the same topic, visit the my YouTube Channel
I hope this was useful and there is more to come.
I do encourage you to like and subscribe to my website and i very much appreciate your support.