Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【备忘清单】 请求: ftp 命令 #596

Open
peachest opened this issue Apr 8, 2024 · 1 comment
Open

【备忘清单】 请求: ftp 命令 #596

peachest opened this issue Apr 8, 2024 · 1 comment
Assignees
Labels

Comments

@peachest
Copy link

peachest commented Apr 8, 2024

说明项目

介绍

ftp 命令允许用户通过FTP(File Transfer Protocol)协议在本地计算机和远程服务器之间传输文件。
FTP 是一种在网络上交换文件的标准协议,它基于客户端-服务器架构。FTP 是 ARPANet 的标准文件传输协议,ARPANet 网络就是现今 Internet 的前身。使用FTP协议时,一方充当客户端,另一方充当服务器,客户端可以上传、下载、删除、重命名文件和目录,以及执行其他文件传输相关的操作。

快速开始

使用匿名模式访问远程 FTP 服务器

ftp ftp.example.com

ftp 会启动交互式命令行

Connected to <host> (<ip address>).
220 (vsFTPd 3.*)
Name (192.168.10.10:root): anonymous # 输入 anonymous 
331 Please specify the password.
Password: # 匿名模式下直接回车
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

连接成功后进入交互式会话.

查看所有命令,使用 helm?

ftp> help
# 或者
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 服务器的目录结构与 Linux 或 Unix 操作系统中的目录结构相似。它有层级结构,包括根目录、子目录和文件。
因此 FTP 上对目录的操作命令与 Linux 上的基本一致

命令 描述
cd 更改当前工作目录到指定目录
lsdir 列出当前目录下的内容
pwd 显示当前目录的绝对路径
mkdir 创建目录
rmdir 删除一个目录
rename <old> <new> 重命名一个目录

文件操作

命令 描述
get <remote> <local> 下载一个文件到本地
mget 下载多个文件到本地
put <local> <remote> 上传一个文件到服务器
mput 上传多个文件到服务器
delete <remote> 删除一个文件
rename <old> <new> 重命名一个文件

选项

ftp -v ftp.example.com

-v:启用或禁用详细模式。在详细模式下,ftp命令会显示所有来自服务器的响应消息。默认情况下,该选项为开启状态。

ftp -d ftp.example.com

-d:启用调试模式。该选项会显示所有FTP传输过程中发送和接收到的命令,有助于调试连接问题。

ftp -n ftp.example.com

-n:禁止自动登录。默认情况下,ftp命令会在连接到远程服务器后尝试自动登录。使用该选项可以禁止该行为,通常与.netrc文件联合使用。

ftp -g ftp.example.com

禁用文件名通配符扩展。ftp命令默认会展开文件名中的通配符。使用该选项可以关闭这一行为。

ftp -p ftp.example.com

-p:使用被动模式(PASV)进行数据连接。被动模式在客户端位于防火墙或NAT后面时非常有用。

ftp -s:script.txt ftp.example.com # Windows
ftp -n ftp.example.com < script # Linux

⚠️ Windows 上使用-s选项指定script.txt脚本执行 ftp 命令。Linux 上可以使用重定向实现。

自动化 FTP 命令脚本

以匿名登录为例

user anonymous "\n"
binary
ls
pwd
quit

说明

  • user anonymous "\n" 使用匿名登录
  • binary 将文件传输模式设置为二进制模式,这对于非文本文件(如图片、压缩文件等)来说是必要的,以确保文件在传输过程中不会被更改。
ftp -n ftp.example.com < script

使用 -n 选项禁止自动登录,这样会继续执行 user 指令,而不是启动交互式命令行。

提供官网

No response

参考资料 URL

How to Use Linux FTP Command to Transfer Files
新手常用的 50 个 Linux FTP 命令
Linux 命令大全手册 | ftp命令 – 文件传输协议客户端

@peachest
Copy link
Author

peachest commented Apr 9, 2024

重新修改了文档,加入了布局配置
ftp.md

jaywcjlove added a commit that referenced this issue Apr 9, 2024
github-actions bot pushed a commit that referenced this issue Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants