ftp

2024-01-01

Connecting to an FTP Server

The fundamental step is establishing a connection. The basic syntax is simple:

ftp <ftp_server_address>

Replace <ftp_server_address> with the actual IP address or domain name of the FTP server. For instance, to connect to ftp.example.com:

ftp ftp.example.com

You’ll likely be prompted for your username and password.

Once connected, you can navigate the remote server’s file system using commands similar to those found in your local shell.

pwd
ls
ls -l
cd /pub/documents
cd ..

Transferring Files

The core functionality of ftp lies in its file transfer capabilities.

get report.pdf
get /pub/images/logo.png mylogo.png
put mydocument.txt
put myimage.jpg /pub/images/newimage.jpg
mget *.txt
mput *.jpg

Handling Passive Mode

Some firewalls or network configurations require using passive mode for successful FTP connections. Enable passive mode with:

passive

After this command, subsequent file transfers will utilize the passive mode. To return to active mode, use:

active

Disconnecting from the Server

When finished, disconnect from the FTP server using:

bye

Advanced Features and Options

The ftp command offers many more options for fine-grained control over transfers, including resuming interrupted transfers, setting transfer speeds, and more. Refer to the man ftp page for a complete list of available options and commands. Experimentation and the manual page are your best allies in mastering this powerful tool. Remember to always be mindful of security best practices when using FTP, particularly when handling sensitive data.