【大数据】HDFS的shell命令

所有FS shell命令使用URL路径作为参数。

HDFS的shell命令:

1.启动

start-all

 第一次启动后会自动在namenode中创建fsimage和edits文件

2.帮助手册

hdfs dfs -help

3.显示目录信息

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

4.添加文件

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

5.从本地复制文件到HDFS中

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

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

6.上传文件到HDFS中

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

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

7.从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.查看文本的内容

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.删除文件

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

10.删除文件夹

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

11.从hdfs的一个路径拷贝到hdfs的另一个路径

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

12.系统信息

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

猜你喜欢

转载自blog.csdn.net/Qmilumilu/article/details/104644645