If you’re using SFTP to transfer files, there are some commands that you should know in order to make the process easier.

SFTP encrypts the more widely utilized file transfer mechanism, FTP. This command-line tool is simple to use as long as you understand the meanings of the commands.

In this blog post, we will go over the most frequently used commands and explain what each one does. With these commands at your disposal, you’ll be able to quickly and easily move files back and forth between your computer and your server. Let’s get started!

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
helpSame 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

Even if your computer doesn’t have an SFTP program, it almost certainly has FTP. FTP is included with every Microsoft operating system, but SFTP isn’t. There are also user-friendly versions of SFTP available that take care of all of the commands accessible through interpretive buttons and menu choices. You’ll need to locate and install an SFTP utility whether you want a GUI SFTP solution or wish to work at the command line.

What is needed for SFTP?

Because Secure File Transfer Protocol software is required, you’ll need an SFTP server application on one of the two computers communicating and a client on the other end. The majority of SFTP tools provide both features.

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 she chooses, but only if she adheres to common FTP standards will the software be able to operate globally across devices that don’t need the identical program installed on them. All FTP utilities will include all of the commands stipulated by applicable RFCs and, if available, may also contain additional features. The CHMOD variable isn’t covered in the FTP standards, so it’s a choice option that some developers add into their programs. It doesn’t have to be included in every version.

How do you grep via SFTP?

The grep shell command isn’t included in the general SFTP environment, so to use grep on a remote file, you’ll need to copy it over using SFTP and then do a search.