Using FTP Command to Transfer Files Under Linux

Source: Internet
Author: User
Keywords linux ftp command to transfer files server to server ftp transfer filezilla transfer files using ftp command
FTP (File Transfer Protocol) is a standard network protocol used to transfer files to and from remote networks. In most cases, you will use a desktop FTP client to connect to a remote server to download or upload files. However, ftp is useful when you are working on a server without a GUI and want to transfer files to or from a remote server via FTP.
Simple Application Server
USD1.00 New User Coupon
* Only 3,000 coupons available.
* Each new user can only get one coupon(except users from distributors).
* The coupon is valid for 30 days from the date of receipt.

When transferring data via ftp, the connection is not encrypted. For secure data transmission, use SCP

To be able to transfer files, you must have at least read access to the source file and write access to the target system

When transferring large files, it is recommended to run the ftp command on the screen or tmux session

Establish FTP connection
To open a ftp connection with 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 will be displayed and you will be prompted to enter the FTP username. In this example, the FTP username is myfreax:
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): myfreax

Different FTP services will display different confirmation messages
After entering the user name, the system will prompt you to enter the password:
Password:

If the password is correct, the remote server will display a confirmation message and ftp> prompt.
230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

If the FTP server you visit accepts anonymous ftp accounts, and you want to log in as an anonymous user anonymous, please use your username and email address as your password

Common FTP commands
Many FTP commands are similar or identical to the commands you type in the Linux shell prompt

Here are some of the most common FTP commands
  • help or ?- List all available FTP commands.
  • cd-cut out the directory on the remote computer.
  • lcd-switch directories on the local computer.
  • ls-List the names of files and directories in the current remote directory.
  • mkdir-Create a new directory in the current remote directory.
  • pwd-Print the current working directory on the remote computer.
  • delete-delete files in the current remote directory.
  • rmdir- delete the directory in the current remote directory.
  • get-Copy a file from remote to local computer.
  • mget-Copy multiple files from remote to local computer.
  • put-Copy a file from local to remote computer.
  • mput-Copy a file from local to remote computer.
Download files using FTP commands
After logging in, your current working directory is the remote user's home directory

When using this ftp command to download a file, the file will be downloaded to the directory where you typed the ftp command.

If you want to download the file to another local directory, use the lcd command to switch to that directory.

Suppose we want to download files to the ~/ftp_downloads directory:
lcd ~/ftp_downloads

To download a single file from a remote server, use the get command. For example, to download the backup.zip file, use the following command:
get backup.zip
The output should look like this:
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 at once, use the mget command. You can provide a list of individual 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 downloading files from the remote FTP server, use bye or quit to close the connection and exit the client
quit
Copy
221-Goodbye. You uploaded 0 and downloaded 6544 kbytes.
221 Logout.
Upload files using FTP commands
To upload files from a local directory to a remote FTP server, use the following put command:
put image.jpg

The output should look like this:
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 a file that is not in the current working directory, please use the absolute path of the file

To upload multiple files from a local directory to a remote FTP server, use the mput command:
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 uploading multiple files, you will be prompted to confirm each file you want to upload.

After uploading the file to the remote FTP server, use bye or close the connection quit

If you have any questions, please leave a message below

If you like our content, you can choose to donate to us in the QR code below, or click the advertisement to support it, thank you for your support

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.