Skip to content
Control Commands
step 1/5

Reading — step 1 of 5

Read

~2 min readFTP Basics

Control Commands

Common FTP commands (RFC 959):

CommandArgsPurpose
USERusernameLogin
PASSpasswordPassword
ACCTaccountOptional account info
QUIT-Goodbye
CWDpathChange directory
CDUP-Up one directory
PWD-Print working dir
LIST[path]Directory listing
NLST[path]Names-only listing
RETRpathRetrieve file
STORpathStore file
DELEpathDelete file
MKDpathMake directory
RMDpathRemove directory
RNFRpathRename from
RNTOpathRename to
TYPEA/IASCII or Binary
MODES/B/CStream/Block/Compressed
STRUF/R/PFile/Record/Page structure
PORTh1,h2,h3,h4,p1,p2Active mode endpoint
PASV-Passive mode
EPRT-Extended (IPv6 active)
EPSV-Extended passive
FEAT-List features
OPTSoptionSet option
HELP[cmd]Help
NOOP-Keep alive
AUTHTLSStart TLS
PROTPProtect data channel
ABOR-Abort transfer
ALLObytesAllocate space (deprecated)
REIN-Reinitialize
STAT[path]Server status / file info
SIZEpathFile size
MDTMpathFile mtime

Reply codes:

  • 1xx: Provisional (transfer starting).
  • 2xx: Success.
  • 3xx: More info needed (e.g., USER → 331 sent password).
  • 4xx: Temporary failure (try later).
  • 5xx: Permanent failure.
C: USER alice
S: 331 Password required for alice
C: PASS s3cret
S: 230 Login successful
C: PWD
S: 257 "/home/alice"
C: TYPE I
S: 200 Type set to I (Binary)
C: PASV
S: 227 Entering Passive Mode (192,168,1,1,123,45)
C: RETR file.bin
S: 150 Opening data connection
[data flows on data channel]
S: 226 Transfer complete

Discussion

Ask a question, share an insight, or help someone who’s stuck.

Sign in to post a comment or reply.

Loading…