Task | Command |
---|---|
List files | hdfs dfs -ls /path/ |
List files recursively | hdfs dfs -ls -R /path/ |
Create a directory | hdfs dfs -mkdir /path/ |
Create parent directories | hdfs dfs -mkdir -p /parent/child/ |
Upload file to HDFS | hdfs dfs -put localfile /hdfs/path/ |
Download file from HDFS | hdfs dfs -get /hdfs/path localfile |
Copy file within HDFS | hdfs dfs -cp /src /dest |
Move file within HDFS | hdfs dfs -mv /src /dest |
Remove file or dir | hdfs dfs -rm /path/file.txt |
Remove directory recursively | hdfs dfs -rm -r /path/dir |
Display contents of a file | hdfs dfs -cat /file/path |
Show file statistics | hdfs dfs -stat /file/path |
Show disk usage | hdfs dfs -du /path/ |
Count files, directories, and bytes | hdfs dfs -count /path/ |
Change file permissions | hdfs dfs -chmod 755 /path/ |
Change file owner | hdfs dfs -chown user:group /path/ |
List all files based on size in decending order | hdfs dfs -ls -R / | grep -v ‘^d’ | awk ‘{print $5, $8}’ | sort -nr |
Leave a Reply