How to set up smartphones and PCs. Informational portal
  • home
  • Advice
  • Memo on FTP commands (we work with FTP from the command line). How to Use Passive FTP Mode in Windows Command Prompt

Memo on FTP commands (we work with FTP from the command line). How to Use Passive FTP Mode in Windows Command Prompt

And today we will look at working with an FTP server through the cmd command line. As I said, this method is used quite rarely, at least by me, since it is easier to work through an FTP client. However, for writing automated scripts for exchanging data between your local machine and the FTP server, this knowledge will be very useful to you.

In this video, we will not write a script, we will do this in the next video, but simply consider the basic commands for working with the FTP server through the command line.

Basic commands for working with the FTP server through the CMD command line

And first we need to run the command line ( Start \ Applications \ Utilities \ Command Prompt) or win+r\cmd.

First of all, you need to switch to the FTP server mode, this is done through the command FTP

Enter USERNAME who has access to this server and PASSWORD

If we lead the team DIR then we will get a list of files and folders that are contained on the FTP server.

I will not talk about all the commands that are used to work with the FTP server through the command line, but only those that we need to write the script. These are mainly commands that allow us to copy files from the FTP server to our local computer and vice versa from the local computer to the FTP server.

You can always dial HELP and you will see a list of supported commands, to find out the purpose of the command, just enter HELP COMMAND_NAME.

But, here the description is very modest, so if you want to know a more detailed description of the various commands, go to my website in a feature article. I'll post the link in the description of this video.

I do not have access to directly write files to the root of this FTP server, but I do have access to the htdocs folder, so let's first go to this folder. This is done by commands CD FOLDER_NAME.

We see that we have nothing in this folder. Let's try to copy here some file from our local computer. To do this, create a folder on the local computer, let's say I have it nod32_update because in one of the following videos, I will talk about how to write a script to automatically update the NOD32 antivirus. And let's create some text document valid 123.txt.

To copy the 123.txt file to the FTP server, enter the command PUT c:\nod32_update\123.txt. The file is copied, we can check it with the command DIR. As you can see, the file was copied exactly to the folder into which we passed through the command CD.

If we need to copy all files from a specific folder on the local computer to a folder on the FTP server, then we need to specify the current local directory and the directory on the server.

We learned to specify the directory on the server, through the command CD

The local directory is specified through the command LCD, if we type it, we will see that the current directory is the folder with the current user's profile. And since I'm going to copy files from another folder, I enter the command LCD PATH_TO_DESIRED_FOLDER

What's the point, there's a team MPUT which copies files from a local folder to a remote one and it does not ask which folders these are, so we need to provide this information.

In order to copy all files from a local folder to a remote folder, I specify the command MPUT *.*, where *.* means all files in the local folder.

Here we are asked a confirmation question for each file, we want to copy it or not, for this we live Enter. To prevent such confirmations from being displayed, there is a command PROMT disables interactive mode off.

Now let's try to do the opposite, namely copy all the files from the remote folder on the FTP server to the local one. This is done through the command MGET*.*.

As you can see, everything is fine, all the necessary files have appeared in our folder and now we can finish working with the FTP server through the command QUIT.

We all know the combination of letters FTP, which stands for File Transfer Protocol. An old but still used technology for transferring files between two computers using a TCP/IP network.

Most of us use some kind of file manager utility or module to work with this protocol. But let's imagine a situation where you need to access an FTP server through the command line. You will not have any panels with a list of files and buttons "Copy" and "Delete". (By the way, I often get on through the command line - it's so easy for me even faster - if I have to do something or check FTP.)

So, the command to work with FTP on both Windows and Unix (including Linux Debian, CentOS, ubuntu, rhel, FreeBSD, etc.) is the same - that's what it's called - "ftp".

Just connect to a specific server - the syntax will also be the same:


But tricks like autologin and automatic acceptance or sending of files - different operating systems have a little bit of their own and we will not analyze them here. But let's analyze - what can be done through the command line in the session itself - and the commands themselves, of course.

So, let's begin. This memo lists the most commonly used commands that will allow you to freely communicate with any server with any set of options.

Teams

Join the specified server.

ftp> open 192.168.0.1


The server will ask you for a username and password.

CLOSE or DISCONNECT

Close the connection to the current FTP server.

Close the connection and exit the FTP utility.

Log in to this server under the specified user (you must be already connected).

ftp> user myusername


where instead of "myusername" substitute the username under which you log in. The FTP server will ask you for the password for this user before letting you in.

LS or DIR

Show a list of files and directories in the current folder on the server.

Upload a list of files from several directories to a file on Your computer.

ftp> mls dir1 dir2 dir3 mylocalfile.txt

Go to the specified folder on the server.

ftp> cd ../another/folder


A special case of this command: CDUP - go to the parent directory - the same as "CD ..":

Navigate to the specified folder your computer.

ftp> cd /home/myusername/ftp

Show the current path (current folder) on the FTP server.

Upload the specified file from the FTP server to the current folder of your computer.

ftp> get myftpfile.txt

Upload multiple files to the current folder on your computer from an FTP server.

ftp>mget file1.txt file2.txt
mget file1.txt? y
mget file2.txt? y

Download the specified file from the FTP server to your computer only if your file is older (ie the remote file is more recent).

ftp> newer myfile1 myfile1


Here the first argument is the name of the file on the server, and the second argument is the name of the file on your computer.

PUT or SEND

Upload the specified file from your computer to the FTP server.

ftp> put mylocalfile.txt

Upload several files to the server from your computer.

ftp> mput myfile1.txt myfile2.txt
mput myfile1.txt? y
mput myfile2.txt? y

Delete the specified file on the server.

ftp>delete remotefile.txt

Delete multiple files on the server.

ftp>mdelete file1 file2

Create a directory on the server.

ftp> mkdir mynewdir

Delete directory on server

ftp> rmdir mydir

Here are the basic commands. Of course, there are more of them, but it is this set that will allow you to successfully work with any FTP server through the command line.

More you, as always, can learn from help. To do this, type "HELP" at the FTP command line and get a list of supported directives.

FTP session example

Here is an example of a short FTP session in which we connect to the server, create a "newfiles" folder and upload the "binfile.bin" file to this folder.

NAME
ftp - file transfer protocol

SYNTAX

Ftp [-v] [-d] [-i] [-n] [-U] [-p] [-g]

DESCRIPTION
The ftp program allows you to transfer files to or receive files from a remote computer, and works with files and directories on a remote computer.

WORK WITH FTP.
To use the ftp program, you need to open a link between your machine and the remote machine where or from where you want to move the file. This program allows you to have multiple links at the same time, although you can issue commands that only affect one link. Multi-machine communication allows you to communicate with multiple machines in a single ftp session. You do not need to re-register on another machine when you want to change the machine for communication. The link that is currently in use is called the current link.

Types of file recording for transfer to ftp.
The ftp program allows you to use two types of notation: ASCII or binary. Use ASCII for text files. Binary is used for binary data, which must be a continuous sequence of bits. ASCII is the default. The binary view can be used for some special files, such as programs, pictures, archives.

ftp call.
To invoke ftp from a UNIX shell, enter the ftp command. When the command is executed, a prompt for that command will appear on your screen. It looks like this:

Ftp> You can specify the name of the machine you want to contact, although this is not required. The following example shows how the machine name ftp.botik.ru is written: $ ftp ftp.botik.ru This is equivalent to using the ftp open command to establish a connection with the machine you named. You can also call ftp without a host name, for example: $ ftp If you didn't set a host name when you called ftp, you must open a link to that host in ftp. This is done using the ftp open command before you start transferring files. For more information on this subject, see the "Description of ftp Commands" section later in this chapter.

ftp options.
Additionally, when calling ftp, you can specify some options for this command. These options are placed after the name of the ftp command, but before the host name, if any. Each option consists of a dash (-) and one letter, for example: -v. Each option has a corresponding command of the same name that can be used inside ftp. You should distinguish between the use of options and the corresponding ftp commands.

-vMakes ftp run in verbose mode. In this mode, ftp messages sent by a remote machine to ftp appear on your display screen. In addition, if you use this mode, after each file transfer is completed, a statistical message about it appears. This mode is set by default if ftp is running interactively. If ftp is running in command mode, verbose mode is disabled, then the -v option turns it on. You can enable this mode inside ftp with the verbose command.
-dMakes ftp run in debug mode. In this mode, ftp messages sent by ftp to a remote machine are displayed on your display screen. If you do not use this option, no information is displayed. You can also invoke this mode in ftp using the debug command.
-nPrevents the use of ftp autoregistration when communicating with a remote machine. When autologin mode is set, ftp will automatically identify you to the remote machine and log you in to that machine. (See "Using the .netrc file for automatic registration" later in this section.) If you use the -n option to disable automatic registration, you will need to use the user command to manually log in to the remote machine.
-gCauses UNIX filenames to be stripped of their extensions, such as the wildcard (*). If you do not use this option, ftp expands filenames with a generic extension in the file list. You can use the glob command instead of this option.
The following are examples of using ftp options: $ ftp -v -d ftp.botik.ru The above command invokes ftp in verbose and debug mode and causes ftp to open a connection to a remote machine called ftp.botik.ru. In debug mode, commands sent to a remote machine are displayed on your screen. The verbose mode displays the recipient's responses and statistics about received bytes of information. $ ftp -vd The above command invokes ftp in verbose and debug mode, but does not open connections to the remote machine. $ ftp -ng ftp.botik.ru The above command invokes ftp with auto-registration and universal extension disabled, and causes a connection to be opened with the remote host ftp.botik.ru. $ ftp -n -d The above command invokes ftp with auto-registration and generic extension removed without opening a connection to any machine.

Using the .netrc file for automatic registration.
You can create a file named .netrc in your home directory as an added convenience. This file contains registration data element strings for each machine you need for automatic communication. When you call ftp specifying a host, that is, when you open a connection to a host at the same time as calling it, ftp reads the .netrc file. If there is a member string for this machine, then ftp will automatically connect your machine to that remote machine. If you have opened the link in verbose mode, you will see how this happens. The file format consists of individual fields, represented by key fields:

Machine name login name password password where machine, login, password are keywords followed by character data required for login:

machineNode name.
loginUser name for registration.
passwordThe password of the user on this node. The password is written in normal unencrypted text form. If you have included your password in the .netrc file, then you must disable this file for your group and all other users to prevent your password from being revealed. Otherwise, ftp will not allow you to use this file. See the documentation for the chmod command for more information on file permissions. There is some risk in writing your password to a file. You must weigh all security conditions. Ask your administrator about all the features before using this file.
If you don't enter a password in the file, ftp will ask you for it. Here is an example entry in the .netrc file: machine admin login guido password open where: admin is the host name, guido is the user that logs into the admin machine, open is the password of the guido user.

Limit for ftp commands.
There are several advanced commands that provide additional convenience to the user. But not all ftp servers understand them. The commands whose use will be described later in this chapter have certain limitations. The ftp program can provide a list of supported commands. To obtain such information, you need to use the command after establishing a connection with the remote machine.

Description of ftp commands.
When the ftp prompt appears on the screen, you can enter one of the commands described later in this section. After executing the command, the ftp prompt will appear again. Depending on which mode is set: verbose or debug, additional messages may appear. After each command, press Enter. The command will not start until you press Enter. If you make a mistake while typing a command, you can use the BACKSPACE key to edit the text.

You do not need to enter the command name in full, you can enter a certain number of characters, sufficient for identification. In most cases, this is one or two characters from the name of the ftp command. However, it is better not to be lazy and to type commands completely. The fact is that the ftp client on the joker server can be changed by the system administrator. Not all clients understand short commands. For example, before they could be used. But one fine day, the ftp program was replaced. They put a more advanced version. I don’t know how advanced she is, but she doesn’t understand short commands.

! This command suspends ftp and invokes the command language (shell) on the local machine. Any character(s) after the exclamation point are treated and executed as shell commands. You can then return to ftp by exiting the shell. All ftp options and associated remote machines are returned to the same state they were in before this command was issued. If a shell command is printed on the same line as !, then only that command is executed. After executing the command, the ftp program returns to command mode.
appendThe append command causes ftp to append the contents of the local file to the end of the file on the remote machine you are currently connected to. When you call this command, you can specify which file to append to which, for example: ftp> append local_file_name file_name of remote_machine You can also use just the command name and then be prompted for filenames, for example: ftp> append (local-file) local_file_name ( remote-file) file_name of the remote_machine
asciiThis command causes ftp to convert files to ASCII code. By default, the code is always ASCII.
bellThis command causes a signal to appear on your terminal after each file transfer is completed. To stop beeping, you need to type this ftp command again.
binaryThis command causes ftp to transfer the file in binary.
quitThis command exits ftp. This command closes all open links.
cdThis command replaces the directory name on the remote machine with a new one. You can write a new name when you call the command, as shown in the example: ftp> cd /usr/bin You can only use the name of the ftp command, then the machine will ask for a new directory name, for example: ftp> cd (remote-directory) /usr/ bin
closeThis command closes the current connection. However, there is no exit from ftp. You can create another connection.
debugThis command turns debug mode on and off. If the mode is turned on, then a message appears on your display about this, there are no messages when you turn it off.
verboseThis command turns the verbose mode on and off. If the mode is turned on, then a message appears on your display about this, there are no messages when you turn it off.
deleteThis command deletes a file on the remote machine you are currently connected to. You can specify the name of the file to be deleted when calling the ftp command: ftp> delete filename to delete If you prefer, you can leave out the name when calling the ftp command. Then the machine will ask you for a name, for example: ftp> delete (remote-file) the name of the file to delete
dirThis command will give you the table of contents of the directory on the remote machine you are connected to. You can specify the name of the directory to be printed when invoking the ftp command. For example: ftp> dir /usr/bin If you don't specify a directory name, the current directory on the remote machine will be printed. You can also have ftp write the results of a command to a file before it appears on the screen. This is done as follows: ftp> dir /usr/bin printfile You must specify the directory name before the name of the output file (here printfile). Thus, if you want to print the current directory to a file called printfile, do this: ftp> dir . printfile where "." means the current directory.
getThis command copies a file from the remote machine you are currently connected to. This file is copied to your directory on the server. Use the mget command to copy multiple files at once. When you call this command, you can specify the name of the file on the remote machine and the name in your directory where you will copy the file. For example: ftp> get remote_machine_filename your_machine_file_name If you just specify the filename of the remote machine you want to copy, the file on your machine will have the same name. Example: ftp> get remote_machinename You can only write the ftp get command. Then the ftp program will ask you for a filename, for example: ftp> get (remote-file) filename of the remote machine (local-file) filename of your machine
globThis command causes ftp to disallow UNIX filename extensions, such as the generic "*". This command serves to both disable and enable the extension, so that if given again, the extension will be enabled again. After allowing the extension, ftp will append the extension to all filenames when listing files.
hashThis command causes ftp to display a "#" character on the screen after each block of data that is sent by the remote machine. The size of the data blocks may vary depending on the software version. Today on the joker machine it is 1024 bytes. After entering this command, the current data block size will be printed. This command turns on and off the output of the "#" character on the screen when it is redialled. Thus, you will be able to evaluate the file transfer speed.
helpThis command displays information about ftp activity. If you specify a command name after help, then information about this command will appear. Simply typing help will bring up a list of ftp commands.
lcdThis command changes the working directory used by ftp on your machine. You can specify the name of the directory you want as a working directory, for example: ftp> lcd /home/student/your_dir_name If you don't specify a directory name, the current directory will be used.
lsThis command prints an abbreviated listing of the directory contents of the remote machine you are currently connected to. You can specify the name of the directory you want to print. For example: ftp> ls /usr/bin If you don't specify a name, the current directory will be printed. You can specify that the results of the command execution be placed in a file before they appear on the display. This is done by specifying the name of a file on your machine where the directory listing should be placed, for example: ftp> ls /usr/bin printfile The directory name must be set before the file is printed (here printfile). For example, if you want to print the current directory to a file named printfile: ftp> ls . printfile where "." put to emphasize that the directory is current.
mdeleteThis command deletes the list of files on the remote machine you are currently connected to. You can specify filenames to delete when calling the command. For example: ftp> mdelete remote_machine_file_name 1file_name... Otherwise, you can just use the command name. The ftp program will prompt you for the name(s): ftp> mdelete (remote-files) filename1filename2...
mdirThis command lists the directory listing of the remote machine and puts the result in a file in your directory. You can specify a list of files on the remote machine and a filename on your machine where to place the result when the command is invoked. For example: ftp> mdir filename of remote_machine... printfile Note that the last name is the name of a file in your directory. It's possible to just use the command name. The ftp program will then prompt you for the file name, for example: ftp> mdir (remote-files) remote_machine_file_name... printfile local-file printfile? y
mgetThis command copies several files from the remote machine you are currently connected to into your directory. Files after copying will have the same names as on the remote machine. You can specify a list of files to copy: ftp> mget remote_machine_file1_name file_2name... If you didn't specify filenames when invoking the command, ftp will prompt you for them: ftp> mget (remote-files) remote_machine_file1_name file_2name...
mkdirThis command creates a directory on the remote machine you are currently connecting to. You can specify a directory name when invoking the command, for example: ftp> mkdir /u/mydir If you don't specify a directory name, ftp will prompt you for it, for example: ftp> mkdir (directory-name) directory_name Of course, to run this command, you must have write permission on the remote machine.
mlsThis command takes an abbreviated list of the group of files in the current directory on the remote machine and places the result in a file on your machine. You can specify a list of files on the remote machine and a file on your machine where to put the result when calling the command, for example: ftp> mls file_name of the remote_machine... printfile remote-files) file_name of remote_machine... printfile local-file printfile? y
mputThis command copies one or more files from your directory to the remote machine you are currently connected to. On the remote machine, the files will have the same names. Of course, you must have write permission on the remote machine to run this command. You can specify a list of files when invoking the command, for example: ftp> mput 1 file_of_your_dir 2 file_of_your_machine... If you don't specify names, ftp will ask you about it: ftp> mput (local-files) file_1_name of_your_dir file_2_name...
nmapUse this command to set and unset the file name resolution mechanism. This command is useful when communicating with UNIX-incompatible machines that use a different way of naming files. For example, servers based on Apple Macintosh. Renaming files on the local machine is done with the get and mget commands, and on the remote machine with the put and mput commands.
ntransUse this command to enable or disable the filename character translation mechanism. This command is useful when connecting to a UNIX-incompatible remote machine that uses a different file naming convention. For example, servers based on Apple Macintosh. Translation of filenames on the local machine is done with the get and mget commands, and on the remote machine with the put and mput commands.
openThis command establishes a connection with a remote machine that is supposed to transfer files. When calling the command, you can specify the machine name, for example: ftp> open ftp.botik.ru If the name is not specified, the program will ask for it: ftp> open (to) machine name port on the remote machine. If a port is specified, then ftp will open communication on that port if it is preferred over the default. Port changes are made if you are asked about it or it is set by the system administrator. If the port is not set, then the program does not request it.
promptThis command prevents you from asking ftp for permission to move between files in multi-file commands such as mget. This command is enabled and disabled when redialling.
putThis command moves a file from your machine to the remote machine you are currently connected to. To transfer multiple files at the same time, use the mput command. You can specify the filename of your machine and the filename of the remote machine when you call the ftp command, for example: ftp> put yourfilename remote_machine_filename or ftp> put yourfilename Of course, you must have write permission on the remote machine to run this command. If you do not specify the name of the file(s), then the program will ask you about them, for example: ftp> put (local-file) your_file_name (remote-file) file_name_of_remote_machine If you do not specify the file name of the remote machine, the put command will create a file on the remote machine with the same name as your machine.
pwdThis command prints the name of the current working directory on the remote machine you are currently connected to.
byeThe command is similar to the quit command mentioned above.
quoteThe command causes ftp to send the parameters you enter into the machine to the remote machine for execution. Options are ftp commands and other options. The commands that ftp supports can be displayed on the screen using the remotehelp command. You can enter this command when invoking the ftp program, for example: ftp> quote NLST If you specify only the command name, ftp will ask you for the command line to use, for example: ftp> quote (command-line to send) NLST This command follows use only on the advice of your system administrator.
recvThis command is the same as the get command above.
remotehelpThis command requests ftp help on the remote machine you are currently connected to. This information tells you what commands the remote machine supports.
renameThis command renames a file on the remote machine you are currently connected to. When calling the command, you can use filenames, for example: ftp> rename old_file_name new_file_name If you used only the command name, then ftp will ask for file names: ftp> rename (from-name) old_file_name (to-name) new_file_name Of course, to execute this command you must have write permission on the remote machine.
rmdirThis command deletes a directory on the remote machine you are currently connected to. You can specify the name of the directory to be deleted when the command is invoked, for example: ftp> rmdir /u/mydir or you can leave the command blank and the machine will prompt you for it: ftp> rmdir (directory-name) /u /mydir This command is not always supported by the remote machine. Of course, you must have write permission on the remote machine to run it.
sendThis command is similar to the put command above.
sendportThis command causes ftp to disable the ability to set the local machine port for remote machine data. This command can be enabled and disabled by typing it again. When calling ftp, a specific port is set by default. This command should be used on the advice of your system administrator. As a rule, it is only needed when working with some "wrong" ftp server that is incompatible with your client program.
statusThis command causes ftp to display its current status on your terminal. The status includes the modes that are selected by the bell, hash, glob, port, type commands.
typeThis command sets the format in which the file is transferred. ASCII and binary codes are allowed. This command is similar to the ascii and binary commands. If you didn't specify a type when calling the command, then ASCII is set.
userThis command allows you to identify yourself on the remote machine when establishing a connection. This auto-registration is enabled with the -n option when calling ftp. In this case, this command is not needed. If automatic registration is disabled, then use this command to register and authenticate yourself on the remote machine. The remote machine needs to be told three kinds of information about who you are: login, password, and resource name. The username is required for all machines, the password and share name are required only for some systems. You can enter all of this information when invoking the user command, for example: ftp> user mike cat myaccount You can leave out all of this information when invoking the command. Then the program will ask you about it, for example: ftp> user (usename) mike(username) password: Account: myaccount(sharename) Note that your password is not displayed when you type it to protect your information. If you have not typed a password or resource name, then you will not be prompted for them.
verboseThis command causes ftp to disable verbose mode. This command is turned on and off when redialling. In verbose ftp mode, protocol messages sent by a remote machine appear on your terminal. In addition, this mode displays statistics after each file is transferred. If this mode is disabled, then this information is not displayed.
? Another name for the help command.

FTP examples.
This section illustrates how ftp can be used. Below are three examples. These examples use two machines, a local machine named HERE and a remote machine named THERE.

Description of 1 example.
This example shows the use of ftp to send and receive files. The ftp command is called with the name of the host machine and the user is automatically logged on to another machine, because. the -n option is not used.

Verbose mode is disabled using the verbose command. The user then changes the working directory on the remote machine to the /etc directory. Because there is no -d option and there is a verbose command, verbose mode is disabled and no messages other than the ftp prompt appear.

The user, using the ls command, obtains an abbreviated listing of the /etc directory on THERE. the ftp command outputs three files in the /etc directory. The get passwd command then copies the passwd file from THERE to HERE. A file called passwd is created on machine HERE if a machine name was specified.

The put command is used to copy a file called wall from the current working directory of the local machine (HERE) to the /etc directory of the remote machine (THERE). This file is copied with the same name because its own name was not specified. After the transfer is complete, the /etc listing appears, which already has four files, including wall, which was just copied from the HERE machine.

The bye command is then used to return to the operating system shell on the local machine HERE.

$ ftp THERE Connected to THERE 220 THERE FTP server (Version 4.160 #1) ready Name (THERE:stevea): Password (THERE:stevea): 331 Password required for stevea. 230 User stevea logged in. ftp> verbose Verbose mode off. ftp> cd /etc ftp> ls passwd volcopy whodo ftp> get paswd ftp>put wall ftp> ls passwd volcopy wall whodo ftp> bye $ Description 2 examples.
This example illustrates the screen images that can be obtained using several ftp options. After calling ftp with the name of the remote host, the user invokes a command that will return the debug mode. The ftp command then prints messages to the screen indicating that the option is enabled. The user then changes the working directory on the remote machine to /etc. Because there are debugging and verbose modes, messages about sending commands to the remote machine (--> CWD / etc) and responses received from the remote machine (250 CWD command successful) will appear on the screen. Note that the cd command, which has the same form as the UNIX change directory command, is sent as a CDW command (change working directory on a remote machine). This command is used by ftp instead of cd so that it works independently of the system command.

Following the cd command, the user puts the pwd command to confirm the change to the working directory. The ftp commands will display on your screen the messages sent between your (local) and remote machine, and then the current working directory on the remote machine will appear. The user then types in the hash option, which prompts a message that the option is allowed. The get wall myfile command tells ftp to retrieve the wall file and place it in the file myfile in the current working directory on your machine. The ftp command will print messages sent between the local and remote machines about the start of a transfer and then print a hash label for each block of information received. After the transfer is completed, the screen displays statistics showing the time it took to transfer and the date the file was transferred. After receiving the file, the user closes the connection with the close command and exits ftp with the bye command.

$ ftp THERE Connected to THERE 220 THERE FTP server (Version 4.160 #1) ready Name (THERE:stevea): Password (THERE:stevea): 331 Password required for stevea. ftp> debug Debugging on (debug = 1) ftp> cd /etc ---> CDW /etc 200 CDW command okay. ftp> pwd ---> PWD 251 ftp> hash Hash mark printing on (1024 bytes/hash mark). ftp> get wall mefile ---> PORT 3,20,0,2,4,51 200 PORT command okay. ---> RETR wall 150 Opening data connection for wall (3.20.0.2.1075)(24384bytes #######################. 226 Transfer complete. 24550 bytes received in 12.00 seconds (2 Kbytes/s) ftp> close ---> QUIT 221 Goodbye.ftp> bye $

To connect to the FTP server, it is not necessary to use any third-party programs - this can also be done using standard Windows features. To do this, you can use the CMD command line. But in order to manage the server through the standard features of the operating system, you will have to learn 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 use CMD

If the CMD command line allowed you to perform all available operations on FTP servers, then perhaps there would be no need for clients. But the reality is that the CMD line is quite limited in terms of server management. Therefore, it’s still better to find an opportunity and download a utility for managing the server via FTP to your computer. For example, download the FileZilla client program to your PC - you can download it for free from the official website of the developers. It won't take long to install. And to connect to the server, you will only need to enter your login, password and hostname in the required line. It is much more difficult to do this through 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 work through NAT.

In fact, this is a very big drawback of CMD. Therefore, reconcile yourself to the fact that the Windows command line is only suitable for manipulations inside the file system without data exchange. Although for those who use the FTP server for routine repetitive 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 CMD command line

To get started, launch a command prompt. You can do this by searching in the "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 connect. After entering this request, you will be able to log in to the server. This can be done using the USER command, which makes an authentication request through the entered login. After you need to enter the PASS command, which means the password. When you enter the 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 commands. 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 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, you can download the data to your computer. To do this, use the GET command. First, write the GET command with the name of the file, and then specify which directory on your computer is the current one so that the server transfers the data to that folder.

These commands are the most commonly used. That is, most users manage the server through 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 with the CMD line. For example, you can add a command completion signal on the server using the BELL string.

If you want to end the session and exit the command line and the server, then write BYE. And to terminate 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 download and after the download is completed, the session will be completely covered.

With CMD, you can easily manipulate directories on the server. For example, to delete a specified directory, use the DELETE command. And in order for a list of files of a certain folder to appear on the screen, write DIR and the path to the directory. If you want to delete more than one folder or file, but several at once, then use the MDELETE command, that is, multi-delete. Similarly, the "m" prefix can be used for other commands, so that several actions can be combined into one. So, to display a list of files from several directories at once, write MDIR, and use MGET to download a batch of data from the server. 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 chance that your FTP server is running 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 send one.

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

The above commands are not a complete list of functions that you can use in FTP. There are other teams as well. And you can find out about them right on the command line if you enter the HELP query. After that, 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 another 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 on the CMD command line never hurt anyone!

Top Related Articles