FTP (File Transfer Protocol) is a most familiar file transfer protocol used to transfer files between a local and remote network. In this tutorial, we will show you how to use the Linux ftp command with examples.
The ftp commands are very useful when you don’t have a system with GUI and you want to transfer files over FTP to or from a remote server. FTP traffic is not encrypted, or a secure data transfer, use SCP or SFTP.
Make sure you have at least read permissions on the source file and write permission on the target system.
Make an FTP connection
To make a ftp session on a remote server, use the
ftp command followed by the remote server IP address or domain name.
For instance, to connect to an FTP server at
192.168.125.96 you would type:
Once the connection established you will be promt to enter your
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 21:35. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (192.168.125.96:localuser): tecnstuff
After entering the username you will be prompted to type your password:
On success validation, it will display a confirmation message with
230 OK. Current restricted directory is / Remote system type is UNIX. Using binary mode to transfer files. ftp>
Common FTP Commands
Below are some of the most common FTP commands:
?– To get list all available FTP commands.
cd– navigate on the remote machine.
lcd– change directory on the local machine.
ls– list the names of the files and directories in the current remote directory.
mkdir– create a new directory.
pwd– show the current working directory on the remote machine.
delete– delete a file in the current remote directory.
rmdir– remove a directory in the current remote directory.
get– download one file from the remote to the local machine.
mget– dowload multiple files from the remote to the local machine.
put– upload one file from the local to the remote machine.
mput– upload one file from the local to the remote machine.
Downloading Files with the ftp Command
By default, when you logged in to your remote server your home directory will be your current working directory.
To download a file from the remote server, use the get command. For example, to download a file named
test.zip you would use the following command:
The output should look something like this:
200 PORT command successful 150-Connecting to port 60609 150 6516.9 kbytes to download 226-File successfully transferred 226 1.123 seconds (measured here), 1.60 Mbytes per second 4463256 bytes received in 1.12 seconds (1.49 Mbytes/s)
You also can download more than one file using
mget command. Provide file names with space separated or use wildcard characters:
mget test1.zip test2.zip
To close the connection to remote server, type
221-Goodbye. You uploaded 0 and downloaded 6544 kbytes. 221 Logout.
Uploading Files with the FTP Command
To transfer a file from a local directory to a remote FTP server, run the put command:
It will show output as below:
200 PORT command successful 150 Connecting to port 34583 226-File successfully transferred 226 0.109 seconds (measured here), 2.48 Kbytes per second 33960 bytes sent in 0.121 seconds (302 kbytes/s)
To upload multiple files from a local directory to a remote FTP server, use the
mput index.php info.php
When uploading multiple files, the command will prompt you to confirm each file you want to upload.
Once you are done uploading files to your remote FTP server close the connection with
In this tutorial, you we shown you how to use the ftp command to download and upload files to your remote FTP server.
Feel free to leave a comment if you have any questions or suggestion.