ftp(1)
π ftp(1) β the User's Reference Manual π
okay bestie, sit DOWN, because we're doing ftp(1) today β yes, that ftp, the ARPANET file transfer program, and it's lowkey iconic β¨
β¨ NAME β¨
ftp β ARPANET file transfer program π¦
β¨ SYNOPSIS β¨
ftp [option ...] [user@host [port]]
β¨ DESCRIPTION β¨
ftp is the user interface to the ARPANET standard File Transfer Protocol. Periodt. It lets you transfer files to and from a remote network site, which is giving very much "main character moving files across the internet" energy π
Also, you can slip a user into the host β just prefix it and follow it with an @. So user@host is the vibe, and that's literally it, no cap.
β¨ OPTIONS β¨
okay so, the options?? You can drop them at the command line, or hand them straight to the command interpreter. Both. She's flexible like that π
-4,--ipv4β Use IPv4 to connect to hosts. β¨-6,--ipv6β Use IPv6 to connect to hosts. β¨-A,--activeβ Enable active mode transfer β this one's the default forftp. π₯-p,--passiveβ Enable passive mode transfer β and this is the default forpftp. πΈ--prompt [text]β Print a command line prompt (and optionally you can give ittexttoo), even if you're not on a tty. Not me being extra about prompts π-N,--netrc filenameβ Select a specific initialization file. Pick your fave, bestie π-v,--verboseβ Verbose mode forcesftpto show you all the responses from the remote server, plus it reports on data transfer statistics. She's telling you EVERYTHING π-t,--traceβ Enable packet tracing. π¦-d,--debugβ Enables debugging. π-e,--no-editβ Disable command line editing. no take-backsies on your typos fr fr-n,--no-loginβ Restrainsftpfrom attempting "auto-login" upon initial connection. So here's the tea: if auto-login is enabled,ftpchecks the.netrcfile (see below) in your home directory for an entry describing an account on the remote machine. If there's no entry,ftpprompts for the remote machine login name (default is the user identity on the local machine), and, if necessary, prompts for a password and an account to login with. π-i,--no-promptβ Turns off interactive prompting during multiple file transfers. bulk mode, no interruptions π-g,--no-globβ Disables file name globbing. π--usageβ Display a short usage message. quick lil recap β¨-?,--helpβ Display a help list. π«Ά-V,--versionβ Display program version. π
β¨ OPERATION β¨
So the client host β and remember, you can prefix it with an optional user followed by an @ β that's the machine ftp is gonna communicate with, and you can name it right on the command line. If you do that, ftp will immediately attempt to establish a connection to an FTP server on that host. If you don't? Then ftp enters its command interpreter and justβ¦ waits for instructions from you. Very demure. Very patient. π§
And while ftp is awaiting your commands, it gives you the prompt:
ftp>
Here's every command ftp recognizes, and yes, we're going through all of them, I don't make the rules π
! [command [args]]β Invoke an interactive shell on the local machine. If there are arguments, the first one is taken to be a command to execute directly, and the rest of the arguments become its arguments. escaped to the local side, slay π₯$ macro-name [args]β Execute the macromacro-namethat 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, the user gets prompted for an account password in a non-echoing input mode. sneaky secret password vibes πappend local-file [remote-file]β Append a local file to a file on the remote machine. Ifremote-fileis left unspecified, the local file name is used to name the remote file β after being altered by anyntransornmapsetting, obviously. File transfer uses the current settings for type, format, mode, and structure. adding, not replacing, periodt πasciiβ Set the file transfer type to network ASCII. This is the default type. the classic πbellβ Arrange that a bell be sounded after each file transfer command is completed. ding! πbinaryβ Set the file transfer type to support binary image transfer. π¦byeβ Terminate the FTP session with the remote server and exitftp. An end of file will also terminate the session and exit. the goodbye we deserve πcaseβ Toggle remote computer file name case mapping duringmgetcommands. 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. lowercase era πcd remote-directoryβ Change the working directory on the remote machine toremote-directory. β¨cdupβ Change the remote machine working directory to the parent of the current remote machine working directory. go up one, bestie β¬οΈchmod mode file-nameβ Change the permission modes of the filefile-nameon the remote system tomode. permissions but make it remote πcloseβ Terminate the FTP session with the remote server, and return to the command interpreter. Any defined macros are erased. so long, macros πcrβ Toggle carriage return stripping duringasciitype file retrieval. Here's the lore: 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 can be distinguished from a record delimiter only whencris off. important!! remember that!! πdelete remote-fileβ Delete the fileremote-fileon the remote machine. gone. deleted. ποΈdebug [debug-value]β Toggle debugging mode. If an optionaldebug-valueis specified, it's used to set the debugging level. When debugging is on,ftpprints each command sent to the remote machine, preceded by the string-->πdir [remote-directory] [local-file]β Print a listing of the directory contents in the directoryremote-directory, and optionally place the output inlocal-file. If interactive prompting is on,ftpwill prompt the user to verify that the last argument is indeed the target local file for receivingdiroutput. If no directory is specified, the current working directory on the remote machine is used. If no local file is specified, orlocal-fileis-, output comes to the terminal. πdisconnectβ A synonym forclose. same energy, different name π«epsv4β Toggle the use of EPSV/EPRT for IPv4 addressing. Default is off. πΈform formatβ Set the file transfer form toformat. The only supported format isnon-print. one option only, she's picky πget remote-file [local-file]β Retrieve theremote-fileand store it on the local machine. If the local file name isn't specified, it's given the same name it has on the remote machine β subject to alteration by the currentcase,ntrans, andnmapsettings. The current settings for type, form, mode, and structure are used while transferring the file. grab it bestie π«Άglobβ Toggle filename expansion formdelete,mgetandmput. If globbing is turned off withglob, the file name arguments are taken literally and not expanded. Globbing formputis done as incsh(1). Formdeleteandmget, each remote file name is expanded separately on the remote machine and the lists are not merged. Expansion of a directory name is likely to be different from expansion of the name of an ordinary file: the exact result depends on the foreign operating system and ftp server, and can be previewed by doing:
mls remote-files -
Note:mgetandmputare not meant to transfer entire directory subtrees of files. That can be done by transferring atar(1)archive of the subtree (in binary mode). no cap, don't try it π«
hash [size]β Toggle hash-sign ("#") printing for each data block transferred. The size of a data block can optionally be specified. If it's not given, it defaults to1024bytes. cute little progress dots β¨help [command]β Print an informative message about the meaning ofcommand. If no argument is given,ftpprints a list of the known commands. ask her anything πidle [seconds]β Set the inactivity timer on the remote server tosecondsseconds. Ifsecondsis omitted, the current inactivity timer is printed. β³imageβ Set binary transfer type. πipv4β Select IPv4 as the only addressing scheme. πipv6β Select IPv6 as the only addressing scheme. πipanyβ Allow IPv4 as well as IPv6 addressing. both?? both. π«Άlcd [directory]β Change the working directory on the local machine. If nodirectoryis specified, the user's home directory is used. local side, home sweet home πlpwdβ Print the name of the current working directory on the local machine. πls [remote-directory] [local-file]β Print a listing of the contents of a directory on the remote machine. The listing includes any system-dependent information that the server chooses to include; for example, most Unix systems will produce output from the command:
ls -l
(See also nlist.) If remote-directory is left unspecified, the current working directory is used. If interactive prompting is on, ftp will prompt the user to verify that the last argument is indeed the target local file for receiving ls output. If no local file is specified, or if local-file is -, the output is sent to the terminal. π
and bestieβ¦ that's not even the whole thing, there's MORE ππ¦
macdef macro-nameβ ok bestie, you're making a macro π Every line after this one gets stored as the macro called macro-name. And how do you stop feeding it lines? A null line β that's consecutive newline characters in a file, or carriage returns from the terminal β kills macro input mode. Periodt.
Heads up on the limits though, no cap: there's a cap of 16 macros and 4096 total characters across all the macros you've defined. Your macros stay defined until you run a close command.
The macro processor is β¨fancyβ¨ and treats $ and \ as special characters:
- A
$followed by a number (or numbers) gets swapped for the corresponding argument on the macro invocation command line. - A
$followed by anisignals the macro processor that the executing macro should be looped π On the first pass,$iis replaced by the first argument on the macro invocation command line; on the second pass it's replaced by the second argument, and so on. - A
\followed by any character is replaced by that character. So use the\to stop the$from getting its special treatment. π
mdelete [remote-files]β deletes the remote-files on the remote machine. Bye felicia ποΈmdir remote-files local-fileβ it's givingdir, but make it multiple: multiple remote files can be specified. If interactive prompting is on,ftpwill prompt you to verify that the last argument really is the target local file for receivingmdiroutput. π«Άmget remote-filesβ expands the remote-files on the remote machine and does agetfor every file name that pops out. Peepglobfor the deets on filename expansion. The resulting file names then get processed according to yourcase,ntrans, andnmapsettings.
Files land in the local working directory, which you can change with lcd directory; and you can make new local directories with ! mkdir directory. πΈ
mkdir directory-nameβ makes a directory on the remote machine. Iconic. πβ¨mls remote-files local-fileβ likenlist, except multiple remote files can be specified, and the local-file is mandatory (no skipping it, bestie). If interactive prompting is on,ftpwill prompt you to verify that the last argument is indeed the target local file for receivingmlsoutput.mode [mode-name]β sets the file transfer mode to mode-name. The default mode is "stream" mode. πmodtime file-nameβ shows the last modification time of the file on the remote machine. Clock check β°mput local-filesβ expands wild cards in the list of local files you passed as arguments, then does aputfor each file in the resulting list. Seeglobfor details of filename expansion. Resulting file names then get processed according to yourntransandnmapsettings.newer file-nameβ gets the file only if the modification time of the remote file is more recent than the file on the current system. If the file doesn't exist on the current system, the remote file is considered newer (fair enough, it's the main character π). Otherwise, this command is identical toget.nlist [remote-directory] [local-file]β prints a list of the files in a directory on the remote machine. If remote-directory is left unspecified, the current working directory is used. If interactive prompting is on,ftpwill prompt you to verify that the last argument is indeed the target local file for receivingnlistoutput. If no local file is specified, or if local-file is-, the output goes straight to the terminal. π₯οΈnmap [inpattern outpattern]β sets or unsets the filename mapping mechanism. No arguments? Then the filename mapping mechanism gets unset. Arguments specified? Then:- remote filenames get mapped during
mputcommands andputcommands issued without a specified remote target filename - local filenames get mapped during
mgetcommands andgetcommands issued without a specified local target filename
- remote filenames get mapped during
This is the moment when you're connecting to a non-Unix remote computer with different file naming conventions or practices. The mapping follows the pattern set by inpattern and outpattern.
[Inpattern] is a template for incoming filenames (which may have already been processed according to the ntrans and case settings). Variable templating happens by including the sequences $1, $2, ..., $9 in inpattern. Use \ to prevent this special treatment of the $ character. All other characters are treated literally, and are used to determine the nmap [inpattern] variable values.
For example, given inpattern $1.$2 and the remote file name "mydata.data", $1 would have the value "mydata", and $2 would have the value "data".
The outpattern determines the resulting mapped filename. The sequences $1, $2, ...., $9 are replaced by any value resulting from the inpattern template. The sequence $0 is replaced by the original filename. Additionally, the sequence [seq1, seq2] is replaced by [seq1] if seq1 is not a null string; otherwise it is replaced by seq2.
For example, the command
nmap $1.$2.$3 [$1,$2].[$2,file]
would yield the output filename "myfile.data" for input filenames "myfile.data" and "myfile.data.old", "myfile.file" for the input filename "myfile", and "myfile.myfile" for the input filename ".myfile".
Spaces may be included in outpattern, as in the example: 'nmap $1 sed "s/ *$//" > $1' . Use the \ character to prevent special treatment of the $,[,[, and , characters. π
ntrans [inchars [outchars]]β sets or unsets the filename character translation mechanism. No arguments? The filename character translation mechanism is unset. Arguments specified? Then:- characters in remote filenames get translated during
mputcommands andputcommands issued without a specified remote target filename - characters in local filenames get translated during
mgetcommands andgetcommands issued without a specified local target filename
- characters in remote filenames get translated during
Useful when you're connecting to a non-Unix remote computer with different file naming conventions or practices. Characters in a filename that match a character in inchars get replaced with the corresponding character in outchars. And if the character's position in inchars is longer than the length of outchars, the character gets deleted from the file name. π
open user@host [port]β establishes a connection to the specified host FTP server. An optional user may be supplied by prefixing it to the host followed by an@. An optional port number may be supplied, in which caseftpwill attempt to contact an FTP server at that port. If theauto-loginoption is on (and it is by default),ftpwill also attempt to automatically log the user in to the FTP server (see below). πͺβ¨passiveβ toggles passive mode. If passive mode is turned on (default is off), theftpclient will send aPASVcommand for all data connections instead of the usualPORTcommand. 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 traditional PORT command, the client listens on a port and sends that address to the remote server, who connects back to it. Passive mode is useful when using ftp through a gateway router or host that controls the directionality of traffic.
(Note that thoughftpservers are required to support thePASVcommand by RFC 1123, some do not.) Not them ignoring the RFC π
promptβ toggles interactive prompting. Interactive prompting occurs during multiple file transfers to allow the user to selectively retrieve or store files. If prompting is turned off (default is on), anymgetormputwill transfer all files, and anymdeletewill delete all files. π₯proxy ftp-commandβ executes anftpcommand on a secondary control connection. This command allows simultaneous connection to two remoteftpservers for transferring files between the two servers. The firstproxycommand should be anopen, to establish the secondary control connection. Enter the command"proxy ?"to see otherftpcommands 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
Third party file transfers depend upon support of the ftp protocol PASV command by the server on the secondary control connection. π¦
put local-file [remote-file]β stores a local file on the remote machine. If remote-file is left unspecified, the local file name is used after processing according to anyntransornmapsettings in naming the remote file. File transfer uses the current settings fortype,format,mode, andstructure.pwdβ prints the name of the current working directory on the remote machine. Where am I?? πquitβ a synonym forbye. πquote arg1 arg2 ...β the arguments specified are sent, verbatim, to the remote FTP server. No edits, no vibes, just straight through. πrecv remote-file [local-file]β a synonym forget. π«Άreget remote-file [local-file]β bestie this is get but with β¨trauma recoveryβ¨. It does the same thing asget, EXCEPT: if local-file already exists and it's smaller than remote-file, ftp assumes local-file is a half-finished copy of remote-file and just picks up from the apparent point of failure ππ«Ά. Lowkey iconic when you're yeeting a HUGE file over a network that keeps dropping the connection. No starting over. We continue. Periodt.rhelp [command-name]β ask the remote FTP server for help. If you pass a command-name, that gets handed to the server too so it knows what you're asking about πrstatus [file-name]β with no arguments, it shows the status of the remote machine. Give it a file-name and it shows the status of file-name on the remote machine. Slay β¨rename [from] [to]β renames the file from on the remote machine to the file to. Glow-up for filenames fr fr πresetβ clears the reply queue. This re-synchronizes command/reply sequencing with the remote ftp server. You might need this after the remote server violates the ftp protocol (rude of it π).restart markerβ restarts the immediately followinggetorputat the indicated marker. On Unix systems, marker is usually a byte offset into the file π§rmdir directory-nameβ deletes a directory on the remote machine. Bye bestie πruniqueβ toggles storing files on the local system with unique filenames β¨. If a file already exists with a name equal to the target local filename for agetormgetcommand, a".1"gets appended to the name. If that resulting name matches another existing file, a".2"gets appended to the original name. And if this keeps going all the way up to".99", an error message prints and the transfer does not happen π. The generated unique filename gets reported. Note:runiquewill not affect local files generated from a shell command (peep below for that). The default value is off.send local-file [remote-file]β a synonym forput. Same energy, different name πsendportβ toggles the use ofPORTcommands. By default, ftp will attempt to use aPORTcommand when establishing a connection for each data transfer. UsingPORTcommands can prevent delays when you're doing multiple file transfers π₯. If thePORTcommand fails, ftp falls back to the default data port. WhenPORTcommand use is disabled, no attempt gets made to usePORTcommands for each data transfer β which is useful for certain FTP implementations that do ignorePORTcommands but, incorrectly, indicate they've been accepted π (lying for no reason).site arg1 arg2 ...β the arguments you specify are sent, verbatim, to the remote FTP server as aSITEcommand. Whatever you say goes, no edits πsize file-nameβ returns the size of file-name on the remote machine πstatusβ shows the current status of ftp. Vibe check on yourself πΈstruct [struct-name]β sets the file transfer structure to struct-name. By default,"stream"structure is used.suniqueβ toggles storing files on the remote machine under unique file names β¨. The remote ftp server must support the ftp protocolSTOUcommand for this to complete successfully. The remote server will report the unique name. Default value is off.systemβ shows the type of operating system running on the remote machine π iykyktenexβ sets the file transfer type to the one you need to talk to TENEX machines.traceβ toggles packet tracing πtype [type-name]β sets the file transfer type to type-name. If no type is specified, the current type gets printed. The default type is network ASCII.umask [newmask]β sets the default umask on the remote server to newmask. If newmask is omitted, the current umask is printed.user user-name [password] [account]β identify yourself to the remote FTP server π«Ά. If the password isn't specified and the server requires it, ftp will prompt you for it (after disabling local echo, so nobody's peeking π). If an account field isn't specified and the FTP server requires it, you'll be prompted for it. If an account field is specified, an account command gets relayed to the remote server after the login sequence completes, but only if the remote server didn't require it for logging in. Unless ftp was invoked with"auto-login"disabled, this whole process happens automatically on initial connection to the FTP server β¨verboseβ toggles verbose mode. In verbose mode, all responses from the FTP server are displayed to you. Plus, if verbose is on, when a file transfer completes, statistics about the efficiency of the transfer get reported π. By default, verbose is on.? [command]β a synonym forhelp.
Command arguments which have embedded spaces may be quoted with quote '"' marks.
π ABORTING A FILE TRANSFER π
To abort a file transfer, use the terminal interrupt key (usually Ctrl-C). Sending transfers get immediately halted. Receiving transfers get halted by sending a ftp protocol ABOR command to the remote server, and discarding any further data received. How fast this actually happens depends on the remote server's support for ABOR processing π¬. If the remote server does not support the ABOR command, an 'ftp>' prompt will not appear until the remote server has finished sending the requested file. So like. Sit there. Suffer. π§
The terminal interrupt key sequence will be ignored when ftp has completed any local processing and is awaiting a reply from the remote server. A long delay in this mode may result from the ABOR processing described above, or from unexpected behavior by the remote server, including violations of the ftp protocol π. If the delay results from unexpected remote server behavior, the local ftp program must be killed by hand. Not a vibe but it is what it is.
π FILE NAMING CONVENTIONS π
Files specified as arguments to ftp commands get processed according to these rules. Learn them, bestie:
- If the file name
'-'is specified, the stdin (for reading) or stdout (for writing) is used. - If the first character of the file name is
'|', the remainder of the argument is interpreted as a shell command. ftp then forks a shell, 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". - Failing the above checks, if "globbing" is enabled, local file names get expanded according to the rules used in
csh(1); c.f. theglobcommand. If the ftp command 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 π
The FTP specification specifies many parameters which may affect a file transfer. The type may be one of "ascii", "image" (binary), "ebcdic", and "local byte size" (for PDP-10's and PDP-20's mostly). ftp supports the ascii and image types of file transfer, plus local byte size 8 for tenex mode transfers.
ftp supports only the default values for the remaining file transfer parameters: mode, form, and struct. That's it. That's the list. π
π ENVIRONMENT π
ftp utilizes the following environment variables:
HOMEβ for default location of a.netrcfile, if one exists.NETRCβ alternate location of the.netrcfile, taking precedence over the standard location.SHELLβ for default shell.
π SEE ALSO π
π¦ HISTORY π¦
The ftp command appeared in 4.2BSD. Vintage. Iconic. Older than your parents' playlist πΈ
π BUGS π
Correct execution of many commands depends upon proper behavior by the remote server. So like. Out of our hands bestie π
An error in the treatment of carriage returns in the 4.2BSD ascii-mode transfer code has been corrected. This correction may result in incorrect transfers of binary files to and from 4.2BSD servers using the ascii type. Avoid this problem by using the binary image type. Avoid this problem by using the binary image type. Not me repeating it for emphasis π
That's the whole page, and it came from GNU Network Utilities, dated February 9, 2019 β¨ ty for reading my ted talk, go transfer some files, mwah πππ
π¦ where this page comes from
- debian trixie: inetutils-ftp 2:2.6-3+deb13u3
- ubuntu questing: inetutils-ftp 2:2.6-1ubuntu3
- ubuntu questing: inetutils-ftp 2:2.6-1ubuntu3.2
- ubuntu resolute: inetutils-ftp 2:2.7-2ubuntu1
- ubuntu resolute: inetutils-ftp 2:2.7-2ubuntu1.1
- ubuntu stonking: inetutils-ftp 2:2.8-2ubuntu1
- Copyright (c) 1985, 1989, 1990, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms