FTP(1)

๐Ÿ“ฆ
version 15.1 ยท 2 versions
, in freebsd 15.1

โœจ FTP(1) โœจ

General Commands Manual โ€” ok bestie grab a snack, this one's a whole journey ๐Ÿ“


๐ŸŒธ NAME ๐ŸŒธ

ftp โ€” the Internet file transfer program. that's it, that's the whole vibe ๐Ÿฆ‹


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

ftp [-46AadefginpRtVv] [-N netrc] [-o output] [-P port] [-q quittime]
    [-r retry] [-s srcaddr] [-T dir,max[,inc]] [[user@]host [port]]
    [[user@]host:[path][/]] [file:///path]
    [ftp://[user[:password]@]host[:port]/path[/][;type=X]]
    [http://[user[:password]@]host[:port]/path] [...]
ftp -u URL file [...]

๐Ÿ’– DESCRIPTION ๐Ÿ’–

okay so ftp is, like, the user interface to the Internet standard File Transfer Protocol. it lets you move files to and from a remote network site. iconic behavior honestly ๐Ÿ‘‘

and here's the cute part โ€” those last five arguments will fetch a file using the FTP or HTTP protocols, or by direct copying, straight into the current directory. it's giving "made for scripts" energy. go read โ€œAUTO-FETCHING FILESโ€ below for the whole story ๐Ÿ’…

options can go on the command line, or you can feed them to the command interpreter. dealer's choice โœจ

๐Ÿ”ฅ the flags ๐Ÿ”ฅ

  • -4 โ€” forces ftp to only use IPv4 addresses. IPv4 only, no cap.
  • -6 โ€” forces ftp to only use IPv6 addresses. IPv6 only, periodt.
  • -A โ€” force active mode ftp. by default ftp tries passive mode first and falls back to active if the server doesn't support passive โ€” this flag makes it always use an active connection. it's only useful for connecting to very old servers that don't implement passive mode properly. like, ancient-server energy ๐Ÿฆ•
  • -a โ€” makes ftp bypass the normal login procedure and use an anonymous login instead. no name needed, you're just a vibe.
  • -d โ€” enables debugging. ๐Ÿ›
  • -e โ€” disables command line editing. useful for Emacs ange-ftp mode. (yes, specifically that.)
  • -f โ€” forces a cache reload for transfers that go through the FTP or HTTP proxies.
  • -g โ€” disables file name globbing. no wildcards for you ๐Ÿ’€
  • -i โ€” turns off interactive prompting during multiple file transfers. no more "are you sure" every two seconds, thank god ๐Ÿ˜ญ
  • -N netrc โ€” use netrc instead of ~/.netrc. go read โ€œTHE .netrc FILEโ€ for more info ๐Ÿ“„
  • -n โ€” restrains ftp from attempting โ€œauto-loginโ€ upon initial connection for non auto-fetch transfers. so like, if auto-login is enabled, ftp will check the .netrc file (see below) in the user's home directory for an entry describing an account on the remote machine. if no entry exists, ftp will prompt for the remote machine login name (default is the user identity on the local machine), and if necessary, prompt for a password and an account with which to login. and to override the auto-login for auto-fetch transfers, just specify the username (and optionally, the password) as appropriate. easy ๐Ÿซถ
  • -o output โ€” when auto-fetching files, save the contents in output. output is parsed according to the โ€œFILE NAMING CONVENTIONSโ€ below. heads up tho: if output is not - and doesn't start with |, then only the first file specified will be retrieved into output; all other files will be retrieved into the basename of their remote name. so like, one file gets the cute custom name, the rest get their government names ๐Ÿ’€
  • -P port โ€” sets the port number to port.
  • -p โ€” enable passive mode operation for use behind connection filtering firewalls. deprecated alert ๐Ÿšจ this option has been deprecated, because ftp now tries to use passive mode by default and falls back to active mode if the server doesn't support passive connections.
  • -q quittime โ€” quit if the connection has stalled for quittime seconds. if it's not giving, we're leaving ๐Ÿ™ˆ
  • -R โ€” restart all non-proxied auto-fetches.
  • -r wait โ€” retry the connection attempt if it failed, pausing for wait seconds.
  • -s srcaddr โ€” uses srcaddr as the local IP address for all connections.
  • -t โ€” enables packet tracing. very "i'm watching you" of it ๐Ÿ”
  • -T direction,maximum[,increment] โ€” set the maximum transfer rate for direction to maximum bytes/second, and if specified, the increment to increment bytes/second. refer to rate for more information.
  • -u URL file [...] โ€” upload files on the command line to URL, where URL is one of the ftp URL types as supported by auto-fetch (with an optional target filename for single file uploads), and file is one or more local files to be uploaded. ship it ๐Ÿš€
  • -V โ€” disable verbose and progress, overriding the default of enabled when output is to a terminal.
  • -v โ€” enable verbose and progress. this is the default if output is to a terminal (and in the case of progress, ftp is the foreground process). forces ftp to show all responses from the remote server, as well as report on data transfer statistics. chatty king ๐Ÿ‘‘

๐Ÿ’ฌ talking to it ๐Ÿ’ฌ

the client host you want ftp to communicate with 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, bestie.

when ftp is awaiting commands from you, the prompt ftp> shows up. and these are the commands it recognizes ๐Ÿ‘‡

  • ! [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. secrets secrets ๐Ÿคซ
  • 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. the blueprint, fr fr.
  • bell โ€” arrange that a bell be sounded after each file transfer command is completed. ๐Ÿ”” yes bestie, a little ding for a job well done.
  • 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. bye bestie ๐Ÿ‘‹
  • case โ€” toggle remote computer file name case mapping during get, mget and mput 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. one level up, like going home ๐Ÿ 
  • chmod mode remote-file โ€” change the permission modes of the file remote-file 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. gone, reduced to atoms ๐Ÿ’€
  • 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. ok that one's a mouthful but it matters ๐Ÿ˜ค
  • delete remote-file โ€” delete the file remote-file on the remote machine.
  • dir [remote-path [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. if remote-path 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 dir output. if no local file is specified, or if local-file is -, the output is sent to the terminal.
  • disconnect โ€” a synonym for close.
  • edit โ€” toggle command line editing, and context sensitive command and file completion. this is automatically enabled if input is from a terminal, and disabled otherwise.
  • epsv epsv4 epsv6 โ€” toggle the use of the extended EPSV and EPRT commands on all IP, IPv4, and IPv6 connections respectively. first try EPSV / EPRT, and then PASV / PORT. this is enabled by default. if an extended command fails then this option will be temporarily disabled for the duration of the current connection, or until epsv, epsv4, or epsv6 is executed again. bestie said try the new thing first โœจ
  • exit โ€” a synonym for bye.
  • features โ€” display what features the remote server supports (using the FEAT command). pop off, tell me what you can do ๐Ÿ‘‘
  • fget localfile โ€” retrieve the files listed in localfile, which has one line per filename.
  • form format โ€” set the file transfer form to format. the default (and only supported) format is โ€œnon-printโ€.
  • ftp host [port] โ€” a synonym for open.
  • ftp_debug [ftp_debug-value] โ€” toggle debugging mode. if an optional ftp_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 -->.
  • gate [host [port]] โ€” Toggles gate-ftp mode, the whole "connect through a proxy" situation that back in the day went through the TIS FWTK and Gauntlet ftp proxies ๐Ÿซถ. Heads up though: this is not permitted if the gate-ftp server hasn't been set โ€” either explicitly by you, or via the FTPSERVER environment variable. If you pass host, gate-ftp mode gets enabled and the gate-ftp server is set to host. And if you also pass port, that's the port used to connect to the gate-ftp server. iykyk ๐Ÿ’…
  • get remote-file [local-file] โ€” Grabs remote-file and drops it on your local machine, slay ๐ŸŽ€. No local-file name given? Then it keeps the same name it has on the remote machine โ€” subject to alteration by the current case, ntrans, and nmap settings, so like, the vibes of your settings get applied. The current settings for type, form, mode, and structure are what get used while transferring. periodt.
  • glob โ€” Toggles filename expansion for mdelete, mget, mput, and mreget. Turn globbing off with glob and the file name arguments get taken literally โ€” not expanded, no cap. Globbing for mput is done as in csh(1). For mdelete, mget, and mreget, each remote file name is expanded separately on the remote machine and the lists are not merged ๐Ÿ™ˆ. Also lowkey important: 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 you can preview it by doing mls remote-files -.
Note: mget, mput and mreget are not meant to transfer entire directory subtrees of files. If that's the goal, transfer a tar(1) archive of the subtree instead (in binary mode) ๐Ÿฆ‹.
  • hash [size] โ€” Toggles hash-sign (#) printing for each data block transferred โ€” the little progress confetti basically โœจ. The size of a data block defaults to 1024 bytes, and you can change it by specifying size in bytes. Enabling hash disables progress though, so pick your fighter ๐Ÿ’€.
  • help [command] โ€” Prints an informative message about the meaning of command ๐Ÿ’–. Give it no argument and ftp prints a list of the known commands. It's giving "asking your bestie what's going on."
  • idle [seconds] โ€” Sets the inactivity timer on the remote server to seconds seconds. Omit seconds and the current inactivity timer gets printed instead. Very "are you still there" energy ๐Ÿ˜ญ.
  • image โ€” A synonym for binary. That's it, that's the whole command ๐Ÿ‘‘.
  • lcd [directory] โ€” Changes the working directory on the local machine. No directory specified? Then the user's home directory is used ๐Ÿ .
  • less file โ€” A synonym for page. Iconic shortcut behavior tbh.
  • lpage local-file โ€” Displays local-file using the program specified by the set pager option ๐ŸŽ€.
  • lpwd โ€” Prints the working directory on the local machine. Short, sweet, slay.
  • ls [remote-path [local-file]] โ€” A synonym for dir. Yup, same vibe, different name ๐Ÿ’….
  • macdef macro-name โ€” Defines a macro, bestie. Subsequent lines get stored as the macro macro-name; a null line (consecutive newline characters in a file, or carriage returns from the terminal) terminates macro input mode ๐Ÿ›‘.

The limits are real: there's a limit of 16 macros and 4096 total characters in all defined macros, and macro names can be a maximum of 8 characters. Macros are only applicable to the current session they're defined within (or, if defined outside a session, to the session invoked with the next open command), and they remain defined until a close command is executed.

To invoke a macro, use the $ command (see above) โœจ.

The macro processor interprets $ and \ as special characters. A $ followed by a number (or numbers) is replaced by the corresponding argument on the macro invocation command line. A $ followed by an i signals the macro processor that the executing macro is to 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. Use the \ to prevent special treatment of the $ ๐Ÿงš.

  • mdelete [remote-files] โ€” Deletes the remote-files on the remote machine. Bye bye, no cap ๐Ÿ’€.
  • mdir remote-files local-file โ€” Like dir, except multiple remote files may be specified. If interactive prompting is on, ftp will prompt the user 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 each file name thus produced. See glob for the details on the filename expansion ๐ŸŒธ. Resulting file names then get processed according to case, ntrans, and nmap settings. Files are transferred into the local working directory, which you can change with lcd directory; new local directories can be created with ! mkdir directory ๐ŸŽ€.
  • mkdir directory-name โ€” Makes a directory on the remote machine. Boom, structure โœจ.
  • mls remote-files local-file โ€” Like ls, except multiple remote files may be specified, and the local-file must be specified. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving mls output ๐Ÿซถ.
  • mlsd [remote-path] โ€” Displays the contents of remote-path (which should default to the current directory if not given) in a machine-parsable form, using MLSD. The format of display can be changed with remopts mlst ... ๐Ÿ’….
  • mlst [remote-path] โ€” Displays the details about remote-path (which should default to the current directory if not given) in a machine-parsable form, using MLST. The format of display can be changed with remopts mlst ... ๐Ÿ‘‘
  • mode mode-name โ€” Sets the file transfer mode to mode-name. The default โ€” and, honestly, the only supported โ€” mode is โ€œstreamโ€ ๐ŸŒˆ.
  • modtime remote-file โ€” Shows the last modification time of the file on the remote machine, in RFC2822 format ๐Ÿ•ฐ๏ธ.
  • more file โ€” A synonym for page. Same energy, different name โญ.
  • mput local-files โ€” Expands wild cards in the list of local files given as arguments and 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 ntrans and nmap settings.
  • mreget remote-files โ€” As per mget, but performs a reget instead of get. Resumey behavior, we love to see it ๐Ÿ”ฅ.
  • msend local-files โ€” A synonym for mput. That's the tweet ๐Ÿ’œ.
  • newer remote-file [local-file] โ€” 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. Otherwise, this command is identical to get ๐ŸŒธ.
  • nlist [remote-path [local-file]] โ€” A synonym for ls. Yup ๐ŸŽ€.
  • nmap [inpattern outpattern] โ€” Sets or unsets the filename mapping mechanism โœจ. No arguments? The filename mapping mechanism is unset. Arguments given? Remote filenames are mapped during mput commands and put commands issued without a specified remote target filename. Similarly, local filenames are mapped during mget commands and get commands issued without a specified local target filename ๐Ÿซถ.

This command is useful when connecting to a non-Unix remote computer with different file naming conventions or practices, iykyk. 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 is accomplished 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]] โ€” the filename glow-up machine โœจ Sets or unsets the whole filename character translation mechanism. Call it with no arguments and the mechanism gets unset (back to zero vibes). Call it with arguments and two things happen: characters in remote filenames get translated during mput commands and during put commands issued without a specified remote target filename, and characters in local filenames get translated during mget commands and get commands issued without a specified local target filename. This is lowkey a lifesaver when you're connecting to a non-Unix remote computer that has different file naming conventions or practices ๐Ÿซถ Any character in a filename that matches a character in inchars gets replaced with the corresponding character in outchars. And if a character's position in inchars is longer than the length of outchars, that character just gets deleted from the file name. bye bestie ๐Ÿ’€
  • open host [port] โ€” establish a connection to the specified host FTP server ๐Ÿ”Œ You can optionally slide a port number in there, in which case ftp will attempt to contact an FTP server at that port. And if the set auto-login option is on โ€” which it is by default, bestie โ€” ftp will also attempt to automatically log the user in to the FTP server (see below). so convenient, we love her ๐Ÿ‘‘
  • page file โ€” retrieve file and display it with the program specified by the set pager option. easy peasy ๐Ÿ“„
  • passive [auto] โ€” toggle passive mode (if no arguments are given). If auto is given, act as if FTPMODE is set to โ€˜autoโ€™ ๐ŸŒ€ If passive mode is turned on (and it is, by default), ftp will send a PASV command for all data connections instead of a 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, it's the other way around: the client listens on a port and sends that address to the remote server, who connects back to it. Passive mode is the move when you're using ftp through a gateway router or a host that controls the directionality of traffic ๐ŸŽ€
ok so heads up: though FTP servers are required to support the PASV command by RFC1123, some of them justโ€ฆ do not ๐Ÿ™ˆ not our fault, not our problem, but now you know.
  • pdir [remote-path] โ€” perform dir [remote-path], and display the result with the program specified by the set pager option ๐Ÿฆ‹
  • pls [remote-path] โ€” perform ls [remote-path], and display the result with the program specified by the set pager option โœจ
  • pmlsd [remote-path] โ€” perform mlsd [remote-path], and display the result with the program specified by the set pager option ๐Ÿ’…
  • preserve โ€” toggle preservation of modification times on retrieved files ๐Ÿ•ฐ๏ธ yes, she can remember the timestamps, iconic behavior
  • progress โ€” toggle display of the transfer progress bar ๐Ÿ“Š The progress bar will be disabled for a transfer that has local-file as โ€˜-โ€™ or for a command that starts with โ€˜|โ€™ โ€” refer to โ€œFILE NAMING CONVENTIONSโ€ for more info. Also: enabling progress disables hash. one or the other, bestie, choose your fighter ๐ŸฅŠ
  • prompt โ€” toggle interactive prompting ๐Ÿ™‹โ€โ™€๏ธ Interactive prompting happens during multiple file transfers so you can selectively retrieve or store files. If prompting is turned off (the default is on, jsyk), any mget or mput will transfer all the files, and any mdelete will delete all the files. no takebacks ๐Ÿ˜ญ

When prompting is on, the following commands are available at a prompt:

  • a โ€” answer โ€˜yesโ€™ to the current file, and automatically answer โ€˜yesโ€™ to any remaining files for the current command ๐ŸŒธ
  • n โ€” answer โ€˜noโ€™, and do not transfer the file ๐Ÿšซ
  • p โ€” answer โ€˜yesโ€™ to the current file, and turn off prompt mode (as is โ€œprompt offโ€ had been given) ๐Ÿ’ค
  • q โ€” terminate the current operation โœ‹
  • y โ€” answer โ€˜yesโ€™, and transfer the file โœ…
  • ? โ€” display a help message ๐Ÿ†˜

Any other response will answer โ€˜yesโ€™ to the current file. so basically mashing keys = consent, noted ๐Ÿ’€

  • proxy ftp-command โ€” execute an ftp command on a secondary control connection ๐ŸŒ€โœจ This lets you have simultaneous connections to two remote FTP servers, for transferring files between the two. 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
ngl, third party file transfers depend upon support of the FTP protocol PASV command by the server on the secondary control connection. no support, no transfer, that's the tea ๐Ÿต
  • put local-file [remote-file] โ€” store 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. very "use what you've got" of her ๐Ÿ’…
  • pwd โ€” print the name of the current working directory on the remote machine ๐Ÿ“ where are we? mystery solved
  • quit โ€” a synonym for bye ๐Ÿ‘‹ that's it, that's the whole thing
  • quote arg1 arg2 ... โ€” the arguments specified are sent, verbatim, to the remote FTP server ๐Ÿ—ฃ๏ธ no editing, no vibes check, just straight through, character for character
  • rate direction [maximum [increment]] โ€” throttle the maximum transfer rate to maximum bytes/second ๐Ÿขโœจ If maximum is 0, disable the throttle.

direction may be one of:

  • all โ€” both directions ๐Ÿ”„
  • get โ€” incoming transfers โฌ‡๏ธ
  • put โ€” outgoing transfers โฌ†๏ธ

maximum can be modified on the fly by increment bytes (default: 1024) each time a given signal is received:

  • SIGUSR1 โ€” increment maximum by increment bytes ๐Ÿ“ˆ
  • SIGUSR2 โ€” decrement maximum by increment bytes. The result must be a positive number ๐Ÿ“‰

If maximum is not supplied, the current throttle rates are displayed ๐Ÿ‘€

Note: rate is not yet implemented for ascii mode transfers. so if you're in ascii mode, the throttle is giving nothing, zero, nada ๐Ÿ˜ญ
  • rcvbuf size โ€” set the size of the socket receive buffer to size ๐Ÿงบ
  • recv remote-file [local-file] โ€” a synonym for get ๐Ÿซถ
  • reget remote-file [local-file] โ€” reget acts like get, except that if local-file exists and is smaller than remote-file, local-file is presumed to be a partially transferred copy of remote-file and the transfer is continued from the apparent point of failure ๐Ÿงšโ€โ™€๏ธโœจ This command is so useful when transferring very large files over networks that are prone to dropping connections โ€” she picks up right where you left off, main character energy ๐Ÿ‘‘
  • remopts command [command-options] โ€” set options on the remote FTP server for command to command-options (whose absence is handled on a command-specific basis). Remote FTP commands known to support options include: โ€˜MLSTโ€™ (used for MLSD and MLST) ๐Ÿ’…
  • rename [from [to]] โ€” rename the file from on the remote machine, to the file to โœ๏ธ glow-ups for filenames only
  • reset โ€” clear reply queue ๐Ÿงน This command re-synchronizes command/reply sequencing with the remote FTP server. Resynchronization may be necessary following a violation of the FTP protocol by the remote server. so when the server is acting up, hit her with the reset ๐ŸŒ€
  • restart marker โ€” restart the immediately following get or put at the indicated marker โฉ On Unix systems, marker is usually a byte offset into the file ๐Ÿ”ข
  • rhelp [command-name] โ€” request help from the remote FTP server ๐Ÿ†˜ If a command-name is specified it is supplied to the server as well. asking the server itself, bold move, love that for us ๐Ÿ’–
  • rmdir directory-name โ€” delete a directory on the remote machine ๐Ÿ—‘๏ธ gone, reduced to atoms
  • rstatus [remote-file] โ€” with no arguments, show status of the remote machine ๐Ÿ“ก If remote-file is specified, show status of remote-file on the remote machine ๐Ÿ”
  • runique โ€” toggle storing of 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" is appended to the name. If the resulting name matches another existing file, a ".2" is appended to the original name. And if this process continues up to ".99", an error message is printed, and the transfer does not take place ๐Ÿ’€ The generated unique filename will be reported. Also important: runique will not affect local files generated from a shell command (see below). The default value is off. ๐Ÿ˜ด
  • send local-file [remote-file] โ€” a synonym for put ๐Ÿ“ค
  • sendport โ€” toggle the use of PORT commands ๐Ÿšช By default, ftp will attempt to use a PORT command when establishing a connection for each data transfer. The use of PORT commands can prevent delays when performing multiple file transfers. If the PORT command fails, ftp will use the default data port. When the use of PORT commands is disabled, no attempt will be made to use PORT commands for each data transfer. This is useful for certain FTP implementations which do ignore PORT commands but, incorrectly, indicate they've been accepted. the audacity ๐Ÿ˜ญ๐Ÿ™ˆ
  • set [option value] โ€” set option to value โš™๏ธ If option and value are not given, display all of the options and their values ๐Ÿ‘€ The currently supported options are:
    • anonpass โ€” defaults to $FTPANONPASS ๐Ÿ”‘
    • ftp_proxy โ€” defaults to $ftp_proxy ๐ŸŒ
    • http_proxy โ€” defaults to $http_proxy ๐Ÿ•ธ๏ธ
    • no_proxy โ€” defaults to $no_proxy ๐Ÿšซ
    • pager โ€” defaults to $PAGER ๐Ÿ“–
  • prompt โ€” defaults to $FTPPROMPT.
  • rprompt โ€” defaults to $FTPRPROMPT.

bestie ok that's the set options wrapped ๐Ÿ’… now we get into the actual commands โ€” the verbs, the actions, the main characters ๐Ÿ‘‘

  • site arg1 arg2 ... โ€” the arguments you type get sent verbatim to the remote FTP server as a SITE command. No edits, no vibes, just straight through ๐Ÿซถ
  • size remote-file โ€” returns the size of remote-file on the remote machine.
  • sndbuf size โ€” sets the size of the socket send buffer to size.
  • status โ€” shows the current status of ftp. like a vibe check but for your session โœจ
  • struct struct-name โ€” sets the file transfer structure to struct-name. the default (and the only one supported, so don't get creative babes) is file.
  • 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 actually complete โ€” no STOU, no slay ๐Ÿ˜ญ. the remote server will report the unique name back. default value is off.
  • system โ€” shows the type of operating system running on the remote machine ๐Ÿ‘€
  • tenex โ€” sets the file transfer type to the one you need to talk to TENEX machines. retro icon behavior ๐Ÿ•ฐ๏ธ
  • throttle โ€” a synonym for rate.
  • trace โ€” toggles packet tracing ๐Ÿ”
  • type [type-name] โ€” sets the file transfer type to type-name. if you give it no type-name, it just prints the current type. the default type is network ASCII.
  • umask [newmask] โ€” sets the default umask on the remote server to newmask. if you leave newmask off, it prints the current umask instead.
  • unset option โ€” unsets option. refer to set for more info ๐Ÿซก
  • usage command โ€” prints the usage message for command. it's giving "help me help you" โœจ
  • user user-name [password [account]] โ€” identifies yourself to the remote FTP server. okay so: if password isn't specified and the server needs one, ftp will prompt you for it (after disabling local echo, so nobody's shoulder-surfing your password ๐Ÿ”’). if an account field isn't specified and the FTP server needs it, you'll get prompted for that too. if you do specify an account field, an account command gets relayed to the remote server after the login sequence finishes โ€” but only if the remote server didn't require it for logging in. and unless ftp was invoked with auto-login disabled, all of this happens automatically on the initial connection to the FTP server. no manual labor required ๐Ÿ’…
  • verbose โ€” toggles verbose mode. in verbose mode, every single response from the FTP server is displayed to you. also, if verbose is on, when a file transfer completes you get statistics about how efficient the transfer was ๐ŸŽ€. by default, verbose is on.
  • xferbuf size โ€” sets the size of the socket send and receive buffers to size.
  • ? [command] โ€” a synonym for help.

few lil ground rules, and they matter fr fr:

Command arguments that have spaces embedded in them can be quoted with " marks.

Commands that toggle a setting can take an explicit on or off argument to force the setting exactly where you want it. no guessing, no "wait what is it set to rn" ๐Ÿ˜Œ

Commands that take a byte count as an argument (like hash, rate, and xferbuf) support an optional suffix on the argument that changes how the number gets interpreted. the supported suffixes are:

b    Causes no modification.  (Optional)
k    Kilo; multiply the argument by 1024
m    Mega; multiply the argument by 1048576
g    Giga; multiply the argument by 1073741824
๐Ÿšจ and this one's important: if ftp receives a SIGINFO (see the status argument of stty(1)) or a SIGQUIT signal while a transfer is in progress, the current transfer rate statistics get written to the standard error output, in the same format as the standard completion message. so you can peek at how it's going mid-download without breaking anything ๐Ÿซถ

๐Ÿฆ‹ AUTO-FETCHING FILES ๐Ÿฆ‹

okay this is the fun part. on top of all the standard commands, this version of ftp supports an auto-fetch feature โœจ to turn it on, you literally just pass the list of hostnames/files on the command line. that's it. that's the whole trick.

these are the valid syntaxes for an auto-fetch element:

[user@]host:[path][/]

the "classic" FTP format ๐Ÿ’พ

if path contains a glob character and globbing is enabled (see glob), then the equivalent of mget path happens.

if the directory component of path contains no globbing characters, it's stored locally under the name basename (see basename(1)) of path, in the current directory. otherwise the full remote name is used as the local name, relative to the local root directory.

ftp://[user[:password]@]host[:port]/path[/][;type=X]

an FTP URL, retrieved using the FTP protocol if set ftp_proxy isn't defined. otherwise the URL gets transferred using HTTP via the proxy defined in set ftp_proxy. if set ftp_proxy isn't defined and user is given, log in as user. in that case, use password if supplied โ€” otherwise prompt the user for one ๐Ÿ”

if you tack on a suffix of ;type=A or ;type=I, the transfer type becomes ascii or binary respectively. the default transfer type is binary.

and to be compliant with RFC3986, ftp interprets the path part of an ftp:// auto-fetch URL like this ๐Ÿ‘‡

  • The / immediately after the host[:port] is interpreted as a separator before the path, and not as part of the path itself.
  • The path is interpreted as a /-separated list of name components. for all but the last such component, ftp performs the equivalent of a cd command. for the last path component, ftp performs the equivalent of a get command.
  • Empty name components โ€” which happen because of // inside the path, or an extra / at the beginning of the path โ€” will cause the equivalent of a cd command without a directory name. this is unlikely to be useful ๐Ÿ™ˆ (like thanks bestie, but no)
  • Any %XX codes (per RFC3986) inside the path components get decoded, with XX being a character code in hexadecimal. this decoding happens after the path has been split into components, but before each component is used in the equivalent of a cd or get command. some often-used codes are %2F (which represents /) and %7E (which represents ~).

the above interpretation has the following consequences:

  • The path is interpreted relative to the default login directory of the specified user or of the anonymous user. if you need the / directory, use a leading path of %2F. if you need a user's home directory (and the remote server supports the syntax), use a leading path of %7Euser/. for example, to retrieve /etc/motd from localhost as the user myname with the password mypass, use ftp://myname:mypass@localhost/%2fetc/motd ๐Ÿ”ฅ
  • The exact cd and get commands can be controlled by careful choice of where you use / and where you use %2F (or %2f). for example, the following URLs correspond to the equivalents of the indicated commands:
ftp://host/dir1/dir2/file         โ€œcd dir1โ€, โ€œcd dir2โ€, โ€œget fileโ€.

ftp://host/%2Fdir1/dir2/file      โ€œcd /dir1โ€, โ€œcd dir2โ€, โ€œget fileโ€.

ftp://host/dir1%2Fdir2/file       โ€œcd dir1/dir2โ€, โ€œget fileโ€.

ftp://host/%2Fdir1%2Fdir2/file    โ€œcd /dir1/dir2โ€, โ€œget fileโ€.

ftp://host/dir1%2Fdir2%2Ffile     โ€œget dir1/dir2/fileโ€.

ftp://host/%2Fdir1%2Fdir2%2Ffile  โ€œget /dir1/dir2/fileโ€.
  • You must have appropriate access permission for each of the intermediate directories used in the equivalent of a cd command. no sneaking past the bouncer ๐Ÿšช

http://[user[:password]@]host[:port]/path

an HTTP URL, retrieved using the HTTP protocol. if set http_proxy is defined, it's used as a URL to an HTTP proxy server. if HTTP authorization is required to retrieve path, and user (and optionally password) is in the URL, use them for the first attempt to authenticate ๐Ÿซก

file:///path

a local URL, copied from /path on the local host ๐Ÿ 

about:topic

displays information about topic; no file is retrieved for this auto-fetched element. supported values include:

  • about:ftp โ€” information about ftp.
  • about:version โ€” the version of ftp. super useful to provide when reporting problems ๐Ÿ›

unless noted otherwise above, and unless -o output is given, the file is stored in the current directory as the basename(1) of path. note that if an HTTP redirect is received, the fetch is retried using the new target URL supplied by the server, with a corresponding new path. using an explicit -o output is recommended, to avoid writing to unexpected file names ๐Ÿ‘€ (yes that's a warning, bestie, pay attention)

if a classic format or an FTP URL format has a trailing / or an empty path component, then ftp will connect to the site and cd to the directory given as the path, and leave you in interactive mode ready for further input ๐Ÿ’ฌ. this will not work if set ftp_proxy is being used.

direct HTTP transfers use HTTP 1.1. proxied FTP and HTTP transfers use HTTP 1.0.

if -R is given, all auto-fetches that don't go via the FTP or HTTP proxies will be restarted ๐Ÿ”. for FTP, that's implemented by using reget instead of get. for HTTP, it's implemented by using the Range: bytes= HTTP/1.1 directive.

if WWW or proxy WWW authentication is required, you'll be prompted to enter a username and password to authenticate with ๐Ÿ”‘

when specifying IPv6 numeric addresses in a URL, you need to surround the address in square brackets. e.g.: ftp://[::1]:21/. this is because colons are used in IPv6 numeric addresses and they're also the separator for the port number. yeah, they're fighting over the same punctuation, iconic conflict ๐Ÿ’€

๐Ÿ›‘ ABORTING A FILE TRANSFER ๐Ÿ›‘

okay so bestie, if you ever need to bail mid-transfer, just hit your terminal interrupt key (that's usually Ctrl+C, iykyk) ๐Ÿ’…

Sending transfers get halted immediately โ€” like, no hesitation, gone. Receiving transfers get halted by sending an FTP protocol ABOR command to the remote server, and then any further data that shows up just gets tossed in the trash ๐Ÿ™ˆ. How fast that actually happens depends on how well the remote server supports ABOR processing. And ngl, if the remote server doesn't support the ABOR command, the prompt won't even appear until the remote server has finished sending the requested file โ€” so you're just sitting there like ๐Ÿ˜ญ

Heads up: if you use the terminal interrupt key sequence whilst ftp is awaiting a reply from the remote server for the ABOR processing, then the connection gets closed. That's different from the traditional behaviour (which ignores the terminal interrupt during this phase), but it's considered more useful. slay, honestly ๐Ÿซถ

๐ŸŒธ FILE NAMING CONVENTIONS ๐ŸŒธ

Files specified as arguments to ftp commands get processed according to these rules, in order:

  1. If the file name - is specified, the stdin (for reading) or stdout (for writing) is used. iconic behaviour, tbh.
  2. If the first character of the file name is |, the rest 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. obsessed with this one ๐ŸŽ€
  3. Failing the above checks, if "globbing" is enabled, local file names are expanded according to the rules used in csh(1); see 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 ๐Ÿ”ฅ

So the FTP specification specifies many parameters which may affect a file transfer, and the type may be one of "ascii", "image" (binary), "ebcdic", and "local byte size" (for PDP-10's and PDP-20's mostly โ€” yes, those exist, don't come for me).

ftp supports the ascii and image types of file transfer, plus local byte size 8 for tenex mode transfers.

And for the remaining file transfer parameters โ€” mode, form, and struct โ€” ftp supports only the default values. no cap ๐Ÿ’€


๐ŸŽ€ THE .netrc FILE ๐ŸŽ€

The .netrc file contains login and initialization information used by the auto-login process. It lives in the user's home directory, unless you override it with the -N netrc option, or specify it in the NETRC environment variable.

The following tokens are recognized; they may be separated by spaces, tabs, or new-lines:

  • machine name โ€” identify a remote machine name. The auto-login process searches the .netrc file for a machine token that matches the remote machine specified on the ftp command line or as an open command argument. Once a match is made, the subsequent .netrc tokens are processed, stopping when the end of file is reached or another machine or a default token is encountered.
  • default โ€” this is the same as machine name except that default matches any name. There can be only one default token, and it must be after all machine tokens. This is normally used as:
default login anonymous password user@site

thereby giving the user an automatic anonymous FTP login to machines not specified in .netrc. This can be overridden by using the -n flag to disable auto-login.

  • login name โ€” identify a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified name.
  • password string โ€” supply a password. If this token is present, the auto-login process will supply the specified string if the remote server requires a password as part of the login process. Note that if this token is present in the .netrc file for any user other than anonymous, ftp will abort the auto-login process if the .netrc is readable by anyone besides the user. ๐Ÿ”’ like, keep your secrets, bestie.
  • account string โ€” supply an additional account password. If this token is present, the auto-login process will supply the specified string if the remote server requires an additional account password, or the auto-login process will initiate an ACCT command if it does not.
  • macdef name โ€” define a macro. This token functions like the ftp macdef command functions. A macro is defined with the specified name; its contents begin with the next .netrc line and continue until a blank line (consecutive new-line characters) is encountered. Like the other tokens in the .netrc file, a macdef is applicable only to the machine definition preceding it. A macdef entry cannot be used by multiple machine definitions; rather, it must be defined following each machine it is intended to be used with. If a macro named init is defined, it is automatically executed as the last step in the auto-login process. For example,
default
macdef init
epsv4 off

followed by a blank line.


โœจ COMMAND LINE EDITING โœจ

ftp supports interactive command line editing, via the editline(3) library. It's enabled with the edit command, and it's enabled by default if input is from a tty. Previous lines can be recalled and edited with the arrow keys, and other GNU Emacs-style editing keys may be used as well. the way that just works ๐Ÿ˜Œ

The editline(3) library is configured with a .editrc file โ€” refer to editrc(5) for more information.

An extra key binding is available to ftp to provide context sensitive command and filename completion (including remote file completion) ๐Ÿฆ‹. To use this, bind a key to the editline(3) command ftp-complete. By default, this is bound to the TAB key.


๐Ÿ’œ COMMAND LINE PROMPT ๐Ÿ’œ

By default, ftp displays a command line prompt of ftp> to the user. This can be changed with the set prompt command.

A prompt can be displayed on the right side of the screen (after the command input) with the set rprompt command.

The following formatting sequences are replaced by the given information:

  • %/ โ€” the current remote working directory.
  • %c[[0]n], %.[[0]n] โ€” the trailing component of the current remote working directory, or n trailing components if a digit n is given. If n begins with 0, the number of skipped components precede the trailing component(s) in the format /<number>trailing (for %c) or ...trailing (for %.).
  • %M โ€” the remote host name.
  • %m โ€” the remote host name, up to the first ..
  • %n โ€” the remote user name.
  • %% โ€” a single %.

๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

ftp uses the following environment variables:

  • FTPANONPASS โ€” password to send in an anonymous FTP transfer. Defaults to `whoami`@.
  • FTPMODE โ€” overrides the default operation mode. Supported values are:
    • active โ€” active mode FTP only
    • auto โ€” automatic determination of passive or active (this is the default)
    • gate โ€” gate-ftp mode
    • passive โ€” passive mode FTP only
  • FTPPROMPT โ€” command-line prompt to use. Defaults to ftp> . Refer to "COMMAND LINE PROMPT" for more information.
  • FTPRPROMPT โ€” command-line right side prompt to use. Defaults to "". Refer to "COMMAND LINE PROMPT" for more information.
  • FTPSERVER โ€” host to use as gate-ftp server when gate is enabled.
  • FTPSERVERPORT โ€” port to use when connecting to gate-ftp server when gate is enabled. Default is port returned by a getservbyname() lookup of ftpgate/tcp.
  • FTPUSERAGENT โ€” the value to send for the HTTP User-Agent header.
  • HOME โ€” for default location of a .netrc file, if one exists.
  • NETRC โ€” an alternate location of the .netrc file.
  • PAGER โ€” used by various commands to display files. Defaults to more(1) if empty or not set.
  • SHELL โ€” for default shell.
  • ftp_proxy โ€” URL of FTP proxy to use when making FTP URL requests (if not defined, use the standard FTP protocol).

See http_proxy for further notes about proxy use.

  • http_proxy โ€” URL of HTTP proxy to use when making HTTP URL requests. If proxy authentication is required and there is a username and password in this URL, they will automatically be used in the first attempt to authenticate to the proxy.

If "unsafe" URL characters are required in the username or password (for example @ or /), encode them with RFC3986 %XX encoding.

Note that the use of a username and password in ftp_proxy and http_proxy may be incompatible with other programs that use it (such as lynx(1)).

NOTE: this is not used for interactive sessions, only for command-line fetches. ๐Ÿ‘€ important!!
  • no_proxy โ€” a space or comma separated list of hosts (or domains) for which proxying is not to be used. Each entry may have an optional trailing :port, which restricts the matching to connections to that port.

๐Ÿฆ‹ EXTENDED PASSIVE MODE AND FIREWALLS ๐Ÿฆ‹

Some firewall configurations do not allow ftp to use extended passive mode. So if you find that even a simple ls appears to hang after printing a message such as this:

229 Entering Extended Passive Mode (|||58551|)

then you will need to disable extended passive mode with epsv4 off. See the above section "The .netrc File" for an example of how to make this automatic. you're welcome ๐Ÿ’–


โญ SEE ALSO โญ

getservbyname(3), editrc(5), services(5)

โœจ STANDARDS โœจ

bestie, ftp really said "I have read the documentation" because it attempts to be compliant with all of these ๐Ÿ’…:

  • RFC0959 โ€” File Transfer Protocol
  • RFC1123 โ€” Requirements for Internet Hosts - Application and Support
  • RFC1635 โ€” How to Use Anonymous FTP
  • RFC2389 โ€” Feature negotiation mechanism for the File Transfer Protocol
  • RFC2428 โ€” FTP Extensions for IPv6 and NATs
  • RFC2616 โ€” Hypertext Transfer Protocol -- HTTP/1.1
  • RFC2822 โ€” Internet Message Format
  • RFC3659 โ€” Extensions to FTP
  • RFC3986 โ€” Uniform Resource Identifier (URI)

like, she's well-read. an academic icon ๐Ÿ‘‘๐Ÿ“š


๐Ÿฆ‹ HISTORY ๐Ÿฆ‹

okay so storytime, the ftp command appeared in 4.2BSD. vintage. classic. the blueprint โœจ

then a whole bunch of features got implemented in NetBSD 1.3 and later releases by Luke Mewburn โŸจlukem@NetBSD.orgโŸฉ โ€” and these are iconic upgrades, no cap:

  • command line editing
  • context sensitive command and file completion
  • dynamic progress bar
  • automatic fetching of files and URLs
  • modification time preservation
  • transfer rate throttling
  • configurable command line prompt
  • and other enhancements over the standard BSD ftp

like he really said "let me make this whole thing slay" and then did ๐Ÿ’€๐Ÿซถ

IPv6 support was added by the WIDE/KAME project (but it may not be present in all non-NetBSD versions of this program, depending if the operating system supports IPv6 in a similar manner to KAME). so if you're on a different flavor, don't come for her if the IPv6 vibe check fails ๐Ÿ™ˆ


๐Ÿ’€ BUGS ๐Ÿ’€

ngl, this is the "she's not perfect, she's real" section. read it carefully bestie:

  • Correct execution of many commands depends upon proper behavior by the remote server. so basically some of this is out of her hands. if the server's acting up, that's a them 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. โ†’ lowkey important, highkey a warning. use binary and move on ๐ŸŽ€
  • ftp assumes that all IPv4 mapped addresses (IPv6 addresses with a form like ::ffff:10.1.1.1) indicate IPv4 destinations which can be handled by AF_INET sockets. However, in certain IPv6 network configurations, this assumption is not true. In such an environment, IPv4 mapped addresses must be passed to AF_INET6 sockets directly. For example, if your site uses a SIIT translator for IPv6-to-IPv4 translation, ftp is unable to support your configuration. so yeah. one specific edge case and she's out ๐Ÿซ 
fr fr: assume the server behaves, use binary for binary files, and check your IPv6 setup before you blame her ๐Ÿ’–

and that's the whole page, bestie!! you made it to the end, I'm so proud ๐Ÿฅน๐Ÿ’œ

this masterpiece is from Debian, dated September 25, 2025, and it lives at FTP(1) in the manual. go forth and transfer files responsibly โœจ๐ŸŒธ๐Ÿ‘‘

๐Ÿ“ฆ where this page comes from
  • freebsd 15.1: base 15.1
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms