List of commands which I use day to day basis to perform my task in HDFS. Checkout below hdfs cheat sheet for reference.

In below list I have covered Copy, Move, Check file/directory size, Change ownership of file/group, delete the files and directories etc.

HDFS Cheat Sheet

hdfs dfs -ls /list of all files and directories in given path
hdfs dfs -ls -h /hdfsproject/pathlist of all files/directories in human readable format
hdfs dfs -ls -d /hdfsproject /path1list of all directories of /hdfs/path1 as plain file
hdfs dfs -mkdir /hdfsproject /path2To create new directory inside hdfs folder
hdfs dfs -mv /hdfsproject/path1 /hdfsproject/Move directory path1 inside /hdfsproject
hdfs dfs -cp /hdfsproject/path1 /hdfsproject/Copy directory path1 in /hdfsproject directory
hdfs dfs -du -h /hdfsproject/file To display the file size
hdfs dfs -du -s /hdfsproject/path1To display list of all files in given HDFS path
hdfs dfs -df /hdfsprojectShows the capacity, free and used space of the filesystem.
hdfs dfs -chmod 755 /hdfsproject/file1Changes permissions of the file.
hdfs dfs -chmod -R 755 /hadoopChanges permissions of the files recursively
hdfs dfs -chown hduser:hdgrp /hadoopChange file group ownership
hdfs dfs -chown -R hduser:hdgrp /hadoopChange file group ownership recursively
hdfs dfs -chgrp ubuntu /hadoopChange group ownership
hdfs dfs -chgrp -R ubuntu /hadoopChange group ownership recursively
hdfs dfs -put /home/ubuntu/sample /hadoopTo copies the file from local file system to HDFS.
hdfs dfs -put -f /home/ubuntu/sample /hadoopTo copies the file from local file system to HDFS, overwrite it if already exist
hdfs dfs -copyFromLocal /home/techieroop/sample /hdfsproject/To copy the file from local filesystem to hdfs path
hdfs dfs -copyToLocal /hdfsproject/file /home/techieroop/To copy the file from HDFS path to local file system
hdfs dfs -rm -f /hdfsprojectIf the file does not exist, do not display a diagnostic message or
modify the exit status to reflect an error.
hdfs dfs -rm -skipTrash /hdfsprojectDelete the directory recursively
hdfs dfs -rm -skipTrash /hdfsprojectDelete the directory recursively and skip the trash
HDFS Cheat Sheet
(Visited 986 times, 12 visits today)