How to use Linux FTP commands

Filed Under: UNIX/Linux

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

# ftp ip-address

For example ,

# ftp 38.76.11.174

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

Output

Linux ftp command

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

ftp> put file_name

For example

ftp> put hello.sh

Output

Uploading A Single File To Server

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

ftp> mput file1 file2 ...

For example

ftp> mput hello.sh output.txt myoutput.txt 

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

Output

Upload Multiple Files

4. Downloading files using FTP command

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

ftp> get file_name

For example

ftp> get install.sh

Output

Download A Single File Using Get Command

For multiple files, use the mget command as shown

ftp> mget file1 file2 ...

For instance ,

ftp> mget file1.txt file2.txt file3.txt

Output

Download Multiple Files With Confirmation

5. Getting help

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

help

OR

?

Output

display all ftp command options

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

Leave a Reply

Your email address will not be published. Required fields are marked *

close
Generic selectors
Exact matches only
Search in title
Search in content
Search in posts
Search in pages