Cmd connection to ftp. Download, upload and delete files from an FTP server from the command line

FTP is an important TCP/IP utility for transferring files between systems. One of the main advantages of FTP is its compatibility with many different remote host systems: files can be transferred between remote Windows 2000, Windows NT and UNIX systems, and even IBM servers such as AS/400. To launch the FTP utility, which has a text interface and comes with Windows 2000 and NT, simply enter ftp at the command line.

Let's list the 10 most useful commands FTP.

10. Help (or?). Many FTP commands can be entered in different ways. For example, Help and a question mark (?) perform the same function. Beginners should start with the Help command, after entering which the system provides the user with full list FTP commands. To get brief description commands to be entered? and then the command name:

Ftp>? open

9. Open. An FTP session typically begins with an Open command, which establishes a connection to the specified FTP server (the remote host must have an FTP service running). After receiving the Open command, the system requests a user ID and password. Many FTP servers allow you to register with an anonymous ID and a blank password. To establish a connection with a computer named teca2, you need to enter

Ftp>open teca2

8. Quit (or Bye). The Quit command ends any open session and exits the FTP shell:

Ftp>quit

To close an open session without terminating FTP, use the Close command.

7. Pwd. The Pwd command displays the directory on the remote machine with which at the moment connection established within an FTP session:

6. Ls. The Ls command shows a list of files and subdirectories located in the current directory on remote computer. Ls allows you to access remote files:

5. Cd. If the file you need is not in the current directory of the remote system, you can use the Cd command to change to another directory. If a connection is established to a UNIX machine, the remote directory is usually indicated by a forward slash (in this case the /downloads directory):

Ftp>cd/downloads

4.Lcd. The Lcd command changes the current directory on the local machine. Any files received from the remote machine will be written to the current directory by default. To change the current local directory to C: emp, you should enter the command

Ftp>lcd C: emp

3. Bin (or Binary). By default, FTP transfers files in ASCII format, which is convenient for text files. But to transfer executable and .zip files, you need to change the transfer type to binary using the Bin command:

To return to ASCII mode, use the ASCII command.

2. Put (or Send). The Put command allows you to copy local file to the current directory of the remote machine. To send a file named localfile.txt to the C: emp directory on the remote system, you need to enter the command

Ftp>put C: emp localfile.txt

1. Get (or Recv). The Get command is used to download files from the Internet (or from remote machines) to the current directory of the local machine. To get a file named remotefile.txt, you would enter the command

Ftp>get remotefile.txt

Michael Auty is the scientific editor of the American Windows NT Magazine, president of TECA, a company specializing in the development of software and provision of consulting services. He can be contacted at:

Team ftp is designed to use the utility of the same name, which is an FTP client with an interface command line.

FTP protocol ( File Transfer Protocol), as you can easily guess from its name, is designed for transferring files between computers. Due to the fact that it provides for the transmission of passwords without encryption, it is one of the most insecure network protocols along with the Telnet protocol and should not be used if the server supports more secure file transfer protocols such as sftp and ftps. Besides the utility ftp On Linux, GUI utilities such as Filezilla or Nautilus can also be used to work with FTP servers. FTP servers accept connections on port 21; Other ports are used for data transmission, which makes it difficult to use firewalls.

The basic command syntax is as follows:

$ ftp [options] [host[:port]]

The utility operates in interactive mode and supports a limited number of parameters. Most important parameters are the parameters -4 And -6 , allowing you to use only the IPv4 and IPv6 protocols for communication with the server, respectively, the parameter -p, which allows you to activate passive mode (simplifying work in systems with firewalls that protect from connections from outside), the parameter -i, which allows you not to display prompts when transferring multiple files in interactive mode, the parameter -n, which prohibits reading server login information from a file .netrc in your home directory and log in automatically, the option -e, which deactivates support for the history mechanism within an interactive session and the parameter -g, which disables support for the filename template mechanism.

Due to the fact that the utility operates in interactive mode, the user will have to use commands to transfer files. The most important commands are listed in the table below.

Team Purpose
! [team] Run command on local system
ascii Activate text data transfer mode (ASCII). It is used by default.
bell Use beep to indicate the end of file transfers.
binary Activate binary data transfer mode.

bye

exit

Quit the utility.
CD<директория> Change the working directory on the remote system.
chmod<права доступа> <имя файла> Change file permissions on the remote system.

close

disconnect

End the FTP session with the remote server and return to online mode.
cr Switch the processing mode for newline transitions. When enabled, their processing will remove the carriage return character for compatibility with UNIX systems.
delete<имя файла> Delete a file on a remote system.
debug [debug level] Activate debug mode with the specified level. In this mode, the utility will display all commands sent to the server and responses to them.

dir [remote directory name] [local file name]

ls [remote directory name] [local file name]

List the contents of a directory on a remote system or write it to a file on the local system if the file name is specified.

get<имя удаленного файла>[local file name]

recv<имя удаленного файла>[local file name]

Receive a file from a remote system and save it under a given name on the local system.
hash Output a hash character to indicate the transmission of each 1024-byte block.

help [command]

? [team]

Display information about the command.
idle [seconds] Set the length of the waiting period before automatically disconnecting from the server.
ipany Use any type of IP address after resolving the server name.
ipv4 Use IPv4 address after server name resolution.
ipv6 Use IPv6 address after server name resolution.
lcd [directory name] Change the working directory on the local system.
mdelete Delete many listed files on a remote system.

mdir [directory names] [local file name]

mls [directory names] [local file name]

nlist [directory names] [local file name]

List the contents of a set of listed directories on a remote system, or write it to a file on the local system if the file name is specified.
mget [remote file names] Receive a set of listed files from a remote system and store it in the local system.
mkdir<имя директории> Create a directory with the given name on the remote system.
modtime<имя файла> Show the last modification time of a file on the remote system.
mput<имена локальных файлов> Upload many listed local files to a remote system.
newer<имя удаленного файла>[local file name] Load the specified file from the remote system only if it has been modified later specified file from the local system.
open<имя узла>[port] Establish a connection to the server with the specified address and port.
passive Enable/disable passive mode.
prompt Switch the confirmation mode when transferring multiple files.

put<имя локального файла>[remote file name]

send<имя локального файла>[remote file name]

Upload the specified local file to the remote system under the given name.
pwd Print the name of the current directory on the remote system.
reget<имя удаленного файла>[local file name] Continue downloading a file with the given name from the remote system and saving the file under the given name on the local system.
rename [filename] [new filename] Change the file name on the remote system.
rmdir<имя директории> Delete a directory on a remote system.
size<имя файла> Display the file size on the remote system.
system Display information about the server operating system.
umask Set the value of the access rights mask for files uploaded to the server.
user<имя пользователя>[password] Introduce yourself to the server.

Installing the utility

If your distribution package does not contain a utility ftp, you will have to install it; The easiest way to do this is using the terminal by executing the command corresponding to your distribution. More details about installing the software are described in.

Team for Linux Mint and Ubuntu:

$ sudo apt-get install ftp

Command for Fedora Workstation:

$ sudo dnf install ftp

Examples of use

Uploading files to the server

First you need to connect to the server. In this case, the anonymous TELE2 server is used, so enter anonymous, and the password is an empty string (to enter it, simply press the key Enter).

$ftp speedtest.tele2.net
220 (vsFTPd 2.3.5)
Name (speedtest.tele2.net:alexu): anonymous
Password:
230 Login successful.
Remote system type is UNIX.

The server allows you to upload files only to a directory upload, so you should go to it.

ftp> cd upload
250 Directory successfully changed.

To load correctly, you need to activate passive mode:

ftp>passive
Passive mode on.

Now you can go to the directory with the downloaded files on your local system and use the command mput to download files. The command supports file name templates and it is with the help of this template that three image files are uploaded to the server:

ftp>lcd nolf228/
Local directory now /home/alexu/nolf228
ftp> mput *.jpg
mput nolf228.jpg? y
227 Entering Passive Mode (90,130,70,73,97,210).
150 Ok to send data.
226 Transfer complete.
190576 bytes sent in 0.16 secs (1.1299 MB/s)
mput splash1024.jpg? y
227 Entering Passive Mode (90,130,70,73,86,152).
150 Ok to send data.
226 Transfer complete.
270176 bytes sent in 0.21 secs (1.2126 MB/s)
mput splash1280.jpg? y
227 Entering Passive Mode (90,130,70,73,84,122).
150 Ok to send data.
226 Transfer complete.
385734 bytes sent in 0.40 secs (943.9138 kB/s)

To complete the utility, just enter the command quit:

ftp> quit
221 Goodbye.

Downloading files from the server

As with uploading files to a server, the first step is to connect to it. In the case of an anonymous TELE2 server, the username is used anonymous and an empty password (entered by simply pressing the key Enter):

$ftp speedtest.tele2.net
Connected to speedtest.tele2.net.
220 (vsFTPd 2.3.5)
Name (speedtest.tele2.net:alexd): anonymous
331 Please specify the password.
Password:
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.

To download files correctly, you need to activate passive mode:

ftp>passive
Passive mode on.

To ensure availability on the server necessary files, you should display a list of files from the current server directory using the command ls:

ftp>ls
227 Entering Passive Mode (90,130,70,73,94,9).
150 Here comes the directory listing.
-rw-r--r-- 1 0 0 1073741824000 Feb 19 2016 1000GB.zip
-rw-r--r-- 1 0 0 107374182400 Feb 19 2016 100GB.zip
-rw-r--r-- 1 0 0 102400 Feb 19 2016 100KB.zip
-rw-r--r-- 1 0 0 104857600 Feb 19 2016 100MB.zip
-rw-r--r-- 1 0 0 10737418240 Feb 19 2016 10GB.zip
-rw-r--r-- 1 0 0 10485760 Feb 19 2016 10MB.zip
-rw-r--r-- 1 0 0 1073741824 Feb 19 2016 1GB.zip
-rw-r--r-- 1 0 0 1024 Feb 19 2016 1KB.zip
-rw-r--r-- 1 0 0 1048576 Feb 19 2016 1MB.zip
-rw-r--r-- 1 0 0 209715200 Feb 19 2016 200MB.zip
-rw-r--r-- 1 0 0 20971520 Feb 19 2016 20MB.zip
-rw-r--r-- 1 0 0 2097152 Feb 19 2016 2MB.zip
-rw-r--r-- 1 0 0 3145728 Feb 19 2016 3MB.zip
-rw-r--r-- 1 0 0 524288000 Feb 19 2016 500MB.zip
-rw-r--r-- 1 0 0 53687091200 Jul 24 2014 50GB.zip
-rw-r--r-- 1 0 0 52428800 Feb 19 2016 50MB.zip
-rw-r--r-- 1 0 0 524288 Feb 19 2016 512KB.zip
-rw-r--r-- 1 0 0 5242880 Feb 19 2016 5MB.zip
drwxr-xr-x 2 106 109 69632 Apr 01 13:41 upload
226 Directory send OK.

To download a single file, use the command get:

ftp>get 1MB.zip
local: 1MB.zip remote: 1MB.zip
227 Entering Passive Mode (90,130,70,73,99,63).
150 Opening BINARY mode data connection for 1MB.zip (1048576 bytes).
226 Transfer complete.
1048576 bytes received in 4.15 secs (247.0279 kB/s)

And, as usual, working with the utility ends by entering the command quit.

To connect to an FTP server, you do not need to use any third party programs- this can be done using standard Windows features. To do this, you can use the CMD command line. But to manage the server through standard features operating system, you will have to study the available commands, since CMD does not have a visual interface. In this article, you will learn the basic FTP commands and how to put them into practice.

Why is it better to download the client than to use CMD?

If only the CMD command line could do everything available operations on FTP servers, then perhaps there would be no need for clients. But the reality is that the CMD line is very limited in terms of server management. Therefore, it’s better to find an opportunity and download to your computer a utility for managing the server via FTP. For example, download the FileZilla client program to your PC - it can be downloaded for free from the official website of the developers. It won't take much time to install. And to connect to the server, you will only need to enter your login, password and host name in the required line. It's much more difficult to do this via CMD.

The specific disadvantage of the CMD line is that you won't even be able to go into passive mode while on the server. And without this mode, you will not be able to exchange files with FTP servers that operate through NAT.

In fact, this is a very big flaw in CMD. Therefore, accept the fact that the Windows command line is only suitable for manipulations inside file system without data exchange. Although for those who use an FTP server for routine, monotonous work, the command line may seem very convenient. But it’s better to try both the client and CMD to draw any conclusions.

What are the commands to manage FTP in the CMD prompt?

To get started, launch the command line. You can do this by searching in Start - find the cmd.exe file and open it, after which the line will be launched.

To connect to the server, you need to use the OPEN command. After this command, you must enter the IP address or hostname with which you want to set up a connection. After entering this request, you will be able to log in to the server. This can be done using the USER command, which makes a request for authentication through the entered login. Then you need to enter the PASS command, which means password. When you enter your password and press “Enter,” you will be authorized on the server.

In general, the command line is only suitable for “surfing” the server, moving files, etc. First, you will need to see the files that are on the server. To do this, use the LS command. Since there is no cursor on the command line, you need to select a directory or file using special teams. Use the CD or LCD line for this - the first is needed to change the current object on the remote computer, and the second is needed for the local one, that is, for your PC.

Although you will not be able to upload your files to the FTP server via CMD, it is possible to download data to your computer. To do this, use the GET command. First, enter the GET command with the file name, and then indicate which directory on your computer is the current one, so that the server will transfer the data to that exact folder.

These commands are used most often. That is, most users manage the server via CMD in order to quickly download files without first installing the client. But you can go much further and use other commands on the server using the CMD prompt. For example, you can add a command completion signal to the server using the BELL string.

If you want to end the session and exit the command line and the server, then enter BYE. And to interrupt the control connection only on the server, so that you remain inside the command line, write CLOSE. In this case, the files that you download to your PC from the server will continue to be downloaded and after the download is complete, the session will be completely closed.

Using CMD you can easily manipulate directories on the server. For example, to delete the specified directory, use the DELETE command. To have a list of files in a specific folder appear on the screen, enter DIR and the path to the directory. If you want to delete not one folder or file, but several at once, then use the MDELETE command, that is, multi-deletion. Similarly, the prefix "m" can be used for other commands so that multiple actions can be combined into one. So, to display a list of files in several directories at once, write MDIR, and to download batches of data from the server, use MGET. But do not confuse the multi-command with a single MKDIR - it is needed in order to generate a directory on the server.

There is a possibility that your FTP server operates without NAT technology, so passive client mode is not needed. In this case, you will be able to upload certain files to the host. Use the MPUT command to upload multiple files, and PUT if you only want to upload one.

Another popular command that will most likely be useful to you is RENAME. Need a command to rename files. It will be useful for those who use the server as a storage for site data. You will also need the PWD command, which determines the current folder on remote server FTP, rather than on your computer, like the LCD line does.

The following commands are a partial list of functions that you can use in FTP. There are other teams too. And you can find out about them right in the command line if you enter the HELP query. After this, a directory will appear with all the available CMD commands that can be used in FTP. Just keep in mind that at this moment you must be connected to the server, otherwise Windows will give you a different directory. And if you want to request help from the server itself, then write REMOTEHELP.

Of course, managing a server with commands is a stone age thing. Therefore, it is better not to waste time, download a normal FTP client to your computer and use the server to the maximum, and not partially. But practice in the team CMD line I haven't bothered anyone yet!

And I thought: does everyone know that to work with FTP storages, standard Windows tools? In this article I will describe three simple methods transferring files via FTP using an example. The same techniques apply in . All you need is , Explorer and the command line.

Method one: Internet Explorer 8

Any Internet user is familiar with HTTP addresses for accessing websites that are entered into address bar browser - for example, . Addresses for accessing FTP servers are built according to the same principle: .

Enter your public FTP storage address, such as Microsoft (Figure A), in the address bar and click . If the connection is successful, you will see the root directory. To access subdirectories and files, click on the main directory. To download a file, click on it right click mouse and select the “Save Target As” option.

As you can see, all database articles, patches, updates, utilities and Microsoft documentation are stored on the server, only they are presented in the form of a list with dates. Detailed information about FTP storage is contained in the "readme.txt" files.

Figure A. Microsoft FTP server as seen from Internet Explorer 8.

Please note: to successfully connect to an FTP server using IE, the “Enable FTP folder view (outside of Internet Explorer)” and “Use passive FTP protocol ( Use Passive FTP (for firewall and DSL modem compatibility) in the Browsing section of the Advanced tab of the Internet Options dialog box. You can call it from the “Tools” menu.

To access private FTP servers, you must enter a username and password (Figure B). However, this way in IE 7 or IE 8 you can only view a list of files. To download you will have to use Explorer ( Windows Explorer). See Fig. for details. C, D, E and F.


Figure B: A username and password are required to access private FTP servers.


Figure C. Select the “Page | Open FTP site in Windows Explorer"(Page | Open FTP Site in Windows Explorer) or "View | Open FTP Site in Windows Explorer (View | Open FTP Site in Windows Explorer) to launch Explorer.



Figure D: In the Internet Explorer Security Warning dialog box, click Allow.

The FTP protocol is one of the common network protocols used by Internet users. The overwhelming majority of people use various FTP clients to download anything from FTP servers. 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