Experiment - Hdfs Commands
Experiment - Hdfs Commands
HDFS COMMANDS
Objectives:
Key concept
HDFS commands are used to access the Hadoop File System. HDFS stands for
‘Hadoop Distributed File System’.
The HDFS is a sub-project of the Apache Hadoop project. This Apache Software
Foundation project is designed to provide a fault-tolerant file system designed to run
on commodity hardware. HDFS is accessed through a set of shell commands.
For executing the HDFS commands , open the terminal in cloudera vm.
Hadoop 2.6.0-cdh5.10.0
copyFromLocal
HDFS Command to copy the file from a Local file system to HDFS.
cat: HDFS Command that reads a file on HDFS and prints the content of that file to the standard
output.
1,kriti,cse,45
2,neha,ece,56
3,jyothi,ce,78
4.priya,mechanical,89
put: HDFS Command to copy single source or multiple sources from local file system to the
destination file system.
copyToLocal
HDFS Command to copy the file from HDFS to Local File System.
[cloudera@quickstart Desktop]$ ls
fsck
hdfs fsck /
Q11) Copy any file present in HDFS to a directory which is also present in HDFS
Touchz: HDFS Command to create a file in HDFS with file size 0 bytes.
cat
HDFS Command that reads a file on HDFS and prints the content of that file to the standard
output.
1,kriti,cse,45
2,neha,ece,56
3,jyothi,ce,78
4.priya,mechanical,89
Q15) Count the number of directories and files inside a directory in HDFS?
count: HDFS Command to count the number of directories, files, and bytes under the paths
that match the specified file pattern.
Usage: hadoop fs -count <path>
1 1 13 /user/cloudera/kriti2018
Deleted empty.txt
rm -r
HDFS Command to remove the entire directory and all of its content from HDFS.
Cp: HDFS Command to copy files from source to destination. This command allows multiple
sources as well, in which case the destination must be a directory.
mv: HDFS Command to move files from source to destination. This command allows multiple
sources as well, in which case the destination needs to be a directory.
Usage command gives all the options that can be used with a particular hdfs command.
help
HDFS Command that displays help for given command or all commands if none is specified.
[cloudera@quickstart Desktop]$
Cluster Balancing
hadoop balancer
expunge: Empties the trash. When you delete a file, it isn’t removed immediately from HDFS,
but is renamed to a file in the /trash directory. As long as the file remains there, you can undelete
it if you change your mind, though only the latest copy of the deleted file can be restored.
tail
This hadoop command will show the last kilobyte of the file to stdout.
27) Append the contents of a file present in local to a file present in HDFS