Reading — step 1 of 5
Read
~2 min readFTP Basics
Control Commands
Common FTP commands (RFC 959):
| Command | Args | Purpose |
|---|---|---|
| USER | username | Login |
| PASS | password | Password |
| ACCT | account | Optional account info |
| QUIT | - | Goodbye |
| CWD | path | Change directory |
| CDUP | - | Up one directory |
| PWD | - | Print working dir |
| LIST | [path] | Directory listing |
| NLST | [path] | Names-only listing |
| RETR | path | Retrieve file |
| STOR | path | Store file |
| DELE | path | Delete file |
| MKD | path | Make directory |
| RMD | path | Remove directory |
| RNFR | path | Rename from |
| RNTO | path | Rename to |
| TYPE | A/I | ASCII or Binary |
| MODE | S/B/C | Stream/Block/Compressed |
| STRU | F/R/P | File/Record/Page structure |
| PORT | h1,h2,h3,h4,p1,p2 | Active mode endpoint |
| PASV | - | Passive mode |
| EPRT | - | Extended (IPv6 active) |
| EPSV | - | Extended passive |
| FEAT | - | List features |
| OPTS | option | Set option |
| HELP | [cmd] | Help |
| NOOP | - | Keep alive |
| AUTH | TLS | Start TLS |
| PROT | P | Protect data channel |
| ABOR | - | Abort transfer |
| ALLO | bytes | Allocate space (deprecated) |
| REIN | - | Reinitialize |
| STAT | [path] | Server status / file info |
| SIZE | path | File size |
| MDTM | path | File 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…