FTP
protocolli
reti
comandi
trasferimento-file
30 apr 2026
Basic FTP Commands
FTP (File Transfer Protocol) is a standard network protocol for transferring files between a client and a server. It follows the client-server model and uses two separate TCP connections: one for commands (port 21) and one for data (port 20 in active mode).
Starting the FTP client
ftp # Opens the interactive FTP client
ftp hostname # Opens the client and connects directly
ftp 192.168.1.10 # Connect via IP address
Connection commands
| Command | Description |
|---|
open <host> | Opens a connection to the specified server |
user <username> | Specifies the username for authentication |
pass <password> | Specifies the password (not recommended in plaintext) |
bye / quit | Closes the connection and exits the FTP client |
close | Closes the server connection but keeps the client open |
disconnect | Synonym for close |
ftp> open ftp.example.com
Connected to ftp.example.com.
Name (ftp.example.com:user): mario
Password: ****
230 Login successful.
Remote and local navigation
| Command | Description |
|---|
ls / dir | Lists files in the current remote directory |
ls -la | Detailed listing (including hidden files) |
cd <dir> | Changes the remote directory |
cd .. | Moves up one level in the remote directory tree |
pwd | Shows the current remote directory |
mkdir <dir> | Creates a directory on the remote server |
rmdir <dir> | Removes a directory on the remote server |
delete <file> | Deletes a file on the remote server |
rename <old> <new> | Renames a file on the remote server |
lcd <dir> | Changes the local directory (on your PC) |
!pwd | Shows the current local directory |
Download (server → client)
| Command | Description |
|---|
get <file> | Downloads a single file from the server |
get <file> <local_name> | Downloads and renames the file locally |
mget <pattern> | Downloads multiple files (e.g. mget *.txt) |
recv <file> | Synonym for get |
ftp> get document.pdf
ftp> get report.docx draft_report.docx
ftp> mget *.jpg
With mget the client asks for confirmation for each file. To disable confirmation: prompt off
Upload (client → server)
| Command | Description |
|---|
put <file> | Uploads a single file to the server |
put <file> <remote_name> | Uploads and renames the file on the server |
mput <pattern> | Uploads multiple files (e.g. mput *.csv) |
send <file> | Synonym for put |
append <file> | Appends the local file to the end of a remote file |
ftp> put report.pdf
ftp> put draft.txt final.txt
ftp> mput *.log
Transfer modes
FTP supports two transfer modes that must be selected correctly before uploading or downloading files.
| Command | Mode | Use |
|---|
ascii | ASCII text | Text files (.txt, .csv, .html) |
binary | Binary (raw) | Any other file (.pdf, .zip, .jpg, .exe) |
ftp> ascii
200 Switching to ASCII mode.
ftp> get readme.txt
ftp> binary
200 Switching to Binary mode.
ftp> get archive.zip
Warning: transferring binary files in ASCII mode corrupts them. Always use binary when in doubt.
Session management
| Command | Description |
|---|
prompt | Toggles interactive confirmation for mget/mput |
prompt off | Disables confirmations (transfers everything without asking) |
status | Shows connection status and current settings |
hash | Toggles display of # characters during transfer |
verbose | Toggles display of server messages |
help / ? | Shows the list of available commands |
help <command> | Shows help for a specific command |
Running local commands
Any command prefixed with ! is executed on the local machine without leaving FTP:
ftp> !ls # list local files
ftp> !pwd # current local directory
ftp> !mkdir new_folder # create local folder
ftp> !cat file.txt # display local file content
Complete session example
$ ftp ftp.example.com
Connected to ftp.example.com.
Name: mario
Password:
230 Login successful.
ftp> ls
200 PORT command successful.
226 Directory send OK.
archive/ documents/ readme.txt
ftp> cd documents
250 Directory successfully changed.
ftp> binary
200 Switching to Binary mode.
ftp> get report.pdf
226 Transfer complete.
ftp> lcd /home/mario/upload
ftp> put project.zip
226 Transfer complete.
ftp> mget *.csv
prompt off
ftp> mget *.csv
226 Transfer complete.
ftp> bye
221 Goodbye.
Essential commands summary
| Category | Commands |
|---|
| Connection | open, user, bye, close |
| Remote navigation | ls, dir, cd, pwd, mkdir |
| Local navigation | lcd, !pwd, !ls |
| Download | get, mget |
| Upload | put, mput |
| Transfer mode | ascii, binary |
| Utilities | prompt, hash, status, help |
Security notes
FTP transmits credentials and data in plaintext on the network. For production environments, prefer:
- SFTP (SSH File Transfer Protocol) — secure transfer over SSH, port 22
- FTPS (FTP over SSL/TLS) — encrypted FTP, port 990 (implicit) or 21 (explicit)
- SCP (Secure Copy) — secure copy over SSH