FTP or File Transfer Protocol is a network protocol used to transfer (upload and download) files and folders via a network. The FTP uses network sockets for communication. FTP is implemented in the TCP protocol for reliability and security. The FTP uses TCP port number 21 in order to start and control FTP transmission. But the TCP port 20 is used for data transmission. As FTP is a standard protocol the port numbers are defined in the
RFC 959 which is created by Abhay Bhushan in 1971.
FTP Port Numbers
The FTP standard defines two port numbers to implement and use the FTP protocol. The TCP 21 is a well-known port number for the FTP. FTP protocol works with 2 channels where the first channel is used to control the session and data transmission and the second channel is used to transfer data. The TCP 21 is used to connect, start and control FTP where TCP 20 is used for data transmission via upload or download. FTP does not use the UDP protocol for reliability and security reasons.
In the following diagram, we can see the Client and Server communication for the FTP protocol. The Data is provided via TCP port number 20 and command&control are provided via TCP port number 21.
Check If FTP Port Is Open In Linux
FTP server can be installed and provided in a Linux system. We can also check the FTP port with the
netstat command if it is opened and running. The “netstat -tl” command is used to list and display open ports with protocol names and statuses. If the FTP port is open and running the state is displayed as
LISTEN like below.
$ netstat -tl
Connect FTP Port with ftp Command via Command Line Interface
The ftp command can be used to connect remote FTP server port via command-line interface. The FTP server IP address or hostname is provided to the ftp command and the FTP connection is established. The username is asked interactively and then the password is required. If credentials are accepted the FTP interactive shell is displayed like below.
$ ftp 192.168.136.136
Connected to 192.168.136.136. 220 ubuntu FTP server (Version 6.4/OpenBSD/Linux-ftpd-0.17) ready. Name (192.168.136.136:ismail): ismail 331 Password required for ismail. Password: 230 User ismail logged in. Remote system type is UNIX. Using binary mode to transfer files. ftp>