FTP(1)

πŸ’– FTP(1) πŸ’–

okay bestie, welcome to the FTP(1) page from the General Commands Manual β€” yes the whole thing, we're doing this properly, no skimming, no gatekeeping 🫢


✨ NAME ✨

ftp β€” Internet file transfer program πŸŒπŸ’Œ


🌸 SYNOPSIS 🌸

ftp [-46pinegvd] [-z debug] [-z nossl] [-z secure] [-z verbose]
    [-z verify=flags] [-z cacert=ca_file] [-z cert=cert_file]
    [-z key=key_file] [-z cipher=list] [host [port]]
pftp [-46inegvd] [-z debug] [-z nossl] [-z secure] [-z verbose]
    [-z verify=flags] [-z cacert=ca_file] [-z cert=cert_file]
    [-z key=key_file] [-z cipher=list] [host [port]]

πŸ¦‹ DESCRIPTION πŸ¦‹

Ftp is literally the user interface to the Internet standard File Transfer Protocol. She lets you move files to and from a remote network site, that's the whole job, and she's iconic for it πŸ‘‘

You can drop options at the command line, or hand them to the command interpreter, whichever vibe you're on ✨

  • -4 β€” only use IPv4 to contact any host. 4eva. πŸ’™
  • -6 β€” IPv6 only. no IPv4 in this house 🚫4️⃣
  • -p β€” use passive mode for data transfers. This is the move when a firewall is blocking connections from the outside world back to your machine. Heads up tho: it requires that the ftp server support the PASV command. Fun fact: this is the default if you invoke the program as pftp 🫢
  • -i β€” turns off interactive prompting during multiple file transfers. silence, bestie 🀫
  • -n β€” restrains ftp from attempting "auto-login" on that first connection. When auto-login is enabled, ftp peeks at the .netrc file (see netrc(5)) in your home directory looking for an entry describing an account on the remote machine. No entry? Then ftp prompts you for the remote machine login name (default is your user identity on the local machine), and if it's needed, it'll prompt for a password and an account to login with. πŸ”
  • -e β€” disables command editing and history support, if it was compiled into the ftp executable. Otherwise? does nothing. literally nothing. girl is unemployed πŸ’€
  • -g β€” disables file name globbing 🚫✨
  • -v β€” the verbose option forces ftp to show all responses from the remote server, plus report on data transfer statistics. nosy in the best way πŸ‘€
  • -d β€” enables debugging πŸ›
  • -z option β€” set SSL (Secure Socket Layer) parameters. The default is to negotiate via ftp protocol if SSL is available on the server side and then switch it on. In this mode you can connect to both conventional and SSL enhanced ftpd's, so you're covered either way πŸ’…

The SSL parameters are:

  • debug β€” send SSL related debugging information to stderr.
  • ssl β€” negotiate SSL at first, then use FTP protocol. Only the FTP protocol negotiation goes encrypted. (Not yet implemented) 🚧
  • nossl, !ssl β€” switch off SSL negotiation πŸ™…
  • secure β€” don't switch back to unencrypted mode (no SSL) if SSL is not available. no downgrades allowed πŸ›‘
  • verbose β€” be verbose about certificates etc. πŸ“œ
  • verify=int β€” set the SSL verify flags. The only sensible value for a client like ftp is 1. (See the macros SSL_VERIFY_* in openssl/ssl.h).
  • cacert=ca_file β€” accept the CA-certificates found in ca_file as verification of the remote server.
  • cert=cert_file β€” use the certificate(s) in cert_file. This file may also carry a key.
  • key=key_file β€” read the key(s) from key_file whenever the certificate file does not suffice.
  • cipher=ciph_list β€” set the preferred ciphers to ciph_list. The environment variable SSL_CIPHER serves the same purpose. (See openssl/ssl.h for suggestions).

The client host and an optional port number with which ftp is to communicate may be specified on the command line. If you do that, ftp will immediately attempt to establish a connection to an FTP server on that host πŸš€. Otherwise, ftp enters its command interpreter and awaits instructions from you. When ftp is awaiting commands from you, the prompt ftp> is provided to you πŸ’¬

The following commands are recognized by ftp:

  • ! [command [args]] β€” invoke an interactive shell on the local machine. If there are arguments, the first is taken to be a command to execute directly, with the rest of the arguments as its arguments. 🐚
  • $ macro-name [args] β€” execute the macro macro-name that was defined with the macdef command. Arguments are passed to the macro unglobbed.
  • account [passwd] β€” supply a supplemental password required by a remote system for access to resources once a login has been successfully completed. If no argument is included, you'll be prompted for an account password in a non-echoing input mode 🀐
  • append local-file [remote-file] β€” append a local file to a file on the remote machine. If remote-file is left unspecified, the local file name is used in naming the remote file, after being altered by any ntrans or nmap setting. File transfer uses the current settings for type, format, mode, and structure. βž•
  • ascii β€” set the file transfer type to network ASCII. This is the default type 🌈
  • bell β€” arrange that a bell be sounded after each file transfer command is completed πŸ””
  • binary β€” set the file transfer type to support binary image transfer 🧬
  • bye β€” terminate the FTP session with the remote server and exit ftp. An end of file will also terminate the session and exit. πŸ‘‹
  • case β€” toggle remote computer file name case mapping during mget commands. When case is on (default is off), remote computer file names with all letters in upper case are written in the local directory with the letters mapped to lower case. πŸ” βž‘οΈπŸ”‘
  • cd remote-directory β€” change the working directory on the remote machine to remote-directory.
  • cdup β€” change the remote machine working directory to the parent of the current remote machine working directory. ⬆️
  • chmod mode file-name β€” change the permission modes of the file file-name on the remote system to mode.
  • close β€” terminate the FTP session with the remote server, and return to the command interpreter. Any defined macros are erased 🧼
  • cr β€” toggle carriage return stripping during ascii type file retrieval. Records are denoted by a carriage return/linefeed sequence during ascii type file transfer. When cr is on (the default), carriage returns are stripped from this sequence to conform with the Unix single linefeed record delimiter. Records on non-Unix remote systems may contain single linefeeds; when an ascii type transfer is made, these linefeeds may be distinguished from a record delimiter only when cr is off. πŸ›€οΈ
  • qc β€” toggle the printing of control characters in the output of ASCII type commands. When this is turned on, control characters are replaced with a question mark if the output file is the standard output. This is the default when the standard output is a tty. ❓
  • delete remote-file β€” delete the file remote-file on the remote machine. πŸ—‘οΈ
  • debug [debug-value] β€” toggle debugging mode. If an optional debug-value is specified it is used to set the debugging level. When debugging is on, ftp prints each command sent to the remote machine, preceded by the string --> πŸ›
  • dir [remote-directory] [local-file] β€” print a listing of the directory contents in the directory, remote-directory, and, optionally, placing the output in local-file. If interactive prompting is on, ftp will prompt you to verify that the last argument is indeed the target local file for receiving dir output. If no directory is specified, the current working directory on the remote machine is used. If no local file is specified, or local-file is -, output comes to the terminal. πŸ“‚
  • disconnect β€” a synonym for close.
  • form format β€” set the file transfer form to format. The default format is "file".
  • get remote-file [local-file] β€” retrieve the remote-file and store it on the local machine. If the local file name is not specified, it is given the same name it has on the remote machine, subject to alteration by the current case, ntrans, and nmap settings. The current settings for type, form, mode, and structure are used while transferring the file. πŸ“₯
  • glob β€” toggle filename expansion for mdelete, mget and mput. If globbing is turned off with glob, the file name arguments are taken literally and not expanded. Globbing for mput is done as in csh(1). For mdelete and mget, each remote file name is expanded separately on the remote machine and the lists are not merged. Expansion of a directory name is likely to be different from expansion of the name of an ordinary file: the exact result depends on the foreign operating system and ftp server, and can be previewed by doing mls remote-files - ✨
Note: mget and mput are not meant to transfer entire directory subtrees of files. That can be done by transferring a tar(1) archive of the subtree (in binary mode). πŸ“¦
  • hash [increment] β€” toggle hash-sign (#) printing for each transferred data block, but only in the absence of an argument. The size of a data block is set to 1024 bytes by default, but can be changed by the argument increment, which also accepts the suffixed multipliers 'k' and 'K' for kilobytes, 'm' and 'M' for Megabytes, and finally 'g' and 'G' for Gigabytes. Setting a size activates hash printing unconditionally. #️⃣
  • help [command] β€” print an informative message about the meaning of command. If no argument is given, ftp prints a list of the known commands. πŸ†˜
  • idle [seconds] β€” set the inactivity timer on the remote server to seconds seconds. If seconds is omitted, the current inactivity timer is printed. ⏳
  • ipany β€” allow the address resolver to return any address family.
  • ipv4 β€” restrict the address resolver to look only for IPv4 addresses.
  • ipv6 β€” restrict host adressing to IPv6 only.

still going bestie, don't go anywhere β€” more of this page is coming πŸ’–

  • lcd [directory] β€” switch up your working directory on the local machine, like your laptop's own little home base πŸ’». Don't pass a directory? It just yeets you to the user's home directory. Simple as that.
  • ls [remote-directory] [local-file] β€” prints a listing of what's inside a directory on the remote machine πŸ—‚οΈ. Heads up bestie, that listing includes whatever system-dependent info the server feels like including β€” most Unix systems will just hand you the output of ls -l (see also nlist, okurr). Leave remote-directory out and it uses the current working directory. If interactive prompting is on, ftp will make you confirm that the last argument really is the target local file for receiving the ls output β€” yes ma'am, double-checking. And if no local file is specified, or local-file is -, the output goes straight to your terminal.
  • macdef macro-name β€” defines a macro, and everything you type after it gets stored as the macro macro-name ✨. A null line (that's consecutive newline characters in a file, or carriage returns from the terminal) ends macro input mode β€” so hit enter twice and you're out. There's a cap: 16 macros max, and 4096 total characters across all of them. Macros stay defined until a close command runs. The macro processor treats $ and \ as special characters. A $ followed by a number (or numbers) gets swapped for the corresponding argument on the macro invocation command line. A $ followed by an i tells the macro processor that the executing macro should be looped β€” first pass $i becomes the first argument on the macro invocation command line, second pass it becomes the second argument, and so on forever. A \ followed by any character is replaced by that character. Use \ to stop $ from getting its special treatment πŸ’….
  • mdelete [remote-files] β€” deletes the remote-files on the remote machine. Gone. Poof. πŸ«₯
  • mdir remote-files local-file β€” literally dir, except you can specify multiple remote files at once πŸŽ€. If interactive prompting is on, ftp prompts you to verify that the last argument is indeed the target local file for receiving mdir output.
  • mget remote-files β€” expands the remote-files on the remote machine and does a get for every file name it produces 🌸. Peep glob for the details on filename expansion. The resulting file names then get processed according to your case, ntrans, and nmap settings. Files land in the local working directory β€” change that with lcd directory, and make brand-new local directories with ! mkdir directory πŸ—οΈ.
  • mkdir directory-name β€” makes a directory on the remote machine, iconic behavior ✨.
  • mls remote-files local-file β€” like nlist, except multiple remote files may be specified, and local-file is mandatory this time, no skipping it. If interactive prompting is on, ftp will prompt you to verify that the last argument is indeed the target local file for receiving mls output.
  • mode [mode-name] β€” sets the file transfer mode to mode-name. The default is "stream" mode 🌊.
  • modtime file-name β€” shows you the last modification time of the file on the remote machine πŸ•°οΈ. Nosy but make it useful.
  • mput local-files β€” expands wild cards in the list of local files you passed as arguments, then does a put for each file in the resulting list πŸš€. See glob for the deets on filename expansion. Resulting file names then get processed according to your ntrans and nmap settings.
  • newer file-name [local-file] β€” only grabs the file if the modification time of the remote file is more recent than the file on the current system ⏱️. If the file doesn't exist on the current system at all, the remote file counts as newer. Other than that, it's identical to get.
  • nlist [remote-directory] [local-file] β€” prints a list of the files in a directory on the remote machine πŸ“‹. Leave remote-directory unspecified and it uses the current working directory. If interactive prompting is on, ftp prompts you to verify that the last argument is indeed the target local file for receiving nlist output. No local file specified, or local-file is -? Output goes to the terminal, easy.
  • nmap [inpattern outpattern] β€” sets or unsets the filename mapping mechanism πŸ¦‹. No arguments = unset it. With arguments, remote filenames get mapped during mput commands and put commands issued without a specified remote target filename; local filenames get mapped during mget commands and get commands issued without a specified local target filename. This one's your bestie when you're connecting to a non-Unix remote computer with different file naming conventions or practices. The mapping follows the pattern set by inpattern and outpattern. inpattern is a template for incoming filenames (which may have already been processed according to the ntrans and case settings). Variable templating happens by including the sequences $1, $2, ..., $9 in inpattern β€” and use \ to prevent that special treatment of $. Every other character is treated literally, and gets used to determine the nmap inpattern variable values. For example, given inpattern $1.$2 and the remote file name "mydata.data", $1 would have the value "mydata", and $2 would have the value "data". The outpattern determines the resulting mapped filename. The sequences $1, $2, ...., $9 are replaced by any value resulting from the inpattern template, and the sequence $0 is replaced by the original filename. On top of that, the sequence [seq1, seq2] is replaced by seq1 if seq1 is not a null string; otherwise it's replaced by seq2. For example, this command
nmap $1.$2.$3 [$1,$2].[$2,file]

would yield the output filename "myfile.data" for input filenames "myfile.data" and "myfile.data.old", "myfile.file" for the input filename "myfile", and "myfile.myfile" for the input filename ".myfile" 🀯. Spaces may be included in outpattern, as in this example: nmap $1 sed "s/ *$//" > $1. Use the \ character to prevent special treatment of the $, [, [, and , characters.

  • ntrans [inchars [outchars]] β€” sets or unsets the filename character translation mechanism πŸ’…. No arguments and it's unset. With arguments, characters in remote filenames get translated during mput commands and put commands issued without a specified remote target filename; characters in local filenames get translated during mget commands and get commands issued without a specified local target filename. Again, chef's kiss for connecting to a non-Unix remote computer with different file naming conventions or practices 🌈. Characters in a filename that match a character in inchars get replaced with the corresponding character in outchars. And if the character's position in inchars is longer than the length of outchars, that character gets deleted from the file name entirely.
  • open host [port] β€” establishes a connection to the specified host FTP server πŸ”Œ. You can optionally hand it a port number, in which case ftp tries to contact an FTP server at that port. If the auto-login option is on (and it is by default), ftp will also try to automatically log you in to the FTP server (see below) πŸ’–.
  • prompt β€” toggles interactive prompting πŸ””. Interactive prompting happens during multiple file transfers so you can selectively retrieve or store files. Turn prompting off (the default is on) and any mget or mput will transfer every file, and any mdelete will delete every file. No take-backs, so be careful bestie.
  • proxy ftp-command β€” executes an ftp command on a secondary control connection πŸ‘―. This lets you connect to two remote ftp servers at the same time and transfer files between them. The first proxy command should be an open, to establish the secondary control connection. Type "proxy ?" to see the other ftp commands you can run on the secondary connection. These commands behave differently when prefaced by proxy: open will not define new macros during the auto-login process, close will not erase existing macro definitions, get and mget transfer files from the host on the primary control connection to the host on the secondary control connection, and put, mput, and append transfer files from the host on the secondary control connection to the host on the primary control connection πŸ”„. Third party file transfers depend upon support of the ftp protocol PASV command by the server on the secondary control connection.
  • put local-file [remote-file] β€” stores a local file on the remote machine πŸ“€. Leave remote-file unspecified and the local file name gets used β€” after being processed according to any ntrans or nmap settings β€” to name the remote file. The transfer uses your current settings for type, format, mode, and structure.
  • pwd β€” prints the name of the current working directory on the remote machine πŸ“. Where even am I.
  • quit β€” a synonym for bye πŸ‘‹.
  • quote arg1 arg2 ... β€” the arguments you specify get sent, verbatim, to the remote FTP server πŸ—£οΈ. No edits, no vibes, just exactly what you typed.
  • recv remote-file [local-file] β€” a synonym for get πŸ’Œ.
  • reget remote-file [local-file] β€” it's get's braver cousin 🫢. If local-file already exists and it's smaller than remote-file, ftp assumes it's a half-finished copy and picks up from the apparent point of failure instead of starting over. If local-file doesn't exist at all, ftp straight-up won't fetch the file, no cap. Basically made for hauling giant files over networks that keep ghosting you and dropping the connection πŸ’€.
  • remotehelp [command-name] β€” ask the remote FTP server for help. Pass a command-name and it gets handed to the server too.
  • remotestatus [file-name] β€” no arguments? It shows the status of the remote machine. Give it a file-name and it shows the status of that file-name on the remote machine.
  • rename [from] [to] β€” rename the file from on the remote machine to the file to. glow up πŸ’…
  • reset β€” clears the reply queue. This one re-synchronizes the command/reply sequencing with the remote ftp server. You might need this resync after the remote server violates the ftp protocol, which is giving chaos 🚩.
  • restart marker β€” restarts the immediately following get or put at the indicated marker. On Unix systems, marker is usually a byte offset into the file.
  • rmdir directory-name β€” delete a directory on the remote machine. bye bestie πŸ‘‹
  • runique β€” toggles storing files on the local system with unique filenames. If a file already exists with a name equal to the target local filename for a get or mget command, a ".1" gets appended to the name. If that resulting name matches another existing file, a ".2" is appended to the original name. If this keeps going all the way up to ".99", an error message is printed and the transfer does not take place 😭. The generated unique filename will be reported to you. Heads up though: runique will not affect local files generated from a shell command (see below). Default value is off.
  • send local-file [remote-file] β€” a synonym for put. same vibe, different name ✨
  • sendport β€” toggles the use of PORT commands. By default, ftp will attempt to use a PORT command when establishing a connection for each data transfer. Using PORT commands can prevent delays when you're doing multiple file transfers. If the PORT command fails, ftp falls back to the default data port. When PORT commands are disabled, no attempt will be made to use them for each data transfer. This is useful for certain FTP implementations which do ignore PORT commands but, incorrectly, indicate they've been accepted πŸ™ˆ.
  • site arg1 arg2 ... β€” the arguments you specify are sent, verbatim, to the remote FTP server as a SITE command.
  • size file-name β€” returns the size of file-name on the remote machine. she's got range πŸ“
  • status β€” show the current status of ftp.
  • struct [struct-name] β€” set the file transfer structure to struct-name. By default the β€œstream” structure is used.
  • sunique β€” toggles storing of files on the remote machine under unique file names. The remote ftp server must support the ftp protocol STOU command for this to complete successfully. The remote server will report the unique name. Default value is off.
  • system β€” show the type of operating system running on the remote machine.
  • tenex β€” set the file transfer type to the one you need to talk to TENEX machines.
  • trace β€” toggles packet tracing.
  • type [type-name] β€” set the file transfer type to type-name. If no type is specified, the current type is printed. The default type is network ASCII.
  • umask [newmask] β€” set the default umask on the remote server to newmask. If newmask is omitted, the current umask is printed.
  • user user-name [password] [account] β€” identify yourself to the remote FTP server πŸͺͺ. If the password isn't specified and the server needs it, ftp will prompt the user for it (after disabling local echo, so no peeking πŸ‘€). If an account field isn't specified and the FTP server requires it, the user will be prompted for it. If an account field is specified, an account command will be relayed to the remote server after the login sequence is completed β€” but only if the remote server didn't require it for logging in. Unless ftp was invoked with β€œauto-login” disabled, this whole process happens automatically on initial connection to the FTP server.
  • verbose β€” toggles verbose mode. In verbose mode, all responses from the FTP server are displayed to the user. Also, if verbose is on, when a file transfer completes, statistics regarding the efficiency of the transfer get reported. By default, verbose is on.
  • ? [command] β€” a synonym for help.

Command arguments which have embedded spaces may be quoted with quote " marks.


πŸ›‘ ABORTING A FILE TRANSFER

To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transfers will be immediately halted. Receiving transfers will be halted by sending a ftp protocol ABOR command to the remote server, and discarding any further data received. How fast this actually happens depends on the remote server's support for ABOR processing. If the remote server does not support the ABOR command, an β€˜ftp>’ prompt will not appear until the remote server has finished sending the requested file. so you'll just be sitting there like πŸ§β€β™€οΈ

The terminal interrupt key sequence will be ignored when ftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode may come from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol. And if the delay is because of unexpected remote server behavior, the local ftp program must be killed by hand πŸ’€.


πŸ—‚οΈ FILE NAMING CONVENTIONS

Files specified as arguments to ftp commands are processed according to the following rules.

  1. If the file name β€˜-’ is specified, the stdin (for reading) or stdout (for writing) is used.
  2. If the first character of the file name is β€˜|’, the remainder of the argument is interpreted as a shell command. Ftp then forks a shell, using popen(3) with the argument supplied, and reads (writes) from the stdout (stdin). If the shell command includes spaces, the argument must be quoted; e.g. β€œ" ls -lt"”. A particularly useful example of this mechanism is: β€œdir more”.
  3. Failing the above checks, if ``globbing'' is enabled, local file names are expanded according to the rules used in the csh(1); c.f. the glob command. If the ftp command expects a single local file (.e.g. put), only the first filename generated by the "globbing" operation is used.
  4. For mget commands and get commands with unspecified local file names, the local filename is the remote filename, which may be altered by a case, ntrans, or nmap setting. The resulting filename may then be altered if runique is on.
  5. For mput commands and put commands with unspecified remote file names, the remote filename is the local filename, which may be altered by a ntrans or nmap setting. The resulting filename may then be altered by the remote server if sunique is on.

βš™οΈ FILE TRANSFER PARAMETERS

The FTP specification specifies many parameters which may affect a file transfer. The type may be one of β€œascii”, β€œimage” (binary), β€œebcdic”, and β€œlocal byte size” (for PDP-10's and PDP-20's mostly). Ftp supports the ascii and image types of file transfer, plus local byte size 8 for tenex mode transfers.

Ftp supports only the default values for the remaining file transfer parameters: mode, form, and struct.


🌍 ENVIRONMENT

Ftp utilizes the following environment variables.

  • HOME β€” for default location of a .netrc file, if one exists.
  • SHELL β€” for default shell.
  • SSL_CIPHER β€” for acceptable cipher combinations.

πŸ‘€ SEE ALSO

ftpd(8), netrc(5), RFC 959


πŸ“œ HISTORY

The ftp command appeared in 4.2BSD.


πŸ› BUGS

Correct execution of many commands depends upon proper behavior by the remote server. (the way that everything is the server's fault and also not our problem 😭)

An error in the treatment of carriage returns in the 4.2BSD ascii-mode transfer code has been corrected. This correction may result in incorrect transfers of binary files to and from 4.2BSD servers using the ascii type. Avoid this problem by using the binary image type. periodt. πŸ’…


and that's the whole page bestie!! πŸŽ€ this icon of a manual page came from Linux NetKit (0.17), dated August 15, 1999, and it lives in section FTP(1) β€” go forth and transfer responsibly πŸ¦‹βœ¨