FTP is the abbreviation for file Transfer Protocol (document Transfer Protocol), and Chinese is called "Interfax protocol". Used for two-way transmission of control files on 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 these applications follow the same protocol to transfer files. In the use of FTP, users often encounter two concepts: "Download" (Download) and "Upload" (Upload).
Generally in a variety of Linux distributions, the default with the FTP software is vsftp, from the various Linux distributions to vsftp recognition can be seen, vsftp should be a good FTP software.
1. Check and install VSFTPD software
Use the following command #rpm-qa |grep VSFTPD can detect if the VSFTPD software is installed,
If it is not installed, install it using the Yum command.
2. Start the service
Using VSFTPD software, mainly includes the following commands:
Start ftp command #service vsftpd start
Stop FTP command #service vsftpd stop
Restart FTP command #service vsftpd restart
3, the VSFTPD configuration
There are three main FTP configuration files, which are located in the/etc/vsftpd/directory, respectively:
Ftpusers This file is used to specify that those users cannot access the FTP server.
User_list the default account that the file uses to indicate that the FTP is not accessible by default
4, take the anonymous user as an example, we remove the configuration file vsftpd.conf inside the following
Anon_upload_enable=yes
Anon_mkdir_write_enable=yes
Two previous # numbers, you can complete the configuration of anonymous users, the anonymous user can log in both upload, download files. Remember to restart the service after modifying the configuration file.
Vsftpd.conf VSFTPD's master configuration file
How do I upload and download files using the FTP command at the command line? Step 1: Establish an FTP connection
To connect to an FTP server, enter and then space on the command to ftp
follow the FTP server's domain name ' domain.com ' or IP address
For example:
ftp domain.com
ftp 192.168.0.1
ftp [email protected].com
Note: The anonymous server is used in this example.
Replace the following example with an IP or domain name for your server address.
Step 2: Login with username and password
The vast majority of FTP servers are password protected, so these FTP servers ask for 'username' and 'password'.
If you connect to an FTP server known as an anonymous FTP server (LCTT: That is, you do not need to have real user information to use as an anonymous FTP server), you can try to use the username as anonymous
well as the blank password:
Name: anonymous
Password:
After that, the terminal will return the following information:
230Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>
Login successful.
Step 3: Directory Operations
FTP commands can list, move, and create folders as if we were using our computer locally. You can ls
print a list of directories, cd
you can change the directory, mkdir
you can create folders.
Listing directories using security settings
ftp>ls
The server will return:
200 PORT command successful.Considerusing PASV.
150Here comes the directory listing.
directory list
....
....
226Directory send OK.
Change Directory:
Change the directory to enter:
ftp>cd directory
The server will return:
250Directory succesfully changed.
Step 4: Download files using FTP
Before downloading a file, we first need to use the lcd
command to set the local accept directory location.
lcd /home/user/yourdirectoryname
If you do not specify a download directory, the file will be downloaded to your working directory when you log in to FTP.
Now, we can use command get to download the file, for example:
getfile
The file is saved in the directory location that is set using the LCD command.
Server return message:
local:file remote:file
200 PORT command successful.Considerusing PASV.
150Opening BINARY mode data connection forfile(xxx bytes).
226File send OK.
XXX bytes received in x.xx secs (x.xxx MB/s).
Download files using FTP
You can use wildcard characters and commands to download multiple files mget
. For example, I'm going to download all the files ending with. xls in the following example.
mget *.xls
Step 5: Upload files using FTP
FTP can also upload files after FTP connection is completed
To put
upload a file using a command:
put file
The absolute path can be used when the file is no longer in the current local directory:
put /path/file
Again, you can upload multiple files:
mput *.xls
Step 6: Close the FTP connection
After completing the FTP work, you need to close the connection for security reasons. There are three commands to close a connection:
bye
exit
quit
Any command can disconnect the FTP server and return:
221Goodbye
For more help, you can use the FTP command to get more help after you connect to the server help
.
Linux Quick Build FTP server