ftp(1)

πŸ“¦
version 2.8 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– ftp(1) β€” the User's Reference Manual πŸ’–

okay bestie, sit DOWN, because we're doing ftp(1) today β€” yes, that ftp, the ARPANET file transfer program, and it's lowkey iconic ✨


✨ NAME ✨

ftp β€” ARPANET file transfer program πŸ¦‹

✨ SYNOPSIS ✨

ftp [option ...] [user@host [port]]

✨ DESCRIPTION ✨

ftp is the user interface to the ARPANET standard File Transfer Protocol. Periodt. It lets you transfer files to and from a remote network site, which is giving very much "main character moving files across the internet" energy πŸ’…

Also, you can slip a user into the host β€” just prefix it and follow it with an @. So user@host is the vibe, and that's literally it, no cap.

✨ OPTIONS ✨

okay so, the options?? You can drop them at the command line, or hand them straight to the command interpreter. Both. She's flexible like that πŸ’–

  • -4, --ipv4 β€” Use IPv4 to connect to hosts. ✨
  • -6, --ipv6 β€” Use IPv6 to connect to hosts. ✨
  • -A, --active β€” Enable active mode transfer β€” this one's the default for ftp. πŸ”₯
  • -p, --passive β€” Enable passive mode transfer β€” and this is the default for pftp. 🌸
  • --prompt [text] β€” Print a command line prompt (and optionally you can give it text too), even if you're not on a tty. Not me being extra about prompts πŸ™ˆ
  • -N, --netrc filename β€” Select a specific initialization file. Pick your fave, bestie πŸŽ€
  • -v, --verbose β€” Verbose mode forces ftp to show you all the responses from the remote server, plus it reports on data transfer statistics. She's telling you EVERYTHING πŸ‘‘
  • -t, --trace β€” Enable packet tracing. πŸ¦‹
  • -d, --debug β€” Enables debugging. πŸ’€
  • -e, --no-edit β€” Disable command line editing. no take-backsies on your typos fr fr
  • -n, --no-login β€” Restrains ftp from attempting "auto-login" upon initial connection. So here's the tea: if auto-login is enabled, ftp checks the .netrc file (see below) in your home directory for an entry describing an account on the remote machine. If there's no entry, ftp prompts for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompts for a password and an account to login with. 😭
  • -i, --no-prompt β€” Turns off interactive prompting during multiple file transfers. bulk mode, no interruptions πŸ’…
  • -g, --no-glob β€” Disables file name globbing. 🌈
  • --usage β€” Display a short usage message. quick lil recap ✨
  • -?, --help β€” Display a help list. 🫢
  • -V, --version β€” Display program version. πŸ“Œ

✨ OPERATION ✨

So the client host β€” and remember, you can prefix it with an optional user followed by an @ β€” that's the machine ftp is gonna communicate with, and you can name it right on the command line. If you do that, ftp will immediately attempt to establish a connection to an FTP server on that host. If you don't? Then ftp enters its command interpreter and just… waits for instructions from you. Very demure. Very patient. 🧚

And while ftp is awaiting your commands, it gives you the prompt:

ftp>

Here's every command ftp recognizes, and yes, we're going through all of them, I don't make the rules πŸ’œ

  • ! [command [args]] β€” Invoke an interactive shell on the local machine. If there are arguments, the first one is taken to be a command to execute directly, and the rest of the arguments become its arguments. escaped to the local side, slay πŸ”₯
  • $ 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, the user gets prompted for an account password in a non-echoing input mode. sneaky secret password vibes πŸ™ˆ
  • 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 to name the remote file β€” after being altered by any ntrans or nmap setting, obviously. File transfer uses the current settings for type, format, mode, and structure. adding, not replacing, periodt πŸ’…
  • ascii β€” Set the file transfer type to network ASCII. This is the default type. the classic πŸŽ€
  • bell β€” Arrange that a bell be sounded after each file transfer command is completed. ding! πŸ””
  • 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. the goodbye we deserve πŸ‘‘
  • 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. lowercase era πŸ’…
  • 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. go up one, bestie ⬆️
  • chmod mode file-name β€” Change the permission modes of the file file-name on the remote system to mode. permissions but make it remote πŸ”
  • close β€” Terminate the FTP session with the remote server, and return to the command interpreter. Any defined macros are erased. so long, macros πŸ’€
  • cr β€” Toggle carriage return stripping during ascii type file retrieval. Here's the lore: 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 can be distinguished from a record delimiter only when cr is off. important!! remember that!! 😭
  • delete remote-file β€” Delete the file remote-file on the remote machine. gone. deleted. πŸ—‘οΈ
  • debug [debug-value] β€” Toggle debugging mode. If an optional debug-value is specified, it's 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 place the output in local-file. If interactive prompting is on, ftp will prompt the user 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. same energy, different name πŸ’«
  • epsv4 β€” Toggle the use of EPSV/EPRT for IPv4 addressing. Default is off. 🌸
  • form format β€” Set the file transfer form to format. The only supported format is non-print. one option only, she's picky πŸ’…
  • get remote-file [local-file] β€” Retrieve the remote-file and store it on the local machine. If the local file name isn't specified, it's 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. grab it bestie 🫢
  • 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). no cap, don't try it 🚫
  • hash [size] β€” Toggle hash-sign ("#") printing for each data block transferred. The size of a data block can optionally be specified. If it's not given, it defaults to 1024 bytes. cute little progress dots ✨
  • help [command] β€” Print an informative message about the meaning of command. If no argument is given, ftp prints a list of the known commands. ask her anything πŸ’–
  • idle [seconds] β€” Set the inactivity timer on the remote server to seconds seconds. If seconds is omitted, the current inactivity timer is printed. ⏳
  • image β€” Set binary transfer type. πŸ’…
  • ipv4 β€” Select IPv4 as the only addressing scheme. 🌈
  • ipv6 β€” Select IPv6 as the only addressing scheme. 🌈
  • ipany β€” Allow IPv4 as well as IPv6 addressing. both?? both. 🫢
  • lcd [directory] β€” Change the working directory on the local machine. If no directory is specified, the user's home directory is used. local side, home sweet home 🏠
  • lpwd β€” Print the name of the current working directory on the local machine. πŸ“
  • ls [remote-directory] [local-file] β€” Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent information that the server chooses to include; for example, most Unix systems will produce output from the command:
ls -l

(See also nlist.) If remote-directory is left unspecified, the current working directory is used. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving ls output. If no local file is specified, or if local-file is -, the output is sent to the terminal. πŸ“


and bestie… that's not even the whole thing, there's MORE πŸ˜­πŸ¦‹

  • macdef macro-name β€” ok bestie, you're making a macro πŸ’– Every line after this one gets stored as the macro called macro-name. And how do you stop feeding it lines? A null line β€” that's consecutive newline characters in a file, or carriage returns from the terminal β€” kills macro input mode. Periodt.

Heads up on the limits though, no cap: there's a cap of 16 macros and 4096 total characters across all the macros you've defined. Your macros stay defined until you run a close command.

The macro processor is ✨fancy✨ and 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 signals the macro processor that the executing macro should be looped πŸ” On the first pass, $i is replaced by the first argument on the macro invocation command line; on the second pass it's replaced by the second argument, and so on.
  • A \ followed by any character is replaced by that character. So use the \ to stop the $ from getting its special treatment. πŸ’…
  • mdelete [remote-files] β€” deletes the remote-files on the remote machine. Bye felicia πŸ—‘οΈ
  • mdir remote-files local-file β€” it's giving dir, but make it multiple: multiple remote files can be specified. If interactive prompting is on, ftp will prompt you to verify that the last argument really is 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 that pops out. Peep glob for the deets 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, which you can change with lcd directory; and you can make new local directories with ! mkdir directory. 🌸

  • mkdir directory-name β€” makes a directory on the remote machine. Iconic. πŸ“βœ¨
  • mls remote-files local-file β€” like nlist, except multiple remote files can be specified, and the local-file is mandatory (no skipping it, bestie). 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 mode is "stream" mode. 🌊
  • modtime file-name β€” shows the last modification time of the file on the remote machine. Clock check ⏰
  • 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 details of filename expansion. Resulting file names then get processed according to your ntrans and nmap settings.
  • newer file-name β€” gets the file only 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, the remote file is considered newer (fair enough, it's the main character πŸ‘‘). Otherwise, this command is identical to get.
  • nlist [remote-directory] [local-file] β€” prints a list of the files in a directory on the remote machine. If remote-directory is left unspecified, the current working directory is used. If interactive prompting is on, ftp will prompt you to verify that the last argument is indeed the target local file for receiving nlist output. If no local file is specified, or if local-file is -, the output goes straight to the terminal. πŸ–₯️
  • nmap [inpattern outpattern] β€” sets or unsets the filename mapping mechanism. No arguments? Then the filename mapping mechanism gets unset. Arguments specified? Then:
    • 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 is the moment 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. Use \ to prevent this special treatment of the $ character. All other characters are treated literally, and are 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. The sequence $0 is replaced by the original filename. Additionally, the sequence [seq1, seq2] is replaced by [seq1] if seq1 is not a null string; otherwise it is replaced by seq2.

For example, the 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 the 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? The filename character translation mechanism is unset. Arguments specified? Then:
    • 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

Useful when you're 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, the character gets deleted from the file name. πŸ’€

  • open user@host [port] β€” establishes a connection to the specified host FTP server. An optional user may be supplied by prefixing it to the host followed by an @. An optional port number may be supplied, in which case ftp will attempt to contact an FTP server at that port. If the auto-login option is on (and it is by default), ftp will also attempt to automatically log the user in to the FTP server (see below). πŸšͺ✨
  • passive β€” toggles passive mode. If passive mode is turned on (default is off), the ftp client will send a PASV command for all data connections instead of the usual PORT command. The PASV command requests that the remote server open a port for the data connection and return the address of that port. The remote server listens on that port and the client connects to it.

When using the more traditional PORT command, the client listens on a port and sends that address to the remote server, who connects back to it. Passive mode is useful when using ftp through a gateway router or host that controls the directionality of traffic.

(Note that though ftp servers are required to support the PASV command by RFC 1123, some do not.) Not them ignoring the RFC 😭
  • prompt β€” toggles interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. If prompting is turned off (default is on), any mget or mput will transfer all files, and any mdelete will delete all files. πŸ”₯
  • proxy ftp-command β€” executes an ftp command on a secondary control connection. This command allows simultaneous connection to two remote ftp servers for transferring files between the two servers. The first proxy command should be an open, to establish the secondary control connection. Enter the command "proxy ?" to see other ftp commands executable on the secondary connection.

The following 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
  • 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. If remote-file is left unspecified, the local file name is used after processing according to any ntrans or nmap settings in naming the remote file. File transfer uses the current settings for type, format, mode, and structure.
  • pwd β€” prints the name of the current working directory on the remote machine. Where am I?? πŸ“
  • quit β€” a synonym for bye. πŸ‘‹
  • quote arg1 arg2 ... β€” the arguments specified are sent, verbatim, to the remote FTP server. No edits, no vibes, just straight through. πŸŽ€
  • recv remote-file [local-file] β€” a synonym for get. 🫢
  • reget remote-file [local-file] β€” bestie this is get but with ✨trauma recovery✨. It does the same thing as get, EXCEPT: if local-file already exists and it's smaller than remote-file, ftp assumes local-file is a half-finished copy of remote-file and just picks up from the apparent point of failure 😭🫢. Lowkey iconic when you're yeeting a HUGE file over a network that keeps dropping the connection. No starting over. We continue. Periodt.
  • rhelp [command-name] β€” ask the remote FTP server for help. If you pass a command-name, that gets handed to the server too so it knows what you're asking about πŸ’…
  • rstatus [file-name] β€” with no arguments, it shows the status of the remote machine. Give it a file-name and it shows the status of file-name on the remote machine. Slay ✨
  • rename [from] [to] β€” renames the file from on the remote machine to the file to. Glow-up for filenames fr fr πŸŽ€
  • reset β€” clears the reply queue. This re-synchronizes command/reply sequencing with the remote ftp server. You might need this after the remote server violates the ftp protocol (rude of it πŸ’€).
  • 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 β€” deletes 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" gets appended to the original name. And if this keeps going all the way up to ".99", an error message prints and the transfer does not happen 😭. The generated unique filename gets reported. Note: runique will not affect local files generated from a shell command (peep below for that). The default value is off.
  • send local-file [remote-file] β€” a synonym for put. Same energy, 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 command use is disabled, no attempt gets made to use PORT commands for each data transfer β€” which is useful for certain FTP implementations that do ignore PORT commands but, incorrectly, indicate they've been accepted πŸ™ˆ (lying for no reason).
  • site arg1 arg2 ... β€” the arguments you specify are sent, verbatim, to the remote FTP server as a SITE command. Whatever you say goes, no edits πŸ’…
  • size file-name β€” returns the size of file-name on the remote machine πŸ“
  • status β€” shows the current status of ftp. Vibe check on yourself 🌸
  • struct [struct-name] β€” sets the file transfer structure to struct-name. By default, "stream" structure is used.
  • sunique β€” toggles storing 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 β€” shows the type of operating system running on the remote machine πŸ‘‘ iykyk
  • tenex β€” sets the file transfer type to the one you need to talk to TENEX machines.
  • trace β€” toggles packet tracing πŸ”
  • type [type-name] β€” sets the file transfer type to type-name. If no type is specified, the current type gets printed. The default type is network ASCII.
  • umask [newmask] β€” sets 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 requires it, ftp will prompt you for it (after disabling local echo, so nobody's peeking πŸ‘€). If an account field isn't specified and the FTP server requires it, you'll be prompted for it. If an account field is specified, an account command gets relayed to the remote server after the login sequence completes, 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 you. Plus, if verbose is on, when a file transfer completes, statistics about 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 get immediately halted. Receiving transfers get 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 like. Sit there. Suffer. 🧘

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 result from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol πŸ’€. If the delay results from unexpected remote server behavior, the local ftp program must be killed by hand. Not a vibe but it is what it is.


πŸŽ€ FILE NAMING CONVENTIONS πŸŽ€

Files specified as arguments to ftp commands get processed according to these rules. Learn them, bestie:

  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 get expanded according to the rules used in 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. That's it. That's the list. πŸ’…


πŸ’– ENVIRONMENT πŸ’–

ftp utilizes the following environment variables:

  • HOME β€” for default location of a .netrc file, if one exists.
  • NETRC β€” alternate location of the .netrc file, taking precedence over the standard location.
  • SHELL β€” for default shell.

πŸ‘‘ SEE ALSO πŸ‘‘


πŸ¦‹ HISTORY πŸ¦‹

The ftp command appeared in 4.2BSD. Vintage. Iconic. Older than your parents' playlist 🌸


πŸ’€ BUGS πŸ’€

Correct execution of many commands depends upon proper behavior by the remote server. So like. Out of our hands bestie 😭

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. Avoid this problem by using the binary image type. Not me repeating it for emphasis πŸ™ˆ


That's the whole page, and it came from GNU Network Utilities, dated February 9, 2019 ✨ ty for reading my ted talk, go transfer some files, mwah πŸ’‹πŸŽ€πŸ’œ
πŸ“¦ where this page comes from