# HDFS常用命令

\[TOC]

## HDFS 常用命令

### ls

`hdfs dfs ls`

### cat

`hdfs dfs -cat /filepath/filename`

### put: 上传本地文件到HDFS

`hdfs dfs -put /localfilepath/filename /hdfspath/`

例如复制当前文件夹下的`file.txt`文件到`hdfs`中的`/user/bovenson/input`命令为:

```
hdfs dfs -put ./file.txt /user/bovenson/input/
```

### get: 从HDFS获取文件到本地

`hdfs dfs -get /hdfsfilepath/filename /localpath/`

例如复制`hdfs`中`/user/bovenson/input`目录下所有文件, 到当前目录下:

`hdfs dfs -get /user/bovenson/input/* ./`

### mkdir

`hdfs dfs -mkdir input/countword`

### mv

`hdfs dfs -mv input/file* input/countword`

### rm

`hdfs dfs -rm /hdfs/path/to/filename`

&#x20;**未完待续...**&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://note.wii.pub/computer-science/data-analysis/hadoop/hdfs-chang-yong-ming-ling.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
