Show Contents / Index / Search

Supported sftp Commands

You can use the following commands in interactive sftp sessions and in sftp batch files.

ascii [-s] [remote_newline] [local_newline]

Sets the current file transfer mode to ASCII. ASCII mode is useful for translating end-of-line characters. Use remote_newline and local_newline if you need to override the default handling of new lines. Supported values for remote_newline are `DOS' (\r\n) and `Unix' (\n). The only supported value for local_newline is `Unix' (\n). Use -s to display the current transfer mode.

binary

Sets the transfer mode to binary. In this mode, files transfer without any modification. Binary is the default transfer mode. This command is useful for turning off ASCII mode within a batch script.

bye

This is a synonym for quit.

cd directory

Changes the remote directory to directory.

chgrp group file

Sets group ownership of files or directories specified by file to group. The group must be specified as a numeric group id (GID).

chmod[-R]mode file

Sets file permissions for the files or directories specified by file. The mode must be specified in numeric format (for example, 664). Use -R to change files and directories recursively.

chown owner file

Sets the owner of the files or directories specified by file to owner. The owner must be specified as a numeric user id (UID).

close

Closes the connection to the remote server without exiting sftp.

dir

This is a synonym for ls.

exit

This is a synonym for quit.

get [--preserve] | [-p] remote-file [remote-file ...]

Copies the specified file or files to the current local working directory. (To copy to a different location, use lcd to change the local working directory.) If a file with the same name already exists, the existing file is overwritten. Wildcards are supported, but name substitution occurs on file names only, not directories. Use either --preserve or -p to preserve file attributes and time stamps.

help [command]

Displays sftp help. Use command to display help on the specified command.

lcd directory

Sets the local directory to directory.

lls [-R | -l | -S | -r] [file]

Displays the local directory listing. Options are -R (recursive), -l (long list format), -S (sort by size; not supported on HP-UX), and -r (reverse order).

lmkdir directory

Creates the specified local directory.

ln

This is a synonym for symlink.

lpwd

Displays the local working directory.

ls [-l | -S | -r] [file ]

Displays the remote directory listing. Options are -l (long list format), -S (sort by size; not supported on HP-UX), and -r (reverse order).

mget

This is a synonym for get.

mkdir directory

Creates the specified remote directory.

mput [--preserve] [-p] local_file [remote_file ]

This is a synonym for put.

open [-l | [user@]host]

Opens a connection to the specified host. Use -l to connect to the local host; in which case both local and remote commands act on files on the local file system.

put [--preserve] | [-p] local_file [local_file ...]

Copies the specified file or files to the current remote working directory. (To copy to a different location, use cd to change the remote working directory.) If a file with the same name already exists, the existing file is overwritten. Wildcards are supported, but name substitution occurs on file names only, not directories. Use either --preserve or -p to preserve file attributes and time stamps.

pwd

Displays the remote working directory.

quit

Exits sftp and closes the connection.

rename source destination

Renames a file from source to destination. No rename occurs if the destination file already exists.

rm file

Deletes the specified remote file or files. Wildcards are supported.

rmdir directory

Deletes the specified remote directory.

symlink linked_path target_path

Creates a symbolic link (soft) from linked_path to target_path on the remote host.