Subcommands

sftp understands a set of commands (subcommands) similar to those of ftp.

The following rules apply:
  • Commands are not case sensitive.
  • Path names that contain spaces must be enclosed in quotes.
  • Glob characters (also called wildcard characters) in path names must be escaped with backslash characters (\). For more information about wildcard characters, refer to the section on file name generation in the sh command description in z/OS UNIX System Services Command Reference.
  • Characters preceded by an unescaped pound sign (#) are treated as a comment. Input up to but not including the next newline is discarded.
ascii
Changes the data transfer type to ASCII.

For outgoing files, convert from EBCDIC code page of the current locale into ASCII before transferring them to the remote host. For incoming files, convert from ASCII into the code page of the current locale before restoring them on the local host.

Restriction: The ascii subcommand is only valid for file transfers between UNIX platforms. It is not valid for file transfers between Windows and UNIX platforms.

binary
Changes the data transfer type to binary. This is the default.
bye
Quits sftp.
cd path
Changes the remote directory to path.
lcd path
Changes the local directory to path.
chgrp grp path
Changes group of file path to grp. grp must be a numeric GID. path can contain glob characters and match multiple files.
chmod mode path
Changes permissions of file path to mode. path can contain glob characters and match multiple files.
chown own path
Changes owner of file path to own. own must be a numeric UID. path can contain glob characters and match multiple files.
df [-hi] [path]
Display usage information for the filesystem holding the current directory (or path if specified). If the -h flag is specified, the capacity information will be displayed using "human-readable" suffixes. The -i flag requests display of inode information in addition to capacity information. This command is only supported on servers that implement the ``statvfs@openssh.com'' extension.
exit
Quits sftp.
get [–aPpr] remote-path [local-path]
Retrieves the remote-path and stores it on the local machine. If the local path name is not specified, it is given the same name it has on the remote machine. remote-path can contain glob characters and match multiple files. If it matches multiple files and local-path is specified, then local-path must specify a directory. If the –P or –p flag is specified, then the file's full permissions and access time are copied as well.
If the -a flag is specified, then attempt to resume partial transfers of existing files.
Note:
Resumption assumes that any partial copy of the local file matches the remote copy. If the remote file differs from the partial local copy then the resultant file is likely to be corrupt.
If the -r flag is specified, then directories will be copied recursively. In this case, the local directory will be created if it does not already exist.
Note:
sftp does not follow symbolic links when performing recursive transfers.
help
Displays help text.
lls [ls-options [path]]
Displays local directory listing of either path or current directory if path is not specified. ls-options is case sensitive. ls-options can contain any flags supported by the local system's ls command. path can contain glob characters and match multiple files.
lmkdir path
Creates local directory specified by path.
ln [-s] oldpath newpath
Creates a symbolic link from oldpath to newpath on the remote host. If the -s flag is specified, the created link is a symbolic link, otherwise it is a hard link. Same as symlink if -s is specified.
lpwd
Prints local working directory.
ls [–1afhlnrSt] [path]
Displays remote directory listing of either path or current directory if path is not specified. path can contain glob characters and match multiple files.
The following flags are recognized and the behavior of ls is altered accordingly:
-1
Produces single-column output.
-a
Lists files beginning with a dot (.).
-f
Does not sort the listing. The default sort order is lexicographical.
-h
When used with a long format option, use unit suffixes: Byte, Kilobyte, Megabyte, Gigabyte, Terabyte, Petabyte, and Exabyte in order to reduce the number of digits to four or fewer using powers of 2 for sizes (K=1024, M=1048576, and so forth).
-l
Displays additional details including permissions and ownership information.
-n
Produces a long listing with user and group information presented numerically.
-r
Reverses the sort order of the listing.
-S
Sorts the listing by file size.
-t
Sorts the listing by last modification time.
lumask umask
Sets local umask to umask.
mkdir path
Creates remote directory specified by path.
progress
Toggles display of progress meter.
put [–Ppr] local-path [remote-path]
Uploads local-path and stores it on the remote machine. If the remote-path name is not specified, it is given the same name it has on the local machine. local-path can contain glob characters and match multiple files. If it matches multiple files and remote-path is specified, then remote-path must specify a directory. If the –P or –p flag is specified, then the file's permissions and access time are copied as well.
If the -r flag is specified, then directories will be copied recursively. In this case, the remote directory must already exist.
Note:
sftp does not follow symbolic links when performing recursive transfers.

When using put -p with -b, if a failure occurs when preserving permissions or access time on the remote system, sftp will not exit and the exit value will not be set to nonzero.

pwd
Displays the remote working directory.
quit
Quits sftp.
reget [-Ppr] remote-path [local-path]
Resume download of remote-path. Equivalent to get with the -a flag set.
rename oldpath newpath
Renames the remote file from oldpath to newpath.
rmdir path
Removes the remote directory specified by path.
rm path
Deletes the remote file specified by path.
symlink oldpath newpath
Creates a symbolic link from oldpath to newpath on the remote host. Same as ln.
version
Displays the sftp version.
!
Escapes to local shell.
! command
Executes command in the local shell.
?
Synonym for help.