一. FTP 說明
Linux下經常使用的FTP Server是vsftp(Very Security File Transfer Protocol),及profpt(Professtional ftp)。本文簡單說明下vsfpt的配置。 php
vsftp提供3種登錄方式:
一、匿名登陸方式
就是不須要用戶名,密碼。就能登陸到ftp服務器。
二、本地用戶方式
須要賬戶名和密碼才能登陸。並且,這個賬戶名和密碼,都是在你linux系統裏面,已經有的用戶。
三、虛擬用戶方式
一樣須要用ftp戶名和密碼才能登陸。可是和上面的區別就是,這個用戶名和密碼,在你linux系統中是沒有的(沒有該用戶賬號) java
二. Vsftp的安裝配置
2.1 安裝
# yum install vsftpd linux
2.2. 相關命令
2.2.1 啓動與關閉
# service vsftpd start
Redirecting to /bin/systemctl start vsftpd.service 服務器
# service vsftpd stop
Redirecting to /bin/systemctl stop vsftpd.service spa
# service vsftpd restart
Redirecting to /bin/systemctl restart vsftpd.service rest
2.2.2 ftp相關操做(此處演示用本地用戶登錄操做)
(1)以系統用戶及密碼登錄
$ ftp 192.168.0.100
Connected to 192.168.0.100 (192.168.0.100).
220 (vsFTPd 3.0.0)
Name (192.168.0.100:tough): tough
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files. ci
(2)pwd-打印ftp服務器端的當前目錄
ftp> pwd
257 "/home/tough" rem
(3)cd-進入ftp服務器端的子目錄
ftp> cd ftp
250 Directory successfully changed. get
(4)ls-顯示ftp服務器端的文件列表
ftp> ls
227 Entering Passive Mode (192,168,0,100,149,127).
150 Here comes the directory listing.
-rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 a.txt
-rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 b.txt
-rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 c.txt
226 Directory send OK. it
(5)!pwd-打印客戶端的當前目錄
ftp> !pwd
/tmp/testftp
(6)!ls-顯示客戶端的文件列表
ftp> !ls -l
total 0
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 a.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 a.php
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 b.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 b.php
(7)get-從服務器端下載文件
ftp> get a.txt
local: a.txt remote: a.txt
227 Entering Passive Mode (192,168,0,100,67,53).
150 Opening BINARY mode data connection for a.txt (0 bytes).
226 Transfer complete.
(8)mget-批量下載
ftp> mget *
mget a.txt?
227 Entering Passive Mode (192,168,0,100,150,33).
150 Opening BINARY mode data connection for a.txt (0 bytes).
226 Transfer complete.
mget b.txt?
227 Entering Passive Mode (192,168,0,100,227,239).
150 Opening BINARY mode data connection for b.txt (0 bytes).
226 Transfer complete.
mget c.txt?
227 Entering Passive Mode (192,168,0,100,203,53).
150 Opening BINARY mode data connection for c.txt (0 bytes).
226 Transfer complete.
ftp> !ls -l
total 0
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 a.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 a.php
-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 a.txt
-rw-rw-r-- 1 tough tough 0 Oct 17 00:18 b.java
-rw-rw-r-- 1 tough tough 0 Oct 17 00:21 b.php
-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 b.txt
-rw-rw-r-- 1 tough tough 0 Oct 17 00:20 c.txt
(爲了區分,此處咱們將ftp服務器端文件標爲綠色,本地文件標爲藍色)
(9)put-上傳本地文件到ftp服務器
ftp> put a.php
local: a.php
227 Entering Passive Mode (192,168,0,100,201,17).
150 Ok to send data.
226 Transfer complete.
(10)mput-批量上傳
ftp> mput *.java /home/tough/ftp
mput a.java?
227 Entering Passive Mode (192,168,0,100,148,208).
150 Ok to send data.
226 Transfer complete.
mput b.java?
227 Entering Passive Mode (192,168,0,100,207,24).
150 Ok to send data.
226 Transfer complete.
mput /home/tough/ftp?
/home/tough/ftp: not a plain file.
ftp> ls -l
227 Entering Passive Mode (192,168,0,100,107,170).
150 Here comes the directory listing.
-rw-r--r-- 1 1000 1000 0 Oct 16 16:23 a.java
-rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 a.txt
-rw-r--r-- 1 1000 1000 0 Oct 16 16:23 b.java
-rw-r--r-- 1 1000 1000 0 Oct 16 16:21 a.php
-rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 b.txt -rw-rw-r-- 1 1000 1000 0 Oct 16 16:18 c.txt 226 Directory send OK.