如何通过命令行示例使用Ftp服务器

Ftp is very popular file transfer protocol over computer networks and internet. Ftp provides simple but efficient commands and features to download and upload files over network. In this tutorial we will look most used FTP commands.

Ftp是计算机网络和Internet上非常流行的文件传输协议。 Ftp提供了简单而有效的命令和功能,可以通过网络下载和上传文件。 在本教程中,我们将介绍最常用的FTP命令。

If you need to install FTP server look following tutorial.

如果您需要安装FTP服务器,请查看以下教程。

http://www.poftut.com/how-to-install-and-configure-vsftpd-ftp-server-in-linux-ubuntu-debian-centos-fedora-rhel/

http://www.poftut.com/how-to-install-and-configure-vsftpd-ftp-server-in-linux-ubuntu-debian-centos-fedora-rhel/

为CentOS,Fedora,RHEL安装Ftp客户端 (Install Ftp Client For CentOS, Fedora, RHEL)

Ftp command is not installed by default most of the distributions. We can install ftp command with the following command.

默认情况下,大多数发行版未安装Ftp命令。 我们可以使用以下命令安装ftp命令。

$ yum install ftp -y
Install Ftp Client For CentOS, Fedora, RHEL
Install Ftp Client For CentOS, Fedora, RHEL
为CentOS,Fedora,RHEL安装Ftp客户端

为Ubuntu,Debian安装Ftp客户端(Install Ftp Client For Ubuntu, Debian)

We can install ftp command for the Ubuntu and Debian like below.

我们可以为Ubuntu和Debian安装ftp命令,如下所示。

$ apt install ftp

连接FTP服务器 (Connection FTP Server)

First step to connect an ftp server is providing the ip address or domain name of the server to the ftp command. In this example we will connect IP address . The user name and password will be asked. We can use anonymous account which user name and password is anonymous

连接ftp服务器的第一步是向ftp命令提供服务器的IP地址或域名。 在此示例中,我们将连接IP地址。 将会询问用户名和密码。 我们可以使用匿名帐户,其用户名和密码是anonymous

$ ftp 192.168.122.156
Connection FTP Server
Connection FTP Server
连接FTP服务器

If the authentication is successful we will get 230 Login Successful response from ftp server.

如果身份验证成功,我们将从ftp服务器获得230 Login Successful响应。

显示连接状态 (Show Connection Status)

After connecting an ftp server we may need to check the connection status and detailed information about the connection. We can use status command.

连接ftp服务器后,我们可能需要检查连接状态和有关连接的详细信息。 我们可以使用status命令。

status

列出文件 (List Files)

Remote ftp servers will provide a lot of files and folders. We can list these files and folders with ls or dir command like below.

远程ftp服务器将提供许多文件和文件夹。 我们可以使用lsdir命令列出这些文件和文件夹,如下所示。

ls

or

要么

dir
List Files 
List Files 
列出文件

列出当前工作目录(List Current Working Directory)

We can list current working directory on the remote ftp server with pwd command.

我们可以使用pwd命令列出远程ftp服务器上的当前工作目录。

pwd

更改远程当前工作目录 (Change Remote Current Working Directory)

We generally need to change current working directory. We will use cd command in order to change current working directory on ftp server. In this example we will change to the directory named backups

我们通常需要更改当前工作目录。 我们将使用cd命令来更改ftp服务器上的当前工作目录。 在此示例中,我们将切换到名为backups的目录。

cd backups
Change Current Directory
Change Current Directory
更改当前目录

更改本地当前工作目录(Change Local Current Working Directory)

We also have a local current working directory too. This will be used to store downloaded files and looking for upload files. We will use lcd . In this example we change local current working directory to the /home/ismail/

我们也有一个本地当前工作目录。 这将用于存储下载的文件并查找上传文件。 我们将使用lcd 。 在此示例中,我们将本地当前工作目录更改为/home/ismail/

lcd /home/ismail

从FTP服务器下载或获取文件 (Download or Get File From FTP Server)

Now we can start the show. The most popular command for ftp is get . get is used to download files from remote ftp server to the local system. File will be download tot the current local working directory. In this example we will download the backup.tar.gz

现在我们可以开始表演了。 ftp最受欢迎的命令是getget用于将文件从远程ftp服务器下载到本地系统。 文件将下载到当前本地工作目录。 在此示例中,我们将下载backup.tar.gz

get backup.tar.gz
Download or Get File From FTP Server
Download or Get File From FTP Server
从FTP服务器下载或获取文件

从FTP服务器下载或获取多个文件(Download or Get Multiple Files From FTP Server)

Wget use mget command in order to download multiple files from ftp server.

Wget使用mget命令以从ftp服务器下载多个文件。

mget backup.tar.gz oldbackup.tar.gz

Also we can use glob *.* to download all files in the current working directory.

我们也可以使用glob *.*来下载当前工作目录中的所有文件。

mget *.*

将文件发送或发送到ftp服务器 (Put Or Send File To The Ftp Server)

We will use put command in order to send or upload local files. In this example we will upload file named backup.tar.gz . The file must be located in the current local working directory if not change local current working directory accordingly.

我们将使用put命令来发送或上传本地文件。 在此示例中,我们将上传名为backup.tar.gz文件。 如果未相应更改本地当前工作目录,则文件必须位于当前本地工作目录中。

put backup.tar.gz

在FTP服务器上创建目录 (Create Directory On Ftp Server)

We can create a directory on the remote ftp server without uploading anything. We will use mkdir command for this.  In this example we will create a directory named public .

我们可以在远程ftp服务器上创建目录,而无需上传任何内容。 我们将为此使用mkdir命令。 在此示例中,我们将创建一个名为public的目录。

mkdir public

删除FTP服务器中的文件 (Delete File In The Ftp Server)

We can use delete command in order to remove or delete files on the remote ftp server. In this example we will delete the file named backup.tar.gz .

我们可以使用delete命令来删除或删除远程ftp服务器上的文件。 在此示例中,我们将删除名为backup.tar.gz的文件。

delete backup.tar.gz

从FTP服务器删除文件夹或目录 (Delete Folder or Directory From Ftp Server)

We can remove empty directories from ftp server with the rmdir command. In this example we will remote directory named iso

我们可以使用rmdir命令从ftp服务器中删除空目录。 在这个例子中,我们将远程目录命名为iso

rmdir iso
Delete Folder or Directory From Ftp Server
Delete Folder or Directory From Ftp Server
从FTP服务器删除文件夹或目录

从FTP服务器断开连接或退出(Disconnect or Exit From Ftp  Server)

We can exit from ftp server interactive shell with the command exit

我们可以使用命令exit从ftp服务器交互外壳exit

exit
LEARN MORE  List of FTP Commands For Linux and Windows with Examples
了解更多Linux和Windows的FTP命令列表以及示例

翻译自: https://www.poftut.com/how-to-use-ftp-server-from-command-line-tutorial-with-examples/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值