Example Uses of the Linux Command FTP

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 operating systems have built-in command line prompts you can use as FTP clients for making an FTP connection. Here are examples that illustrate typical uses of the command FTP for remotely copying, renaming, and deleting files.

FTP Command Examples and Descriptions

 ftp abc.xyz.edu

This command attempts to connect to the ftp server at abc.xyz.edu. 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. After you are logged in, you can get a list of the available ftp commands using the help function:

 ftp> help

The help function lists the commands that you can use to show the directory contents, transfer files, and delete files.

 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 "customers," if it exists.

 ftp> cd ..

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.

 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

Add 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 mget you can download multiple images. This command downloads all files that end with ".jpg."

 ftp> mput *.jpg

This command uploads all the files that end with ".jpg."

 ftp> mdelete *.jpg

This deletes all files that end with ".jpg."

 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 exits the ftp program.