filezilla的应用
用户的配置查看上一篇文章FTP3种用户的配置
进入filezilla软件测试
用yy用户登录发现可以上传下载创建删除
再用cc用户登录发现不能上传不能删除不能创建只能下载
ftp&lftp&wget客户端的应用
以命令行的方式连接ftp,一般只会用到上传和下载两种操作
上传只能用ftp(麻烦)和lftp(方便)
下载可以用ftp、lftp和wget
先看ftp和lftp命令由哪个包提供的
[root@cjy ~]# yum provides *bin/ftp
Last metadata expiration check: 1:53:47 ago on Wed 13 Dec 2023 03:22:46 PM CST.
ftp-0.17-89.el9.x86_64 : The standard UNIX FTP (File Transfer Protocol) client
Repo : appstream
Matched from:
Other : *bin/ftp
[root@cjy ~]# yum provides *bin/lftp
Last metadata expiration check: 1:54:50 ago on Wed 13 Dec 2023 03:22:46 PM CST.
lftp-4.9.2-4.el9.i686 : A sophisticated file transfer program
Repo : appstream
Matched from:
Other : *bin/lftp
lftp-4.9.2-4.el9.x86_64 : A sophisticated file transfer program
Repo : appstream
Matched from:
Other : *bin/lftp
下载2个服务
[root@cjy ~]# yum -y install ftp lftp
ftp的用法
[root@cjy ~]# ftp -h
Usage: { ftp | pftp } [-Apinegvtd] [hostname]
-A: enable active mode
-p: enable passive mode (default for ftp and pftp)
-i: turn off prompting during mget
-n: inhibit auto-login
-e: disable readline support, if present
-g: disable filename globbing
-m: don't force data channel interface to the same as control channel
-v: verbose mode
-t: enable packet tracing [nonfunctional]
-d: enable debugging
使用ftp命令连接并下载
[root@cjy ~]# ls
anaconda-ks.cfg
[root@cjy ~]# ftp 192.168.159.141
Connected to 192.168.159.141 (192.168.159.141).
220 (vsFTPd 3.0.5)
Name (192.168.159.141:root): yy 此处输入错误只能用ctrl+u删除
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> ?
Commands may be abbreviated. Commands are:
! debug mdir sendport site
$ dir mget put size
account disconnect mkdir pwd status
append exit mls quit struct
ascii form mode quote system
bell get modtime recv sunique
binary glob mput reget tenex
bye hash newer rstatus tick
case help nmap rhelp trace
cd idle nlist rename type
cdup image ntrans reset user
chmod lcd open restart umask
close ls prompt rmdir verbose
cr macdef passive runique ?
delete mdelete proxy send
ftp> ls
227 Entering Passive Mode (192,168,159,141,165,64).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 3 Dec 13 09:00 666.txt
226 Directory send OK.
ftp> get 666.txt
local: 666.txt remote: 666.txt
227 Entering Passive Mode (192,168,159,141,46,181).
150 Opening BINARY mode data connection for 666.txt (3 bytes).
226 Transfer complete.
3 bytes received in 2.8e-05 secs (107.14 Kbytes/sec)
ftp> bye
221 Goodbye.
[root@cjy ~]# ls
666.txt anaconda-ks.cfg
下载文件到指定目录
[root@cjy ~]# ls /opt/
[root@cjy ~]# ftp 192.168.159.141
Connected to 192.168.159.141 (192.168.159.141).
220 (vsFTPd 3.0.5)
Name (192.168.159.141:root): yy
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> lcd /opt
Local directory now /opt
ftp> get 666.txt
local: 666.txt remote: 666.txt
227 Entering Passive Mode (192,168,159,141,234,114).
150 Opening BINARY mode data connection for 666.txt (3 bytes).
226 Transfer complete.
3 bytes received in 0.000116 secs (25.86 Kbytes/sec)
[root@cjy ~]# ls /opt/
666.txt
上传
[root@cjy ~]# touch /opt/555
[root@cjy ~]# ls /opt/
555 666.txt
切到ftp
ftp> put 555
local: 555 remote: 555
227 Entering Passive Mode (192,168,159,141,209,154).
150 Ok to send data.
226 Transfer complete.
ftp> ls
227 Entering Passive Mode (192,168,159,141,211,44).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:00 666.txt
226 Directory send OK.
创建
ftp> mkdir hh
257 "/hh" created
ftp> ls
227 Entering Passive Mode (192,168,159,141,148,253).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:00 666.txt
drwxr-xr-x 2 1001 1001 6 Dec 13 09:30 hh
226 Directory send OK.
[root@cjy ~]# ls /opt/
555 666.txt
[root@cjy ~]# ls /data/
555 666.txt hh
删除
删目录
rmdir只能删除没有文件的空目录
ftp> rmdir hh
250 Remove directory operation successful.
ftp> ls
227 Entering Passive Mode (192,168,159,141,118,51).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:00 666.txt
226 Directory send OK.
删文件
ftp> delete 666.txt
250 Delete operation successful.
ftp> ls
227 Entering Passive Mode (192,168,159,141,104,161).
150 Here comes the directory listing.
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
226 Directory send OK.
lftp的用法
[root@cjy ~]# lftp --help
Usage: lftp [OPTS] <site>
`lftp' is the first command executed by lftp after rc files
-f <file> execute commands from the file and exit
-c <cmd> execute the commands and exit
--norc don't execute rc files from the home directory
--help print this help and exit
--version print lftp version and exit
Other options are the same as in `open' command:
-e <cmd> execute the command just after selecting
-u <user>[,<pass>] use the user/password for authentication
-p <port> use the port for connection
-s <slot> assign the connection to this slot
-d switch on debugging mode
<site> host name, URL or bookmark name
登录
[root@cjy ~]# lftp -u yy,123 192.168.159.141
lftp yy@192.168.159.141:~>
帮助文档
lftp yy@192.168.159.141:~> help
!<shell-command> (commands)
alias [<name> [<value>]] attach [PID]
bookmark [SUBCMD] cache [SUBCMD]
cat [-b] <files> cd <rdir>
chmod [OPTS] mode file... close [-a]
[re]cls [opts] [path/][pattern] debug [OPTS] [<level>|off]
du [options] <dirs> edit [OPTS] <file>
exit [<code>|bg] get [OPTS] <rfile> [-o <lfile>]
glob [OPTS] <cmd> <args> help [<cmd>]
history -w file|-r file|-c|-l [cnt] jobs [-v] [<job_no...>]
kill all|<job_no> lcd <ldir>
lftp [OPTS] <site> ln [-s] <file1> <file2> ls [<args>]
mget [OPTS] <files> mirror [OPTS] [remote [local]]
mkdir [OPTS] <dirs> module name [args] more <files>
mput [OPTS] <files> mrm <files>
mv <file1> <file2> mmv [OPTS] <files> <target-dir>
[re]nlist [<args>] open [OPTS] <site>
pget [OPTS] <rfile> [-o <lfile>] put [OPTS] <lfile> [-o <rfile>] pwd [-p]
queue [OPTS] [<cmd>] quote <cmd>
repeat [OPTS] [delay] [command] rm [-r] [-f] <files>
rmdir [-f] <dirs> scache [<session_no>]
set [OPT] [<var> [<val>]] site <site-cmd>
source <file> torrent [OPTS] <file|URL>...
user <user|URL> [<pass>] wait [<jobno>] zcat <files>
zmore <files>
创建
创建文件(以文本编辑器的方式打开一个新文件,需要写入内容,不然无法创建)
lftp yy@192.168.159.141:/> edit 123
get: Access failed: 550 Failed to open file. (123)
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 6 Dec 13 09:46 123
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
创建目录
lftp yy@192.168.159.141:/> mkdir 888
mkdir ok, `888' created
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 6 Dec 13 09:46 123
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
drwxr-xr-x 2 1001 1001 6 Dec 13 09:47 888
删除
rm -rf文件目录都可以删除
lftp yy@192.168.159.141:/> rm -rf 123
rm ok, `123' removed
lftp yy@192.168.159.141:/> rm -rf 888
rm ok, `888' removed
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:28 555
上传
[root@cjy ~]# ls /opt/
555 666.txt
put只能上传文件
lftp yy@192.168.159.141:/> ls
lftp yy@192.168.159.141:/> put 555 666.txt
3 bytes transferred
Total 2 files transferred
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
mirror才能上传目录
[root@cjy ~]# ls
555 666.txt anaconda-ks.cfg hh
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
lftp yy@192.168.159.141:/> mirror -R hh
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
drwxr-xr-x 2 1001 1001 6 Dec 13 09:59 hh
下载
[root@cjy ~]# rm -rf 555 666.txt
[root@cjy ~]# ls
anaconda-ks.cfg hh
get只能下载文件
lftp yy@192.168.159.141:/> get 555 666.txt
3 bytes transferred
Total 2 files transferred
[root@cjy ~]# ls
555 666.txt anaconda-ks.cfg hh
mirrot才能下载目录
[root@cjy ~]# ls
555 666.txt anaconda-ks.cfg hh
lftp yy@192.168.159.141:/> ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
drwxr-xr-x 2 1001 1001 6 Dec 13 09:59 hh
lftp yy@192.168.159.141:/> mirror hh xx
[root@cjy ~]# ls
555 666.txt anaconda-ks.cfg hh xx
-e 可以不进lftp里面使用命令
[root@cjy ~]# lftp -u yy,123 192.168.159.141 -e ls
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
drwxr-xr-x 2 1001 1001 6 Dec 13 09:59 hh
lftp yy@192.168.159.141:/> quit
[root@cjy ~]# lftp -u yy,123 192.168.159.141 -e 'ls;quit'
-rw-r--r-- 1 1001 1001 0 Dec 13 09:51 555
-rw-r--r-- 1 1001 1001 3 Dec 13 09:51 666.txt
drwxr-xr-x 2 1001 1001 6 Dec 13 09:59 hh
快速登录的别名
[root@cjy ~]# alias dl='lftp -u yy,123 192.168.159.141'
[root@cjy ~]# dl
lftp yy@192.168.159.141:~> quit
wget的用法
用wget -h查看用法
先下载服务
[root@cjy ~]# yum -y install wget
下载
[root@cjy ~]# ls
666.txt anaconda-ks.cfg xx
[root@cjy ~]# wget --ftp-user yy --ftp-password 123 192.168.159.141:666.txt
--2023-12-13 18:15:47-- ftp://192.168.159.141/666.txt
=> ‘666.txt.1’
Connecting to 192.168.159.141:21... connected.
Logging in as yy ... Logged in!
==> SYST ... done. ==> PWD ... done.
==> TYPE I ... done. ==> CWD not needed.
==> SIZE 666.txt ... 3
==> PASV ... done. ==> RETR 666.txt ... done.
Length: 3 (unauthoritative)
666.txt.1 100%[===========================>] 3 --.-KB/s in 0s
2023-12-13 18:15:47 (113 KB/s) - ‘666.txt.1’ saved [3]
[root@cjy ~]# ls
666.txt 666.txt.1 anaconda-ks.cfg xx