Updated March 14, 2023
Introduction to FTP Command
FTP stands for File Transfer Protocol. The responsibility of FTP is to transform a file from one location to another. For transforming file, FTP uses TCP services. It uses two TCP connections, i.e. control connection and data connection. Both control connection and data connection use well-known port 21 and well-known port 20, respectively. In this article, we will discuss different FTP Commands.
For communication, a client sends commands to the server, and in return, the server sends a response to the client. Commands that are sent from the client side are in the form ASCII character set.
FTP commands can be categorized into the following six groups.
- Access Commands
- File management commands
- Data formatting commands
- Port defining commands
- File transferring commands
- Miscellaneous commands
let’s discuss these commands one by one
1. Access Commands
Users can use these commands to access the remote system.
Below is a list of access commands
- USER: This command is used to give information about the user. It takes one argument, i.e. user id.
- PASS: This command is used to set the user’s password, or using this user can log into the system. It takes one argument, i.e. user password.
- ACCT: It gives information about the user account. It takes one argument, i.e. account name.
- QUIT: To log out from the system, this command is used.
- ABOR: It aborts the previous command.
- REIN: It is used to reinitialize the system.
2. File Management Commands
Users can access the file system present on the remote system using these commands. It allows a user to create a new directory, delete files, navigate throughout the directories, etc.
Below is the list of file management commands
- CWD: This command is used to switch from one directory to another. It takes one argument, i.e. directory name.
- CDUP: It is used to switch to the parent directory.
- DELE: It is used to delete the file from the directory. It takes one argument, i.e. file name.
- LIST: It will give a list of all files present in the specified directory. It takes one argument, i.e. directory name.
- NLIST: It will give a list of files without their attributes present in the specified directory. It takes one argument, i.e. directory name.
- MKD: This command is used to create a new directory. It takes one argument, i.e. directory name.
- RMD: This command is used to remove the directory. It takes one argument, i.e. directory name.
- PWD: It will display the name of the current directory.
- RNTO: It is used to rename the file. It takes one argument, i.e. a new file name.
- SMNT: It is used for mounting a file system. It takes one argument, i.e. file system name.
- RNFR: It is used to identify a file that needs to be renamed. It takes one argument, i.e. Old file name.
3. Data Formatting Commands
for defining data attributes, these commands have been used. It defines data attributes like type of file, the structure of data and the transmission modes.
- TYPE: It defines the type of file. It takes five arguments for defining the file type. A for ASCII, E for EBCDIC, I for an image, N for nonprint and T for telnet.
- STRU: It defines the organization of data. It takes three arguments. F for file, R for the record, and P for the page.
- MODE: This command is used to define the transmission mode of the file. It takes three arguments. S for the stream, B for block and C for compressed.
4. Port Defining Commands
It is used for defining the port number for connection at the client-side. Port number can be assigned using one of the fooling methods.
- The client can choose an ephemeral port number using the PORT command and then send it to the server using passive open. After receiving an ephemeral port number, sever creates an active open.
- The client uses the PASV command and tells the server to choose any port number. A server makes passive open on that port number and sends that port number to the client. After receiving a port number from a server, the client issues active open for that port number.
Below is the list of port defining commands
- PORT: This command allows a client to choose a port number. It takes one argument, i.e. six-digit identifier.
- PASV: This command let the server to choose a port number.
5. File Transfer Commands
For transferring files, these commands are used. These commands take one argument, i.e. file name.
Below is the list of file transfer commands
- RETR: The client uses this command to retrieve files from the server.
- STOR: The client uses this command to stores files on the server.
- APPE: It is similar to the STOR command, but if the file exists, then data must be appended to it.
- STOU: It is also similar to the STOR command, but every file name should be unique in the directory.
- ALLO: This command is to allocate storage space for files on the server.
- STAT: This command will display the status of the specified files.
- REST: This command will position the file marker at specified data points.
6. Miscellaneous Commands
These commands are used for delivering information to the FTP user on the client side.
Below is the list of miscellaneous commands.
- HELP: This command will display information about the server.
- NOOP: This command is used to check whether the server is alive or not.
- SITE: This command will specify the specific commands. It takes one argument, i.e. commands.
- SYST: This command will display information about the operating system used by the server.
This has been a guide to FTP Commands. Here we have discussed the basic concept with a list of the top 6 FTP Commands in detail. You may also look at the following articles to learn more –