How to Use FTP Command in Linux to Transfer Files

How to Use FTP Command in Linux to Transfer Files

In this article we are going to shows how to use FTP command in Linux. If you want to learn about FTP command in Linux with Examples then this post is ideal for you.

FTP stands for File Transfer Protocol is a standard communication protocol that is used to transfer files between clients and servers over the Internet. FTP traffic is not encrypted so it is not secure to transfer data over the internet. For a secure data transfer, you can use SCP or SFTP.

Linux is an operating system, like Windows OS, iOS, and Mac OS. Linux is one of the most popular operating system on the planet, Android is also powered by Linux OS(operating system).


Establish an FTP connection

To establish a ftp connection on a remote server, Run the ftp command with domain name or IP address of the FTP server as show below:

ftp domain.com

OR

ftp 108.167.146.90

OR

ftp user@ftpdomain.com

When you run one of the above command, it will established the connection and prompted to enter your FTP username and password one by one.

If the username and password is correct, you will get a confirmation message as show below:

Output
230 OK. Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Most common FTP Commands in Linux

  • help or ? -it is list all the available FTP commands.
  • cd – it is used to change the directory on the remote machine.
  • lcd – change the directory on the local machine.
  • ls – list the names of the files and directories in the current remote directory.
  • mkdir – create a new directory within the current remote directory.
  • pwd – print the current working directory on the remote machine.
  • delete – remove a file in the current remote directory.
  • rmdir– remove a directory in the current remote directory.
  • get – It is used to copy one file from the remote to the local machine.
  • mget – copy multiple files from the remote to the local machine.
  • put – It will copy one file from the local to the remote machine.
  • mput – copy one file from the local to the remote machine.

How to Download Files with FTP

Before downloading a file from remote server, set the file download directory on the local FTP with the help of lcd command:

lcd /home/user/directory_name

When the download directory is not specify on Local FTP, the file will be downloaded in the current directory:

To download a file from the remote server, you can use the get command as show below:

get file_name.txt

You can also download multiple files at once with the help of mget command. To do that run the command below:

mget file_name1.txt file_name2.txt file_name3.txt

After downloading the files, you can close the connection using commands below:

quit

OR

bye

How to Upload Files with FTP

With the help of FTP, you can also upload files from a local directory to remote FTP server. To upload a file on remote FTP server, run the put command as show below:

put file_name.txt

When the file is not in your current working directory, use the absolute path to the file:

put /path/file_name.txt

To upload multiple files at once, run the the mput command:

mput file_name1.txt file_name2.txt file_name3.txt

That’s all.

If you face any error and issue in above steps , please use comment box below to report.

If our tutorials helped you, please consider buying us a coffee. We appreciate your support!

Thank you for your support.

Leave a Comment

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Scroll to Top