Big data-the final part of the complete Collection of commonly used hadoop commands
Software environment
RHEL6.8hadoop2.8.1apache-maven-3.3.9findbugs-1.3.9protobuf-2.5.0.tar.gzjdk-8u45
(operating environment root installation started hadoop)
Hadoop fs = = hdfs dfs
Upload files to the root directory of hadoop / download to local
Hadoop dfs-put filename /
Hadoop dfs-get / filename
#'/'is not the root directory of Linux, but represents the root directory of hadoop
Upload and download files
[root@hadoop01 software] # hdfs dfs-put apache-maven-3.3.9-bin.zip /
[root@hadoop01 software] # hdfs dfs-ls /
[root@hadoop01 software] # hdfs dfs-put apache-maven-3.3.9-bin.zip /
[root@hadoop01 software] # cd
[root@hadoop01 ~] # hdfs dfs-get / apache-maven-3.3.9-bin.zip
Help
[- moveFromLocal...]
[- moveToLocal]
Check the contents of the files in hadoop
Hadoop dfs-ls /
[root@hadoop01 ~] # hdfs dfs-ls /
Found 3 items
-rw-r--r-- 3 root supergroup 8617253 2018-04-26 09:20 / apache-maven-3.3.9-bin.zip
-rw-r--r-- 3 root supergroup 59776 2018-04-26 09:14 / install.log
-rw-r--r-- 3 root supergroup 11067 2018-04-26 08:46 / install.log.syslog
View the contents of the files in hadoop
Hadoop fs-cat filename
[root@hadoop01 ~] # hadoop fs-cat / file1
one hundred and eleven
Create a folder
Hadoop fs-mkdir-p / filename/filename
[root@hadoop01] # hadoop fs-mkdir-p / filename/filename
Delete file Delete dir
[root@hadoop01] # hadoop fs-rm-r-f / file1
Deleted / file1
[root@hadoop01] # hadoop fs-rm-r-f / filename
Deleted / filename
# [- rm [- f] [- r |-R] [- skipTrash] [- safely].]
1. Configure the Recycle Bin
Vi core-site.xml
Fs.trash.interval
10080 # Recycle Bin retention time (minutes)
two。 test
Hadoop fs-rm-r-f / xxxx enters the Recycle Bin and can be recovered.
Hadoop fs-rm-r-f-skipTrash / xxxx cannot be recovered without entering the Recycle Bin.
a. Enter the Recycle Bin
[root@hadoop01 ~] # hadoop fs-ls /
Found 4 items
-rw-r--r-- 3 root supergroup 8617253 2018-04-26 09:20 / apache-maven-3.3.9-bin.zip
Drwxr-xr-x-root supergroup 0 2018-04-26 09:35 / dir
-rw-r--r-- 3 root supergroup 59776 2018-04-26 09:14 / install.log
-rw-r--r-- 3 root supergroup 11067 2018-04-26 08:46 / install.log.syslog
[root@hadoop01] # hadoop fs-rm-r-f / install.log
09:38:28 on 18-04-26 INFO fs.TrashPolicyDefault: Moved: 'hdfs://172.16.18.133:9000/install.log' to trash at: hdfs://172.16.18.133:9000/user/root/.Trash/Current/install.log
[root@hadoop01 ~] # hadoop fs-ls
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38. Trash
[root@hadoop01 ~] # hadoop fs-ls
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38. Trash
[root@hadoop01] # hadoop fs-ls. Trash /
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38. Trash / Current
[root@hadoop01 ~] # hadoop fs-ls. Trash / Current
Found 1 items
-rw-r--r-- 3 root supergroup 59776 2018-04-26 09:14. Trash / Current/install.log
Restore the file you just deleted
[root@hadoop01 ~] # hadoop fs-ls / user
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38 / user/root
[root@hadoop01 ~] # hadoop fs-ls / user/root/
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38 / user/root/.Trash
[root@hadoop01 ~] # hadoop fs-mv / user/root/.Trash/Current/install.log /
[root@hadoop01 ~] # hadoop fs-ls /
Found 5 items
-rw-r--r-- 3 root supergroup 8617253 2018-04-26 09:20 / apache-maven-3.3.9-bin.zip
Drwxr-xr-x-root supergroup 0 2018-04-26 09:35 / dir
-rw-r--r-- 3 root supergroup 59776 2018-04-26 09:14 / install.log
-rw-r--r-- 3 root supergroup 11067 2018-04-26 08:46 / install.log.syslog
Drwx--root supergroup 0 2018-04-26 09:38 / user
b. Do not enter the Recycle Bin
[root@hadoop01] # hadoop fs-rm-r-f-skipTrash / install.log.syslog
Deleted / install.log.syslog
[root@hadoop01 ~] # hadoop fs-ls
Found 1 items
Drwx--root supergroup 0 2018-04-26 09:38. Trash
[root@hadoop01 ~] # hadoop fs-ls. Trash / Current
[root@hadoop01 ~] #
Hdfs fs-moveFromLocal / input/xx.txt / input/xx.txt-cut and paste locally to hdfs
Hdfs fs-moveToLocal / input/xx.txt / input/xx.txt-cut and paste from hdfs to local
Hdfs fs-appedToFile. / hello.txt / input/hello.txt-append a file to the end of another file
Note: appedToFile moveToLocal moveFromLocal is strictly case-sensitive
Hdfs fs-cat / input/hello.txt-View the contents of the file
Hdfs fs-tail / input/hello.txt-displays a file to the end
Hdfs fs-text / input/hello.txt-print the contents of the file as a string
Hdfs fs-chmod 666 / input/hello.txt-modify file permissions
Hdfs fs-chown ruoze.ruoze / input/hello.txt-- modify the file to which it belongs
Hdfs fs-copyFromLocal / input/hello.txt / input/-- copy from the local file system to hdfs
Hdfs fs-copyToLocal / input/hello.txt / input/-- copy from hdfs to local
Hdfs fs-cp / input/xx.txt / output/xx.txt-copy from hdfs to one path to another
Hdfs fs-mv / input/xx.txt / output/xx.txt-move from hdfs to one path to another
Hdfs fs-df-h /-statistics on the free space information of the file system
Hdfs fs-du-s-h /-Statistics folder size information
Hadoop fs-count / aaa-count the number of file nodes in a specified directory
Hadoop fs-setrep 3 / input/xx.txt-sets the number of file copies for hdfs