hadoop(五): shell命令
hdfs dfs
- -cat URI : 查看文件内容
- hdfs dfs -cat hdfs dfs -cat hdfs://mycluster/user/root/rcc1
- hdfs dfs -cat file:///usr/hdp/2.4.2.0-258/hadoop/bin/rcc
- -ls <args>: 查文件列表
- 返回格式:permissions number_of_replicas userid groupid filesize modification_date modification_time filename
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
- -mkdir <paths> : 创建目录
- The behavior is much like unix mkdir -p creating parent directories along the path
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 ~]# hdfs dfs -mkdir hdfs://mycluster/user/root/zhu
[root@hdp2 ~]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
drwxr-xr-x - root hdfs -- : zhu - -copyFromLocal <localsrc> URI: 上传文件,类似于put
- -put <localsrc> ... <dst>
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
[root@hdp2 ~]# hdfs dfs -put /usr/zhu/a1.png /user/root/zhu
[root@hdp2 ~]# hdfs dfs -copyFormLocal /usr/zhu/a2.png /user/root/zhu
-copyFormLocal: Unknown command
[root@hdp2 ~]# hdfs dfs -copyFromLocal /usr/zhu/a2.png /user/root/zhu
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
-rw-r--r-- root hdfs -- : /user/root/zhu/a2.png
[root@hdp2 ~]#
- -copyToLocal [-ignorecrc] [-crc] URI <localdst> : 下载到本地
- -get [-ignorecrc] [-crc] <src> <localdst>
[root@hdp2 ~]# clear
[root@hdp2 ~]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
-rw-r--r-- root hdfs -- : /user/root/zhu/a2.png
[root@hdp2 ~]# hdfs dfs -copyToLocal hdfs://mycluster/user/root/zhu/a1.png /usr/zhu/tmp
[root@hdp2 ~]# hdfs dfs -get /usr/root/zhu/a2.png /usr/zhu/tmp
get: `/usr/root/zhu/a2.png': No such file or directory
[root@hdp2 ~]# hdfs dfs -get /user/root/zhu/a2.png /usr/zhu/tmp
[root@hdp2 ~]# cd /usr/zhu/tmp
[root@hdp2 tmp]# ll
total
-rw-r--r-- root root Sep : a1.png
-rw-r--r-- root root Sep : a2.png
[root@hdp2 tmp]#
- -count [-q] <paths> :统计
- The output columns with -count are: DIR_COUNT, FILE_COUNT, CONTENT_SIZE FILE_NAME
- The output columns with -q are: QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA
[root@hdp2 tmp]# hdfs dfs -count /user/root/zhu
/user/root/zhu
[root@hdp2 tmp]# hdfs dfs -count -q /user/root/zhu
none inf none inf /user/root/zhu
[root@hdp2 tmp]# - -du [-s] [-h] URI [URI …]: 统计大小
- The -s option will result in an aggregate summary of file lengths being displayed, rather than the individual file
- The -h option will format file sizes in a "human-readable" fashion (e.g 64.0m instead of 67108864)
[root@hdp2 tmp]# hdfs dfs -du -h /user/root/zhu
84.9 K /user/root/zhu/a1.png
54.5 K /user/root/zhu/a2.png
[root@hdp2 tmp]#
- -rm -r [-skipTrash] URI [URI …]
- -r: Recursive version of delete
[root@hdp2 tmp]# hdfs dfs -ls /user/root/zhu
Found items
-rw-r--r-- root hdfs -- : /user/root/zhu/a1.png
[root@hdp2 tmp]# hdfs dfs -rm -r /user/root/zhu
// :: INFO fs.TrashPolicyDefault: Namenode trash configuration: Deletion interval = minutes, Emptier interval = minutes.
Moved: 'hdfs://mycluster/user/root/zhu' to trash at: hdfs://mycluster/user/root/.Trash/Current
[root@hdp2 tmp]# hdfs dfs -ls /user/root/zhu
ls: `/user/root/zhu': No such file or directory
[root@hdp2 tmp]#
- -touchz URI [URI …]
- Create a file of zero length
[root@hdp2 tmp]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 tmp]# hdfs dfs -touchz a.txt
[root@hdp2 tmp]# hdfs dfs -ls
Found items
drwx------ - root hdfs -- : .Trash
drwxr-xr-x - root hdfs -- : .hiveJars
-rw-r--r-- root hdfs -- : a.txt
-rw-r--r-- root hdfs -- : mapred
-rw-r--r-- root hdfs -- : rcc1
[root@hdp2 tmp]# hdfs dfs -cat /user/root/a.txt
[root@hdp2 tmp]#
- 小结:
- 本质就是linux文件操作命令
hadoop(五): shell命令的更多相关文章
- 【转】Hadoop FS Shell命令
FS Shell 调用文件系统(FS)Shell命令应使用 bin/hadoop fs <args> 的形式. 所有的的FS shell命令使用URI路径作为参数.URI格式是scheme ...
- hadoop入门:hadoop使用shell命令总结
第一部分:Hadoop Bin后面根据项目的实际需要Hadoop Bin 包括:Hadoop hadoop的Shellhadoop-config.sh 它的作用是对一些变量进行赋值 HAD ...
- Hadoop常见shell命令
Hadoop中常见的shell命令 1.如何将Linux本地的数据上传到HDFS中? hadoop fs -put 本地的文件 HDFS中的目录hdfs dfs -put 本地的文件 HDFS中的目录 ...
- hadoop(五)scp命令copy文件和配置(完全分布式准备二)|7
机器的克隆参考centos7克隆ip|机器名|映射关系|别名配置(hadoop完全分布式准备一) 那么问题来了,如果我们有30台机器,之间可以互相访问,那我们如何快速安装配置环境如jdk hadoop ...
- Hadoop Shell命令字典(可收藏)
可以带着下面问题来阅读: 1.chmod与chown的区别是什麽?2.cat将路径指定文件的内容输出到哪里?3.cp能否是不同之间复制?4.hdfs如何查看文件大小?5.hdfs如何合并文件?6.如何 ...
- Hadoop Shell命令字典
转载自:https://www.aboutyun.com//forum.php/?mod=viewthread&tid=6983&extra=page%3D1&page=1&a ...
- Hadoop Shell命令大全
hadoop支持命令行操作HDFS文件系统,并且支持shell-like命令与HDFS文件系统交互,对于大多数程序猿/媛来说,shell-like命令行操作都是比较熟悉的,其实这也是Hadoop的极大 ...
- Hadoop学习记录(2)|HDFS shell命令|体系结构
HDFS的shell 调用文件系统(FS)shell命令使用hadoop fs的形式 所有的FS shell命令使用URI路径作为参数. URI格式是scheme://authority/path.H ...
- 部分linux系统命令(shell 命令)和hadoop命令
linux系统命令(shell 命令): ls : 只列出文件/目录 ls -l : 会显示文件的详情,如大小等 ls -lh : 会显示文件的详情,但大小以k或者M为单位 ls ../ : ...
随机推荐
- 重学STM32----(一)
在这学习stm32半年的时间中,虽然明显的感觉到自己在进步,但是还是发现学习方法的错误.由于急功近利的性格,在学习stm32之初,我选择了最简单的办法,用库函数来写程序,而且也由于我这急功近利的性格, ...
- 联合与枚举 、 高级指针 、 C语言标准库(一)
1 输入一个整数,求春夏秋冬 1.1 问题 在实际应用中,有的变量只有几种可能取值.如人的性别只有两种可能取值,星期只有七种可能取值.在 C 语言中对这样取值比较特殊的变量可以定义为枚举类型.所谓枚举 ...
- Ubuntu 14.04 AM335x TI-RTOS 编译
/************************************************************************************* * Ubuntu 14.0 ...
- RPi 2B USB 远程桌面
/******************************************************************** * RPi 2B USB 远程桌面 * 说明: * 用作废的 ...
- Debian 入门安装与配置1
Debian 入门安装与配置1 最近安装了多个发行版本的Linux,包括Ubuntu.Fedora.Centos和Debian,发现只有Debian在界面和稳定性等综合特性上表现最优,自己也最喜欢,所 ...
- Install GD on mac
Lots of bioinformatics software are based on perl. Some of them, for example, Circos, NGS toolkit... ...
- scrollView滚动(通过代码)
平时的开发中可能会要求scrollview滚动,一般的方法时通过scrollview.scrollto(0,1000);来实现,但是注意这个方法是在scrollview停止动画之后才能执行的,因为如果 ...
- linux shell 逻辑运算符、逻辑表达式详解
shell的逻辑运算符 涉及有以下几种类型,因此只要适当选择,可以解决我们很多复杂的判断,达到事半功倍效果. 一.逻辑运算符 逻辑卷标 表示意思 1. 关于档案与目录的侦测逻辑卷标! -f 常用!侦测 ...
- Linux一些常用软件的源码安装
Sreen: wget ftp://ftp.gnu.org/pub/gnu/screen/screen-4.0.3.tar.gz .tar.gz cd screen- ./configure make ...
- Codeforces Round #280 (Div. 2) A B C 暴力 水 贪心
A. Vanya and Cubes time limit per test 1 second memory limit per test 256 megabytes input standard i ...