How do I use FTP from a command line?
This page contains all information about how to connect to and utilize FTP from a command-line interface, such as the Linux shell or MS-DOS.
Note: FTP (File Transfer Protocol) is not secure transmission, which means that anyone intercepting your connection could access any data passed over it, including your account and password. We highly recommend using SFTP (Secure File Transfer Protocol) for more secure communication.
Connect using FTP
With the help of using FTP, to connect to another computer, you need to type FTP and hit Enter at the Linux shell, MS-DOS prompt or command line. You can use the open command in order to connect to the FTP server after you are in FTP, as demonstrated in the example below.
open ftp.example.com
You would replace example.com with the domain name or IP address of the location where you are connecting in the example above. An instance would be open 192.168.1.12
Note: The open command connects to the FTP server with the help of using TCP port 21 by default. If you need to connect to a different TCP port, insert the port number after the domain name or IP address in the open command.
You will see a username and password prompt on the screen once you have connected. Then, on the basis of your rights, the server makes it capable of browsing, transmitting, or receiving files once these credentials are entered. Additionally, some servers may allow anonymous logins via a guest account or an e-mail address.
Send and receive a file in FTP
Use the get command to download files from the server to your machine, as illustrated in the instance below. You would obtain the file myfile.htm in this case.
get myfile.htm
Tip
You can use mget and wildcards if you wish to get numerous files. For instance, you can type mget *.htm in order to get all files with the extension.htm. At the end, you can disable prompt with the help of typing prompt if you don-t want to be prompted each time a file is transmitted.
In order to transmit a file to another connected computer, you need to use the send command, as demonstrated in the example below. We are delivering myfile.htm to the current directory in this example.
send myfile.htm
It's critical to keep in mind that the files you transfer must be in your local working directory. In other words, the file must be saved in the directory where the FTP command was entered. Use the LCD command in order to change to the local directory where your files are kept. To change the local directory to the Windows directory on Windows, type lcd c:windows.
FTP commands
Each of the following commands may or may not work on the basis of your FTP version as well as the operating system. Are the commands available to you can be found by typing -help or a? The following is a list of FTP commands found in the Windows command-line FTP command.
Command |
Information |
! |
The exclamation point command toggles between FTP and the operating system for a short time of period. Typing exit returns you to the FTP command line at the time you are using the operating system. |
? |
Its use is to open the help screen. |
append |
This command is used to append content to a local file. |
ascii |
Use this command when you need to switch to ASCII transfer mode. |
bell |
Its use is to turn bell on as well as off. |
binary |
The use of this command is to switch to binary transfer mode. |
bye |
It is used to exits from FTP. |
cd |
Used for changing for directory. |
close |
It is used to exits from FTP. |
delete |
As implies its name, this command is used for deleting the files. |
debug |
Use the debug command when you need to set debugging on or off. |
dir |
Lists files if a connection is established. dir -C this command displays the list the files in wide format. dir -1 lists the files in alphabetical order in bare format. dir -r displays the contents of a directory in reverse alphabetical order. dir -R displays the contents of the current directory and its subdirectories. dir -S lists files in alphabetical order in bare format |
disconnect |
The work of this command is same as the commands close and bye, it is also used to exit from FTP. |
get |
Takes a file from the computer that is connected. |
glob |
Turns on or off globing. When this option is disabled, wildcards are not allowed and the file name in the put and get commands is treated literally. |
hash |
It is used to turn on or off hash mark printing. When the device is turned on, a hash mark (#) is displayed for every 1024 bytes of data received |
help |
If command is typed after help, you will see the help screen displays information about the command. |
lcd |
If lcd is typed alone, it displays the local directory, and it changes the local directory if the path is typed after lcd. |
literal |
Sends a one-line response to the connected computer in the form of a literal command. |
ls |
It displays lists of the files on the machine that is connected remotely. |
mdelete |
This command is used to delete the multiple files. |
mdir |
This command displays the contents of many remote folders. |
mget |
It is used to access several files. |
mkdir |
Its use is to make a directory |
mls |
This command displays the list contents of many remote folders. |
mput |
The word of this command is to send multiple files |
open |
Its use is to open address. |
prompt |
Its use is to enable or disable the prompt. |
put |
This command is used to send one file. |
pwd |
It offers users the option to print working directory. |
quit |
The working of this command is to exit from FTP. |
quote |
Used same as the literal command. |
recv |
It is used to receive file. |
remotehelp |
Use this command when you need to get help from remote server. |
rename |
Its use is to renames a file. |
rmdir |
On the remote computer, this command deletes a directory. |
send |
It is used to send single file. |
status |
Shows the status of the options that are currently enabled and disable. |
trace |
Used for Toggle packet tracing. |
Type |
This command is used to set file transfer type. |
user |
Its use is to send new user information. |
verbose |
This command is used to set verbose on or off. |
|