What are the common commands of HDFS
In this article, the editor introduces in detail "what are the common commands of HDFS", which are detailed, the steps are clear, and the details are handled properly. I hope that this article "what are the common commands of HDFS" can help you solve your doubts.
Since HDFS is a distributed file system for accessing data, the operation of HDFS is the basic operation of the file system, such as file creation, modification, deletion, modification permissions, folder creation, deletion, renaming and so on. The operation command for HDFS is similar to the operation of Linux's shell for files, such as ls, mkdir, rm, and so on.
1. Basic operation
1. Create a directory
Hadoop fs-mkdir / hdfs # create a hdfs folder under the root directory
2. View the catalog
> hadoop fs-ls / # lists the files in the directory drwxr-xr-x-root supergroup 0 2016-03-05 00:06 / hdfs
3. Cascade create directory
> hadoop fs-mkdir-p / hdfs/d1/d2
4. Cascading list catalogue
> hadoop fs-ls-R / drwxr-xr-x-root supergroup 0 2016-03-05 00:10 / hdfsdrwxr-xr-x-root supergroup 0 2016-03-05 00:10 / hdfs/d1drwxr-xr-x-root supergroup 0 2016-03-05 00:10 / hdfs/d1/d2
5. Upload local files to HDFS
> echo "hello hdfs" > > local.txt > hadoop fs-put local.txt / hdfs/d1/d2
6. View the contents of files in HDFS
> hadoop fs-cat / hdfs/d1/d2/local.txthello hdfs
7. Download the contents of the file on hdfs
> hadoop fs-get / hdfs/d1/d2/local.txt
8. Delete the hdfs file
> hadoop fs-rm / hdfs/d1/d2/local.txtDeleted / hdfs/d1/d2/local.txt
9. Delete the directory in hdfs
> hadoop fs-rmdir / hdfs/d1/d2
10. Modify the permissions of the file
> hadoop fs-ls / hdfsdrwxr-xr-x-root supergroup 0 2016-03-05 00:21 / hdfs/d1 # Note File permissions > hadoop fs-chmod 777 / hdfs/d1drwxrwxrwx-root supergroup 0 2016-03-05 00:21 / hdfs/d1 # modified
11. Modify the user to which the file belongs
> hadoop fs-chown admin / hdfs/d1 # modify the user of the file as admin > hadoop fs-ls / hdfsdrwxrwxrwx-admin supergroup 0 2016-03-05 00:21 / hdfs/d1
12. Modify the user group of the file
> hadoop fs-chgrp admin / hdfs/d1 > hadoop fs-ls / hdfsdrwxrwxrwx-admin admin 0 2016-03-05 00:21 / hdfs/d1
As there are a lot of commands for hdfs operation, we will explain the more common operations above.
2. All commands for HDFS file operation
View mode hadoop fs
[root@iZ28csbxcf3Z ~] # hadoop fsUsage: hadoop fs [generic options] [- appendToFile...] [- cat [- ignoreCrc]...] [- checksum...] [- chgrp [- R] GROUP PATH...] [- chmod [- R] PATH...] [- chown [- R] [OWNER] [: [GROUP]] PATH...] [- copyFromLocal [- f] [- p] [- l].] [- copyToLocal [ -p] [- ignoreCrc] [- crc]...] [- count [- Q] [- h]...] [- cp [- f] [- p |-p [topax]...] [- createSnapshot []] [- deleteSnapshot] [- df [- h] [...] [- du [- s] [- h]...] [- expunge] [- get [- p] [- ignoreCrc] [- crc]...] [- getfacl [- R]] [- getfattr [- R] {- n name |-d} [- e en]] [- getmerge [- nl]] [- help [cmd.]] [- ls [- d] [- h] [- R] [...] [- mkdir [- p].] [- moveFromLocal.] [- moveToLocal] [- mv. .] [- put [- f] [- p] [- l]...] [- renameSnapshot] [- rm [- f] [- r |-R] [- skipTrash]...] [- rmdir [- ignore-fail-on-non-empty]...] [- setfacl [- R] [{- b |-k} {- m |-x}] | [--set]] [- setfattr {- n name [- v value] | |-x name}] [- setrep [- R] [- w].] [- stat [format].] [- tail [- f]] [- test-[defsz]] [- text [- ignoreCrc].] [- touchz.] [- usage [cmd.]] After reading this, the article "what are the common commands of HDFS" has been introduced. If you want to master the knowledge points of this article, you still need to practice and use it yourself. If you want to know more about related articles, welcome to follow the industry information channel.