Common FTP Commands under Linux

1. Connect to ftp server

Format: ftp [hostname| ip-address]
a) Enter on the linux command line:

ftp 192.168.1.1

b) The server asks you for your username and password, enter the username and corresponding password respectively, and you can pass the authentication.

2. Download the file

Download files usually use the two commands get and mget.
a) get
format: get [remote-file] [local-file]
transfers the file from the remote host to the local host.
To get /usr/your/1.htm on the remote server, then

ftp> get /usr/your/1.htm 1.htm (enter)


b) mget       
format: mget [remote-files]
receives a batch of files from the remote host to the local host.
To get all files under /usr/your/ on the server, then

ftp> cd /usr/your/
ftp> mget *.* (回车)


At this point every time a file is downloaded, there will be a prompt. If you want to get rid of the prompt, execute before the mget *.* command: prompt off

Note: The files are downloaded to the current directory of the linux host. For example, if the ftp command is run under /usr/my, the files are downloaded to /usr/my.

3. Upload files

a) put
format: put local-file [remote-file]
transfers a local file to the remote host.
If you want to transfer the local 1.htm to the remote host /usr/your, and rename it to 2.htm

ftp> put 1.htm /usr/your/2.htm (enter)


b) mput
format: mput local-files
transfers a batch of files from the local host to the remote host.
If you want to upload all html files in the local current directory to the server /usr/your/

ftp> cd /usr/your (enter)
ftp> mput *.htm (enter)


Note: The uploaded files are all from the current directory of the host. For example, if the ftp command is run under /usr/my, only the file linux under /usr/my will be uploaded to the server under /usr/your.

4. Disconnect bye: Disconnect from the server.

ftp> bye (carriage return)

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326654029&siteId=291194637
Recommended