For a person who often touches the computer, FTP appears in every corner of our life invisibly. File uploading and downloading in daily life are often achieved by FTP.
Professionally, FTP is the English abbreviation of File Transfer Protocol, and the Chinese abbreviation is "Text Transfer Protocol". For bidirectional transfer of control files over the Internet. At the same time, it is also an application (Application). There are different FTP applications based on different operating systems, and all of them follow the same protocol to transfer files. In the use of FTP, users often encounter two concepts: "Download" and "Upload". "Downloading" a file is copying a file from a remote host to your computer; "uploading" a file is copying a file from your own computer to a remote host. In Internet language, a user can upload (download) files to (from) a remote host through a client program.
Whether it is Windows or Linux, FTP has its own role. In Windows, we may be able to operate ftp through a visual interface. But how do we operate under pure command line Linux.
method/step
-
In the installed Linux, when I entered ftp, it was prompted that I did not find the ftp command. I checked it online and said that I was going to install a vsftpd. First set the permission to root, or add sudo before the command. The instructions are as follows:
yum install vsftpd
or
sudo yum install vsftpd
-
Then after installation, enter /sbin/service vsftpd restart to restart vsftpd.
-
Then install ftp.
yum install vsftpd
-
Then after entering ftp, you can enter the ftp control interface as much as possible.
-
Now if you want to log in to an FTP, you can enter the FTP through the open command.
For example: open 127.0.0.0
If FTP sets permissions, you may need to enter a username and password after entering.
In this way, you can directly enter the FTP to operate.
END
Operation instructions
-
The operation instructions of FTP are actually very similar to Linux, as follows:
1. ls lists the current directory of the remote machine 2. cd changes the working directory on the remote machine 3. lcd changes the working directory on the local machine 4. ascii sets the file transfer mode to ASCII mode 5, binary sets the file transfer mode to binary mode 6, close terminates the current ftp session 7, hash displays a # sign after each transfer of data in the data buffer 8, get (mget) transfers the specified file from the remote machine to the local machine 9, put (mput) transfers from the local machine Specify the file to the remote machine 10, open to connect to the remote ftp site 11, and exit to exit ftp.
-
For example: download file
Before downloading files, you must set up a local directory to store the downloaded files.
lcd /home/123/web ##Set the local storage directory to /home/usr by default
get 123.txt ##Download 123.txt file to /home/123/web
get -c 123.txt ##Breakpoint resume download
mget *.txt ## Batch download all txt files
mget -c *.txt ##Breakpoint resume
mget -c ./123/aaa/*.txt ##Breakpoint resume, batch download all txt files in the aaa directory on the ftp side
pget -c -n 10 file.dat
##Download file.dat with up to 10 threads in a way that allows resuming
##The default value can be used by setting the value of set pget:default-n 5.
mirror aaa/
##Download the entire aaa directory, and the subdirectories will also be automatically copied to the local auto-created directory
-
For example: uploading a file
put 123.txt ##Same as download
mput *.txt ##Same as download
mirror -R aaa/ ##Same as download
-
For example: view ftp file
ls *.txt ##Find all txt files in the current directory
ls ./123/ ##List all files in the 123 directory
find . -name "*.txt" ##Recursively find all txt files on the site
find ./xx -name "*.txt" ##Find all txt files in the xx directory
Attachment 1: The second time ls reads the local cache, you can use rels instead of ls or catch off / catch on to switch catch, catch flush to clear the local catch
Appendix 2: The command to browse the local directory can be used !ls, such as !ls /usr/local/bin/
END