hdfs dfs命令
appendToFile
Usage: hdfs dfs -appendToFile <localsrc> ... <dst>
追加一个或者多个文件到hdfs制定文件中.也可以从命令行读取输入.
· hdfs dfs -appendToFile localfile /user/hadoop/hadoopfile
· hdfs dfs -appendToFile localfile1 localfile2 /user/hadoop/hadoopfile
· hdfs dfs -appendToFile localfile hdfs://nn.example.com/hadoop/hadoopfile
· hdfs dfs -appendToFile - hdfs://nn.example.com/hadoop/hadoopfile Reads the input from stdin.
Exit Code:
Returns 0 on success and 1 on error.
cat
Usage: hdfs dfs -cat URI [URI ...]
查看内容.
Example:
· hdfs dfs -cat hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
· hdfs dfs -cat file:///file3 /user/hadoop/file4
Exit Code:
Returns 0 on success and -1 on error.
Chgrp【change group】
Usage: hdfs dfs -chgrp [-R] GROUP URI [URI ...]
修改所属组.
Options
· The -R option will make the change recursively through the directory structure.
chmod
Usage: hdfs dfs -chmod [-R] <MODE[,MODE]... | OCTALMODE> URI [URI ...]
修改权限.
Options
· The -R option will make the change recursively through the directory structure.
chown
Usage: hdfs dfs -chown [-R] [OWNER][:[GROUP]] URI [URI ]
修改所有者.
Options
· The -R option will make the change recursively through the directory structure.
copyFromLocal
Usage: hdfs dfs -copyFromLocal <localsrc> URI
Similar to put command, except that the source is restricted to a local file reference.
Options:
· The -f option will overwrite the destination if it already exists.
copyToLocal
Usage: hdfs dfs -copyToLocal [-ignorecrc] [-crc] URI <localdst>
Similar to get command, except that the destination is restricted to a local file reference.
count
Usage: hdfs dfs -count [-q] [-h] <paths>
列出文件夹数量、文件数量、内容大小. The output columns with -count are: DIR_COUNT, FILE_COUNT, CONTENT_SIZE FILE_NAME
The output columns with -count -q are: QUOTA, REMAINING_QUATA, SPACE_QUOTA, REMAINING_SPACE_QUOTA, DIR_COUNT, FILE_COUNT, CONTENT_SIZE, FILE_NAME
The -h option shows sizes in human readable format.
Example:
· hdfs dfs -count hdfs://nn1.example.com/file1 hdfs://nn2.example.com/file2
· hdfs dfs -count -q hdfs://nn1.example.com/file1
· hdfs dfs -count -q -h hdfs://nn1.example.com/file1
Exit Code:
Returns 0 on success and -1 on error.
cp
Usage: hdfs dfs -cp [-f] [-p | -p[topax]] URI [URI ...] <dest>
复制文件(夹),可以覆盖,可以保留原有权限信息
Options:
· The -f option will overwrite the destination if it already exists.