# hadoop fs / hdfs

## hadoop 指令用起來就像 Linux 指令一般，但他以 `Hadoop fs`作為指令，而以 Linux 指令作為 args。

## 常見的如下：

> * **顯示目錄下所有檔案 :**
>
> > ### **`hadoop fs -ls <hdfs file path>`**
>
> * **取得檔案內容 :**
>
> > ### **`hadoop fs -cat <hdfs file path>`**
>
> * **取得 尾部1000 字節內的檔案內容(同 unix 系統的 tail)：**
>
> > ### **`hadoop fs -tail <hdfs file path>`**
>
> * **搬動檔案 :**
>
> > ### **`hadoop fs -mv <hdfs file path>`**
>
> * **複製檔案 :**
>
> > ### **`hadoop fs -cp <hdfs file path from> <hdfs file path destination>`**
>
> * **建立路徑 :**
>
> > ### **`hadoop fs -mkdir <hdfs file path>`**
>
> * **確認檔案狀態 -e:檔案是否存在, -z: 檔案是否為空,  -d: 是否是目錄 :**
>
> > ### **`hadoop fs -test [-ezd]`**
>
> * **將本地檔案置放到 hdfs 上**
>
> > ### **`hadoop fs -put <local file> <hdfs file path>`**
>
> * **刪除檔案**
>
> > ### **`hadoop -rm [-r] <hdfs file path>`**

### 以上範例使用 hadoop fs ，但在新版本裡頭，這已經處於 deplicate 的狀態，後續建議用 hdfs dfs 的指令。


---

# 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://lin-guan-ting.gitbook.io/hdfs_/chapter1.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.
