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:
Command | Description |
---|---|
? | List of all commands or explain a command, eg ? get |
! | Leave the environment temporarily * |
cd | Change the active directory path on the remote host |
chmod | Change the permissions of files on the remote host |
chown | Change the owner of files on the remote host |
dir | List the contents of the current directory on the remote host |
exit | Close the connection and leave SFTP |
get | Copy a file from the remote host to the local computer |
help | Same as ? |
lcd | Change the active directory on the local system |
lls | List the contents of the current directory on the local computer |
lmkdir | Create a directory on the local computer |
ln | Create a symbolic link for a file on the remote host |
lpwd | Show the present working directory on the local computer |
ls | Same as dir |
lumask | Change the local umask value |
mkdir | Create a directory on the remote host |
put | Copy a file from the local computer to the remote host |
pwd | Show the present working directory path on the remote host |
quit | Same as exit |
rename | Rename a file on the remote host |
rm | Delete a file on the remote host |
rmdir | Remove an empty directory on the remote host |
symlink | Same as ln |
version | Show 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.