FTP

August 29, 2024 ยท View on GitHub

An old protocol for file transfers.

You shouldn't use this normally, except some companies may use it for anonymous uploads for vendor support cases, eg. Informatica.

FTP Clients

GUI

Command Line

The ftp command is provided by several packages

  • GNU inetutils
    • on Mac brew install inetutils
  • lftp - more sophisticated - bookmarking, tab completion can transfer several files in parallel
    • on Mac brew install lftp
  • ncftp - - more sophisticated - bookmarking, tab completion can transfer several files in parallel
    • on Mac brew install inetutils
  • curl - curl -u user:password ftp://ftp.example.com/file.txt -O
    • built-in on Mac, usually the curl package on most Linux distributions
  • tnftp

FTP Servers

FTP Client Commands

Usually as simple as:

ftp <host.domain.com>

and then using a series of FTP commands to put or get files inside the FTP shell.

Many of these will be familiar to unix command line users.

CommandDescription
openconnect to an ftp server eg. open <host.domain.com>. Usually you don't need to do this if starting ftp <host.domain.com>
loginlogin if not using anonymous FTP. Enter username and password when prompted
lslist directory contents
dirlist directory contents with more details like file sizes
mkdirCreates a directory on the remote server eg. mkdir my_new_directory
cdchange to a directory
lcdchange to a local directory on your machine
getdownload a file from the remote server to the local machine eg. get filename.txt
mgetdownload multiple files from the remote server eg. get *.txt
putupload a file from the local machine to the remote server eg. put filename.txt
mputupload multiple files to the remote server eg. put *.txt
deletedeletes a file on the remote server eg. delete filename.txt
rmdirdelete a directory on the remote server eg. rmdir my_new_directory
pwddisplay the current directory on the remote server
lpwddisplay the current local directory on your machine
asciiswitch the transfer mode to ASCII (useful for text files)
binaryswitch the transfer mode to binary (useful for non-text files like images, videos or .tar.gz tarballs)
quit / byelogs out and end the FTP session
prompttoggles interactive mode on/off, which asks for confirmation before performing multiple operations (like mget and mput)
renamerename a file on the remote FTP server eg. rename oldname.txt newname.txt
chmodchange the permissions of a file on the remote server (if supported) eg. chmod 755 script.sh
statusshows the current status of your FTP session
hashtoggle hash-mark printing (#) for file transfers to show progress
!execute a command on the local machine without leaving the FTP session eg. ! ls to list local directory files to see filenames to transfer
quotesend an arbitrary command to the remote FTP server eg. quote SITE CHMOD 755 filename.txt
passivetoggle passive mode on/off to work around network issues connecting

Example

Install lftp on Mac:

brew install lftp
lftp tsftp.informatica.com