Catalog / FTP Commands Cheatsheet

FTP Commands Cheatsheet

A quick reference guide to commonly used FTP (File Transfer Protocol) commands. This cheat sheet covers basic commands for connecting to FTP servers, navigating directories, uploading, and downloading files. It's designed for users interacting with FTP through a command-line interface.

Basic FTP Commands

Connection and Authentication

ftp [hostname]

Connects to the specified FTP server.

open [hostname]

Opens a connection to the specified host.

user [username]

Specifies the username for login.

password [password]

Specifies the password for the user.

account [account-name]

Sends a supplemental account password required by some systems.

close

Closes the current FTP connection.

bye or quit

Terminates the FTP session and exits.

Navigation

pwd

Prints the current working directory on the remote server.

ls or dir

Lists the files and directories in the current remote directory.

cd [directory]

Changes the current directory on the remote server.

cdup

Changes to the parent directory on the remote server.

mls [remote-files] [local-file]

Generates a listing of the specified remote files.

File Transfer Commands

Downloading Files

get [remote-file] [local-file]

Downloads a single file from the remote server. If local-file is not specified, the file is downloaded to the current directory with the same name as the remote-file.

mget [remote-files]

Downloads multiple files from the remote server using wildcard characters.

recv [remote-file] [local-file]

Alias for get command.

Uploading Files

put [local-file] [remote-file]

Uploads a single file to the remote server. If remote-file is not specified, the file is uploaded to the current directory with the same name as the local-file.

mput [local-files]

Uploads multiple files to the remote server using wildcard characters.

send [local-file] [remote-file]

Alias for put command.

append [local-file] [remote-file]

Appends a local file to a remote file. If the remote file doesn’t exist, it will be created.

mput [local-files]

Upload multiple files using wildcards.

File Management

delete [remote-file]

Deletes a file on the remote server.

mdelete [remote-files]

Deletes multiple files on the remote server using wildcard characters.

rename [old-name] [new-name]

Renames a file on the remote server.

mkdir [directory-name]

Creates a new directory on the remote server.

rmdir [directory-name]

Removes a directory on the remote server.

Advanced FTP Commands

Transfer Modes

ascii

Sets the transfer mode to ASCII (text) mode.

binary

Sets the transfer mode to binary mode. Essential for non-text files like images or executables.

image

Alias for binary mode.

type [type-name]

Sets the file transfer type. Use type ascii or type binary.

Other Useful Commands

status

Displays the current status of the FTP connection.

system

Shows the type of operating system running on the remote server.

help [command]

Displays help information for the specified FTP command.

! or shell

Escapes to the local shell.

prompt

Toggles prompting during multiple file transfers. Useful to turn off for automated scripts.

verbose

Toggles verbose mode. When on, displays more detailed output.

Passive and Active Modes

Understanding Transfer Modes

FTP can operate in two modes: Active and Passive. These modes define how the data connection (used for transferring files) is established. The choice of mode is often determined by firewall configurations.

Active Mode

How it Works:

The client initiates the control connection (port 21). The server initiates the data connection back to the client (port > 1023).

Problems:

Firewalls often block incoming connections to the client, making active mode problematic.

Passive Mode

How it Works:

The client initiates both the control connection (port 21) and the data connection (port > 1023) to the server.

Advantages:

More firewall-friendly as the client initiates all connections.

Command:

passive - Toggles passive mode on or off. Most clients default to passive mode.