Version command
It will Prints the version.
syntax: C:\Users\HP>Hadoop version
mkdir and ls command
Mkdir command is used to create a directory. In Hadoop dfs there is no home directory by default.
Syntax: hdfs dfs -mkdir /<folder name>
e.g:
Ls command is used to list all the files.It will print all the directories present in HDFS.
Syntax: C:\hadoop-2.8.0>hdfs dfs -ls /
df command
df command is used for showing the capacity,size and free space available on the hdfs file system.The - h option formats the file size in human readable form.
Syntax: C:\hadoop-2.8.0>Hdfc dfs -df
C:\hadoop-2.8.0>Hdfc dfs -df -h
touchz command
Touchz command is used to creates an empty file.
In below example we created raja.txt file in programmingraja directory.
Syntax: hdfsdfs -touchz<file_path>
E.g.
lsr command
lsr command is used to show all files in directory.
Syntax: C:\hadoop-2.8.0>hdfs dfs -lsr /
put command
put command is used to copy files or folders from local file system to hdfs store. put command is the most important command.
For example I want to copy pro2.txt file which is present in my computer location --> c:/hadoop_pro to HDFS store so for that put command is used.
Syntax:
E.g.
C:\hadoop-2.8.0>hdfs dfs -put ../hadoop_pro/pro2.txt /programmingraja
get command
get command is used to copy files or folders from hdfs store to local file system(my computer).
Here I have a raja.txt file in HDFS store now by using get commandwe get copy of this file to our local file system location--> c:\hadoop_pro
Syntax:
hdfsdfs -copyToLocal<<srcfile(on hdfs)><local file dest>
E.g.
C:\hadoop-2.8.0>hdfs dfs -get /programmingraja/raja.txt ../hadoop_pro
cat command
Cat command is used to print file contents.
Syntax: hdfsdfs -cat <path>
E.g.
C:\hadoop-2.8.0>hdfs dfs -cat /programmingraja/pro2.txt
cp command
cp command is used to copy files within hdfs.
Here,we have two folders programmingraja and ekta now we copy programmingraja folder to ekta.
Syntax: hdfsdfs -cp <src(on hdfs)><dest(on hdfs)>
E.g.
C:\hadoop-2.8.0>dfs -cp /programmingraja /ekta
du command
It will give the size of each file in directory.
Syntax: hdfsdfs -du <dirName>
E.g.
C:\hadoop-2.8.0>hdfs dfs -du /programmingraja
dus command
It will give the total size of directory.
Syntax: hdfsdfs -dus<dirName>
E.g.
C:\hadoop-2.8.0>hdfs dfs -dus /ekta
mv command
This command is used to move files within hdfs.
Syntax: hdfsdfs -mv <src(on hdfs)><src(on hdfs)>
here we have two directory ekta and programmingraja.
lets cut abc.txt file from ekta to programmingraja.
After successful execution of mv command abc.txt file is moved from ekta to programmingraja.
rmr command
This command removes entire directory from HDFS store.
Syntax: hdfs dfs -rmr<filename/directoryName>
E.g.
C:\hadoop-2.8.0>hdfs dfs -rmr /mypro
checksum command
E.g.
C:\hadoop-2.8.0>hdfs dfs -checksum /ekta/pro2.txt
count command
Syntax:
C:\hadoop-2.8.0>hdfs dfs -count -v /
C:\hadoop-2.8.0>hdfs dfs -count -v -q /
C:\hadoop-2.8.0>hdfs dfs -count -v -u/
fsck command
The fsck Hadoop command is used to check health of the HDFS.
E.g.
C:\hadoop-2.8.0>hdfs fsck /programmingraja/ -files
0 Comments
if you have any problem, please let me know