Standard Windows utility "FTP client" from the command line (CMD) - for backing up or downloading files without your participation (automatically). Download and upload files via FTP using the Ftp console from the command line

Hello everyone, today I’ll tell you about the ftp.exe utility as a tool for working with FTP servers.

To work with FTP servers, it is not at all necessary to use cumbersome (and sometimes not free) FTP clients; for simple operations, the utility included in Windows server 2008 R2 or Windows 7 is quite suitable command line ftp.exe.

To run ftp.exe, you need to call the dialog box “ Execute» and dial ftp. The client will print a prompt in the shell cmd.exe and will be immediately ready to work:

The ftp.exe utility as a tool for working with FTP servers-01Syntax ftp.exe very simple and described in sufficient detail in the built-in help, which can be called with the command help:

In the help system ftp.exe exist brief descriptions all teams. They are called by the command help. Let's see, for example, what the command does dir. To do this, let's dial help dir:

Let's try to establish a connection with some ftp server. Let it be linuxcenter.ru. The team will help us with this open linuxcenter.ru:

After connecting to the ftp server, we need to tell it in what mode we will work with it. There are only two modes: port-mode channel And passive-mode data channel. In 99 cases out of 100 it is used passive mode(will tell you more about the differences Wikipedia), we inform the server that we are not an exception to the rule, with the command quote PASV:

Now we can begin to perform operations with data: navigate through the directory structure and display their listings, upload and download files, change the formats of transferred data, etc. However, ftp servers are different. Therefore, first it would be useful to familiarize yourself with the syntax supported remote server. There is a command for this remotehelp:

To close an active connection, use the command close, to exit ftp.exe - quit. AND help to help you. This is how you can still work with the ftp server. Site material

If the host you specified has an FTP server, it will ask you for a username and password. You can log in using your own username, if you have one, or you can log in as anonymous. Anonymous FTP sites are very often used as program archives. Once connected, you will receive an invitation ftp>. FTP uses separate commands, but they are similar to standard commands. The list of basic FTP commands is given in Table 4.3.

Notes

1 Help on commands can be obtained: about the utility ftp- on command ftph; about FTP commands - by command ftp>help or ftp> ?; about each FTP command - one command at a time ftp>helpcommand_name.

2 You can connect to an FTP server and exchange files in the Total Commander environment using the command Network - Connect withFTP-server... .

Table 4.3 – Basic FTP client commands

Usage

open sername

Opens a connection to the server. This name can be specified immediately when entering the ftp command that boots the client

ls or dir

Displays the contents of the server directory (remote computer)

CD dirname

Moves to another working directory (named dirname) on the server

put filename

Rewrites the file filename from the local computer to the server. The command is prohibited for anonymous users

get filename

Rewrites a file from the server to local computer

mput

Writes a group of files. Similar to the put command, but wildcards are allowed. Confirmation will be requested before each file is written. To cancel confirmations, enter prompt

mget

Overwrites a group of files. Similar to the get command, but wildcards are allowed. Confirmation will be requested before each file is copied. To cancel confirmations, enter prompt

Toggles symbol output # for each kilobyte transferred (buffer)

Logging out of the FTP client

Closes the connection to this server and returns to command mode. This command is automatically executed when you exit the FTP client

4.2.5.5 In order for a computer to find another on a network, there must be a mechanism for describing how to “get” from one computer to another. This mechanism for choosing the best path is called routing. A route is specified by a pair of addresses: a “destination address” and a “network gateway” (gateway) ( network gateway– hardware router or software for interfacing computer networks using different protocols). This pair indicates that if you are trying to connect to a destination address, you need to communicate through the network gateway.

Routing tables are an important part of the TCP/IP protocol in Windows, but the operating system does not show them to the average user. The utility is used to process network route tables route. To display the routing table (IP routing), you need to open a command prompt and enter the command routeprint(run without parameters, command route displays a certificate). But before looking at the routing table, it is advisable to enter the command on the command line ipconfig / all(or ipconfig - all), showing the installation of the TCP/IP protocol on the computer. You can also look at the TCP/IP section in the properties of the network adapter, but the first method is preferable (the data entered into the TCP/IP properties determines the protocol setting for the selected network, and the command ipconfig shows how Windows actually configured the protocol). If there are several network adapters, it is difficult to remember which settings apply to which adapter. The team ipconfig shows the list different settings in easy readable format based on network adapter.

If you're having trouble getting packets through your network, it's best to start the diagnostic process by comparing the information provided by the command ipconfig, with information in routing tables. To understand the information contained in the tables, it is necessary to understand how the router works. Router or router (router) is a network device that, based on information about the network topology and certain rules, makes decisions about forwarding packets between different network segments (routers are one example of hardware network gateways). Network segment– a logically or physically separate part of the network (when dividing an IP-based network into logical segments, or logical subnets, each segment is allocated a range of addresses, which is specified by the network address and network mask; as a rule, the physical network segment is limited by the network device that provides connection of segment nodes to the rest of the network). The router's job is to route traffic (traffic) (flow of packets) from one network to another. Therefore, a router can consist of several network adapters, each of which is connected to a different network segment. Thus, a route is a sequence of routers through which a packet passes.

When a user sends a packet to a different network segment than the one the computer is connected to, the packet is forwarded to the router. The router then determines the segment to which the packet should be forwarded. It doesn't matter whether the router is connected to two network segments or ten. The router's decision making process is the same, and it is based on routing tables. The routing table is divided into five columns:

– “Network Destination” column – all network segments to which the router is connected are presented here;

– “Netmask” column – shows the subnet mask, but not network interface, to which the segment is connected, and the segment itself. This allows the router to determine the address class for the destination network;

– Gateway Address column – after the router has determined the destination network to which it needs to send the packet, it checks the gateway list. This list “tells” the router through which IP address the packet should be sent to the destination network;

– “Interface” column – provides information about the network adapter connected to the destination network. It would be more accurate to say that this column provides information about the IP address of the network adapter that connects the router to the destination network. But the router is smart enough to understand what the address is assigned to;

– “Metric” column – provides information about the metric (weight) of the route. The metrics of entries in the table play a role in calculating the shortest routes to various recipients. Metrics come into play when there are multiple routes for sending packets, i.e. in this Windows case checks metrics to determine the shortest path (if there is only one route to reach the destination, metrics are not used).

There are many options for using the command route. Its syntax is as follows:

route [-f] [-p] [team [end_point] [mask netmask] [gateway] [metric metrics]] [if interface]]

Parameter -f is optional. It instructs Windows to clear the routing tables of all entries that are not a host route (routes with a subnet mask of 255.255.255.255), a loopback network route (routes with an endpoint of 127.0.0.0 and a subnet mask of 255.0.0.0), or a multicast route broadcasts (routes with endpoint 224.0.0.0 and subnet mask 240.0.0.0). When this parameter is used in conjunction with one of the commands, the route table is cleared before the command is executed.

Parameter –p makes a certain route permanent. When using this option with the command add the specified route is added to the registry and used to initialize the IP routing table each time TCP/IP starts (by default, added routes are not saved when TCP/IP starts). When using the parameter with the command print– displays a list of permanent routes. All other commands ignore this parameter. Permanent routes are stored in the registry at HKEY_ LOCAL_ MACHINE\ SYSTEM\ CurrentControlSet\ Servi- ces\ Tcpip\ Parameters\ PersistentRoutes.

Team in syntax route may consist of four options: add– adding a route; change– changing an existing route; delete– deleting a route or routes and print– print the route or routes. Can be used special characters on the team. If you need to print routes for the 192.x.x.x subnet, you can use the command routeprint 192.* .

End_point route can be a network IP address (where the host bits in network address have a value of 0), the IP address of the route to the host, or the value 0.0.0.0 for the default route.

Parametermask netmask specifies the network mask (also known as subnet mask) according to the destination. The netmask can be a subnet mask corresponding to the network IP address, such as 255.255.255.255 for a route to a host, or 0.0.0.0 for a default route (the default route is used if none of the other routes are suitable). If this parameter is omitted, the subnet mask 255.255.255.255 is used. The endpoint cannot be more precise than the corresponding subnet mask. In other words, the value of bit 1 in the endpoint address is not possible if the value of the corresponding bit in the subnet mask is 0.

Gateway specifies the forwarding or next-hop IP address at which the set of addresses defined by the endpoint and subnet mask is available. For locally connected subnet routes, the gateway address is the IP address assigned to the interface that is connected to the subnet. For remote routes that are accessible through one or more routers, the gateway address is the directly accessible IP address of the nearest router.

Parametermmetric metrics specifies an integer route cost metric (ranging from 1 to 9999) that is used to select one of several routes in the routing table that most closely matches the destination address of the forwarded packet. The route with the lowest metric is selected. The metric reflects the number of transitions, the speed of the path, the reliability of the path, throughput ways and means of administration.

Parameterif interface indicates the index of the interface through which the destination is accessible, i.e. tells Windows which adapter to use. To display a list of interfaces and their corresponding indexes, use the command route print. Interface index values ​​can be either decimal or hexadecimal. Before hexadecimal numbers enter 0x. In case the parameter if omitted, the interface is determined from the gateway address.

FTP (File Transfer Protocol) is the most popular protocol for transferring files (download and upload) from one system to another system. This provides a fast way to transfer files. There are many applications available on Linux and Windows such as VSFTPD, ProFTPD for Linux, FileZilla Server for windows and macOS.

Eat various ways I use a graphical environment to connect to the FTP server, but system administrator must know the power of the command line. And in this topic “Download and upload files via FTP using the console” I will tell you how you can work with the command line to transfer/receive data.

1. Connect to an FTP server using the command line

To connect to any server using the command line, use the terminal.

$ ftp ftp.site

2. Upload file to FTP server

To upload a file to the server use FTP put. First, you need to go to the desired folder on FTP server to download the file and use the following command.

Ftp> cd uploads ftp> put /home/captain/my_file.txt

3. Download one file from FTP server

To download a file from an FTP server, we use the get command. Using this command we can download one file. To download any file from FTP server, first login to the FTP server, then go to the directory and use the following command to download any file:

Ftp> get my_file.txt

4. Upload multiple files to FTP server

To upload multiple files to an FTP server we use the MPUT command. We can specify a wildcard character to upload multiple files to the server at the same time. Firstly go to the desired folder on the FTP server to upload the file and use the following command. It will upload all files with .txt extension to the /home/captain directory for uploaded files on the FTP server.

Ftp> cd uploads ftp> lcd /home/captain/ ftp> put *.txt

5. Download multiple files from FTP server

To download multiple files from an FTP server, we use the MGET command. Using this command you can upload files.

Ftp> mget *.txt

Teams.

!
Exit shell

?
Print help about local information

append
Add to file

ascii
Set the transfer type to ASCII. Use this to transfer text files (HTM files).

bell
Sound signal when command completes.

binary
Set the transfer type to binary. Use this to transfer binary files (XE files and graphics).

bye

CD
Change remote working directory (use ".." to change to parent).

close
End the FTP session.

delete
Delete the deleted file.

debug
Switch debug mode.

dir
List (show) the contents of a remote directory.

disconnect
End the FTP session.

get
Get a file (see also mget).

glob
Switch extension metacharacter from local filename.

hash
Toggle printing '#' for each buffer passed.

help
Show a list of commands.

lcd
Change local working directory.

literal
Send a custom FTP command.

ls
Show the contents of a remote directory.

mdelete
Deleting multiple files.

mdir

mget
Get multiple files (see also get)

mkdir
Create a directory on the remote machine.

mls
List the contents of several remote directories.

mput
Send multiple files (see also put).

open
Connect to remote FTP.

prompt
Rough interactive prompt on multiple teams (this is a switch)

put
Send one file (see also mput).

pwd
Print working folder(where you are now) on a remote machine.

quit
End the connection session and work.

quote
Send a custom FTP command. You can view a list of raw FTP commands at www.nsftools.com/tips/RawFTP.htm

recv
Receive file

remotehelp
Get help from remote server

rename
Get file.

rmdir
Delete a directory on a remote machine.

send
Send one file.

status
Show current status.

trace
Toggle packet tracing.

type
Set transfer file type

user
Send new user information.

verbose
Toggle verbose mode.

The topic “Download and upload files via FTP using the console” is completed.

FTP (File Transfer Protocol) is a popular network protocol that is used to copy files from one computer to another in local network, or on the Internet. FTP is one of the oldest application protocols, appearing long before HTTP, and even before TCP/IP, in 1971.

The FTP protocol is vulnerable, meaning FTP cannot encrypt its traffic, all transmissions are plaintext, so usernames, passwords, commands and data can be read by anyone able to intercept the packet over the network. For secure data transfer, the SFTP (Secure File Transfer Protocol) protocol is used. Unlike standard FTP, it encrypts both commands and data, preventing passwords and sensitive information from being transmitted openly over the network. SFTP is similar in functionality to FTP, but because it uses a different protocol, standard FTP clients cannot communicate with an SFTP server and vice versa. Next, we will look at the basic commands for working with the FTP program.

FTP client is one of the most Linux distributions. Let's start by launching the program and ftp connection and, of course, consider the basic commands for downloading from an ftp server and uploading to ftp, creating directories, deleting files, etc. In this article we will describe only the basic commands, and at the end of the article we will provide help and a manual from the console - you can always find out about the purpose of the command and its syntax, as well as about all the available commands on a specific ftp server.

FTP connection

To start an FTP connection, just enter the command ftp<сервер> For example:

ftp test.hostingthutor.com

After pressing enter, the command output will be as follows:

Connected to test..55.5.11).
220 test..
Name (test.site:ftpuser):

Another way to connect is to run ftp from the console, and after that connect to the ftp server using the command open:

ftp
ftp> test.site

In addition, it is possible to connect via IP:

ftp 114.55.5.11

Or with this request ftp This e-mail is being protected from spambots. To view it, your browser must have Javascript support enabled, that is:

ftp This e-mail is being protected from spambots. To view it, your browser must have Javascript enabled
230 User ftpuser logged in
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

From the message it is clear that the binary (binary) transfer type is used to transfer files. Binary file transfer mode is the transfer of files in the form in which they are stored on the FTP server. Ascii (text) mode is used to transmit only text files. You can enter commands ascii or binary to switch between transmission modes. Binary mode must be used for all non-text file types - images, archives, programs, etc.

So, let's move on to the commands for navigating and going through the ftp server directories:

pwd - the command will show the current directory on the ftp server:

ftp>pwd
257 "/" is the current directory

ls - the command will show a list of files and directories in the current directory:

ftp>ls
227 Entering Passive Mode.
150 Opening ASCII mode data connection for file list
-rw-r--r-- 1 ftpuser ftpuser 3034978 Jun 31 19:02 file1.tar.gz
-rw-r--r-- 1 ftpuser ftpuser 30842294 Jul 31 20:08 file2.tar.gz
-rw-r--r-- 1 ftpuser ftpuser 67798316 Jul 31 19:46 file3.tar.gz
-rw-r--r-- 1 ftpuser ftpuser 6001252 Jan 17 12:02 file4.zip
-rw-r--r-- 1 ftpuser ftpuser 31386394 Jan 17 11:28 file5.tar.gz
drwxr-xr-x 2 ftpuser ftpuser 4 Jan 17 20:23 www
-rw-r--r-- 1 ftpuser ftpuser 48546694 Jan 17 11:33 file6.zip
226 Transfer complete

CD<имядиректории> - command to go to the desired directory:

ftp> cd www
250 CWD command successful

We check with the team pwd :

ftp>pwd
257 "/www" is the current directory

mkdir<имя директории> - creating a new directory (directory):

ftp> mkdir tmp
257 "/tmp" - Directory successfully created

rmdir<имя директории> - deleting a directory (directory):

ftp> rmdir tmp
250 RMD command successful

Deleting files on an ftp server

delete<имяфайла> - deletes a file on a remote ftp server:

ftp> delete test1.sql
250 DELE command successful

Downloading files from ftp

get - download the file to your local machine. get fileName or get fileName newFileName

ftp>get file.zip
local: file.zip remote: file.zip
227 Entering Passive Mode.

226 Transfer complete
486694 bytes received in 0.229 secs (6.5e+04 Kbytes/sec)

Download file.zip to your local machine as file2.zip:

ftp> get file.zip file2.zip
local: file2.zip remote: file.zip
227 Entering Passive Mode.
150 Opening BINARY mode data connection for file.zip (486694 bytes)
226 Transfer complete
486694 bytes received in 0.306 secs (9.4e+04 Kbytes/sec)

Using the command get from the remote ftp server, files are copied to the current local directory. To change the current local directory you need to use the command lcd:

lcd<путь> - change the current directory on the local machine:

ftp> lcd /root
Local directory now /root

To download multiple files from remote ftp server to your local machine, you can use the command mget .

ftp> mget *.sql
mget test2.sql? y
227 Entering Passive Mode.
(23957080 bytes)
226 Transfer complete
23957080 bytes received in 0.233 secs (1e+05 Kbytes/sec)
mget test1.sql? y
227 Entering Passive Mode.
(11873185 bytes)
226 Transfer complete
11873185 bytes received in 0.135 secs (8.6e+04 Kbytes/sec)

The download of each file must be confirmed (yes / no) y /n .

Another download option mget :

ftp> mget test1.sql test2.sql
mget test1.sql? y
227 Entering Passive Mode.

226 Transfer complete
11873185 bytes received in 0.101 secs (1.1e+05 Kbytes/sec)
mget test2.sql? y
227 Entering Passive Mode.

226 Transfer complete
23957080 bytes received in 0.204 secs (1.1e+05 Kbytes/sec)

Uploading a file to an ftp server

put<имяфайла> - command to upload one file to an ftp server.

ftp> put test1.sql
local: test1.sql remote: test1.sql
227 Entering Passive Mode.
150 Opening BINARY mode data connection for test1.sql
226 Transfer complete
11873185 bytes sent in 0.129 secs (9e+04 Kbytes/sec)

For upload multiple files you can immediately use the command mput :

ftp> mput test1.sql test2.sql
mput test1.sql? y
227 Entering Passive Mode.
150 Opening BINARY mode data connection for test1.sql
226 Transfer complete
11873185 bytes sent in 0.0964 secs (1.2e+05 Kbytes/sec)
mput test2.sql? y
227 Entering Passive Mode.
150 Opening BINARY mode data connection for test2.sql
226 Transfer complete
23957080 bytes sent in 0.354 secs (6.6e+04 Kbytes/sec)

Each file upload must be confirmed. y / n (Not really).

Another command option mput :

ftp> mput *.sql
mput test1.sql? y
227 Entering Passive Mode.
150 Opening BINARY mode data connection for test1.sql
226 Transfer complete
11873185 bytes sent in 0.0985 secs (1.2e+05 Kbytes/sec)
mput test2.sql? y
227 Entering Passive Mode.
150 Opening BINARY mode data connection for test2.sql
226 Transfer complete
23957080 bytes sent in 0.2 secs (1.2e+05 Kbytes/sec)

If large files are uploaded to FTP, then it would be a good idea to monitor the progress of the upload. For this you can use the commands hash And tick .

hash - the command after which ftp will print the “#” character every 1024 bytes of data:

ftp> hash
Hash mark printing on (1024 bytes/hash mark).
put file2.tar.gaz
##########################
226 Transfer complete
785888111 bytes sent in 6.94 secs (1.1e+05 Kbytes/sec)

tick - the command will display the byte counter:

ftp>tick
Hash mark printing off.
Tick ​​counter printing on (10240 bytes/tick increment).
ftp> put file2.tar.gz
local: file2.tar.gz remote: file2.tar.gz
227 Entering Passive Mode.
150 Opening BINARY mode data connection for file2.tar.gz
Bytes transferred: 912706618 -> counter
226 Transfer complete
912706618 bytes sent in 8.08 secs (1.1e+05 Kbytes/sec)

That's all basic set commands for working with ftp in the console. To view the list of available commands on a given FTP server, you can use the command help :

ftp>help
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

You can also get short help for each command. help<команда> :

ftp>help status
status show current status

ftp>help quit
quit terminate ftp session and exit

ftp>help bye
bye terminate ftp session and exit

And finally, the two teams above quit or bye to close the ftp session and exit:

ftp> quit
221 Goodbye.

Detailed information with descriptions of commands can be obtained using man ftp on the command line.

# man ftp
Formatting page, please wait...
FTP(1) BSD General Commands Manual FTP(1)

NAME
ftp - Internet file transfer program

SYNOPSIS
ftp [-Apinegvd]
pftp [-Apinegvd]
................
...............

The FTP protocol is one of the most common network protocols, used by Internet users. The overwhelming number of people use various FTP clients. But not many people know that Windows allows you to connect to FTP servers from the command line.

In this tip you will learn how download files from FTP servers using simple DOS commands.

In order to download file from FTP from Windows command line, let's perform a few simple steps:

  1. Open a command prompt Windows string by clicking Start - Run, typing cmd and pressing Enter.
  2. Run the following command: Using this command, we will connect to the Microsoft ftp server.
  3. Enter the username anonymous. The server of this well-known company allows anonymous users to connect:
  4. Enter your e-mail as a password (you can enter a non-existent one):
  5. Congratulations on your successful login!
  6. In order to see what files and directories are available on the ftp server, enter the dir command:
  7. As a result, we get a list of files and directories located on the ftp server:
  8. To go to the required directory, use the cd command:
  9. The message "250 CWD command successeful" will indicate that we have successfully moved to the directory we need:
  10. In order to download the file we need, enter the get command and the name of the downloaded file:
  11. After successfully receiving the file, the system will notify us:
  12. To leave the ftp server and disconnect from it, run the bye command:

Perhaps many will say that it is much more convenient to download files using multifunctional download managers or ftp clients. But if necessary (or as an alternative), you can use simple DOS commands that will allow you download files from ftp at no additional cost.

Share