0% found this document useful (0 votes)
5 views

hdfs commands

The document provides a comprehensive list of HDFS commands along with their descriptions and usage examples. Key commands include -ls for listing files, -mkdir for creating directories, -put for uploading files, and -get for downloading files from HDFS. Additional commands for file manipulation, size checking, and recursive operations are also detailed.

Uploaded by

singhrounak.1199
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

hdfs commands

The document provides a comprehensive list of HDFS commands along with their descriptions and usage examples. Key commands include -ls for listing files, -mkdir for creating directories, -put for uploading files, and -get for downloading files from HDFS. Additional commands for file manipulation, size checking, and recursive operations are also detailed.

Uploaded by

singhrounak.1199
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

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

hdfs dfs -rmdir /a123

4) -put Command:
-put command is used to copy a file from local file system to HDFS

hdfs dfs -put D:\a1.txt /user/Dell

hdfs dfs -put C:\Users\Dell\Desktop\a1.txt /user/Dell

5) -copyFromLocal Command:
-copyFromLocal command is another alternate of -put command which will copy a file
from local file system to HDFS

hdfs dfs -copyFromLocal C:\Users\Dell\Desktop\a2.txt /user/Dell

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

hdfs dfs -rm /user/Dell/a3.txt

8) -moveFromLocal Command:
-moveFromLocal command is used to move a file from local file system to HDFS.

hdfs dfs -moveFromLocal C:\Users\Dell\Desktop\a3.txt /user/Dell

9) -cp Command:
-cp command is used to copy a file from one directory to another directory in HDFS

hadoop fs -cp /user/Dell/a3.txt /user

10) -mv Command:


-mv command is used to move a file from one directory to another directory in HDFS
hadoop fs -mv /user/Dell/a1.txt /user

11) -du Command:


-du command is used to check the size of individual files and dir in any HDFS
directory

hadoop fs -du /user ( for size of each file in directory)

12) -dus Command:


-dus command is used to check the size of an entire directory

hadoop fs -dus /user ( for size of entire directory)

13) -touchz Command:


-touchz command is used to create a new file in HDFS

hadoop fs -touchz /user/Dell/new.txt

14) -get Command:


-get command is used to copy a file from HDFS to local file system

hadoop fs -get /user/Dell/a2.txt C:\Users\Dell\Desktop ( hdfs to local)

15) -appendToFile Command:


-appendToFile Command is used to append a file

hadoop fs -appendToFile C:\Users\Dell\Desktop\append.txt /user/Dell/a2.txt

16) -tail Command:


-tail command is used to get the last 1kb of a file

hadoop fs -tail /user/Dell/a2.txt

17) -head Command:


-head command is used to fetch the first 1kb of a file in HDFS

hadoop fs -head /user/Dell/a2.tx

18) -stat Command:


-stat command will provide the statistical information of a file in HDFS

hadoop fs -stat /user/Dell/a2.txt

19) -ls -R Command:


this command is used to list down the files recursively in a given location

hadoop fs -ls -R /user/Dell

20) -rm -r Command:


This command is used to recursively delete the files and directories.

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

1) hadoop fs -rm -r /user/test/sample.txt

You might also like