The Wayback Machine - https://web.archive.org/web/20241009114839/https://www.geeksforgeeks.org/file-transfer-protocol-ftp/
Open In App

File Transfer Protocol (FTP)

Last Updated : 28 Apr, 2024
Summarize
Comments
Improve
Suggest changes
Like Article
Like
Save
Share
Report
News Follow

File transfer protocol (FTP) is an Internet tool provided by TCP/IP. The first feature of FTP is developed by Abhay Bhushan in 1971. It helps to transfer files from one computer to another by providing access to directories or folders on remote computers and allows software, data, text file to be transferred between different kinds of computers. The end-user in the connection is known as localhost and the server which provides data is known as the remote host. 

The goals of FTP are: 

  • It encourages the direct use of remote computers.
  • It shields users from system variations (operating system, directory structures,  file structures, etc.)
  • It promotes sharing of files and other types of data.

Why FTP?

FTP is a standard communication protocol. There are various other protocols like HTTP which are used to transfer files between computers, but they lack clarity and focus as compared to FTP. Moreover, the systems involved in connection are heterogeneous systems, i.e. they differ in operating systems, directory, structures, character sets, etc the FTP shields the user from these differences and transfer data efficiently and reliably. FTP can transfer ASCII, EBCDIC, or image files. The ASCII is the default file share format, in this, each character is encoded by NVT ASCII. In ASCII or EBCDIC the destination must be ready to accept files in this mode. The image file format is the default format for transforming binary files.

FTP Clients

FTP works on a client-server model. The FTP client is a program that runs on the user’s computer to enable the user to talk to and get files from remote computers. It is a set of commands that establishes the connection between two hosts, helps to transfer the files, and then closes the connection. Some of the commands are: get filename(retrieve the file from server), mget filename(retrieve multiple files from the server ), ls(lists files available in the current directory of the server). There are also built-in FTP programs, which makes it easier to transfer files and it does not require remembering the commands.

Type of FTP Connections

FTP connections are of two types:

Active FTP connection: In an Active FTP connection, the client establishes the command channel and the server establishes the data channel. When the client requests the data over the connection the server initiates the transfer of the data to the client. It is not the default connection because it may cause problems if there is a firewall in between the client and the server.

Passive FTP connection: In a Passive FTP connection, the client establishes both the data channel as well as the command channel. When the client requests the data over the connection, the server sends a random port number to the client, as soon as the client receives this port number it establishes the data channel. It is the default connection, as it works better even if the client is protected by the firewall. 

Anonymous FTP 

Some sites can enable anonymous FTP whose files are available for public access. So, the user can access those files without any username or password. Instead, the username is set to anonymous and the password to the guest by default. Here, the access of the user is very limited. For example, the user can copy the files but not allowed to navigate through directories.

How FTP works?

The FTP connection is established between two systems and they communicate with each other using a network. So, for the connection, the user can get permission by providing the credentials to the FTP server or can use anonymous FTP.

When an FTP connection is established, there are two types of communication channels are also established and they are known as command channel and data channel. The command channel is used to transfer the commands and responses from client to server and server to client. FTP uses the same approach as TELNET or SMTP to communicate across the control connection. It uses the NVT ASCII character set for communication. It uses port number 21. Whereas the data channel is used to actually transfer the data between client and server. It uses port number 20.

The FTP client using the URL gives the FTP command along with the FTP server address. As soon as the server and the client get connected to the network, the user logins using User ID and password. If the user is not registered with the server, then also he/she can access the files by using the anonymous login where the password is the client’s email address. The server verifies the user login and allows the client to access the files. The client transfers the desired files and exits the connection. The figure below shows the working of FTP.

Detail steps of FTP

  • FTP client contacts FTP server at port 21 specifying TCP as transport protocol.
  • Client obtain authorization over control connection.
  • Client browse remote directory by sending commands over control connection.
  • When server receives a command for a file transfer, the server open a TCP data connection to client.
  • after transferring one file, server closes connection.
  • server opens a second TCP data connection to transfer another file.
  • FTP server maintains state i.e. current directory, earlier authentication.

Transmission mode

FTP transfer files using any of the following modes:

  • Stream Mode: It is the default mode. In stream mode, the data is transferred from FTP to TCP in stream bytes. Here TCP is the cause for fragmenting data into small segments. The connection is automatically closed if the transforming data is in the stream bytes. Otherwise, the sender will close the connection.
  • Block Mode: In block mode, the data is transferred from FTP to TCP in the form of blocks, and each block followed by a 3-byte header. The first byte of the block contains the information about the block so it is known as the description block and the other two bytes contain the size of the block.
  • Compressed Mode: This mode is used to transfer big files. As we know that, due to the size limit we can not transfer big files on the internet, so the compressed mode is used to decrease the size of the file into small and send it on the internet.

FTP Commands

Sr. no.  Command Meaning
   1.     cd Changes the working directory on the remote host
   2.    close Closes the FTP connection
   3.    quit Quits FTP
   4.    pwd displays the current working Directory on the remote host
   5.  dir or ls Provides a Directory Listing of the current working directory
   6.    help Displays a list of all client FTP commands
   7. remotehelp Displays a list of all server FTP commands
   8.    type Allows the user to specify the file type
   9.    struct   specifies the files structure

Applications of FTP

The following are the applications of FTP:

  • FTP connection is used by different big business organizations for transferring files in between them, like sharing files to other employees working at different locations or different branches of the organization.
  • FTP connection is used by IT companies to provide backup files at disaster recovery sites.
  • Financial services use FTP connections to securely transfer financial documents to the respective company, organization, or government.
  • Employees use FTP connections to share any data with their co-workers.

Advantages

  • Multiple transfers: FTP helps to transfer multiple large files in between the systems.
  • Efficiency: FTP helps to organize files in an efficient manner and transfer them efficiently over the network.
  • Security: FTP provides access to any user only through user ID and password. Moreover, the server can create multiple levels of access.
  • Continuous transfer: If the transfer of the file is interrupted by any means, then the user can resume the file transfer whenever the connection is established.
  • Simple: FTP is very simple to implement and use, thus it is a widely used connection.
  • Speed: It is the fastest way to transfer files from one computer to another.

Disadvantages

  • Less security: FTP does not provide an encryption facility when transferring files. Moreover, the username and passwords are in plain text and not a combination of symbols, digits, and alphabets, which makes it easier to be attacked by hackers.
  • Old technology: FTP is one of the oldest protocols and thus it uses multiple TCP/IP connections to transfer files. These connections are hindered by firewalls.
  • Virus: The FTP connection is difficult to be scanned for viruses, which again increases the risk of vulnerability.
  • Limited: The FTP provides very limited user permission and mobile device access.
  • Memory and programming: FTP requires more memory and programming efforts, as it is very difficult to find errors without the commands.


Previous Article
Next Article

Similar Reads

Heat Transfer Formula
Heat is a type of energy that moves from a hot to a cold thing. When we contact something cold, heat from our bodies is transferred to the cold item. Heat is transferred between objects of differing temperatures. The passage of heat ceases when the two objects reach the same temperature. Heat Transfer Heat transfer occurs when energy from a higher-
3 min read
What is Data Transfer Rate?
Data Transfer Rate (DTR) can be defined as the ratio of the total amount of digital data transferred between two points in some defined period of time. Where the two points can be two network components say two computers or data can be transferred between a thumb drive and a hard drive. Data transfer rate is actually a measure of the speed at which
7 min read
Redox Reactions in terms of Electron Transfer
A variety of chemical and biological reactions like burning of different types of fuels (wood, kerosene, coal, LPG, petrol, diesel), digestion of food in animals, photosynthesis by plants, extraction of aluminum from alumina, electricity generation from batteries or cell, rusting of iron fall in the category of redox reaction. What is a Redox React
4 min read
Heat Transfer Formulas
Heat is a measure of thermal energy that can be transferred from one point to another. Heat is the transfer of kinetic energy from an energy source to a medium or from one medium or object to another medium or object. Heat is one of the important components of phase changes associated with work and energy. Heat is also the measure of kinetic energy
6 min read
MOET Technology (Multiple Ovulation Embryo Transfer Technology)
Multiple Ovulation and Embryo Transfer (MOET) is a method of reproductive technology widely used in animal breeding, particularly in livestock production. MOET technique is used for accelerating genetic progress and increasing the reproductive efficiency of a genetically superior individual animal. MOET is a three-step process that involves stimula
6 min read
What is Bandwidth and Protocol in Networking?
Downloading is a phenomenon in which we receive data from the internet on your system. For example- music, video, audio, etc., and Bandwidth is measured as the amount of data that can be transferred from one point to another within a network in a specific amount of time. A protocol is a set of rules. Rules are used to define each step and process d
6 min read
How to Password Protect a File in MS PowerPoint?
Microsoft PowerPoint is a presentation of topics that allows us to create "presentation slides" that can be displayed on the computer screen or on a widescreen. A PowerPoint presentation is a good way to convey information, ideas, thoughts to a large audience. It helps in creating a topic in a proper manner by providing various features like editin
2 min read
Reading Rows from a CSV File in Python
CSV stands for Comma Separated Values. This file format is a delimited text file that uses a comma as a delimiter to separate the text present in it. Or in other words, CSV files are used to store data in tabular form. As per the name suggested, this file contains the data which is separated by a comma and every line of a file is considered a recor
5 min read
Copying file using FileStreams in Java
The main logic of copying a file is to read the file associated with FileInputStream variable and write the read contents into the file associated with FileOutputStream variable. We can copy a file from one location to another using FileInputStream and FileOutputStream classes in Java. Now before adhering forward let us discuss essential methods th
4 min read
Java.io.File Class in Java
Java File class is Java's representation of a file or directory pathname. Because file and directory names have different formats on different platforms, a simple string is not adequate to name them. Java File class contains several methods for working with the pathname, deleting and renaming files, creating new directories, listing the contents of
6 min read
Delete a File Using Java
Java provides methods to delete files using java programs. On contrary to normal delete operations in any operating system, files being deleted using the java program are deleted permanently without being moved to the trash/recycle bin. Methods used to delete a file in Java: 1. Using java.io.File.delete() function: Deletes the file or directory den
2 min read
File Compression in Photoshop using Vector Tools
We all utilize image compression as a daily tool, thus it's essential. Without it, sending enormous files would take hours, we would be emailing hundreds of megabyte-sized files, our landing page would never load, and navigating the internet would feel like walking through thick mud. But being aware of how and why picture files are compressed might
5 min read
Understanding file sizes | Bytes, KB, MB, GB, TB, PB, EB, ZB, YB
The memory of a Computer is any physical device that is capable of storing information whether it is large or small and stores it temporarily or permanently. For example, Random Access Memory (RAM), is a type of volatile memory that stores information for a short time, on an integrated circuit used by the Operating System. Memory can be either vola
14 min read
Tense Chart in English - Rules, Examples, Types & Mind map
Tense Chart: The Tense Chart is a visual representation of the various verb tenses in English. It organizes the verb tenses in English. It outlines the various forms of the verb according to their uses. By using a tense chart, one can easily understand the relationship between the various forms of verbs and be able to make appropriate verb choices
10 min read
Logic Gates - Definition, Types, Uses
Logic gates are the fundamental components of all digital circuits and systems. In digital electronics, there are seven main types of logic gates used to perform various logical operations. A logic gate is basically an electronic circuit designed by using components like diodes, transistors, resistors, capacitors, etc., and capable of performing lo
12 min read
Periodic Table of Elements
The Periodic table of elements is a systematic arrangement of 118 known chemical elements. These chemical elements are organized in order of increasing atomic number. The horizontal rows from left to right are called periods while the vertical columns from top to bottom are called groups in a periodic table. Table of Content What is Periodic Table
5 min read
Types of Computers
Pre-Requisite: Basics of Computer A computer is an electronic device that has storage, computations, input (data), output (data) and networking capabilities. With the growing AI, computers also have learning capabilities from the data provided. The input and output data can be in different forms like text, images, audio and video. A computer proces
7 min read
Software and its Types
Software is a collection of instructions, data, or computer programs that are used to run machines and carry out particular activities. It is the antithesis of hardware, which refers to a computer's external components. A device's running programs, scripts, and applications are collectively referred to as "software" in this context. What is a Softw
7 min read
Generations of Computers - Computer Fundamentals
Generations of Computer: The modern computer took its shape with the arrival of your time. It had been around the 16th century when the evolution of the computer started. The initial computer faced many changes, obviously for the betterment. It continuously improved itself in terms of speed, accuracy, size, and price to urge the form of the fashion
9 min read
Trigonometric Identities
Trigonometric identities play an important role in simplifying expressions and solving equations involving trigonometric functions. These identities, which involve relationships between angles and sides of triangles, are widely used in fields like geometry, engineering, and physics. In this article, we’ll explore the most important trigonometric id
11 min read
Introduction of Object Oriented Programming
As the name suggests, Object-Oriented Programming or OOPs refers to languages that use objects in programming. Object-oriented programming aims to implement real-world entities like inheritance, hiding, polymorphism, etc in programming. The main aim of OOP is to bind together the data and the functions that operate on them so that no other part of
6 min read
C Hello World Program
The “Hello World” program is the first step towards learning any programming language and also one of the simplest programs you will learn. To print the "Hello World", we can use the printf function from the stdio.h library that prints the given string on the screen. C Program to Print "Hello World"The following C program displays "Hello World" in
2 min read
Types of Operating Systems
An Operating System performs all the basic tasks like managing files, processes, and memory. Thus, the operating system acts as the manager of all the resources, i.e. resource manager. Thus, the operating system becomes an interface between the user and the machine. It is one of the most required software that is present in the device. Operating Sy
11 min read
Dictionaries in Python
A Python dictionary is a data structure that stores the value in key: value pairs. Example: Here, The data is stored in key: value pairs in dictionaries, which makes it easier to find values. [GFGTABS] Python Dict = {1: 'Geeks', 2: 'For', 3: 'Geeks'} print(Dict) [/GFGTABS]Output{1: 'Geeks', 2: 'For', 3: 'Geeks'} Python dicti
10 min read
Java Hello World Program
Java is one of the most popular and widely used programming languages and platforms. Java is fast, reliable, and secure. Java is used in every nook and corner from desktop to web applications, scientific supercomputers to gaming consoles, cell phones to the Internet. In this article, we will learn how to write a simple Java Program. Steps to Implem
5 min read
Exceptions in Java
Exception Handling in Java is one of the effective means to handle runtime errors so that the regular flow of the application can be preserved. Java Exception Handling is a mechanism to handle runtime errors such as ClassNotFoundException, IOException, SQLException, RemoteException, etc. What are Java Exceptions?In Java, Exception is an unwanted or
10 min read
Interfaces in Java
An Interface in Java programming language is defined as an abstract type used to specify the behavior of a class. An interface in Java is a blueprint of a behavior. A Java interface contains static constants and abstract methods. What are Interfaces in Java?The interface in Java is a mechanism to achieve abstraction. Traditionally, an interface cou
11 min read
Python Exception Handling
We have explored basic python till now from Set 1 to 4 (Set 1 | Set 2 | Set 3 | Set 4).  In this article, we will discuss how to handle exceptions in Python using try, except, and finally statements with the help of proper examples.  Error in Python can be of two types i.e. Syntax errors and Exceptions. Errors are problems in a program due to which
9 min read
Inline Functions in C++
C++ provides inline functions to reduce the function call overhead. An inline function is a function that is expanded in line when it is called. When the inline function is called whole code of the inline function gets inserted or substituted at the point of the inline function call. This substitution is performed by the C++ compiler at compile tim
9 min read
Constructors in C++
Constructor in C++ is a special method that is invoked automatically at the time an object of a class is created. It is used to initialize the data members of new objects generally. The constructor in C++ has the same name as the class or structure. It constructs the values i.e. provides data for the object which is why it is known as a constructor
7 min read