> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/ask/flat/chapter-36-file-transfer-protocol-ftp/di-36.1-jie-wen-jian-chuan-shu-xie-yi-ftp-gai-shu.md).

# 36.1 Overview of File Transfer Protocol (FTP)

The File Transfer Protocol (FTP) provides users with file upload and download services.

## Overview

FTP (File Transfer Protocol) is one of the earliest application-layer protocols in the TCP/IP protocol suite, used for network file transfer.

Setting up an FTP server on FreeBSD enables fast file transfer and sharing in both LAN and internet environments.

This section introduces three commonly used FTP server software packages:

| Software  | Features                                                                                                                                                                                     | Use Cases and Target Users                                                      |
| --------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------- |
| Pure-FTPd | ISC license (functionally equivalent to the 2-clause BSD license), security-first, supports multiple operating systems, relatively complete implementation of the FTP protocol specification | Provides high flexibility for ISPs and hosting services, suitable for beginners |
| ProFTPD   | GPLv2 license, supports multiple operating systems, single main configuration file, strong extensibility                                                                                     | Suitable for users familiar with Apache HTTP Server (similar syntax)            |
| vsftpd    | GPLv2 (with exception clauses) license, supports IPv6 and SSL encryption, supports virtual users, virtual IPs, fine-grained user and IP control, bandwidth limiting                          | Oriented towards production environments                                        |

## Security of the FTP Protocol

The standard FTP protocol transmission process is insecure: both passwords and data are sent in plaintext, and no encryption is applied by default.

~~Perhaps completely phasing out the FTP protocol is the only solution.~~

> **Note**
>
> Running an anonymous FTP server may pose potential risks. In particular, careful consideration should be given to whether anonymous users are allowed to upload files. FTP sites may become venues for unauthorized commercial software transactions, or even lead to more serious consequences. If anonymous FTP uploads are required, ensure that permissions are set correctly so that other anonymous users cannot read files before the administrator reviews them.

## FTP Client Usage Examples

Using telnet to test the FTP service:

```sh
# telnet localhost 21
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
220 FTP Server ready
quit
221 Goodbye.
```

The above command is used to test whether port 21 of the FTP service on the local host is available.

Using the `ftp` command provides a convenient way to connect to an FTP server. Its basic usage is as follows:

```sh
ftp [options] [IP address]
```

FTP commands:

```sh
put              Upload
bell             Sound a beep when file transfer is complete
dir/ls           Display files and folders in the current directory
cd               Change directory
delete           Delete a file
get remote_file  Download a remote file from the server
bye              End the session with the server
```

In addition, the following FTP protocol commands can be sent to the server via `quote`:

```sh
quote acct [account_info]  Submit account information (sends the ACCT command)
quote feat                 Display the features supported by this server (sends the FEAT command)
```

Operation example:

```powershell
PS C:\Users\ykla> ftp 192.168.179.150	# Connect to the specified FTP server using the FTP client
Connected to 192.168.179.150.
220 Welcome to blah FTP service.
200 Always in UTF8 mode.
User(192.168.179.150:(none)): ftptest
331 Please specify the password.
Password:

230 Login successful.
ftp> ls	# List files and subdirectories in the current FTP directory
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
FreeBSD完全攻略QA版 (冯宝坤，陈子鸿编著, 冯宝坤, 陈子鸿编著, 冯宝坤, 陈子鸿).pdf
FreeBSD技术内幕 ((美) Michael Urban，(美)Brian Tiemann著 智慧东方工作室译).pdf
哲学史期末.docx
马克思主义哲学原理.doc
226 Directory send OK.
ftp: 288 bytes received in 0.00 seconds 96.00 KB/s.
ftp> delete 哲学史期末.docx
250 Delete operation successful.
ftp> dir	# Display a detailed file listing of the current FTP directory, including permissions, size, and modification time
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 1003     14       147170778 Mar 06 15:39 FreeBSD完全攻略QA版 (冯宝坤，陈子鸿编著, 冯宝坤, 陈子鸿编著, 冯宝坤, 陈子鸿).pdf
-rw-------    1 1003     14       47037557 Mar 06 15:39 FreeBSD技术内幕 ((美) Michael Urban，(美)Brian Tiemann著 智慧东方工作室译).pdf
-rw-------    1 1003     14         591146 Oct 20 11:28 马克思主义哲学原理.doc
226 Directory send OK.
ftp: 435 bytes received in 0.01 seconds 54.38 KB/s.
ftp> get 马克思主义哲学原理.doc
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 马克思主义哲学原理.doc (591146 bytes).
226 Transfer complete.
ftp: 591146 bytes received in 0.01 seconds 42224.71 KB/s.
ftp> ls
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
FreeBSD完全攻略QA版 (冯宝坤，陈子鸿编著, 冯宝坤, 陈子鸿编著, 冯宝坤, 陈子鸿).pdf
FreeBSD技术内幕 ((美) Michael Urban，(美)Brian Tiemann著 智慧东方工作室译).pdf
马克思主义哲学原理.doc
226 Directory send OK.
ftp: 266 bytes received in 0.00 seconds 66.50 KB/s.
ftp> lcd
Local directory now C:\Users\ykla.
ftp> put UOS使用打印机.pdf	# Upload a local file to the FTP server
200 PORT command successful. Consider using PASV.
150 Ok to send data.
226 Transfer complete.
ftp: 1269989 bytes sent in 0.04 seconds 36285.40 KB/s.
ftp> dir
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-------    1 1003     14       147170778 Mar 06 15:39 FreeBSD完全攻略QA版 (冯宝坤，陈子鸿编著, 冯宝坤, 陈子鸿编著, 冯宝坤, 陈子鸿).pdf
-rw-------    1 1003     14       47037557 Mar 06 15:39 FreeBSD技术内幕 ((美) Michael Urban，(美)Brian Tiemann著 智慧东方工作室译).pdf
-rw-------    1 1003     14        1269989 Mar 27 15:13 UOS使用打印机.pdf
-rw-------    1 1003     14         591146 Oct 20 11:28 马克思主义哲学原理.doc
226 Directory send OK.
ftp: 515 bytes received in 0.01 seconds 46.82 KB/s.
ftp> bye	# Disconnect from the FTP server and exit the client
221 Goodbye.
```

FTP downloads files to the current working directory by default (i.e., the directory where the ftp command was started).


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://book.bsdcn.org/ask/flat/chapter-36-file-transfer-protocol-ftp/di-36.1-jie-wen-jian-chuan-shu-xie-yi-ftp-gai-shu.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.
