FTP(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โ forcesftpto only use IPv4 addresses. IPv4 only, no cap.-6โ forcesftpto only use IPv6 addresses. IPv6 only, periodt.-Aโ force active mode ftp. by defaultftptries 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โ makesftpbypass 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โ restrainsftpfrom attempting โauto-loginโ upon initial connection for non auto-fetch transfers. so like, if auto-login is enabled,ftpwill check the.netrcfile (see below) in the user's home directory for an entry describing an account on the remote machine. if no entry exists,ftpwill 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, becauseftpnow 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,ftpis the foreground process). forcesftpto 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 themacdefcommand. 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 anyntransornmapsetting. 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 exitftp. an end of file will also terminate the session and exit. bye bestie ๐caseโ toggle remote computer file name case mapping duringget,mgetandmputcommands. whencaseis 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 duringasciitype file retrieval. records are denoted by a carriage return/linefeed sequence duringasciitype file transfer. whencris 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 anasciitype transfer is made, these linefeeds may be distinguished from a record delimiter only whencris 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 commandls -l. if remote-path is left unspecified, the current working directory is used. if interactive prompting is on,ftpwill prompt you to verify that the last argument is indeed the target local file for receivingdiroutput. if no local file is specified, or if local-file is-, the output is sent to the terminal.disconnectโ a synonym forclose.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 extendedEPSVandEPRTcommands on all IP, IPv4, and IPv6 connections respectively. first tryEPSV/EPRT, and thenPASV/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 untilepsv,epsv4, orepsv6is executed again. bestie said try the new thing first โจexitโ a synonym forbye.featuresโ display what features the remote server supports (using theFEATcommand). 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 foropen.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,ftpprints 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 theFTPSERVERenvironment 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 currentcase,ntrans, andnmapsettings, so like, the vibes of your settings get applied. The current settings fortype,form,mode, andstructureare what get used while transferring. periodt.globโ Toggles filename expansion formdelete,mget,mput, andmreget. Turn globbing off withgloband the file name arguments get taken literally โ not expanded, no cap. Globbing formputis done as incsh(1). Formdelete,mget, andmreget, 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 doingmls remote-files -.
Note:mget,mputandmregetare not meant to transfer entire directory subtrees of files. If that's the goal, transfer atar(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 to1024bytes, and you can change it by specifying size in bytes. Enablinghashdisablesprogressthough, so pick your fighter ๐.help [command]โ Prints an informative message about the meaning of command ๐. Give it no argument andftpprints 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 forbinary. 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 forpage. Iconic shortcut behavior tbh.lpage local-fileโ Displays local-file using the program specified by theset pageroption ๐.lpwdโ Prints the working directory on the local machine. Short, sweet, slay.ls [remote-path [local-file]]โ A synonym fordir. 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โ Likedir, except multiple remote files may be specified. If interactive prompting is on,ftpwill prompt the user to verify that the last argument is indeed the target local file for receivingmdiroutput ๐.mget remote-filesโ Expands the remote-files on the remote machine and does agetfor each file name thus produced. Seeglobfor the details on the filename expansion ๐ธ. Resulting file names then get processed according tocase,ntrans, andnmapsettings. Files are transferred into the local working directory, which you can change withlcd 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โ Likels, except multiple remote files may be specified, and the local-file must be specified. If interactive prompting is on,ftpwill prompt the user to verify that the last argument is indeed the target local file for receivingmlsoutput ๐ซถ.mlsd [remote-path]โ Displays the contents of remote-path (which should default to the current directory if not given) in a machine-parsable form, usingMLSD. The format of display can be changed withremopts 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, usingMLST. The format of display can be changed withremopts 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 forpage. Same energy, different name โญ.mput local-filesโ Expands wild cards in the list of local files given as arguments and does aputfor each file in the resulting list. Seeglobfor details of filename expansion ๐ฆ. Resulting file names then get processed according tontransandnmapsettings.mreget remote-filesโ As permget, but performs aregetinstead ofget. Resumey behavior, we love to see it ๐ฅ.msend local-filesโ A synonym formput. 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 toget๐ธ.nlist [remote-path [local-file]]โ A synonym forls. 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 duringmputcommands andputcommands issued without a specified remote target filename. Similarly, local filenames are mapped duringmgetcommands andgetcommands 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 duringmputcommands and duringputcommands issued without a specified remote target filename, and characters in local filenames get translated duringmgetcommands andgetcommands 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 caseftpwill attempt to contact an FTP server at that port. And if theset auto-loginoption is on โ which it is by default, bestie โftpwill 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 theset pageroption. easy peasy ๐passive [auto]โ toggle passive mode (if no arguments are given). If auto is given, act as ifFTPMODEis set toโautoโ๐ If passive mode is turned on (and it is, by default),ftpwill send aPASVcommand for all data connections instead of aPORTcommand. ThePASVcommand 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 traditionalPORTcommand, 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 usingftpthrough 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]โ performdir [remote-path], and display the result with the program specified by theset pageroption ๐ฆpls [remote-path]โ performls [remote-path], and display the result with the program specified by theset pageroption โจpmlsd [remote-path]โ performmlsd [remote-path], and display the result with the program specified by theset pageroption ๐preserveโ toggle preservation of modification times on retrieved files ๐ฐ๏ธ yes, she can remember the timestamps, iconic behaviorprogressโ 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: enablingprogressdisableshash. 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), anymgetormputwill transfer all the files, and anymdeletewill 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 anftpcommand on a secondary control connection ๐โจ This lets you have simultaneous connections to two remote FTP servers, for transferring files between the two. The firstproxycommand should be anopen, 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:
openwill not define new macros during the auto-login processclosewill not erase existing macro definitionsgetandmgettransfer files from the host on the primary control connection to the host on the secondary control connectionput,mput, andappendtransfer 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 anyntransornmapsettings 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 solvedquitโ a synonym forbye๐ that's it, that's the whole thingquote arg1 arg2 ...โ the arguments specified are sent, verbatim, to the remote FTP server ๐ฃ๏ธ no editing, no vibes check, just straight through, character for characterrate direction [maximum [increment]]โ throttle the maximum transfer rate to maximum bytes/second ๐ขโจ If maximum is0, 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:rateis not yet implemented forasciimode 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 forget๐ซถreget remote-file [local-file]โregetacts likeget, 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 forMLSDandMLST) ๐rename [from [to]]โ rename the file from on the remote machine, to the file to โ๏ธ glow-ups for filenames onlyresetโ 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 followinggetorputat 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 atomsrstatus [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 agetormgetcommand, 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:runiquewill not affect local files generated from a shell command (see below). The default value is off. ๐ดsend local-file [remote-file]โ a synonym forput๐คsendportโ toggle the use ofPORTcommands ๐ช By default,ftpwill attempt to use aPORTcommand when establishing a connection for each data transfer. The use ofPORTcommands can prevent delays when performing multiple file transfers. If thePORTcommand fails,ftpwill use the default data port. When the use ofPORTcommands is disabled, no attempt will be made to usePORTcommands for each data transfer. This is useful for certain FTP implementations which do ignorePORTcommands 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 aSITEcommand. 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 offtp. 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) isfile.suniqueโ toggles storing files on the remote machine under unique file names. the remote FTP server must support the FTP protocolSTOUcommand for this to actually complete โ noSTOU, 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 forrate.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 tosetfor 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,ftpwill 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, anaccountcommand 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 unlessftpwas invoked withauto-logindisabled, 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 forhelp.
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: ifftpreceives aSIGINFO(see thestatusargument ofstty(1)) or aSIGQUITsignal 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 thehost[: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,ftpperforms the equivalent of acdcommand. for the last path component,ftpperforms the equivalent of agetcommand. - Empty name components โ which happen because of
//inside the path, or an extra/at the beginning of the path โ will cause the equivalent of acdcommand without a directory name. this is unlikely to be useful ๐ (like thanks bestie, but no) - Any
%XXcodes (per RFC3986) inside the path components get decoded, withXXbeing 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 acdorgetcommand. 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
anonymoususer. 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/motdfromlocalhostas the usermynamewith the passwordmypass, useftp://myname:mypass@localhost/%2fetc/motd๐ฅ - The exact
cdandgetcommands 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
cdcommand. 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 aboutftp.about:versionโ the version offtp. 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 whilstftpis awaiting a reply from the remote server for theABORprocessing, 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:
- If the file name
-is specified, the stdin (for reading) or stdout (for writing) is used. iconic behaviour, tbh. - If the first character of the file name is
|, the rest of the argument is interpreted as a shell command.ftpthen forks a shell, usingpopen(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 ๐ - Failing the above checks, if "globbing" is enabled, local file names are expanded according to the rules used in
csh(1); see theglobcommand. If theftpcommand expects a single local file (e.g.put), only the first filename generated by the "globbing" operation is used. - For
mgetcommands andgetcommands with unspecified local file names, the local filename is the remote filename, which may be altered by acase,ntrans, ornmapsetting. The resulting filename may then be altered ifruniqueis on. - For
mputcommands andputcommands with unspecified remote file names, the remote filename is the local filename, which may be altered by antransornmapsetting. The resulting filename may then be altered by the remote server ifsuniqueis 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:
machinename โ identify a remote machine name. The auto-login process searches the.netrcfile for amachinetoken that matches the remote machine specified on theftpcommand line or as anopencommand argument. Once a match is made, the subsequent.netrctokens are processed, stopping when the end of file is reached or anothermachineor adefaulttoken is encountered.defaultโ this is the same asmachinename except thatdefaultmatches any name. There can be only onedefaulttoken, and it must be after allmachinetokens. 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.
loginname โ identify a user on the remote machine. If this token is present, the auto-login process will initiate a login using the specified name.passwordstring โ 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.netrcfile for any user other thananonymous,ftpwill abort the auto-login process if the.netrcis readable by anyone besides the user. ๐ like, keep your secrets, bestie.accountstring โ 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 anACCTcommand if it does not.macdefname โ define a macro. This token functions like theftpmacdefcommand functions. A macro is defined with the specified name; its contents begin with the next.netrcline and continue until a blank line (consecutive new-line characters) is encountered. Like the other tokens in the.netrcfile, amacdefis applicable only to themachinedefinition preceding it. Amacdefentry cannot be used by multiplemachinedefinitions; rather, it must be defined following eachmachineit is intended to be used with. If a macro namedinitis 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 with0, 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 onlyautoโ automatic determination of passive or active (this is the default)gateโ gate-ftp modepassiveโ passive mode FTP only
FTPPROMPTโ command-line prompt to use. Defaults toftp>. 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 whengateis enabled.FTPSERVERPORTโ port to use when connecting to gate-ftp server whengateis enabled. Default is port returned by agetservbyname()lookup offtpgate/tcp.FTPUSERAGENTโ the value to send for the HTTP User-Agent header.HOMEโ for default location of a.netrcfile, if one exists.NETRCโ an alternate location of the.netrcfile.PAGERโ used by various commands to display files. Defaults tomore(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 ProtocolRFC1123โ Requirements for Internet Hosts - Application and SupportRFC1635โ How to Use Anonymous FTPRFC2389โ Feature negotiation mechanism for the File Transfer ProtocolRFC2428โ FTP Extensions for IPv6 and NATsRFC2616โ Hypertext Transfer Protocol -- HTTP/1.1RFC2822โ Internet Message FormatRFC3659โ Extensions to FTPRFC3986โ 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.2BSDascii-mode transfer code has been corrected. This correction may result in incorrect transfers of binary files to and from4.2BSDservers using theasciitype. Avoid this problem by using thebinaryimage type. โ lowkey important, highkey a warning. usebinaryand move on ๐ ftpassumes that all IPv4 mapped addresses (IPv6 addresses with a form like::ffff:10.1.1.1) indicate IPv4 destinations which can be handled byAF_INETsockets. However, in certain IPv6 network configurations, this assumption is not true. In such an environment, IPv4 mapped addresses must be passed toAF_INET6sockets directly. For example, if your site uses a SIIT translator for IPv6-to-IPv4 translation,ftpis 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
- Copyright (c) 1996-2008 The NetBSD Foundation, Inc
- Copyright (c) 1985, 1989, 1990, 1993 The Regents of the University of California. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms