logo

Practical Computing Advice and Tutorials

Tue: 23 Jul 2019


Site Content

Programming
&
Development


Technical Knowhow


Command Line Interface


Security

The File Transfer Protocol (ftp)

The File Transfer Protocol (ftp) is the standard protocol used for transferring files between a 'client' and a 'server' and can be a handy tool to use on your LAN. It's not something that one should use on anything other than a LAN that's under your control, because the connection is not encrypted. For public networks, sftp (Secure File Transfer Protocol) is a popular option, but there are others. By using a secure option, not only are the login details encrypted, but also the data file.

The computer to which you want to connect will need to be running a ftp server: if you need help with that, let me know by leaving a comment. The term used to download a file is 'get' and to upload a file, it's 'put'.

To get a file, there are a couple of options one can use, such as your web browser: if you type ftp://192.168.2.100 into the address bar, your browser will try to connect to a ftp server at that IP address, and if successful, you'll be prompted for a username a and password before being presented with the index of files. Another option is to use an app, such as FileZilla, which is a very good GUI based file management app.


Using ftp From a CLI

The command is ftp <ip address> so if your server ip address is 192.168.2.100, the command is ftp 192.168.2.100

While it's possible to specify to which directory you what any file you 'get', to be saved, the easiest way to use this command is to start the process from the destination directory (e.g. if you want to 'get' a file from a server and save it in a directory called ' Documents', start the ftp process from the 'Documents' directory). The same can be said for files you want to 'put' onto the server: start the ftp process from your source directory.

After you enter the ftp command, you should then be prompted for a user name, then a password. If the login is successful, you'll get the message 230 Login successful and a prompt: ftp>

Assuming that the file server is running a Unix like OS, the standard Unix commands can now be used, such as ls to see a list a files and directories ls -a to include the hidden ones ls -l to see a detailed list cd Documents to changed to a directory called 'Documents'. Entering a ? will list the commands you can use.

To get a file, simply type get and followed by the name of the file you need. The same with put to send a file to the server.

A Tip: If you've started a ftp process and connected to the server, but you need to quickly look back at the client side file system, enter a ! This will reverse the session and display the client prompt. The exit command will then get you back to the server. As an aside, if you type remotehelp then it should show you all the commands that the server can receive — all these can be used with the quote command. E.g. quote PASV