How do I use FTP from a command line?
Note: FTP is not an encrypted transmission, which means any data sent over it, including your username and password could be read by anyone who may intercept your transmission. If you're wanting a more secure transmission we suggest using SFTP.
To connect to another computer using FTP at the MS-DOS prompt, command line, or Linux shell type FTP and press enter. Once in FTP> Type:
In the above example, you'd substitute example.com for the name of your domain you're wanting to connect to. In addition to the domain name the IP address of the computer you're trying to connected to can also be typed in, for example, open 192.168.1.12.
Once connected, a username and password prompt will appear. If these are entered properly you'll be successfully connected to the server where you can browse the files, send files, or receive files depending on your rights. Some servers may also allow anonymous logins you can connect to these computers using guest or e-mail address.
To get files from the server onto your own computer use the get command as shown in the example below. In this example, you would get the file myfile.htm.
Tip: If you want to get more than one file use mget and wildcards, for example, if you wanted to get all files that end with .htm you could type mget *.htm. Finally, if you do not want to be prompted as each file is being sent make sure to type prompt to disable prompting.
To send a file from your computer to the computer you are connected to assuming you have the rights use the send command as shown in the example below. In this example, we are sending the myfile.htm to the directory we're currently in.
It is important to realize that the files being sent must be in your local working directory. In other words the directory you were in when you typed the FTP command. If you want to change to the directory that contains your files use the lcd command. For example, on Windows you'd type lcd c:\windows to set the local directory to the Windows directory.
Depending upon the version of FTP and the operating system being used, each of the below commands may or may not work. Typing -help or a ? will list the commands available to you. Below is a general description of FTP commands available in the Windows command line FTP command.
|!||This command toggles back and forth between the operating system and ftp. Once back in the operating system, typing exit takes you back to the FTP command line.|
|?||Access the Help screen.|
|append||Append text to a local file.|
|ascii||Switch to ASCII transfer mode|
|bell||Turns bell mode on or off.|
|binary||Switches to binary transfer mode.|
|bye||Exits from FTP.|
|close||Exits from FTP.|
|delete||Deletes a file.|
|debug||Sets debugging on or off.|
|dir||Lists files if connected. |
dir -C = Will list the files in wide format.
dir -1 = Lists the files in bare format in alphabetic order
dir -r = Lists directory in reverse alphabetic order.
dir -R = Lists all files in current directory and sub directories.
dir -S = Lists files in bare format in alphabetic order.
|disconnect||Exits from FTP.|
|get||Get file from the computer connected to.|
|glob||Sets globbing on or off. When turned off the file name in the put and get commands is taken literally and wildcards will not be looked at.|
|hash||Sets hash mark printing on or off. When turned on for each 1024 bytes of data received a hash-mark (#) is displayed.|
|help||Access the Help screen and displays information about command if command typed after help.|
|lcd||Displays local directory if typed alone or if path typed after lcd will change local directory.|
|literal||Sends a literal command to the connected computer with an expected one line response.|
|ls||Lists files of the remotely connected computer.|
|mdir||Lists contents of multiple remote directories.|
|mget||Get multiple files.|
|mls||Lists contents of multiple remote directories.|
|mput||Sent multiple files|
|prompt||Enables or disables the prompt.|
|put||Send one file|
|pwd||Print working directory|
|quit||Exits from FTP.|
|quote||Same as the literal command.|
|remotehelp||Get help from remote server.|
|rename||Renames a file.|
|rmdir||Removes a directory on the remote computer.|
|send||Send single file.|
|status||Shows status of currently enabled and disabled options|
|trace||Toggles packet tracing.|
|Type||Set file transfer type.|
|user||Send new user information.|
|verbose||Sets verbose on or off.|