10+ frequently using ftp commands with example Unix/Linux

File Transfer Protocol

FTP stands for ‘File Transfer Protocol’ which is used to transfer file from one server to another. FTP follows a client-server architecture which utilizes separate control and data connections between the ftp client and server.

Considering the case of Linux servers, there are lot of command line options are available for FTP operations. We can simply upload and download files to and from remote servers using FTP commands. There are mainly two types of FTP connection to server, Active and Passive. By-default, two ports are associated with FTP transferring method, port 20 and 21. Port 21 is using to establish connection and the port 20 is the default data transfer port.

In this post I am explaining some commonly using FTP command-line options with example. We can connect to remote server by using different ways, please see the below pasted details:

1. How to connect to a server via ftp ?

You can connect to your account by following methods.

# ftp domain.com
# ftp IP-Address-of-server 
# ftp Host-name-of-server


root@server [~]# ftp domain.com
Connected to domain.com (111.222.333.111).
220---------- Welcome to Pure-FTPd [privsep] [TLS] ----------
220-You are user number 2 of 50 allowed.
220-Local time is now 08:41. 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 (domain.com:root): USERNAME 
Password : PASSWORD 

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

2. How to list files under current folder?

“ls” command to list all content in the folder.

ftp > ls


ftp> ls

227 Entering Passive Mode (198,15,127,170,49,187)
150 Accepted data connection
drwx--x--x   16 crybit     crybit           4096 Jan  8 02:03 .
drwx--x--x   16 crybit     crybit           4096 Jan  8 02:03 ..
-rw-r--r--    1 crybit     crybit             18 Jul 18 06:19 .bash_logout
-rw-r--r--    1 crybit     crybit            176 Jul 18 06:19 .bash_profile
-rw-r--r--    1 crybit     crybit            124 Jul 18 06:19 .bashrc
-rw-------    1 crybit     crybit             23 Sep 13 21:12 .contactemail
drwx------    5 crybit     crybit           4096 Jan  7 04:04 .cpanel
-rw-------    1 crybit     crybit             14 Dec 28 01:42 .ftpquota
drwxr-x---    2 crybit     99               4096 Aug 29 02:25 .htpasswds
-rw-------    1 crybit     crybit             15 Aug 29 02:51 .lastlogin

3. Change Directory

ftp> cd dirName

Where dirName is the directory name.

4. How to change the Local directory ?

Local directory means, the present working directory of the server.

ftp> lcd dirName

The ‘lcd’ command alone will display the current local directory of your server.

ftp> lcd
Local directory now /root
ftp> lcd /home/
Local directory now /home
ftp> lcd
Local directory now /home

5. Download/Copy file to local directory.

ftp> get filename


ftp> get .ftpquota
local: .ftpquota remote: .ftpquota
227 Entering Passive Mode (198,15,127,170,33,202)
150 Accepted data connection
226-File successfully transferred
226 0.014 seconds (measured here), 0.97 Kbytes per second
14 bytes received in 0.0122 secs (1.15 Kbytes/sec)

Download/Copy more than one file from server.

ftp> mget file1 file2

6. Turn On / Off Interactive Prompting

The ftp command prompt sets interactive prompting; “on” which enables prompting so that you can verify of each step of the multiple commands, “off” allows the commands to act unimpeded

ftp> prompt on
Interactive mode off.
ftp> prompt off
Interactive mode on.

7. How to delete a file from server?

ftp> delete fileName

8. Upload One File

Upload a file means, copy a file from local machine to server.

ftp> put fileName

Upload Multiple Files

ftp> mput file1 file2

9. How to Create a Directory ?

ftp> mkdir dirName

Where dirName is the directory name.

10. Delete a Directory

ftp> rmdir dirName

11. How to Set The Mode Of File Transfer ?

To set mode as ascii

ftp> ascii

To set mode as binary

ftp> binary

12. How to get more commands details and help?

ftp> ?
ftp> help


How to get a short description about each command?

ftp> help commandName


ftp> help mkdir
mkdir           make directory on the remote machine

13. How can I disconnected from ftp prompt ?

ftp> quit
ftp> bye

That’s it. Have fun with ftp 🙂 .

Post navigation

Arunlal A

Senior System Developer at Zeta. Linux lover. Traveller. Let's connect! Whether you're a seasoned DevOps pro or just starting your journey, I'm always eager to engage with like-minded individuals. Follow my blog for regular updates, connect on social media, and let's embark on this DevOps adventure together! Happy coding and deploying!

17 thoughts on “10+ frequently using ftp commands with example Unix/Linux

  1. Hello Arun Lal
    New to Unix

    I have a Unix Server A and from Windows machine (install folder) I need to upload the files
    Windows Machine Path : C:\Windows\install

    I need to upload this install folder to
    Can you please suggest how can I move forward?

    1. Hi Zayad,

      You can use put or mput commands to upload files.
      If you’ve any trouble using commands, you can use any FTP clients on your Windows machine.

      EG : FileZilla

  2. Hi friends,

    I need to upload a file from my computer to the server using ftp and also,
    need to download a file from server to my computer using ftp can u please suggest me how to perform those two steps.

    1. If you’re interest to do this via command line interface, you can use get and put commands to download and upload files respectively.
      Otherwise you can use any FTP applications like FileZilla.

Leave a Reply

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