hadoop hdfs 常用命令

2021-09-01 16:29:08 字數 2041 閱讀 8621

[size=large]hadoop常用命令:

hadoop fs

檢視hadoop hdfs支援的所有命令

hadoop fs –ls

列出目錄及檔案資訊

hadoop fs –lsr

迴圈列出目錄、子目錄及檔案資訊

hadoop fs –put test.txt /user/sunlightcs

將本地檔案系統的test.txt複製到hdfs檔案系統的/user/sunlightcs目錄下

hadoop fs –get /user/sunlightcs/test.txt .

將hdfs中的test.txt複製到本地檔案系統中,與-put命令相反

hadoop fs –cat /user/sunlightcs/test.txt

檢視hdfs檔案系統裡test.txt的內容

hadoop fs –tail /user/sunlightcs/test.txt

檢視最後1kb的內容

hadoop fs –rm /user/sunlightcs/test.txt

從hdfs檔案系統刪除test.txt檔案,rm命令也可以刪除空目錄

hadoop fs –rmr /user/sunlightcs

刪除/user/sunlightcs目錄以及所有子目錄

hadoop fs –copyfromlocal test.txt /user/sunlightcs/test.txt

從本地檔案系統複製檔案到hdfs檔案系統,等同於put命令

hadoop fs –copytolocal /user/sunlightcs/test.txt test.txt

從hdfs檔案系統複製檔案到本地檔案系統,等同於get命令

hadoop fs –chgrp [-r] /user/sunlightcs

修改hdfs系統中/user/sunlightcs目錄所屬群組,選項-r遞迴執行,跟linux命令一樣

hadoop fs –chown [-r] /user/sunlightcs

修改hdfs系統中/user/sunlightcs目錄擁有者,選項-r遞迴執行

hadoop fs –chmod [-r] mode /user/sunlightcs

修改hdfs系統中/user/sunlightcs目錄許可權,mode可以為相應許可權的3位數或+/-,選項-r遞迴執行

hadoop fs –count [-q] path

檢視path目錄下,子目錄數、檔案數、檔案大小、檔名/目錄名

hadoop fs –cp src [src …] dst

將檔案從src複製到dst,如果指定了多個src,則dst必須為乙個目錄

hadoop fs –du path

顯示該目錄中每個檔案或目錄的大小

hadoop fs –dus path

類似於du,path為目錄時,會顯示該目錄的總大小

hadoop fs –expunge

清空**站,檔案被刪除時,它首先會移到臨時目錄.trash/中,當超過延遲時間之後,檔案才會被永久刪除

hadoop fs –getmerge src [src …] localdst [addnl]

獲取由src指定的所有檔案,將它們合併為單個檔案,並寫入本地檔案系統中的localdst,選項addnl將在每個檔案的末尾處加上乙個換行符

hadoop fs –touchz path

建立長度為0的空檔案

hadoop fs –test –[ezd] path

對path進行如下型別的檢查:

-e path是否存在,如果path存在,返回0,否則返回1

-z 檔案是否為空,如果長度為0,返回0,否則返回1

-d 是否為目錄,如果path為目錄,返回0,否則返回1

hadoop fs –text path

顯示檔案的內容,當檔案為文字檔案時,等同於cat,檔案為壓縮格式(gzip以及hadoop的二進位制序列檔案格式)時,會先解壓縮

hadoop fs –help ls

檢視某個[ls]命令的幫助文件 [/size]

hadoop hdfs常用命令

1.hadoop fs 檢視hadoop hdfs支援的所有命令 2.hadoop fs ls 列出目錄及檔案資訊 3.hadoop fs lsr 迴圈列出目錄 子目錄及檔案資訊 4.hadoop fs put test.txt user sunlightcs 將本地檔案系統的test.txt複製到...

Hadoop hdfs常用命令

model host2 hadoop dfs ls deprecated use of this script to execute hdfs command is deprecated.instead use the hdfs command for it.found 3 items drwx m...

hadoop HDFS常用命令

hdfs提供 shell 命令列客戶端,使用方法如下 cat ignorecrc checksum chgrp r group path.chmod r path.chown r owner group path.copyfromlocal f p copytolocal p ignorecrc c...