Skip to content
Search

File Transfer Protocol

lastmod 2026-02-20created 2014-01-0416 edits

File Transfer Protocol (FTP) is a protocol for transferring files between a server and a client over the TCP/IP protocol. FTP belongs to the application layer of the TCP/IP protocol table, and although it has a long history, it is still frequently used on the Internet.

Connection types

Unlike HTTP, there are two types of connections:

  • Command connection: First, a connection for user authentication and commands is made to the server's port 21, the control port, and the commands issued by the client are delivered through it.
  • Data transfer connection: For the actual file transfer, a new connection is made when needed.
    • Active mode (photo mode): The server makes a data connection from its data port, port 20, to the point specified by the client. The port specified by the client is usually one numbered above 1023. It may not work well when the client is in an environment that uses a firewall, NAT (IP masquerading), etc.; in that case, use passive mode.
    • Passive mode: Lets the client connect to the server port specified by the server. In this case, both sides usually use ports above 1023.

In either mode, two connections are made. However, if the FTP port is changed and there is a firewall, depending on the firewall's Inspection mode settings, FTP communication may work normally while communication that uses the FTP-DATA port, such as the get or ls commands, may not.

Example

get
Download
mget
Download multiple files
put
Upload
mput
Upload multiple files
ls
List files on the connected SFTP
!ls
List files on the local server
!{명령어}
Run on the local server

Main FTP commands

Command

RFC

Description

ABOR

-

Abort the current file transfer

ACCT

-

Account information

ADAT

RFC 2228

Authentication/security data

ALLO

-

Allocate enough disk space to receive a file

APPE

-

Append

AUTH

RFC 2228

Authentication/security mechanism

CCC

RFC 2228

Clear command channel

CDUP

-

Change to parent directory

CONF

RFC 2228

Confidentiality protection command

CWD

-

Change working directory

DELE

-

Delete file

ENC

RFC 2228

Privacy protected channel

EPRT

RFC 2428

Specify an extended address and port needed for server connection

EPSV

RFC 2428

Enter extended passive mode

FEAT

RFC 2389

Show list of features added by the server

LANG

RFC 2640

Language negotiation

LIST

-

Returns information about a file or directory if specified. If not specified, returns information about the current working directory

LPRT

RFC 1639

Specify a long address and list needed for server connection

LPSV

RFC 1639

Enter long passive mode

MDTM

RFC 3659

Return the last modified time of the specified file

MIC

RFC 2228

Integrity protected command

MKD

-

Make directory

MLSD

RFC 3659

Shows the contents of a directory if a directory is named

MLST

RFC 3659

Provides data only for what was entered on the command line

MODE

-

Set transfer mode (stream, block, compressed)

NLST

-

Return a list of file names in the specified directory

NOOP

-

No operation (dummy packet: usually used to check whether the line is alive)

OPTS

RFC 2389

Select feature options

PASS

-

Password

PASV

-

Enter passive mode

PBSZ

RFC 2228

Protection buffer size

PORT

-

Specify an address and port needed for server connection

PROT

RFC 2228

Data channel protection level

PWD

-

Print working directory. Returns the current directory of the host computer

QUIT

-

Disconnect

REIN

-

Reinitialize the connection

REST

-

Restart transfer from the specified point

RETR

-

Transfer a copy of the file

RMD

-

Remove directory

RNFR

-

Rename from (original name)

RNTO

-

Rename to (target name)

SITE

-

Send the specified command to the remote server

SIZE

RFC 3659

Return file size

SMNT

-

Mount file structure

STAT

-

Return current status

STOR

-

Accept data and store it as a file on the server side

STOU

-

Store file uniquely

STRU

-

Set transfer structure

SYST

-

Return system type

TYPE

-

Set transfer mode (ASCII/binary)

USER

-

Authentication user name

Main FTP response codes

  • 200: Command OK.
  • 500: Syntax error, command not recognized.
  • 501: Syntax error in parameters or arguments.
  • 502: Command not implemented.
  • 110: Restart marker reply.
  • 119: Terminal not available, attempting mailbox function.
  • 211: System status, or system help reply.
  • 212: Directory status.
  • 213: File status.
  • 214: Help message.
  • 120: Service ready in nnn minutes.
  • 125: Data connection already open; transfer starting.
  • 225: Data connection open; no transfer in progress.
  • 425: Can't open data connection.
  • 226: Closing data connection; requested file action successful.
  • 227: Entering passive mode. h1, h2, h3, h4, p1, p2.
  • 230: User logged in, proceed.
  • 530: Not logged in.
  • 331: User name ok, need password.
  • 332: Need account for login.
  • 532: Need account for storing files.
  • 150: File status ok; about to open data connection.
  • 152: Unknown user; mail will be forwarded by the administrator.
  • 250: Requested file action ok, completed.
  • 350: Requested file action pending further information.
  • 450: Requested file action not taken: file unavailable.
  • 550: Requested action not taken: file unavailable.
  • 451: Requested action aborted: local error in processing.
  • 551: Requested action aborted: page type unknown.
  • 452: Requested action not taken: insufficient storage space in system.
  • 552: Requested file action aborted: exceeded storage allocation.
  • 553: Requested action not taken: no file name.

Projects

ftpclient-cpp
https://github.com/embeddedmz/ftpclient-cpp
C++ client for making FTP requests
FileZilla
FTP client
fineftp-server
https://github.com/continental/fineftp-server
C++ FTP Server Library for Windows, Linux & more

Network-attached storage (NAS)

See also

Favorite site

References


  1. List_of_ftp_server_return_codes.pdf ↩

author Zer0 sitemap