FTP (File Transfer Protocol) is a standard Internet protocol for transferring files between remote network.
In this tutorial, we will show you through practical examples of how to use Linux ftp command.
In most cases, you will use a desktop FTP client to connect to a remote server and download or upload files. However, ftp on when you work without a GUI server and you want to transfer files via FTP to a remote server or transfer files from a remote server, the command is useful.
Before you begin
When transferring data via ftp, connection is not encrypted. To secure data transmission, use the SCP.
To be able to transfer files, you must have at least read access to the source file and write permission on the target system.
When transferring large files, it is recommended to run ftp commands on the screen or tmux session.
Run directory of the ftp command is the local working directory.
FTP connection
-
To open the ftp connection to a remote system, use the ftp command followed by the remote server IP address or domain name:
ftp 192.168.42.77
- If the connection is established, a confirmation message, the system will prompt you to enter the FTP user name, in this example, FTP user name linuxidc:
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.42.77:localuser): linuxidc
You may see a different confirmation message depending on the FTP service running on the remote server.
-
After entering a user name, you will be prompted to enter the password:
Password:
- If the password is correct, a confirmation message and the remote server ftp> prompt is displayed.
230 OK. Current restricted directory is / Remote system type is UNIX. Using binary mode to transfer files. ftp>
If you access the FTP server accepts anonymous ftp account, and you want to log in as an anonymous user anonymous identity, please use the e-mail address as the user name and password.
Common FTP commands
Many FTP command and the command you type in the Linux shell prompt similar or identical.
Here are some of the most common FTP commands
- help or -? lists all available FTP commands.
- cd - change directory on the remote computer.
- lcd - Change to the directory on the local computer.
- ls - list the name of the current remote directory files and directories.
- mkdir - Create a new directory in the current remote directory.
- pwd - print the current working directory on the remote computer.
- delete - delete the files in the current remote directory.
- rmdir- delete the directory of the current remote directory.
- get - to copy a file from the remote to the local computer.
- mget - Copy multiple files from the remote to the local computer.
- put - to copy a file from the local to the remote computer.
- mput - to copy a file from the local to the remote computer.
Command to download files using FTP
Once logged in, your current working directory is the remote user's home directory.
When you use the ftp command to download a file, the file will be downloaded to your type ftp command directory.
If you want to download the file to another local directory, use the lcd command to change to that directory.
Suppose we want to download the file to ~ / ftp_downloads catalog:
lcd ~/ftp_downloads
From a remote server to download a single file, use the get command. For example, to download a file named, backup.zip please use the following command:
get backup.zip
The output should be as follows:
200 PORT command successful 150-Connecting to port 60609 150 6516.9 kbytes to download 226-File successfully transferred 226 2.356 seconds (measured here), 2.70 Mbytes per second 6673256 bytes received in 2.55 seconds (2.49 Mbytes/s)
To download multiple files, use the mget command. You can provide a single list of file names or use wildcards.
mget backup1.zip backup2.zip
When downloading multiple files, you will be prompted to confirm each file.
mget backup1.zip? y 200 PORT command successful 150 Connecting to port 52231 226-File successfully transferred 226 0.000 seconds (measured here), 31.51 Kbytes per second 14 bytes received in 0.00058 seconds (23.6 kbytes/s) mget backup2.zip? y 200 PORT command successful 150-Connecting to port 59179 150 7.2 kbytes to download 226-File successfully transferred 226 0.000 seconds (measured here), 16.68 Mbytes per second 7415 bytes received in 0.011 seconds (661 kbytes/s)
After completion of the remote FTP server to download the file, close the connection with a bye or quit.
quit
221-Goodbye. You uploaded 0 and downloaded 6544 kbytes. 221 Logout.
Upload files using FTP command
To file uploaded to a remote FTP server from a local directory, use the following command put:
put image.jpg
The output should be as follows:
200 PORT command successful 150 Connecting to port 34583 226-File successfully transferred 226 0.849 seconds (measured here), 111.48 Kbytes per second 96936 bytes sent in 0.421 seconds (225 kbytes/s)
If you want to upload the file is not in the current working directory, use the absolute path to the file.
To add multiple files uploaded to a remote FTP server from a local directory, use the following command mput:
mput image1.jpg image2.jpg
mput image1.jpg? y 200 PORT command successful 150 Connecting to port 41075 226-File successfully transferred 226 1.439 seconds (measured here), 102.89 Kbytes per second 151586 bytes sent in 1.07 seconds (138 kbytes/s) mput image2.jpg? y 200 PORT command successful 150 Connecting to port 40759 226-File successfully transferred 226 1.727 seconds (measured here), 111.75 Kbytes per second 197565 bytes sent in 1.39 seconds (138 kbytes/s)
When you upload multiple files, you are prompted to confirm that you want to upload each file.
After completing the upload files to a remote FTP server, or close the connection with the bye quit.
in conclusion
In this tutorial, you learned how to use the ftp command to download and upload files to a remote FTP server. FTP (File Transfer Protocol) is a standard Internet protocol for transferring files between remote network.
In this tutorial, we will show you through practical examples of how to use Linux ftp command.
In most cases, you will use a desktop FTP client to connect to a remote server and download or upload files. However, ftp on when you work without a GUI server and you want to transfer files via FTP to a remote server or transfer files from a remote server, the command is useful.
Before you begin
When transferring data via ftp, connection is not encrypted. To secure data transmission, use the SCP.
To be able to transfer files, you must have at least read access to the source file and write permission on the target system.
When transferring large files, it is recommended to run ftp commands on the screen or tmux session.
Run directory of the ftp command is the local working directory.
FTP connection
-
To open the ftp connection to a remote system, use the ftp command followed by the remote server IP address or domain name:
ftp 192.168.42.77
- If the connection is established, a confirmation message, the system will prompt you to enter the FTP user name, in this example, FTP user name linuxidc:
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.42.77:localuser): linuxidc
You may see a different confirmation message depending on the FTP service running on the remote server.
-
After entering a user name, you will be prompted to enter the password:
Password:
- If the password is correct, a confirmation message and the remote server ftp> prompt is displayed.
230 OK. Current restricted directory is / Remote system type is UNIX. Using binary mode to transfer files. ftp>
If you access the FTP server accepts anonymous ftp account, and you want to log in as an anonymous user anonymous identity, please use the e-mail address as the user name and password.
Common FTP commands
Many FTP command and the command you type in the Linux shell prompt similar or identical.
Here are some of the most common FTP commands
- help or -? lists all available FTP commands.
- cd - change directory on the remote computer.
- lcd - Change to the directory on the local computer.
- ls - list the name of the current remote directory files and directories.
- mkdir - Create a new directory in the current remote directory.
- pwd - print the current working directory on the remote computer.
- delete - delete the files in the current remote directory.
- rmdir- delete the directory of the current remote directory.
- get - to copy a file from the remote to the local computer.
- mget - Copy multiple files from the remote to the local computer.
- put - to copy a file from the local to the remote computer.
- mput - to copy a file from the local to the remote computer.
Command to download files using FTP
Once logged in, your current working directory is the remote user's home directory.
When you use the ftp command to download a file, the file will be downloaded to your type ftp command directory.
If you want to download the file to another local directory, use the lcd command to change to that directory.
Suppose we want to download the file to ~ / ftp_downloads catalog:
lcd ~/ftp_downloads
From a remote server to download a single file, use the get command. For example, to download a file named, backup.zip please use the following command:
get backup.zip
The output should be as follows:
200 PORT command successful 150-Connecting to port 60609 150 6516.9 kbytes to download 226-File successfully transferred 226 2.356 seconds (measured here), 2.70 Mbytes per second 6673256 bytes received in 2.55 seconds (2.49 Mbytes/s)
To download multiple files, use the mget command. You can provide a single list of file names or use wildcards.
mget backup1.zip backup2.zip
When downloading multiple files, you will be prompted to confirm each file.
mget backup1.zip? y 200 PORT command successful 150 Connecting to port 52231 226-File successfully transferred 226 0.000 seconds (measured here), 31.51 Kbytes per second 14 bytes received in 0.00058 seconds (23.6 kbytes/s) mget backup2.zip? y 200 PORT command successful 150-Connecting to port 59179 150 7.2 kbytes to download 226-File successfully transferred 226 0.000 seconds (measured here), 16.68 Mbytes per second 7415 bytes received in 0.011 seconds (661 kbytes/s)
After completion of the remote FTP server download files, bye or close the connection quit.
quit
221-Goodbye. You uploaded 0 and downloaded 6544 kbytes. 221 Logout.
Upload files using FTP command
To file uploaded to a remote FTP server from a local directory, use the following command put:
put image.jpg
The output should be as follows:
200 PORT command successful 150 Connecting to port 34583 226-File successfully transferred 226 0.849 seconds (measured here), 111.48 Kbytes per second 96936 bytes sent in 0.421 seconds (225 kbytes/s)
If you want to upload the file is not in the current working directory, use the absolute path to the file.
To add multiple files uploaded to a remote FTP server from a local directory, use the following command mput:
mput image1.jpg image2.jpg
mput image1.jpg? y 200 PORT command successful 150 Connecting to port 41075 226-File successfully transferred 226 1.439 seconds (measured here), 102.89 Kbytes per second 151586 bytes sent in 1.07 seconds (138 kbytes/s) mput image2.jpg? y 200 PORT command successful 150 Connecting to port 40759 226-File successfully transferred 226 1.727 seconds (measured here), 111.75 Kbytes per second 197565 bytes sent in 1.39 seconds (138 kbytes/s)
When you upload multiple files, you are prompted to confirm that you want to upload each file.
After completing the upload files to a remote FTP server, or close the connection with the bye quit.
in conclusion
In this tutorial, you learned how to use the ftp command to download and upload files to a remote FTP server.