Collation of HDFS common commands
Brief introduction:
The HDFS file system provides quite a number of shell operation commands, which greatly facilitates programmers and system managers to view and modify files on HDFS. Further, the name and format of HDFS's operation commands are quite consistent with those of Unix/Linux 's commands, so the cost of learning HDFS commands is greatly reduced. 1. Command help [hadoop@hadoop000 ~] $hdfs dfsUsage: hadoop fs [generic options] [- appendToFile...] [- cat [- ignoreCrc]...] [- checksum...] [- chgrp [- R] GROUP PATH...] [- chmod [- R] PATH...] [- chown [- R] [OWNER] [: [GROUP]] PATH... ] [- copyFromLocal [- f] [- p] [- l] [- d]...] [- copyToLocal [- f] [- p] [- ignoreCrc] [- crc]...] [- count [- Q] [- h] [- v] [- t []] [- u] [- x]...] [- cp [- f] [- p |-p [topax] [- d]...] [- createSnapshot []] [- deleteSnapshot] [- df [- h] [...]] [- du [- s] [- h] [- x]...] [- expunge] [- find...] [- get [- f] ] [- p] [- ignoreCrc] [- crc]...] [- getfacl [- R]] [- getfattr [- R] {- n name |-d} [- e en]] [- getmerge [- nl] [- skip-empty-file]] [- help [cmd...]] [- ls [- C] [- d] [- h] [- Q] [- R] [- t] [- S] [- r] [- u] [..] [- mkdir [- p].] [- moveFromLocal...] [- moveToLocal] [- mv.] [- put [- f] [- p] [- l] [- d]. ] [- renameSnapshot] [- rm [- f] [- r |-R] [- skipTrash] [- safely]...] [- 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.] [- truncate [- w].] [ -usage [cmd...] # Note: hdfs dfs is equivalent to hadoop fs2. File manipulation command case
Hdfs dfs-copyFromLocal / local/data / hdfs/data: upload local files to hdfs (the original path can only be one file)
Hdfs dfs-put / tmp/ / hdfs/: different from copyFromLocal, the original path of put can be a folder, etc.
Hadoop fs-ls /: view the root directory file
Hadoop fs-ls / tmp/data: view the / tmp/data directory
Hadoop fs-cat / tmp/a.txt: view a.txt, same as-text
Hadoop fs-mkdir dir: create directory dir
Hadoop fs-get / aaa/jdk.tar.gz: equivalent to copyToLocal, which downloads files from hdfs to local
Hadoop fs-df-h /: statistics on the free space of the file system
Hadoop fs-cp / aaa/jdk.tar.gz / bbb/jdk.tar.gz.2: copy hdfs from one path of hdfs to another path
Hadoop fs-mv / aaa/jdk.tar.gz /: move files in the hdfs directory
Hadoop fs-du-s-h / aaa/*: size information of statistical folders
Hadoop fs-rm-r / aaa/bbb/: delete files or folders
Hadoop fs-rmdir / aaa/bbb/ccc: delete a directory
Hadoop fs-tail / weblog/access_log.1: displays the end of a file
3. Administrative command # command helps [hadoop@hadoop000 ~] $hdfs dfsadminUsage: hdfs dfsadminNote: Administrative commands can only be run as the HDFS superuser. [- report [- live] [- dead] [- decommissioning]] [- safemode] [- saveNamespace] [- rollEdits] [- restoreFailedStorage true | false | check] [- refreshNodes] [- setQuota.] [- clrQuota.] [- setSpaceQuota [- storageType].] [- clrSpaceQuota [- storageType].] [ -finalizeUpgrade] [- rollingUpgrade []] [- refreshServiceAcl] [- refreshUserToGroupsMappings] [- refreshSuperUserGroupsConfiguration] [- refreshCallQueue] [- refresh [arg1..argn] [- reconfig] [- printTopology] [- refreshNamenodes datanode_host:ipc_port] [- deleteBlockPool datanode_host:ipc_port blockpoolId [force]] [- setBalancerBandwidth] [- getBalancerBandwidth] [- fetchImage] [- allowSnapshot] [- disallowSnapshot] [- shutdownDatanode [upgrade]] [- evictWriters] [- getDatanodeInfo] [- metasave filename] [- triggerBlockReport [- incremental]] [- help [cmd]]
Hdfs dfsadmin-report: show all dataNode
Hdfs dfsadmin-safemode leave: leave safe mode