SFTP commands cheat sheet header image

See also: Best Free SFTP Servers

SFTP offers a secure connection to transfer files between computers with encryption. Although many people assume the acronym stands for Secure File Transfer Protocol, it is actually the SSH File Transfer Protocol.

SFTP is a variation of the File Transfer Protocol (FTP), which is one of the oldest internet applications. Both SFTP and FTP are standard definitions, not programs. It is up to others to write an SFTP program, but they must follow the SFTP standard in order to make it compatible with other SFTP programs.

In a standard implementation, an SFTP program runs at the command-line interface. The utility has its own environment. So when you enter an SFTP session, you should see the command line prompt change to sftp>.

Once logged into an SFTP session, normal commands for the operating system won’t work. Instead, you must use the command language specified in the SFTP standard.

Most frequently used SFTP commands

Some most commonly used SFTP commands include:

CommandDescription
?List of all commands or explain a command, eg ? get
!Leave the environment temporarily *
cdChange the active directory path on the remote host
chmodChange the permissions of files on the remote host
chownChange the owner of files on the remote host
dirList the contents of the current directory on the remote host
exitClose the connection and leave SFTP
getCopy a file from the remote host to the local computer
help Same as ?
lcdChange the active directory on the local system
llsList the contents of the current directory on the local computer
lmkdirCreate a directory on the local computer
lnCreate a symbolic link for a file on the remote host
lpwdShow the present working directory on the local computer
lsSame as dir
lumaskChange the local umask value
mkdirCreate a directory on the remote host
putCopy a file from the local computer to the remote host
pwdShow the present working directory path on the remote host
quitSame as exit
renameRename a file on the remote host
rmDelete a file on the remote host
rmdirRemove an empty directory on the remote host
symlink              Same as ln
versionShow the SFTP version

* to return to SFTP type exit. Execute commands in the underlying operating system without leaving SFTP by putting ! in front of the command, eg !date

SFTP implementations

Not every computer will have an SFTP program, but just about all computers do have FTP. For example, FTP is bundled into all Microsoft operating systems, but SFTP isn’t. There are also GUI versions of SFTP available and they take care of all of the available commands for you through interpretive buttons and menu options. Whether you prefer a GUI SFTP implementation or you want to use the system at the command line, you will need to find and install an SFTP utility.

Do you have a favorite SFTP program that you use a lot? Leave a message in the comments section below and let us all know about it.

View or Download the Cheat Sheet JPG image

Right-click on the image below to save the JPG file (759 width x 860 height in pixels), or click here to open it in a new browser tab. Once the image opens in a new window, you may need to click on the image to zoom in and view the full-sized jpeg.

SFTP Commands Cheat Sheet

View or Download the cheat sheet PDF file

Download the cheat sheet PDF file here. When it opens in a new browser tab, simply right click on the PDF and navigate to the download menu.

SFTP Commands FAQs

What is a good SFTP server?

Files.com is a cloud file management service that acts as a file transfer hub. It uses SFTP to pass files securely between client computers and the client account storage space.

File devices

Once a file is resident on the server it can be distributed many times over without having to transfer the file again – the user emails the recipient a link for direct secure access on the Files.com server instead.Start a 30-day free trial.

Files.com Start 30-day FREE Trial

What is needed for SFTP?

An SFTP connection requires appropriate software, so you will need an SFTP server utility on one of the two devices in communication and a client at the other end. Most SFTP utilities provide both functions.

Why doesn't the CHMOD command work on all FTP or SFTP servers?

The developer of an FTP server utility can create the service in any way, but the software will only be able to work universally interacting with other devices that don’t need to have the same software installed on it, if the developer follows the common FTP standards. All FTP utilities will include all of the commands stipulated in the relevant RFCs and then will possibly also have extra functionality. CHMOD is not specified in the FTP standards and therefore, it is an optional extra that some developers program into their software. It doesn’t have to be included in every implementation.

How do you grep via SFTP?

The grep shell command isn’t built into the standard SFTP environment, so in order to use grep on a remote file, you will need to transfer the file to the local computer with SFTP and then perform a grep.

See also: SolarWinds SFTP/SCP Server review & SFTP Commands Cheat Sheet

Image: Server web secure by RRZEicons via Wikimedia Commons. Licensed under CC BY-SA 3.0