• Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate
TecNStuff
Menu
  • Home
  • Linux
  • Ubuntu
  • Debian
  • CentOS
  • Linux Commands
  • About Us
  • Donate

How to Use Linux FTP Command to Transfer Files

Written by Admin, Updated On May 13, 2020
ftp, terminal

FTP (File Transfer Protocol) is a most familiar file transfer protocol used to transfer files between a local and remote network. In this tutorial, we will show you how to use the Linux ftp command with examples.

How to Use Linux FTP Command to Transfer Files

The ftp commands are very useful when you don’t have a system with GUI and you want to transfer files over FTP to or from a remote server. FTP traffic is not encrypted, or a secure data transfer, use SCP or SFTP.

Make sure you have at least read permissions on the source file and write permission on the target system.

Make an FTP connection#

To make a ftp session on a remote server, use the ftp command followed by the remote server IP address or domain name.

For instance, to connect to an FTP server at 192.168.125.96 you would type:

ftp 192.168.125.96

Once the connection established you will be promt to enter your ftp username:

220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 1 of 50 allowed.
220-Local time is now 21:35. Server port: 21.
220-This is a private system - No anonymous login
220-IPv6 connections are also welcome on this server.
220 You will be disconnected after 15 minutes of inactivity.
Name (192.168.125.96:localuser): tecnstuff

After entering the username you will be prompted to type your password:

Password:

On success validation, it will display a confirmation message with ftp> prompt.

230 OK. Current restricted directory is /
Remote system type is UNIX.
Using binary mode to transfer files.
ftp>

Common FTP Commands#

Below are some of the most common FTP commands:

  • help or ? – To get list all available FTP commands.
  • cd – navigate on the remote machine.
  • lcd – change directory on the local machine.
  • ls – list the names of the files and directories in the current remote directory.
  • mkdir – create a new directory.
  • pwd – show the current working directory on the remote machine.
  • delete – delete a file in the current remote directory.
  • rmdir– remove a directory in the current remote directory.
  • get – download one file from the remote to the local machine.
  • mget – dowload multiple files from the remote to the local machine.
  • put – upload one file from the local to the remote machine.
  • mput – upload one file from the local to the remote machine.

Downloading Files with the ftp Command#

By default, when you logged in to your remote server your home directory will be your current working directory.

To download a file from the remote server, use the get command. For example, to download a file named test.zip you would use the following command:

get test.zip

The output should look something like this:

200 PORT command successful
150-Connecting to port 60609
150 6516.9 kbytes to download
226-File successfully transferred
226 1.123 seconds (measured here), 1.60 Mbytes per second
4463256 bytes received in 1.12 seconds (1.49 Mbytes/s)

You also can download more than one file using mget command. Provide file names with space separated or use wildcard characters:

mget test1.zip test2.zip

To close the connection to remote server, type bye or quit:

quit
221-Goodbye. You uploaded 0 and downloaded 6544 kbytes.
221 Logout.

Uploading Files with the FTP Command#

To transfer a file from a local directory to a remote FTP server, run the put command:

put index.php

It will show output as below:

200 PORT command successful
150 Connecting to port 34583
226-File successfully transferred
226 0.109 seconds (measured here), 2.48 Kbytes per second
33960 bytes sent in 0.121 seconds (302 kbytes/s)

To upload multiple files from a local directory to a remote FTP server, use the mput command:

mput index.php info.php

When uploading multiple files, the command will prompt you to confirm each file you want to upload.

Once you are done uploading files to your remote FTP server close the connection with bye or quit.

Conclusion#

In this tutorial, you we shown you how to use the ftp command to download and upload files to your remote FTP server.

Feel free to leave a comment if you have any questions or suggestion.

If our content helps you, please consider buying us a coffee

Thank you for your support.

Share On
Share on Facebook
Share on Twitter
Share on Reddit
Share on Tumblr
 Previous Article How to Use Linux Screen
Next Article   How to Install Yarn on CentOS 8

Related Posts

  • How to Use sed to Find and Replace String in Files

    How to Use sed to Find and Replace String in Files

    December 18, 2020
  • Linux Head Command

    Linux Head Command

    December 16, 2020
  • Rename Files and Directories in Linux

    How to Rename Files and Directories in Linux

    December 15, 2020

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on Debian 10
    How to Install Python 3.9 on Debian 10 December 25, 2020
  • How to Install Python 3.9 on Ubuntu 20.04
    How to Install Python 3.9 on Ubuntu 20.04 December 21, 2020
  • How to Install GIMP on Ubuntu 20.04
    How to Install GIMP 2.10 on Ubuntu 20.04 December 22, 2020
  • How to Install Notepad++ on Debian 10
    How to Install Notepad++ on Debian 10 December 23, 2020
  • How to Install Php 8 on Debian 10
    How to Install PHP 8 on Debian 10 January 2, 2021
© 2020 TecNStuff All rights reserved. This website is using and storing cookies on your browser. By using this website you agree our Privacy Policy.  Follow us -  Twitter | Facebook