Hadoop is a Java-based framework and it runs on Linux based windows so commands are important for Hadoop. Hadoop Commands are used to access the all HDFS cluster files and directories. Here we discuss basic and important Hadoop commands to manage HDFS.
Latest and Updated Hadoop Training Topics PDF Download
Basic Commands:
1. mkdir:
mkdir is used to create the main directory
Syntax: Hadoop fs -mkdir
2. ls
Used to list out all directory in HDFS
Syntax: hadoop fs -ls <args>
3. mv <src><dest>
This command used to move one file from source to destination
Syntax: hadoop fs -mv <src> <dest>
4. cp <src><dest>
This command used to copy the file from source to destination within HDFS
Syntax: hadoop fs -cp <src> <dest>
5. fs -df hdfs
This command used to report the number of spaces used in hdfs files
Syntax: hadoop fs -df hdfs
6. fs -count hdfs
Used to count the number of files and directories within HDFS
Syntax: hadoop fs -count hdfs
7. rm
This command used to remove any diectory
Syntax: hadoop fs -rm <arg>
8. cat
Used to displays the contents of filename
Syntax: hadoop fs cat
9. fs -expunge
This command used to empty the trash
Syntax: hadoop fs -expunge
10. du <path>
Used to shows disk usage
Syntax: hadoop fs -du
11. tail
This command used to displays the last few lines fo file
Syntax: hadoop fs -tail <path[filename]>
12. touchz <path>
This command used to create a file and it contains current time and timestamp
Syntax: hadoop fs- touchz