Common HDFS Commands | *1. Copy file to HDFS* | hdfs dfs -put /home/cloudera/localfile.txt /user/cloudera/ | *2. Copy file from HDFS* | hdfs dfs -get /user/cloudera/localfile.txt /home/cloudera/ | *3. List directories/files* | hdfs dfs -ls /user/cloudera/ | *4. Display file contents* | hdfs dfs -cat /user/cloudera/localfile.txt | *5. Create a directory* | hdfs dfs -mkdir /user/cloudera/newdir | *6. Remove directory/file* | hdfs dfs -rm -r /user/cloudera/newdir | *7. Count number of files* | hdfs dfs -count /user/cloudera/ | *8. Merge files* | hdfs dfs -getmerge /user/cloudera/folder/* /home/cloudera/merged.txt | *9. Concatenate two files in HDFS* | hdfs dfs -cat /user/cloudera/file1.txt /user/cloudera/file2.txt | hdfs dfs -put - /user/cloudera/merged.txt | *10. Find checksum* | hdfs dfs -checksum /user/cloudera/localfile.txt
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter