Linux Ftp Notes

The ftp server is more common on the Internet. The function of the Linux ftp command is to control the transfer of files between the local machine and the remote machine by means of commands. Here are some frequently used commands of the Linux ftp command. ftp operation will be very easy.

The general format of the Linux ftp command is as follows:

$ ftp hostname/IP

Where "hostname/IP" is the hostname 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 will try to connect with the ftp service program of the remote machine; if the host name is not specified, ftp will give a prompt, waiting for the user to enter the command:
$ ftp
ftp >
At this time, enter the open command after the ftp> prompt and add the host name or IP address, and it will try to connect to the specified host.
No matter which method is used, if the connection is successful, you need to log in on the remote machine. If the user has an account on the remote machine, he can use this account through ftp and need to provide a password. The read and write permissions of the user account on the remote computer determine what files the user can download on the remote computer and which directory the uploaded files are placed in.
Many ftp sites have special accounts that can be used if there is no dedicated login account for the remote machine. The login name for this account is anonymous (also known as anonymous ftp), and when using this account, an email address is required as a password.
If the remote system provides an anonymous ftp service, users can use this service to log into a special, publicly available directory. Generally, two directories are specially provided: the pub directory and the incoming directory. The pub directory contains all the files for the site for public use, and the incoming directory holds files uploaded to the site.
Once the user has successfully logged in on the remote site using ftp, he will get the "ftp>" prompt. Now you can freely use the commands provided by ftp, you can use the help command to get a list of available commands, or you can specify a specific command name after the help command to get the description of this command.

The most commonly used commands are:
ls List the current directory
of the remote machine cd Change the working directory on the remote machine
lcd Change the working directory on the local machine
ascii Set the file transfer mode to ASCII mode
binary Set the file transfer mode to binary mode
close Terminate the current ftp session
Hash Displays a # sign every time the data in the data buffer is transferred
get (mget) Transfer the specified file from the remote machine to the local machine
put (mput) Transfer the specified file from the local machine to the remote machine
open Connect the remote ftp site
disconnected connect to remote machine and exit ftp
? show local help information
! go to shell

The following is a brief introduction to the commonly used ftp commands.
◆ start the ftp session
open command is used to open a session with the remote host. The general format of this command is:
◆open hostname/IP
If you want to connect with more than one site during an ftp session, usually just use the ftp command without parameters. If you only want to connect to one computer during the session, then specify the remote hostname or IP address as an argument to the ftp command on the command line.
◆ Terminate the ftp session
close, disconnect, and bye commands are used to terminate the session with the remote machine. The close and disronnect commands close the connection to the remote machine, but leave the user in the ftp program on the local computer. And the bye command closes the connection between the user and the remote machine, and then exits the ftp program on the user's machine.
◆Change directory
The "cd [directory]" command is used to change the directory on the remote machine during the ftp session, and the lcd command changes the local directory so that the user can specify where to find or place local files.
◆Remote Directory Listing
The ls command lists the contents of a remote directory, just like using the ls command in an interactive shell. The general format of the ls command is:
ls [directory] [local file]
If a directory is specified as an argument, ls lists the contents of that directory. If the name of a local file is given, the directory listing is put into the file you specify on the local machine.
◆Get files from the remote system
The get and mget commands are used to get files from the remote machine. The general format of the get command is:
get filename
You can also give the local filename, which is the filename of the file to be obtained when it was created on your local machine. If you do not give a local file name, the original name of the remote file is used.
The mget command gets multiple remote files at once. The general format of the mget command is:
mget filename list
Use a space-separated or wildcard list of filenames to specify the files to get, each of which requires the user to confirm transfer.
◆Send files to the remote system
The put and mput commands are used to send files to the remote machine. The general format of the Put command is:
put filename The
mput command sends multiple local files at a time. The general format of the mput command is:
mput filename list
Use a space-separated or wildcard list of filenames to specify the files to send. For each of these files, the user is asked to confirm whether to send it.
◆Change the file transfer mode
By default , ftp transfers files in ASCII mode, and the user can also specify other modes. The function of ascii and brinary commands is to set the mode of transmission. Transferring files in ASCII mode is fine for plain text, but to avoid corruption of binary files, users can transfer files in binary mode.
◆Check transfer status When
transferring large files, you may find it useful to have ftp provide feedback about the transfer. The hash command makes ftp print a # character on the screen after each transmission of the data in the data buffer. This command can be used both when sending and receiving files.
◆Local commands in ftp
When you use ftp, the character "!" is used to transmit a command to the command shell on the local machine. Useful if the user is in an ftp session and needs the shell to do something. For example, the user wants 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 current local directory.

The Linux ftp command is introduced here, which should be enough to use the ftp tool under the Linux system.

Guess you like

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