![linux 命令 ftp](https://i-blog.csdnimg.cn/blog_migrate/b1ad3b68c882565682462fe19731a1d5.png)
linux 命令 ftp
FTP protocol and tools are used to transfer data over network in a simple manner. There are different FTP tools with GUI support which can provide simple usage without knowing any command but in some cases we may need to use FTP commands. In this tutorial we will learn how to use FTP commands with example in operating systems like Windows and Linux.
FTP协议和工具用于以简单方式通过网络传输数据。 有多种具有GUI支持的FTP工具,它们可以在不知道任何命令的情况下提供简单的用法,但是在某些情况下,我们可能需要使用FTP命令。 在本教程中,我们将学习如何在Windows和Linux等操作系统中使用FTP命令作为示例。
逃脱壳 (Escape Shell)
!
执行宏 (Execute Macro)
Defined macros can be executed with the $
by providing the macro name. In this example we will run macro named test
通过提供宏名称,可以使用$
执行定义的宏。 在此示例中,我们将运行名为test
宏
$test
打印本地帮助信息 (Print Local Help Information)
We can print help information about local commands with ?
我们可以使用?
打印有关本地命令的帮助信息?
?
![Print Local Help Information](https://i-blog.csdnimg.cn/blog_migrate/c60de0797ba6d65537750a3fc98ab43d.png)
将帐户命令发送到远程服务器(Send Account Command To Remote Server)
After connecting an FTP server we can change the current user with account
command. This will as for the USER and PASS information.
连接FTP服务器后,我们可以使用account
命令更改当前用户。 这将与USER和PASS信息相同。
account
附加到文件 (Append To A File)
We can append into existing file with append
command like below.
我们可以使用如下所示的append
命令将其追加到现有文件中。
append
设置ASCII传输类型 (Set ASCII Transfer Type)
There are different transfer types. We can use ascii
to change text transfer mode.
有不同的传输类型。 我们可以使用ascii
更改文本传输模式。
ascii
命令完成时发出提示音 (Beep When Command Completed)
beep
command will play sound after the given command is completed.
给定命令完成后, beep
命令将播放声音。
beep
设置二进制传输类型 (Set Binary Transfer Type)
Other than ascii
type there is also binary
transfer type where there will be no translation during transfer.
除ascii
类型外,还有binary
传输类型,在传输过程中不会进行翻译。
binary
终止FTP会话并退出 (Terminate FTP Session and Exit)
We can terminate current FTP session and exit from FTP shell with bye
command like below.
我们可以使用下面的bye
命令终止当前的FTP会话并从FTP Shell退出。
![Terminate FTP Session and Exit](https://i-blog.csdnimg.cn/blog_migrate/73ac44d6c90655c4ecd427ee6965af1c.png)
bye
切换区分大小写 (Toggle Case Sensitivity)
Case sensitivity can be enabled or disabled with case
command like below.
可以使用如下case
命令启用或禁用case
。
case
更改远程工作目录 (Change Remote Working Directory)
We can change current working directory of the remote system or server with the cd
command. In this example we will navigate to the remote directory Mirror
我们可以使用cd
命令更改远程系统或服务器的当前工作目录。 在此示例中,我们将导航到远程目录Mirror
cd Mirror
![Change Remote Working Directory](https://i-blog.csdnimg.cn/blog_migrate/9d1bea0568dcb93963a756aace144a3b.png)
将远程目录更改为父目录(Change Remote Directory To Parent Directory)
cdup
will automatically change current working directory of remote system to the parent or single upper level.
cdup
会自动将远程系统的当前工作目录更改为父级或单个上级目录。
cdup
更改远程文件权限 (Change Remote File Permissions)
If we have enough privileges we can change remote system file permissions iwth chmod
like in Linux systems.
如果我们有足够的特权,我们可以像在Linux系统中那样使用chmod
更改远程系统文件的权限。
chmod
终止FTP会话 (Terminate FTP Session)
Another command to terminate FTP sessions but this command will not exit from interactive FTP shell.
另一个终止FTP会话的命令,但该命令不会从交互式FTP Shell中退出。
close
![Terminate FTP Session](https://i-blog.csdnimg.cn/blog_migrate/60f62588b5032e8dc1f403ecfa593130.png)
启用/禁用回车剥离(Enable/Disable Carriage Return Stripping)
cr
启用/禁用调试 (Enable/Disable Debugging)
If we have problem about executing commands we may need more information. We can run commands in verbose mode with debug
command.
如果我们对执行命令有疑问,我们可能需要更多信息。 我们可以使用debug
命令以详细模式运行命令。
debug
![Enable/Disable Debugging](https://i-blog.csdnimg.cn/blog_migrate/cee4c76806da92c55e5b643673fc5885.png)
删除远程文件(Delete Remote File)
We can delete remote file with delete
command. In this exmaple we will delete file named old.txt
我们可以使用delete
命令删除远程文件。 在此old.txt
我们将删除名为old.txt
文件
delete old.txt
列出远程目录的内容 (List Contents of Remote Directory)
We can list contents , files and folders of the remote system with the dir
command like below.
我们可以使用dir
命令列出远程系统的内容,文件和文件夹,如下所示。
$ dir
![List Contents of Remote Directory](https://i-blog.csdnimg.cn/blog_migrate/6ef1d8709753f6f0631706d75c2eef45.png)
终止FTP会话(Terminate FTP Session)
We can close current FTP session or connection but stay in the FTP shell with disconnect
command.
我们可以关闭当前的FTP会话或连接,但可以使用disconnect
命令保留在FTP Shell中。
disconnect
![Terminate FTP Session](https://i-blog.csdnimg.cn/blog_migrate/261f2acc093d6d982a0e91e17a843d51.png)
终止FTP会话并退出(Terminate FTP Session and Exit)
We can terminate current FTP session and exit from FTP shell with exit
command.
我们可以终止当前的FTP会话,并使用exit
命令从FTP Shell exit
。
exit
![Terminate FTP Session and Exit](https://i-blog.csdnimg.cn/blog_migrate/d57d2de180fafa105e3dde4683897b14.png)
设置文件传输格式(Set File Transfer Format)
form
接收档案 (Receive File)
We can download from remote system with get
command. We will download file named timestamp.txt
in this example.
我们可以使用get
命令从远程系统下载。 在此示例中,我们将下载名为timestamp.txt
文件。
get timestamp.txt
![Receive File](https://i-blog.csdnimg.cn/blog_migrate/c74b161c691485ea108e1a86d2dfcf18.png)
显示本地帮助信息(Display Local Help Information)
help
![Display Local Help Information](https://i-blog.csdnimg.cn/blog_migrate/9a8cc743a4377539b7e578c920cbb093.png)
设置二进制传输类型(Set Binary Transfer Type)
image
允许使用任何IP地址族 (Allow Use Of Any IP Address Family)
ipany
仅保留IPv4 (Resctrict Only IPv4)
ipv4
仅限制IPv6 (Restrict Only IPv6)
ipv6
更改本地工作目录 (Change Local Working Directory)
As we work also local system we can change local directory with lcd
command.
当我们也在本地系统上工作时,我们可以使用lcd
命令更改本地目录。
lcd Downloads/
![Change Local Working Directory](https://i-blog.csdnimg.cn/blog_migrate/5cd06d4ce5b0b93c48bace26d6847113.png)
列出远程目录的内容(List Contents Of Remote Directory)
The one of the most popular FTP command is ls
which will list contents, files, folders of the remote system.
最受欢迎的FTP命令之一是ls
,它将列出远程系统的内容,文件,文件夹。
ls
![List Contents Of Remote Directory](https://i-blog.csdnimg.cn/blog_migrate/f182a376d5c1e63d4290ed9b84897635.png)
定义宏(Define Macro)
macdef
删除多个文件 (Delete Multiple Files)
We can delete multiple files and folders with a single command. In this example we will delete files named 1.txt
, 2.txt
, 3.txt
我们可以使用一个命令删除多个文件和文件夹。 在此示例中,我们将删除名为1.txt
, 2.txt
, 3.txt
mdelete 1.txt 2.txt 3.txt
在远程上创建目录 (Create Directory On Remote)
We can create a directory on the remote system with mkdir
command. In this example we will create directory named backup
我们可以使用mkdir
命令在远程系统上创建目录。 在此示例中,我们将创建名为backup
目录。
mkdir backup
列出多个远程目录的内容 (List Contents Of Multiple Remote Directories)
mls
设置文件传输模式 (Set File Transfer Mode)
mode
显示远程文件的最后修改时间 (Show Last Modification Time Of Remote File)
We can show last modification time of the file on the remote system with modtime
command. We will list modification time of the filelist.gz
on the remote system.
我们可以使用modtime
命令显示远程系统上文件的最后修改时间。 我们将列出远程系统上filelist.gz
修改时间。
modtime filelist.gz
![Show Last Modification Time Of Remote File](https://i-blog.csdnimg.cn/blog_migrate/7d85c0c1fecc2b71e25a9806b5cd64cf.png)
发送多个文件(Send Multiple Files)
We can put multiple files with mput
command. In this example we will send files 1.txt
, 2.txt
, 3.txt
我们可以使用mput
命令放置多个文件。 在此示例中,我们将发送文件1.txt
, 2.txt
, 3.txt
mput
如果远程文件比本地文件新,则获取文件 (Get File If Remote File Is Newer Than Local File)
We can only get file if remote file is newer then local file. In this example we check remote file 1.txt
with local file 1.txt
如果远程文件比本地文件新,我们只能获取文件。 在此示例中,我们检查远程文件1.txt
与本地文件1.txt
newer 1.txt 1.txt
列出远程目录的内容 (List Contents Of Remote Directory)
nlist
将模板设置为默认文件名映射 (Set Template For default File Name Mapping)
nmap
为默认文件名映射设置转换表 (Set Translation Table For Default File Name Mapping)
ntrans
连接远程FTP服务器和端口 (Connect Remote FTP Server and Port)
We can connect to the FTP server with open
command from FTP shell. In this example we will connect to the ftp.itu.edu.tr
.
我们可以使用来自FTP shell的open
命令连接到FTP服务器。 在此示例中,我们将连接到ftp.itu.edu.tr
open ftp.itu.edu.tr
![Connect Remote FTP Server and Port](https://i-blog.csdnimg.cn/blog_migrate/4563bf3a3a52bbc2838fcbbc7b59bdf0.png)
进入被动传输模式(Enter Passive Transfer Mode)
passive
强制交互式提示多个命令 (Force Interactive Prompting on Multiple Commands)
prompt
在备用连接上发出命令 (Issue Command On Alternate Connection)
proxy
发送单个文件 (Send Single File)
We can use put
command in order to send single file to the FTP server. In this example we will send file named data.txt
to the remote system.
我们可以使用put
命令将单个文件发送到FTP服务器。 在此示例中,我们将名为data.txt
文件发送到远程系统。
put data.txt
在远程系统上打印工作目录 (Print Working Directory on Remote System)
We can print and list current working directory of the remote system or server. We will use pwd
without any option.
我们可以打印并列出远程系统或服务器的当前工作目录。 我们将不带任何选项使用pwd
。
pwd
![Print Working Directory on Remote System](https://i-blog.csdnimg.cn/blog_migrate/08a200e70df4510aef891dc85135f29e.png)
打印? 代替控制字符 (Print ? In Place Of Control Characters)
qc
终止FTP会话并退出 (Terminate FTP Session and Exit)
Another good command in order to terminate FTP session and exit from FTP shell.
另一个好命令,以终止FTP会话并从FTP Shell退出。
quit
![Terminate FTP Session and Exit](https://i-blog.csdnimg.cn/blog_migrate/265973dbee8e9ef1c88c6d6ac10de455.png)
发送任意FTP命令(Send Arbitrary FTP Command)
quote
接收档案 (Receive File)
Another good command in order to download file from remote FTP server we will use recv
command with the file name we want to download. In this example we will download file named timestamp.txt
.
为了从远程FTP服务器下载文件,另一个很好的命令是我们将recv
命令与我们要下载的文件名一起使用。 在此示例中,我们将下载名为timestamp.txt
文件。
recv timestamp.txt
![Receive File](https://i-blog.csdnimg.cn/blog_migrate/32c6811cc7e9df480c7dd63ad2b1073e.png)
在本地文件末尾获取重新启动的文件(Get File Restarting At End Of Local File)
reget
重新命名文件 (Rename File)
We can rename a remote file. We will use rename
with the current name of file and new name of the file. We will rename file named data.txt
into newdata.txt
我们可以重命名一个远程文件。 我们将使用rename
以及文件的当前名称和文件的新名称。 我们将名为data.txt
文件重命名为newdata.txt
rename data.txt newdata.txt
清除排队的命令答复 (Clear Queued Command Replies)
reset
重新启动文件传输(按字节计数) (Restart File Transfer At Byte Count)
restart
从远程服务器获取帮助 (Get Help From Remote Server)
rhelp
删除远程系统上的目录 (Remove Directory On Remote System)
We can remote a directory on the remote FTP server or system with rmdir
by providing the directory name. In this example we will remove directory named old
通过提供目录名称,我们可以使用rmdir
在远程FTP服务器或系统上远程目录。 在此示例中,我们将删除名为old
目录
rmdir old
显示远程系统的状态 (Show Status Of Remote System)
After connecting remote FTP server or system we can print current status about the remote system and connection with the rstatus
command.
连接远程FTP服务器或系统后,我们可以使用rstatus
命令打印有关远程系统和连接的当前状态。
rstatus
![Show Status Of Remote System](https://i-blog.csdnimg.cn/blog_migrate/1a2847a136cc4ad17efc91f04ada12db.png)
We can see that there are following information
我们可以看到以下信息
- Connected IP address连接的IP地址
- Mode or Type which is ASCII in this case在这种情况下为ASCII的模式或类型
- Sessions bandwith limit which is unlimited in this example会话带宽限制,在此示例中是无限的
- Sessions timeout which is 300 seconds in this example会话超时,在此示例中为300秒
- Control connection type which is plain text in this example控制连接类型,在此示例中为纯文本
- Data connection type which is plain text in this example数据连接类型,在此示例中为纯文本
- Connected client count to the remote FTP server which is 2 in this example连接的客户端数到远程FTP服务器,在此示例中为2
- Server software name and version with its banner which is vsFTPd 2.2.2 in this example 在此示例中,服务器软件名称和版本及其标语为vsFTPd 2.2.2
切换本地文件的唯一存储 (Toggle Store Unique for Local File)
runique
发送一个文件 (Send One file)
We can send a single file to the remote server with the send
command by specifying file name. In this example we will send file named data.txt
通过指定文件名,我们可以使用send
命令将单个文件发送到远程服务器。 在此示例中,我们将发送名为data.txt
文件
send data.txt
为每个数据连接启用/禁用端口 (Enable/Disable Use Of PORT For Each Data Connection)
sendport
显示远程文件的大小 (Show Size Of Remote File)
We can print the size of the given file on the remote server with size
command and providing the file name. In this example we will print the size of the filelist.gz
我们可以使用size
命令并提供文件名在远程服务器上打印给定文件的size
。 在此示例中,我们将打印filelist.gz
的大小。
size filelist.gz
![Show Size Of Remote File](https://i-blog.csdnimg.cn/blog_migrate/7b14c4fabff5601a29981b7e379348fb.png)
显示当前状态(Show Current Status)
We can print current status of the connection and technical details with status
command.
我们可以使用status
命令打印连接的当前状态和技术详细信息。
status
![Show Current Status](https://i-blog.csdnimg.cn/blog_migrate/7b624902513830c064b7d65a7423390b.png)
设置文件传输结构(Set File Transfer Structure)
struct
在远程系统上切换唯一存储 (Toggle Store Unique On Remote System)
sunique
显示远程系统类型 (Show Remote System Type)
While working with remote FTP server operating system is important. We can get information about remote system with system
command like below.
在使用远程FTP服务器时,操作系统很重要。 我们可以使用以下system
命令获取有关远程系统的信息。
system
![Show Remote System Type](https://i-blog.csdnimg.cn/blog_migrate/b26d1666d47437bca1e3cfa70cd7f22d.png)
设置Tenex文件传输类型(Set Tenex File Transfer Type)
tenex
传输期间启用/禁用打印字节计数器 (Enable/Disable Printing Byte Counter During Transfers)
tick
启用/禁用软件包跟踪 (Enable/Disable Package Tracing)
trace
设置文件传输类型 (Set File Transfer Type)
type
在远程系统上获取Umask (Get Umask On Remote System)
umask
发送新的用户信息 (Send New User Information)
We can relogin with different user name by using user
command. We will provide user name and password interactively.
我们可以使用user
命令以不同的用户名重新登录。 我们将以交互方式提供用户名和密码。
user
![Send New User Information](https://i-blog.csdnimg.cn/blog_migrate/c3216f565201e3da1388c18cc18f24ac.png)
启用/禁用详细模式(Enable/Disable Verbose Mode)
Like debug mode with can enable and disable verbose mode with verbose
command like below.
像debug mode with可以通过如下的verbose
命令启用和禁用verbose模式。
verbose
![Enable/Disable Verbose Mode](https://i-blog.csdnimg.cn/blog_migrate/b4a3d1dec523452195de469ac0f4d837.png)
翻译自: https://www.poftut.com/list-of-ftp-commands-for-linux-and-windows-with-examples/
linux 命令 ftp