Skip to content

Instantly share code, notes, and snippets.

@melodie11
Created April 24, 2026 00:24
Show Gist options
  • Select an option

  • Save melodie11/e4e7dd7df410624c9b3b31bfac558cb4 to your computer and use it in GitHub Desktop.

Select an option

Save melodie11/e4e7dd7df410624c9b3b31bfac558cb4 to your computer and use it in GitHub Desktop.
Man lftp - part 1
lftp(1) General Commands Manual lftp(1)
NAME
lftp - Sophisticated file transfer program
SYNTAX
lftp [-d] [-e cmd] [-p port] [-u user[,pass]] [site]
lftp -f script_file
lftp -c commands
lftp --version
lftp --help
VERSION
This man page documents lftp version 4.8.1.
DESCRIPTION
lftp is a file transfer program that allows sophisticated FTP, HTTP and
other connections to other hosts. If site is specified then lftp will
connect to that site otherwise a connection has to be established with
the open command.
lftp can handle several file access methods - FTP, FTPS, HTTP, HTTPS,
HFTP, FISH, SFTP and file (HTTPS and FTPS are only available when lftp is
compiled with GNU TLS or OpenSSL library). You can specify the method to
use in `open URL' command, e.g. `open http://www.us.ker‐
nel.org/pub/linux'. HFTP is ftp-over-http-proxy protocol. It can be used
automatically instead of FTP if ftp:proxy is set to
`http://proxy[:port]'. Fish is a protocol working over an ssh connection
to a unix account. SFtp is a protocol implemented in SSH2 as SFTP subsys‐
tem.
Besides FTP-like protocols, lftp has support for BitTorrent protocol as
`torrent' command. Seeding is also supported.
Every operation in lftp is reliable, that is any non-fatal error is han‐
dled properly and the operation is repeated. So if downloading breaks, it
will be restarted from the point automatically. Even if FTP server does
not support the REST command, lftp will try to retrieve the file from the
very beginning until the file is transferred completely.
lftp has shell-like command syntax allowing you to launch several com‐
mands in parallel in background (&). It is also possible to group com‐
mands within () and execute them in background. All background jobs are
executed in the same single process. You can bring a foreground job to
background with ^Z (c-z) and back with command `wait' (or `fg' which is
alias to `wait'). To list running jobs, use command `jobs'. Some commands
allow redirecting their output (cat, ls, ...) to file or via pipe to ex‐
ternal command. Commands can be executed conditionally based on termina‐
tion status of previous command (&&, ||).
If you exit lftp before all jobs are not finished yet, lftp will move it‐
self to nohup mode in background. The same thing happens with a real mo‐
dem hangup or when you close an xterm.
lftp has built-in mirror which can download or update a whole directory
tree. There is also reverse mirror (mirror -R) which uploads or updates a
directory tree on server. Mirror can also synchronize directories between
two remote servers, using FXP if available.
There is command `at' to launch a job at specified time in current con‐
text, command `queue' to queue commands for sequential execution for cur‐
rent server, and much more.
On startup, lftp executes /etc/lftp.conf and then ~/.lftprc and
~/.lftp/rc (or ~/.config/lftp/rc if ~/.lftp does not exist). You can
place aliases and `set' commands there. Some people prefer to see full
protocol debug, use `debug' to turn the debug on. Use `debug 3' to see
only greeting messages and error messages.
lftp has a number of settable variables. You can use `set -a' to see all
variables and their values or `set -d' to see list of defaults. Variable
names can be abbreviated and prefix can be omitted unless the rest be‐
comes ambiguous.
If lftp was compiled with OpenSSL (configure --with-openssl) it includes
software developed by the OpenSSL Project for use in the OpenSSL Toolkit.
(http://www.openssl.org/)
Commands
! shell command
Launch shell or shell command.
!ls
To do a directory listing of the local host.
alias [name [value]]
Define or undefine alias name. If value is omitted, the alias is unde‐
fined, else it takes the value value. If no argument is given the current
aliases are listed.
alias dir ls -lF
alias less zmore
at time [ -- command ]
Wait until the given time and execute given (optional) command. See also
at(1).
attach [PID]
Attach the terminal to specified backgrounded lftp process.
bookmark [subcommand]
The bookmark command controls bookmarks.
Site names can be used in the open command directly as-is or in any com‐
mand that accepts input URLs using the bm:site/path format.
add <name> [<loc>] add current place or given location to book‐
marks and bind to given name
del <name> remove bookmark with name
edit start editor on bookmarks file
import <type> import foreign bookmarks
list list bookmarks (default)
cache [subcommand]
The cache command controls local memory cache. The following subcommands
are recognized:
stat print cache status (default)
on|off turn on/off caching
flush flush cache
size lim set memory limit, -1 means unlimited
expire Nx set cache expiration time to N seconds (x=s) minutes (x=m)
hours (x=h) or days (x=d)
cat files
cat outputs the remote file(s) to stdout. (See also more, zcat and
zmore)
cd rdir
Change current remote directory. The previous remote directory is stored
as `-'. You can do `cd -' to change the directory back. The previous di‐
rectory for each site is also stored on disk, so you can do `open site;
cd -' even after lftp restart.
chmod [OPTS] mode files...
Change permission mask on remote files. The mode can be an octal number
or a symbolic mode (see chmod(1)).
-c, --changes like verbose but report only when a change is made
-f, --quiet suppress most error messages
-v, --verbose output a diagnostic for every file processed
-R, --recursive change files and directories recursively
close [-a]
Close idle connections. By default only with the current server, use -a
to close all idle connections.
cls [OPTS] files...
`cls' tries to retrieve information about specified files or directories
and outputs the information according to format options. The difference
between `ls' and `cls' is that `ls' requests the server to format file
listing, and `cls' formats it itself, after retrieving all the needed in‐
formation.
-1 single-column output
-a, --all show dot files
-B, --basename show basename of files only
--block-size=SIZ use SIZ-byte blocks
-d, --directory list directory entries instead of con‐
tents
-F, --classify append indicator (one of /@) to entries
-h, --human-readable print sizes in human readable format
(e.g., 1K)
--si likewise, but use powers of 1000 not
1024
-k, --kilobytes like --block-size=1024
-l, --long use a long listing format
-q, --quiet don't show status
-s, --size print size of each file
--filesize if printing size, only print size for
files
-i, --nocase case-insensitive pattern matching
-I, --sortnocase sort names case-insensitively
-D, --dirsfirst list directories first
--sort=OPT "name", "size", "date"
-S sort by file size
--user, --group,
--perms, --date,
--linkcount, --links show individual fields
--time-style=STYLE use specified time format
command cmd args...
execute given command ignoring aliases.
debug [OPTS] level|off
Switch debugging to level or turn it off. Options:
-T truncate output file
-o <file> redirect debug output to the file
-c show message context
-p show PID
-t show timestamps
du [OPTS] path...
Summarize disk usage. Options:
-a, --all write counts for all files, not just direc‐
tories
--block-size=SIZ use SIZ-byte blocks
-b, --bytes print size in bytes
-c, --total produce a grand total
-d, --max-depth=N print the total for a directory (or file,
with --all) only if it is N or fewer levels
below the command line argument;
--max-depth=0 is the same as --summarize
-F, --files print number of files instead of sizes
-h, --human-readable print sizes in human readable format (e.g.,
1K 234M 2G)
-H, --si likewise, but use powers of 1000 not 1024
-k, --kilobytes like --block-size=1024
-m, --megabytes like --block-size=1048576
-S, --separate-dirs do not include size of subdirectories
-s, --summarize display only a total for each argument
--exclude=PAT exclude files that match PAT
echo [-n] string
Prints (echos) the given string to the display.
edit [OPTS] file
Retrieve remote file to a temporary location, run a local editor on it
and upload the file back if changed. Options:
-k keep the temporary file
-o <temp> explicit temporary file location
eval [-f format ] args...
without -f it executes given arguments as a command. With -f, arguments
are transformed into a new command. The format can contain plain text and
placeholders $0...$9 and $@, corresponding to the arguments.
exit [bg] [top] [parent] [kill] [code]
exit will exit from lftp or move to background if there are active jobs.
If no job is active, code is passed to operating system as lftp's termi‐
nation status. If code is omitted, the exit code of last command is used.
`exit bg' forces moving to background when cmd:move-background is false.
`exit top' makes top level `shell' (internal lftp command executor) ter‐
minate. `exit parent' terminates the parent shell when running a nested
script. `exit kill' kills all numbered jobs before exiting. The options
can be combined, e.g. `at 08:00 -- exit top kill &' kills all jobs and
makes lftp exit at specified time.
fg
Alias for `wait'.
find [OPTS] directory...
List files in the directory (current directory by default) recursively.
This can help with servers lacking ls -R support. You can redirect output
of this command. Options:
-d MD, --max-depth=MD specify maximum scan depth
-l, --ls use long listing format
ftpcopy
Obsolete. Use one of the following instead:
get ftp://... -o ftp://...
get -O ftp://... file1 file2...
put ftp://...
mput ftp://.../*
mget -O ftp://... ftp://.../*
or other combinations to get FXP transfer (directly between two FTP
servers). lftp would fallback to plain copy (via client) if FXP transfer
cannot be initiated or ftp:use-fxp is false.
get [-E] [-a] [-c] [-e] [-P N] [-O base] rfile [-o lfile] ...
Retrieve the remote file rfile and store it as the local file lfile. If
-o is omitted, the file is stored to local file named as base name of
rfile. You can get multiple files by specifying multiple instances of
rfile (and -o lfile). Does not expand wildcards, use mget for that.
-c continue, reget
-E delete source files after successful transfer
-e delete target file before the transfer
-a use ascii mode (binary is the default)
-P N download N files in parallel
-O <base> specifies base directory or URL where files should be
placed
Examples:
get README
get README -o debian.README
get README README.mirrors
get README -o debian.README README.mirrors -o debian.mirrors
get README -o ftp://some.host.org/debian.README
get README -o ftp://some.host.org/debian-dir/ (end slash is important)
get1 [OPTS] rfile
Transfer a single file. Options:
-o <lfile> destination file name (default - base‐
name of rfile)
-c continue, reget
-E delete source files after successful
transfer
-a use ascii mode (binary is the default)
-d create the directory of the target file
--source-region=<from-to> transfer specified region of source
file
--target-position=<pos> position in target file to write data
at
glob [OPTS] [command] patterns
Glob given patterns containing metacharacters and pass result to given
command or return appropriate exit code.
-f plain files (default)
-d directories
-a all types
--exist return zero exit code when the patterns expand to non-empty list
--not-exist return zero exit code when the patterns expand to an empty list
Examples:
glob echo *
glob --exist *.csv && echo "There are *.csv files"
help [cmd]
Print help for cmd or if no cmd was specified print a list of available
commands.
history [OPTS] [cnt]
View or manipulate the command history. Optional argument cnt specifies
the number of history lines to list, or "all" to list all entries. Op‐
tions:
-w <file> Write history to file.
-r <file> Read history from file; appends to current history.
-c Clear the history.
-l List the history (default).
jobs [OPTS] [job_no...]
List running jobs. If job_no is specified, only list a job with that num‐
ber. Options:
-v verbose, several -v increase verbosity
-r list just one specified job without recursion
kill all|job_no
Delete specified job with job_no or all jobs. (For job_no see jobs)
lcd ldir
Change current local directory ldir. The previous local directory is
stored as `-'. You can do `lcd -' to change the directory back.
ln [-s] existing-file new-link
Make a hard/symbolic link to an existing file. Option -s selects cre‐
ation of a symbolic link.
local command
Run specified command with local directory file:// session instead of re‐
mote session. Examples:
local pwd
local ls
local mirror /dir1 /dir2
lpwd
Print current working directory on local machine.
ls params
List remote files. You can redirect output of this command to file or via
pipe to external command. By default, ls output is cached, to see new
listing use rels or cache flush.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment