0% found this document useful (0 votes)
70 views2 pages

HDFS Basic Commands

The document describes basic HDFS commands including: 1. ls and lsr to list files and directories recursively; mkdir to create directories; touchz to create empty files. 2. copyFromLocal/put and copyToLocal/get to copy files between local and HDFS; moveFromLocal to move from local to HDFS. 3. cp to copy within HDFS; mv to move within HDFS; rmr to delete files and directories recursively including contents.

Uploaded by

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

HDFS Basic Commands

The document describes basic HDFS commands including: 1. ls and lsr to list files and directories recursively; mkdir to create directories; touchz to create empty files. 2. copyFromLocal/put and copyToLocal/get to copy files between local and HDFS; moveFromLocal to move from local to HDFS. 3. cp to copy within HDFS; mv to move within HDFS; rmr to delete files and directories recursively including contents.

Uploaded by

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

HDFS basic commands

ls: This command is used to list all the files. Use lsr for recursive approach. It is useful when we
want a hierarchy of a folder.
hdfs dfs –ls <path>
hdfs dfs –ls /

mkdir: To create a directory. In Hadoop dfs there is no home directory by default. So let’s first


create it.
hdfs dfs -mkdir <folder name>
hdfs dfs -mkdir /testDir

touchz: It creates an empty file.


hdfs dfs -touchz <file_path>

copyFromLocal (or) put: To copy files/folders from local file system to hdfs store. This is the
most important command. Local filesystem means the files present on the OS.
hdfs dfs -copyFromLocal sample.txt /testDir

cat: To print file contents


hdfs dfs -cat /testDir/sample.txt

copyToLocal (or) get: To copy files/folders from hdfs store to local file system
hdfs dfs -copyToLocal <<srcfile(on hdfs)> <local file dest>
hdfs dfs -copyToLocal /testDir/sample.txt copy_sample.txt

moveFromLocal: This command will move file from local to hdfs


hdfs dfs -moveFromLocal <local src> <dest(on hdfs)>
hdfs dfs -moveFromLocal copy_sample.txt /testDir/

cp: This command is used to copy files within hdfs. Lets copy folder geeks to geeks_copied.
hdfs dfs -cp <src(on hdfs)> <dest(on hdfs)>
hdfs dfs -cp /testDir/sample.txt /testDir/backup
Note: here it is assumed that folder ‘backup’ is present under /testDir

mv: This command is used to move files within hdfs.


hdfs dfs -mv <src(on hdfs)> <src(on hdfs)>
hdfs dfs -mv /testDir/sample.txt /testDir/backup/

rmr: This command deletes a file from HDFS recursively. It is very useful command when you
want to delete a non-empty directory.
hdfs dfs -rmr <filename/directoryName>
hdfs dfs -rmr /testDir/backup
Note: It will delete all the content inside the directory then the
directory itself.

du: It will give the size of each file in directory


hdfs dfs -du <dirName>

dus:: This command will give the total size of directory/file.


hdfs dfs -dus <dirName>

stat: It will give the last modified time of directory or path. In short it will give stats of the
directory or file.
hdfs dfs -stat <hdfs file>

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy