hdfs commands
hdfs commands
1) -ls Command:
-ls command is used to list down the file and directories of a given location in
HDFS.
hdfs dfs -ls / (this will return all the file and directories of the root
location in HDFS i.e. / )
2) -mkdir Command:
-mkdir command is used to make a new directory in HDFS
hdfs dfs -mkdir /a123 (this command will create a directory named a123 in / of
HDFS)
3) -rmdir Command:
-rmdir commmand is used to remove a directory in HDFS
4) -put Command:
-put command is used to copy a file from local file system to HDFS
5) -copyFromLocal Command:
-copyFromLocal command is another alternate of -put command which will copy a file
from local file system to HDFS
6) -cat Command:
-cat command is used to read the content of a file from HDFS
hdfs dfs -cat /user/Dell/a1.txt ( this will read the content of the file a1.txt
from HDFS)
7) -rm Command:
-rm command is used to remove a file from HDFS
8) -moveFromLocal Command:
-moveFromLocal command is used to move a file from local file system to HDFS.
9) -cp Command:
-cp command is used to copy a file from one directory to another directory in HDFS
hadoop fs -rm -r /user/Dell (this will delete all the files and dir of Dell
as well)
-----------------************************-------------------
ls commands:
1) hadoop fs -ls -d
2) hadoop fs -ls -h
3) hadoop fs -ls -R
( d- list directories as plain files, h-> format size in human readable format i.e.
bytes
R-> to list recursively)
rm command:
–rm: Only files can be removed but directories can’t be deleted by this command
–rm r: Recursively remove directories and files
–skipTrash: used to bypass the trash then it immediately deletes the source
–f: mention that if there is no file existing
–rR: used to recursively delete directories