Are there other commands like scp but for deleting files and folders?

I am using scp to copy stuff to a remote location. But sometimes scp does not work as expected, I have found that sometimes the copy does not complete properly (possibly when I have added new files to the folder I am copying).

So I want to remove the remote folder first and then do the copy to ensure that I have exactly what I need.

Are there other commands like scp (e.g. srm or smv)? Or is there a way to remove remote folders and files?


The ssh command will allow you to execute pretty much any command on the remote host, e.g.,

ssh yourlogin@remotehost rmdir somedir

where in this example somedir is relative to the home directory of yourlogin.


Rsync will copy an entire path/tree and check files already at the destination and not bother copying them if they're unchanged. If you use the --delete option, it will delete any files that are at the destination that are no longer at the source. It works over ssh


If your remote SSH server supports the SFTP subsystem (most do, unless it's been explicitly disabled), you can use the sftp shell (or any other SFTP client) to manipulate files and directories on the remote server.

Unfortunately, one thing the basic sftp shell apparently does not handle is recursive directory removal; in order to delete a directory, you have to delete all its contents first. Most other clients (especially graphical ones) typically do support it, though.

(You don't mention what your local OS is, but if it's Linux, you can use your native file manager as GUI SFTP client by pointing it at a URL like sftp://user@host/path/. For Windows, WinSCP is a decent client, and FileZilla is a good cross-platform solution.)