How to use Linux FTP commands With Examples

FTP (File Transfer Protocol), is a protocol commonly used for the transfer of files between a client and a server. In this guide, you will learn how to use Linux FTP commands with practical examples. Without much further ado, let’s jump right in.

Prerequisite

VSFTPD (Very Secure File Transfer Protocol Daemon) installed and properly configured. It’s also crucial to point out that you must have read permissions from the source file and write permissions on the FTP server. This enables you to transfer files to and fro in a secure/encrypted manner.

1. Establishing an FTP connection

To establish an FTP connection with a remote server, use the syntax below on the terminal

For example ,

Upon establishing a connection, you will thereafter be prompted for a username and a password

Output

ftp-login

If the username and password details were correct, you will get a ‘login successful’ notification on the terminal alongside the FTP system type.

2. Commonly used FTP commands

Once in the ftp prompt, let’s examine some of the commonly used command options.

  1. ? or help – This displays all available FTP commands
  2. ls – This lists all the files and directories in the current remote directory
  3. lcd – This dislays the current directory in the local machine
  4. put – Uploads or copies a file from the local machine to the remote FTP server
  5. mput– Uploads or copies multiple files from the local machine to the remote FTP server
  6. get – Downloads or copies files from the remote FTP server to the local machine
  7. mget – Downloads or copies mutiple files from the remote FTP server to the local machine
  8. mkdir – Creates a new directory in the current remote directory
  9. rmdir – Deletes a directory in the current remote directory
  10. delete– Delete a directory in the current remote directory

3. Uploading files using FTP command

To upload or copy a file to an FTP server, first ensure that you are connecting to the FTP server from the directory containing the files you want to upload.

Once logged in, use the syntax

For example

Output

To upload multiple files , use the mput command as shown.

For example

You will be prompted for confirmation for each of the files awaiting upload. Press y.

Output

uploading-a-single-file-to-server

4. Downloading files using FTP command

To download a file from the FTP server , use the get command as shown

For example

Output

download-a-single-file-using-get-command

For multiple files, use the mget command as shown

For instance ,

Output

download-a-single-file-using-get-command

5. Getting help

To list all the options that are available for use with the ftp command, execute.

OR

Output

download-a-single-file-using-get-command

6. A note about GUI FTP clients

One of the drawbacks of transferring files via the terminal is time wasted uploading or downloading files one by one. FileZilla is a free and opensource FTP client that allows you to upload or download files and directories over TLS and SFTP. If you have a bulk of files or directories that need to be uploaded or downloaded, then using a GUI based FTP client is highly recommended. Other free GUI FTP clients include

  1. WinSCP
  2. Core FTP
  3. Coffecup

By admin

Leave a Reply