Hadoop学习(四) FileSystem Shell命令详解
FileSystem Shell中大多数命令都和unix命令相同,只是两者之间的解释不同,如果你对unix命令有基本的了解,那么对于FileSystem Shell的命令,你将会感到很亲切。
appendToFile
$ hdfs dfs -appendToFile localfile /user/hadoop/hadoopfile
$ hdfs dfs -appendToFile localfile1 localfile2 /user/hadoop/hadoopfile
$ hdfs dfs -appendToFile localfile hdfs://nn.example.com/hadoop/hadoopfile
$ hdfs dfs -appendToFile - hdfs://nn.example.com/hadoop/hadoopfile Reads the input from stdin
cat
$ hdfs dfs -cat hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
$ hdfs dfs -cat file:///file3 /user/hadoop/file4
chgrp
$ hdfs df -chgrp bigdata hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
$ hdfs df -chgrp bigdata file:///file3 /user/hadoop/file4
chmod
#g+w表示给组划分权限,a+w表示给所有用户和组划分权限,u+w表示给用户划分权限
$ hdfs dfs -chmod g+w hdfs://nn1.example.com/file1
$ hdfs dfs -chmod -R g+w hdfs://nn1.example.com/file2
chown
$ hdfs dfs -chown -R newOwner:newOwner_group hdfs://nn1.example.com/file1
copyFromLocal
$ hdfs dfs -copyFromLocal localfile /user/hadoop/hadoopfile
copyToLocal
$ hdfs dfs -copyFromLocal /user/hadoop/hadoopfile localfile
count
- -q:输出列QUOTA, REMAINING_QUATA、SPACE_QUOTA、REMAINING_SPACE_QUOTA、DIR_COUNT、FILE_COUNT、CONTENT_SIZE、FILE_NAME
- -h:可读格式的大小
$ hdfs dfs -count hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
$ hdfs dfs -count -q hdfs://nn1.example.com/file1
$ hdfs dfs -count -q -h hdfs://nn1.example.com/file1
cp
$ hdfs dfs -cp /user/hadoop/file1 /user/hadoop/file2
$ hdfs dfs -cp /user/hadoop/file1 /user/hadoop/file2 /user/hadoop/dir
du
- -s:该选项将导致显示文件长度的汇总,而不是单个文件。
- -h:选项将格式中的“可读的”时尚大小文件(如64.0m代替67108864)
$ hdfs dfs -du /user/hadoop/dir1 /user/hadoop/file1 hdfs://nn.example.com/user/hadoop/dir1
expunge
$ hdfs dfs -expunge
get
$ hdfs dfs -get /user/hadoop/file localfile
$ hdfs dfs -get hdfs://nn.example.com/user/hadoop/file localfile
getfacl
- R:列出所有文件和目录递归ACL。
- path:文件或目录列表。
$ hdfs dfs -getfacl /file
$ hdfs dfs -getfacl -R /dir
getfattr
- -R:递归列出所有文件和目录的属性。
- -n name:转储命名扩展属性值。
- -d:转储所有扩展属性的价值与路径。
- -e encoding:检索后编码值。有效的编码是“文本”、“妖术”,和“Base64”。编码值为文本字符串括在双引号,编码值为十六进制和Base64是前缀0x 0。
- path:文件或目录。
$ hdfs dfs -getfattr -d /file
$ hdfs dfs -getfattr -R -n user.myAttr /dir
getmerge
$ hdfs dfs -getmerge hdfs://nn1.example.com/file1 localfile
ls
$ hdfs dfs -ls /user/hadoop/file1
lsr
$ hdfs dfs -lsr /user/hadoop/file1
mkdir
$ hdfs dfs -mkdir /user/hadoop/dir1 /user/hadoop/dir2
$ hdfs dfs -mkdir hdfs://nn1.example.com/user/hadoop/dir hdfs://nn2.example.com/user/hadoop/dir
moveFromLocal
$ hdfs dfs -moveFromLocal localfile hdfs://nn1.example.com/file1
moveToLocal
$ hdfs dfs -moveToLocal hdfs://nn1.example.com/file1 localfile
mv
$ hdfs dfs -mv /user/hadoop/file1 /user/hadoop/file2
$ hdfs dfs -mv hdfs://nn.example.com/file1 hdfs://nn.example.com/file2 hdfs://nn.example.com/file3 hdfs://nn.example.com/dir1
put
$ hdfs dfs -put localfile /user/hadoop/hadoopfile
$ hdfs dfs -put localfile1 localfile2 /user/hadoop/hadoopdir
$ hdfs dfs -put localfile hdfs://nn.example.com/hadoop/hadoopfile
$ hdfs dfs -put - hdfs://nn.example.com/hadoop/hadoopfile Reads the input from stdin.
rm
$ hdfs dfs -rm hdfs://nn.example.com/file /user/hadoop/emptydir
rmr
$ hdfs dfs -rmr hdfs://nn.example.com/file /user/hadoop/emptydir
setfcal
$ hdfs dfs -setfacl -m user:hadoop:rw-/file
$ hdfs dfs -setfacl -x user:hadoop /file
$ hdfs dfs -setfacl -b /file
$ hdfs dfs -setfacl -k /dir
$ hdfs dfs -setfacl --set user::rw-,user:hadoop:rw-,group::r--,other::r--/file
$ hdfs dfs -setfacl -R -m user:hadoop:r-x /dir
$ hdfs dfs -setfacl -m default:user:hadoop:r-x /dir
setrep
$ hdfs dfs -setrep -w /user/hadoop/dir1
stat
$ hdfs dfs -stat path
tail
$ hdfs dfs -tail pathname
test
- -e:将检查文件是否存在,如果为true,则返回0。
- -z:将检查文件是否为零长度,如果为真则返回0。
- -d:将检查路径是否为目录,如果为true则返回0。
$ hdfs dfs -test -e filename
text
$ hdfs dfs -text src
touchz
$ hdfs dfs -touchz pathname
Hadoop学习(四) FileSystem Shell命令详解的更多相关文章
- adb shell 命令详解,android
http://www.miui.com/article-275-1.html http://noobjava.iteye.com/blog/1914348 adb shell 命令详解,android ...
- adb shell 命令详解,android, adb logcat
http://www.miui.com/article-275-1.html http://noobjava.iteye.com/blog/1914348 adb shell 命令详解,android ...
- 【Devops】【docker】【CI/CD】关于jenkins构建成功后一步,执行的shell命令详解+jenkins容器运行宿主机shell命令的实现方法
1.展示这段shell命令 +详解 #================================================================================= ...
- Linux主要shell命令详解(上)
[摘自网络] kill -9 -1即实现用kill命令退出系统 Linux主要shell命令详解 [上篇] shell是用户和Linux操作系统之间的接口.Linux中有多种shell,其中缺省使用的 ...
- linux shell 脚本攻略学习11--mkdir和touch命令详解
一.创建目录(mkdir命令详解) amosli@amosli-pc:~/learn$ mkdir dir amosli@amosli-pc:~/learn/dir$ mkdir folder amo ...
- ubuntu学习笔记-tar 解压缩命令详解(转)
tar 解压缩命令详解 -c: 建立压缩档案 -x:解压-t:查看内容-r:向压缩归档文件末尾追加文件-u:更新原压缩包中的文件 这五个是独立的命令,压缩解压都要用到其中一个,可以和别的命令连用但只能 ...
- hadoop Shell命令详解
调用文件系统(FS)Shell命令应使用bin/hadoop fs <args>的形式.所有的的FS shell命令使用URI路径作为参数.URI路径详解点击这里. 1.cat说明:将路径 ...
- Hadoop学习之Mapreduce执行过程详解
一.MapReduce执行过程 MapReduce运行时,首先通过Map读取HDFS中的数据,然后经过拆分,将每个文件中的每行数据分拆成键值对,最后输出作为Reduce的输入,大体执行流程如下图所示: ...
- Hive Shell 命令详解
Hive服务介绍 Hive默认提供的cli(shell)服务,如果需要启动其他服务,那么需要service参数来启动其他服务,比如thrift服务.metastore服务等.可以通过命令hive -- ...
随机推荐
- Linux 网卡的解决方法
1. 编辑70-persistent-net配置文件: # vi /etc/udev/rules.d/70-persistent-net.rules 如果没有就新建一个,添加如下内容: # PCI d ...
- 在已有软件加壳保护 下实现 Inline hook
如写的不好请见谅,本人水平有限. 个人简历及水平:. http://www.cnblogs.com/hackdragon/p/3662599.html 正常情况: 接到一个项目实现对屏幕输出内容的获取 ...
- 设计模式——观察者模式(ObserverPattern)
观察者模式(ObserverPattern):观察者模式又称发布-订阅(Publish/Subscribe)模式,定义了一个中一对多的依赖关系,让多个观察者对象同时监听某一个主题对象.这个主题对象在状 ...
- vue.js--基础 数据的双向绑定
所谓双向绑定:就是改变modle,就会改变view,改变view,也会改变modle 下面案例,点击getMthod(),获取msg的内容,在点击setMthod()改变msg的内容,你会发现H1的值 ...
- 【mysql案例】mysql5.6.14配置my.cnf多实例,mysql_install_db初始化不读取my.cnf配置文件
1.1.1. mysql5.6.14多实例my.cnf时,初始化不读取my.cnf配置文件 [环境描写叙述] 在多实例配置的/etc/my.cnf环境中,运行mysql_install_db后.启动M ...
- 【[NOI2006]最大获利】
题目 并不知到为什么这道题讲了这么久 我们发现这道题就是最小割的板子啊,完全可以套上文理分科的板子 把每个机器和\(T\)连边,容量为\(p_i\),这些\(p_i\)并不计入总贡献 对于每一个要求我 ...
- 课堂笔记——while循环
用 while循环 1.100以内所有数的和 static void Main1(string[] args) //不是自己做的 { //100以内所有数的和 ; ; //初始条件 ) //循环条件 ...
- Android学习笔记_31_通过后台代码生成View对象以及动态加载XML布局文件到LinearLayout
一.布局文件part.xml: <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android&qu ...
- 【题解】洛谷P1350 车的放置(矩阵公式推导)
洛谷P1350:https://www.luogu.org/problemnew/show/P1350 思路 把矩阵分为上下两块N与M 放在N中的有i辆车 则放在M中有k-i辆车 N的长为a 宽为 ...
- 魔板 Magic Squares(广搜,状态转化)
题目背景 在成功地发明了魔方之后,鲁比克先生发明了它的二维版本,称作魔板.这是一张有8个大小相同的格子的魔板: 1 2 3 4 8 7 6 5 题目描述 我们知道魔板的每一个方格都有一种颜色.这8种颜 ...