[Big Data] HDFS shell commands

All FS shell commands use the URL path as a parameter.

HDFS shell command:

1. Start

start-all

 After the first boot, the fsimage and edits files will be automatically created in the namenode

2. Help Manual

hdfs dfs -help

3. Display catalog information

hdfs dfs -ls /      //  /代表根目录
hdfs dfs -ls -R  // -r为递归显示

4. Add files

hdfs dfs -mkdir /test
hdfs dfs -mkdir -p /test/imput   // -p代表递归创建,子目录文件

5. Copy files from local to HDFS

hdfs dfs -copyFromLocal ./start-all.cmd  /test/imput  

//将当前目录的start-all.cmd 复制到/test/imput中

6. Upload files to HDFS

hdsf dfs -put ./start-all.cmd /test/imput  

//会报错文件已经存在,也验证了hdfs系统的只能一次写入,多次读取的特性
//但命令格式正确

7. Get files from HDFS

hdfs dfs -get /test/imput/start-all.cmd  ./star-all.cmd.back
hdfs dfs -copyTolocal /test/imput/start-all.cmd  ./star-all.cmd.back

8. View the content of the text

hdfs dfs -cat /test/imput/start-all.cmd  
//显示全部内容
hdfs dfs -tail /test/imput/start-all.cmd 
//显示一个文件的末尾
hdfs dfs -text /test/imput/start-all.cmd 
//以字符形式打印一个文件的内容

9. Delete files

hdfs dfs -rm -f /test/imput/start-all.cmd 
//-f代表强制删除

10. Delete the folder

hdfs dfs -rm -r /test/imput/
//-r代表递归删除

11. Copy from one path of hdfs to another path of hdfs

hdfs dfs -cp /test/imput/start-all.cmd  /test/start-all.cmd  

12. System Information

hdfs dfs -df -h  /
//统计文件系统的可用空间信息
//-h
hdfs dfs -du -s -h /test
//统计文件夹的大小信息
hdfs dfs -cout /
//统计一个指定目录下的文件节点数量

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/Qmilumilu/article/details/104644645
Recommended