FTP is the simplest and most familiar file transfer protocol that exchanges files between a local computer and a remote computer or network. The Linux and Unix operating systems have built-in command line instructions that you can use as FTP clients to make an FTP connection.
Warning: an FTP transmission is not encrypted. Anyone who intercepts the transmission can read the data it sends, including its username and password.
For secure transmission, use SFTP .
1. Establish an FTP connection
In order to use the various FTP commands, you must establish a connection to the network or remote computer. Do this by opening a terminal window in Linux and typing ftp followed by a domain name or an IP address of the FTP server, such as ftp 192.168.0.1 or ftp domain.com. For example:
This command tries to connect to the ftp server in abc.xyz.edu. If you are successful, it asks you to log in with a username and password. Public FTP servers often allow you to log in using the anonymous username and your email address as a password or without a password.
When you log in correctly, you will see an ftp> prompt on the terminal screen. Before going any further, get a list of available FTP commands using the help function . It is useful because depending on your system and software, some of the FTP commands listed may or may not work.
2. Examples and descriptions of the FTP command
The FTP commands used with Linux and Unix differ from the FTP commands used with the Windows command line. Here are examples that illustrate the typical uses of Linux FTP commands to copy, rename, and delete files remotely.
The help function lists the commands you can use to display the contents of the directory, transfer files and delete files.
The ftp>? Command achieve the same
This command prints the names of the files and subdirectories in the current directory on the remote computer.
ftp> cd customers
This command changes the current directory to the subdirectory called clients if it exists.
This changes the current directory to the main directory.
ftp> lcd [images]
This command changes the current directory on the local computer to images, if it exists.
This changes to ASCII mode to transfer text files. ASCII is the default value in most systems.
This command changes to binary mode to transfer all files that are not text files.
ftp> get image1.jpg
This downloads the image1.jpg file from the remote computer to the local computer.
Warning: if there is already a file on the local computer with the same name, it is overwritten.
ftp> put image2.jpg
Load the image2.jpg file from the local computer to the remote computer .
Warning: if there is already a file on the remote computer with the same name, it is overwritten.
Adding an exclamation point in front of a command executes the specified command on the local computer. So! Ls lists the names of the files and directories of the current directory on the local computer.
ftp> mget * .jpg
With the mget command. you can download multiple images This command downloads all the files that end with .jpg.
ftp> rename [from] [to]
The rename command changes the name of the file named [from] to the new name [to] on the remote server.
ftp> put local-file [remote-file]
This command stores a local file on the remote machine. Send local-file [remote file] does the same.
ftp> mput * .jpg
This command uploads all the files that end in .jpg to the active folder on the remote computer.
ftp> delete remote-file
Delete the file named remote-file on the remote computer.
ftp> mdelete * .jpg
This erases all the files that end with .jpg in the active folder of the remote computer.
ftp> size file-name
Determine the size of a file on the rebooted computer with this command.
ftp> mkdir [directory-name]
Make a new directory on the remote server.
The command prompt activates or deactivates the interactive mode so that commands are executed in multiple files without user confirmation.
The quit command terminates the FTP session and exits the FTP program. The commands bye and exit achieve the same.
3. Command line options
The options, also called indicators or modifiers, modify the function of an FTP command. Typically, a command-line option follows the main FTP command after a space. Here is a list of modifiers that you can add to FTP commands and a description of what they do.
- -4 Use only IPv4 when contacting a host
- -6 Use only IPv6
- -e Disables support for history and command editing
- -p Use passive mode for data transfers
- -i Disables the interactive function during file transfers
- -n Prevents automatic logon on the first connection
- -g Disables the globbing file name
- -v Forces the delete server to show all the answers
- -d Run debugging