我用已经搭建好的Hadoop集群做命令的展示,首先要在hadoop路径下的bin目录下进行
查看Hadoop文件
./hadoop fs -ls /
Found 3 items
drwxr-xr-x - hadoop supergroup 0 2019-04-18 16:41 /hbase001
drwxrwx--- - hadoop supergroup 0 2019-04-02 16:39 /tmp
drwxr-xr-x - hadoop supergroup 0 2019-04-02 16:21 /user
创建文件夹
./hadoop fs -mkdir /input
./hadoop fs -ls /
Found 4 items
drwxr-xr-x - hadoop supergroup 0 2019-04-18 16:41 /hbase001
drwxr-xr-x - hadoop supergroup 0 2019-07-04 10:22 /input
drwxrwx--- - hadoop supergroup 0 2019-04-02 16:39 /tmp
drwxr-xr-x - hadoop supergroup 0 2019-04-02 16:21 /user
级联创建文件夹
hadoop fs -mkdir -p /output/a
查看hsdf根目录下子文件夹里面的文件
hadoop fs -ls -R /output
上传文件
./hadoop fs -put test.txt /input
./hadoop fs -copyFromLocal test.txt /input
./hadoop fs -ls /input
Found 1 items
-rw-r--r-- 2 hadoop supergroup 0 2019-07-04 10:33 /input/test.txt
查看文件
./hadoop fs -cat /input/test.txt
./hadoop fs -tail –f /input/test.txt
下载文件
./hadoop fs -get /input ~/
./hadoop fs -copyToLocal /input ~/
删除文件
./hadoop fs -rm -r /input
修改文件权限
./hadoop fs -chmod 777 /input
复制文件
./hadoop fs -cp /input/test.txt /output
移动文件
./hadoop fs -mv /input/test.txt /output