Ftp servers are more common on the Internet. Linux ftp commands use commands to control file transfer between local and remote hosts, here we will introduce some frequently used Linux ftp commands in detail. I believe it will be very easy to master these ftp operations using Linux.
The common format of Linux ftp commands is as follows:
$ Ftp host name/IP Address
The "host name/IP Address" is the host name or IP address of the remote machine to be connected. In the command line, the host name is an option. If the host name is specified, ftp tries to connect to the ftp service program of the remote machine. If the host name is not specified, ftp will give a prompt, wait for the user to enter the command:
$ Ftp
Ftp>
At this time, enter the open command and add the host name or IP address after the ftp> prompt to try to connect to the specified host.
No matter which method is used, if the connection is successful, You need to log on to the remote machine. If you have an account on a remote machine, you can use this account through ftp and provide a password. The read and write permissions of the user account on the remote machine determine what files the user can download and the directory to which the uploaded files are stored.
If you do not have a dedicated Logon account for a remote machine, many ftp sites have special accounts that can be used. The login name of this account is anonymous (also known as anonymous ftp). When using this account, enter the email address as the password.
If the remote system provides the anonymous ftp service, you can use this service to log on to a special directory for public use. Generally, two directories are provided: pub directory and incoming directory. The pub directory contains all the files on the site for public use. The incoming directory stores the files uploaded to the site.
Once the user successfully logs on to the remote site using ftp, the "ftp>" prompt is displayed. Now you can freely use commands provided by ftp. You can use the help command to obtain a list of available commands, or you can specify a specific command name after the help command to obtain instructions on this command.
The most common commands are:
Ls to list the current directory of the remote machine
Cd changes the working directory on a remote machine
LCD changes the working directory on the local machine
Set the file transmission mode to ascii in ASCII mode.
Set the file transfer mode to binary.
Close to terminate the current ftp session
Each time the hash data is transmitted in the data buffer, A # number is displayed.
Get (mget) transfers specified files from a remote machine to a Local Machine
Put (mput) transfers the specified file from the local machine to the remote machine
Open connection to remote ftp site
Disconnect from a remote machine and exit ftp
? Display local help information
! Go to Shell
Below is a brief introduction to common ftp commands.
◆ Start an ftp session
The open command is used to open a session with the remote host. The common format of this command is:
◆ Open host name/IP Address
If you need to connect to more than one site during an ftp session, only ftp commands without parameters are used. If you only want to connect to a computer during a session, specify the remote host name or IP address on the command line as the ftp command parameter.
◆ Terminate an ftp session
The close, disconnect, and bye commands are used to terminate a session with a remote machine. Close and disronnect commands close the connection to the remote machine, but leave the user in the ftp program of the local computer. And the bye command close the connection between the user and the remote machine, and then exit the ftp program on the user machine.
◆ Change Directory
The "cd [Directory]" command is used to change the directory on the remote machine during an ftp session. The LCD command changes the local directory so that you can specify the location for searching or storing local files.
◆ Remote directory list
The ls command lists the contents of a remote directory, just like using the ls command in an interactive shell. The common format of the ls command is:
Ls [Directory] [local file]
If a directory is specified as the parameter, ls will list the contents of the directory. If a local file name is provided, the directory list is put into the file you specified on the local machine.
◆ Obtain files from a remote system
Get and mget commands are used to obtain files from a remote machine. The common format of the get command is:
Get File Name
You can also provide a local file name, which is the name of the file to be obtained when it is created on your local machine. If you do not provide a local file name, use the original name of the remote file.
The mget command obtains multiple remote files at a time. The general format of the mget command is:
Mget File Name List
Use a list of file names separated by spaces or with wildcards to specify the file to be retrieved. For each file, you must confirm whether the file is transmitted.
◆ Send a file to a remote system
The put and mput commands are used to send files to remote machines. The general format of the Put command is:
Put file name
The mput Command sends multiple local files at a time. The general format of the mput command is:
Mput File Name List
Use a list of file names separated by spaces or with wildcards to specify the files to be sent. You are required to confirm whether to send each file.
◆ Change file transmission mode
By default, ftp transfers files in ASCII mode. You can also specify other modes. The ascii and brinary commands are used to set the transmission mode. Transferring files in ASCII mode is very good for plain text, but to avoid damages to binary files, users can transmit files in binary mode.
◆ Check transmission status
When transferring large files, ftp may find it useful to provide feedback on Transmission Conditions. The hash command enables ftp to print a # character on the screen after data in the data buffer is transmitted every time. This command can be used to send and receive files.
◆ Local commands in ftp
When you use ftp, the character "!" It is used to send a command to the command shell on the local machine. It is useful if a user is in an ftp session and needs shell to do something. For example, you need to create a directory to save the received files. If you enter! Mkdir new_dir, Linux creates a directory named new_dir in the user's local directory.
Here, the Linux ftp command is introduced here. It should be enough to use the ftp tool in Linux.