Sample Uses of the Linux FTP Command

Using the FTP Protocol With Linux Computers

Woman using a laptop at home
Gary Houlder/Taxi/Getty Images

  FTP is the simplest and most familiar file transfer protocol that exchanges files between a local computer and a remote computer or network. Linux and Unix operating systems have built-in command line prompts you can use as FTP clients for making an FTP connection. 

Warning: An FTP transmission is not encrypted. Anyone who intercepts the transmission can read the data you send, including your username and password. For a secure transmission, use SFTP.

Establish an FTP Connection

Before you can use the various FTP commands, you must establish a connection with the remote network or computer. Do this by opening a terminal window in Linux and typing ftp followed by a domain name or an IP address of the FTP server, such as ftp or ftp For example:


This command attempts to connect to the ftp server at If it succeeds, it asks you to log in using a username and password. Public FTP servers often allow you to log in using the username anonymous and your email address as a password or with no password at all.

When you log in successfully, you see an ftp> prompt on the terminal screen. Before you go any further, get a list of the available FTP commands using the help function. It is useful because depending on your system and software, some of the FTP commands listed may or may not work.

FTP Command Examples and Descriptions

The FTP commands used with Linux and Unix differ from the FTP commands used with the Windows command line. Here are examples that illustrate typical uses of the Linux FTP commands for remotely copying, renaming, and deleting files.

 ftp> help

The help function lists the commands that you can use to show the directory contents, transfer files, and delete files. The command ftp> ? accomplishes the same thing.

 ftp> ls

This command prints the names of the files and subdirectories in the current directory on the remote computer.

ftp> cd customers

This command changes the current directory to the subdirectory named customers if it exists.

 ftp> cdup

This changes the current directory to the parent directory.

 ftp> lcd [images]

This command changes the current directory on the local computer to images, if it exists.

 ftp> ascii

This changes to ASCII mode for transferring text files. ASCII is the default on most systems.

 ftp> binary

This command changes to binary mode for transferring all files that are not text files.

 ftp> get image1.jpg

This downloads the file image1.jpg from the remote computer to the local computer. Warning: If there already is a file on the local computer with the same name, it is overwritten.

 ftp> put image2.jpg

Uploads the file image2.jpg from the local computer to the remote computer. Warning: If there already is a file on the remote computer with the same name, it is overwritten.

 ftp> !ls

Adding an exclamation mark in front of a command executes the specified command on the local computer. So !ls lists the file names and directory names of the current directory on the local computer.

 ftp> mget *.jpg

With the mget command. you can download multiple images. This command downloads all files that end with .jpg.

ftp> rename [from] [to]

The rename command changes the file named [from] to the new name [to] on the remote server.

ftp> put local-file [remote-file]

This command stores a local file on the remote machine. Send local-file [remote file] does the same thing.

 ftp> mput *.jpg

This command uploads all the files that end with .jpg to the active folder on the remote machine.

ftp> delete remote-file

Deletes the file named remote-file on the remote machine.

 ftp> mdelete *.jpg

This deletes all files that end with .jpg in the active folder on the remote machine.

ftp> size file-name

Determine the size of a file on the remote machine with this command.

ftp> mkdir [directory-name]​

Make a new directory on the remote server.

 ftp> prompt

The prompt command turns interactive mode on or off so that commands on multiple files are executed without user confirmation.

 ftp> quit

The quit command terminates the FTP session and exits the FTP program. The commands bye and exit accomplish the same thing. 

Command Line Options

Options (also called flags or switches) modify the operation of an FTP command. Usually, a command line option follows the main FTP command after a space. Here is a list of options you can append to FTP commands and a description of what they do.

  • -4  Use only IPv4 when contacting a host
  • -6  Use only IPv6
  • -e  Disables history support and command editing
  • -p  Use passive mode for data transfers
  • -i   Turns off interactive prompted during file transfers
  • -n  Prevents auto-login on first connection
  • -g  Disables file name globbing
  • -v  Forces the remove server to show all responses
  • -d  Engages debugging