Basic Hadoop Commands
Basic Hadoop Commands
1. mkdir:
This is no different from the UNIX mkdir command and is used to create a directory
on an HDFS environment.
2. touchz:
This command can be used to create a file of zero bytes size in HDFS filesystem.
Example:
$ hadoop fs -touchz /user/training/BBA/sample.txt
3. ls:
This is no different from the UNIX ls command and it is used for listing
the directories present under a specific directory in an HDFS system. The –lsr
command may be used for the recursive listing of the directories and files
under a specific folder.
$ hadoop fs -ls /
$ hadoop version
5. cat:
This command is similar to the UNIX cat command and is used for displaying the
contents of a file on the console.
Example:
$ hadoop fs -cat /user/data/sampletext.txt
6. cp:
This command is similar to the UNIX cp command, and it is used for copying files
from one directory to another directory within the HDFS file system.
Example:
$ hadoop fs -cp /user/data/sample1.txt /user/hadoop1
$ hadoop fs -cp /user/data/sample2.txt /user/test/in1
7. mv:
This command is similar to the UNIX mv command, and it is used for moving a file
from one directory to another directory within the HDFS file system.
Example:
$ hadoop fs -mv /user/hadoop/sample1.txt /user/text/
8. Put
The Hadoop fs shell command put is similar to the copyFromLocal,
which copies files or directory from the local filesystem to the destination in
the Hadoop filesystem.
$ hadoop fs -put sample.txt /user/data/