pftp Command in Linux
The pftp command in Linux is a client to transfer the file over the internet using the File Transfer Protocol (FTP). It functions similarly to the standard FTP client, but it ensures that data connections are established in Passive Mode, which is useful when the client is behind a firewall or NAT (Network Address Translation
It is important to note that pftp in most modern Linux distributions has been deprecated and replaced with ftp. The pftp command is deprecated primarily because modern FTP clients, including ftp, generally support both active and passive modes, eliminating the need for a separate command like pftp.
Table of Contents
Here is a comprehensive guide to the options available with the pftp command −
Syntax of ftp Command
The syntax of ftp command in Linux is as follows −
ftp [options] [hostname]
In the above syntax, the [options] field is used to specify optional flags such as -v, -i, or others. The [hostname] is used to specify the remote server's IP address to connect to.
ftp Command Options
The options for the ftp command are listed in the following table −
Option | Description |
---|---|
-A | To use active mode for transfer (Default is passive) |
-4 | To use only IPv4 |
-6 | To use only IPv6 |
-p | To use passive mode for transfer (default) |
-i | To disable interactive prompts for batch transfer |
-e | To disable command editing |
-g | To disable file globbing |
-m | To disable binding for the same interface for passive transfer |
-v | To enable verbose mode |
-d | To enable debugging mode |
FTP Interface Commands
The ftp command initiates a separate interface after connecting to the remote system. In the remote system, there is another set of sub-commands that are used for further operations. The sub-commands are listed below −
Command | Description |
---|---|
! [command [args]] | To invoke the interactive shell on the local system |
$ [macro-name [args]] | To execute a defined macro |
account [passwd] | To supply a password for the remote system |
append | To append a local file on a file on the remote system |
ascii | To set the file transfer type to network ASCII (default) |
binary | To set the file transfer type to binary image |
bye/quit/exit | To end the ftp session |
cd [remote-directory] | To change the directory on the remote system |
chmod [mode] [file-name] | To change the permissions on the remote system |
close/disconnect | To close the ftp session |
delete [remote-file] | To delete a file on the remote system |
dir [remote-directory] [local-file] | To list the directory content on the remote system |
get [remote-file] [local-file] | To retrieve or download files from the remote system |
hash | To print the # sign for each transferred data |
help | To display help |
lcd [directory] | To change the working directory on the local machine. |
ls [remote-directory] [local-file] | To list directory contents on the remote system |
mls [remote-directory] [local-file] | To list the content of multiple directories |
mkdir [directory-name] | To create a directory on the remote system |
mdelete [remote-files] | To delete multiple remote files |
mget [remote-files] | To retrieve multiple files from the remote machine |
mput [local-files] | To send multiple files to the remote machine |
open [host] [port] | To connect to an FTP server at a specified host and port |
put [local-file] [remote-file] | To send or upload a file to the remote system |
pwd | To print the current working directory on the remote system |
rename [from] [to] | To rename a file on the remote system |
rmdir [directory-name] | To remove the directory on the remote system |
status | To show the status of the FTP session |
user [user-name] [password] [account] | To login to an FTP server |
Examples of ftp Command in Linux
This section explores how to use ftp command in Linux with examples −
- Establishing FTP Connection
- Listing Directories
- Changing Directory
- Creating Directories
- Downloading a File
- Uploading a File
- Renaming a File
- Deleting a File
- Displaying Operating System Type
- Checking the Status of the Current FTP Session
- Displaying Usage Help
- Closing the FTP Connection
Establishing FTP Connection
An FTP connection must be established with the remote system before transferring files. To connect, use the ftp command followed by the remote system's IP address −
ftp 192.168.0.144
Before configuring the FTP interface, the system will prompt for the username and password of the remote system. Once the credentials are entered, the FTP connection will be established.

Listing Directories
To list the contents of the remote system, use the ls command. To view the contents of the current directory, use the following command −
ls

To list the content of a specific directory, specify the path of the directory −
ls myDir
Changing Directory
To change the directory on the remote system, use the cd command with the directory name or path −
cd myProject

To go back to the previous directory, use −
cd ..
Creating Directories
To create a directory on the remote system, use the mkdir command followed by the directory name.
mkdir testDir

Downloading a File
To download a file from the remote system, use the get command. For example, to download a file test.txt file from the remote machine, use the get command in the following way −
get test.txt
To download the file and save it with a different name on the local system, use the get command in the following way −
get test.txt downloaded.txt
The above command will download the test.txt file as a downloaded.txt file on the local system.
To download multiple files, use the mget command in the FTP session −
mget test1.txt test2.txt
Before downloading multiple files, the command will prompt with the [anpqy] option. Here is the breakdown of these options −
Key | Option | Description |
---|---|---|
a | All | Apply the action to all subsequent files without prompting |
n | No | Skip the current action |
p | Prompt | Ask for confirmation on each action |
q | Quit | Cancel the operation |
y | Yes | Proceed with the current action |
Uploading a File
To upload a file from the local system to the remote system, use the put command followed by the file name.
put test.txt
To upload with a different name, use −
put test.txt uploaded.txt
The above command will upload the test.txt file as an uploaded.txt file on the remote system.
To upload multiple files, use the mput command −
mput test1.txt test2.txt
When uploading multiple files, a prompt with the [anpqy] options will be displayed.
Renaming a File
To rename a file on the remote system, use the rename command. For example, to change test.txt to sample.txt, use the following command −
rename file.txt newFile.txt

Deleting a File
To remove a file from the remote system, use the delete command followed by the file name.
delete file1.txt

To delete multiple files, use the mdelete command as shown below −
mdelete file1.txt file2.txt

When deleting multiple files, a prompt with the [anpqy?] options will appear.
Displaying Operating System Type
To display the operating system type of the remote system, use the system command −
system

Checking the Status of the Current FTP Session
To check the status of the current FTP session, use the status command −
status

Displaying Usage Help
To list all FTP commands available to the client, use the help command −
help

Closing the FTP Connection
To close the current FTP session but leave the FTP client running, use the disconnect command −
disconnect

To close the FTP connection and FTP client, type the bye command and press Enter.
bye

Or type quit or, exit and press Enter.
Conclusion
In conclusion, the pftp command in Linux was once a useful tool for transferring files using FTP in passive mode, especially when clients were behind firewalls or NAT. However, with modern FTP clients like ftp supporting both active and passive modes, pftp has been deprecated.
The ftp command, which now handles both modes, is more versatile and commonly used across Linux distributions. It provides various options and sub-commands for managing FTP sessions, including connecting, transferring files, and managing directories.